@pithy-sh/auth 0.12.2 → 0.14.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 +1 -1
- package/dist/admin/users.d.ts +19 -1
- package/dist/admin/users.d.ts.map +1 -1
- package/dist/admin/users.js +18 -1
- package/dist/http/adminRoutes.d.ts.map +1 -1
- package/dist/http/adminRoutes.js +40 -22
- package/dist/http/guards.d.ts.map +1 -1
- package/dist/http/guards.js +12 -2
- package/dist/http/responses.d.ts +10 -10
- package/dist/http/responses.d.ts.map +1 -1
- package/dist/http/responses.js +12 -12
- package/dist/http/schemas.d.ts +45 -11
- package/dist/http/schemas.d.ts.map +1 -1
- package/dist/http/schemas.js +50 -13
- package/dist/mcp/http/schemas.d.ts.map +1 -1
- package/dist/mcp/http/schemas.js +2 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/docs/account-lifecycle.md +3 -3
- package/package.json +5 -5
- package/src/admin/users.ts +40 -2
- package/src/http/adminRoutes.ts +67 -40
- package/src/http/guards.ts +12 -2
- package/src/http/responses.ts +13 -13
- package/src/http/schemas.ts +98 -26
- package/src/mcp/http/schemas.ts +4 -5
- package/src/version.generated.ts +1 -1
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ So: **do not "improve" this by matching more addresses, and do not make the refu
|
|
|
62
62
|
|
|
63
63
|
## Account lifecycle
|
|
64
64
|
|
|
65
|
-
An account can be suspended or deleted, and the kit refuses it at every door. An operator suspends and reinstates one through `POST /auth/admin/users/:userId/suspend` and `/reinstate`, under `auth:users:suspend`, with a reason the trail keeps. They delete one through `DELETE /auth/admin/users/:userId` — soft by default, restorable through `POST …/restore` until the purge window closes, or `mode: "hard"` to purge now — under `auth:users:delete`, and export everything the kit holds about one person through `
|
|
65
|
+
An account can be suspended or deleted, and the kit refuses it at every door. An operator suspends and reinstates one through `POST /auth/admin/users/:userId/suspend` and `/reinstate`, under `auth:users:suspend`, with a reason the trail keeps. They delete one through `DELETE /auth/admin/users/:userId` — soft by default, restorable through `POST …/restore` until the purge window closes, or `mode: "hard"` to purge now — under `auth:users:delete`, and export everything the kit holds about one person through `POST …/export` with the reason in the body, under `auth:users:export`. A person deletes their own account with `DELETE /auth/account { confirm: true }`, which is what the App Store and Google Play require of an app with accounts. A purge Workflow, hosted by your own Worker, erases a deleted account from every capability that holds it, one step per capability; the four that keep a person's rows — payments, email, audit and the control plane's legal holds — say why, and the export says it with them. A legal hold on the account stops its purge until it is released, and when the Worker's `retention` block declares class ages, the daily pass soft-deletes an account inactive past them through this same lifecycle. Auth's own routes, sign-in and token refresh answer `auth/account_suspended` or `auth/account_deleted` (403); another capability's `requireAuth()` answers 401, and the client's next refresh gets the code. The admin user reads say where each account stands — `state`, `suspendedUntil` and `purgeAfter` — read the way enforcement reads them. [`docs/account-lifecycle.md`](docs/account-lifecycle.md) has the two states, the record, the scopes, the routes, the purge and the Workflow classes to export for it, the mail, the hooks, the screens, and the purge contribution a capability declares for its own rows.
|
|
66
66
|
|
|
67
67
|
**Every purge can be proved.** The purge records an audit event per step and on completion, and names the step it stopped at when it gives up. `GET /control-plane/erasure/user/:userId`, under `erasure:read`, attests one account's erasure from that record: when it was deleted, by which kind of actor and why, soft or hard, each step erased or kept with its reason, the purge's state, and the audit event behind each step by id and chain position. `GET /control-plane/erasure?since&until` counts every purge in a period and names each failed or overdue one. Nothing about the person crosses but the id. [`docs/CONTROL-PLANE.md` §12](../../docs/CONTROL-PLANE.md#erasure) has the shape.
|
|
68
68
|
|
package/dist/admin/users.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
+
import type { DatabaseSchema } from "@pithy-sh/core/src/data/db";
|
|
4
|
+
import { type Expression, type ExpressionBuilder, type SqlBool } from "kysely";
|
|
3
5
|
import { Session, User } from "../data/betterAuth";
|
|
4
6
|
import { Device, type DevicePlatform } from "../data/device";
|
|
5
|
-
import type { AuthDatabase } from "../data/tables";
|
|
7
|
+
import type { AuthDatabase, AuthTables } from "../data/tables";
|
|
8
|
+
import type { AccountStanding } from "../lifecycle/state";
|
|
6
9
|
/**
|
|
7
10
|
* The reads a management dashboard's user panes resolve to, and the lookups its revocations need.
|
|
8
11
|
*
|
|
@@ -46,11 +49,26 @@ export interface AdminSubList<T> {
|
|
|
46
49
|
export interface ListUsersOptions {
|
|
47
50
|
/** Free text matched against email and display name. Absent lists everyone, newest first. */
|
|
48
51
|
search?: string;
|
|
52
|
+
/** Where the account stands, judged at `now` exactly as `accountStanding` judges it. */
|
|
53
|
+
state?: AccountStanding["state"];
|
|
54
|
+
/** Whether the address is verified. */
|
|
55
|
+
verified?: boolean;
|
|
56
|
+
/** Created at or after this instant. Inclusive. */
|
|
57
|
+
since?: Date;
|
|
58
|
+
/** Created before this instant. Exclusive. */
|
|
59
|
+
until?: Date;
|
|
60
|
+
/** The instant `state` is judged at. Defaults to the moment of the read. */
|
|
61
|
+
now?: Date;
|
|
49
62
|
/** The previous page's `nextCursor`. A malformed one is a first page, never an error. */
|
|
50
63
|
cursor?: string;
|
|
51
64
|
/** How many rows to return, clamped into `[1, MAX_PAGE_SIZE]` by `pageLimit`. */
|
|
52
65
|
limit?: number;
|
|
53
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* The rows `accountStanding` reads as `state` at `now`, as one predicate: deleted outranks suspended, and a
|
|
69
|
+
* suspension ends at the instant its `suspendedUntil` names.
|
|
70
|
+
*/
|
|
71
|
+
export declare function standingPredicate(state: AccountStanding["state"], now: Date): (eb: ExpressionBuilder<DatabaseSchema<AuthTables>, "pithyAuthUsers">) => Expression<SqlBool>;
|
|
54
72
|
/**
|
|
55
73
|
* Users, newest first, optionally filtered by a free-text term over email and display name.
|
|
56
74
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/admin/users.ts"],"names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AE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAapH;AAED,6DAA6D;AAC7D,MAAM,WAAW,yBAAyB;IACxC,4FAA4F;IAC5F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wGAAwG;IACxG,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,EAAE,EAAE,YAAY,EAChB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAoC5B;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,EAAE,EAAE,YAAY,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAO/D;AAED,2FAA2F;AAC3F,wBAAsB,iBAAiB,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAG3F"}
|
package/dist/admin/users.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Session, User } from "../data/betterAuth.js";
|
|
4
4
|
import { Device } from "../data/device.js";
|
|
5
5
|
import { ValidationError } from "@pithy-sh/core/src/error/pithyError";
|
|
6
|
+
import { SQLiteBoolean, SQLiteDate } from "@pithy-sh/core/src/data/codecs";
|
|
6
7
|
import { MAX_BOUND_PARAMETERS, boundParameterBudget } from "@pithy-sh/core/src/data/boundParameters";
|
|
7
8
|
import { decodeCursor, pageLimit, toPage } from "@pithy-sh/core/src/data/cursor";
|
|
8
9
|
import { sql } from "kysely";
|
|
@@ -41,6 +42,18 @@ function likePattern(term) {
|
|
|
41
42
|
return `%${term.replace(/[\\%_]/g, (char) => `\\${char}`)}%`;
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
45
|
+
* The rows `accountStanding` reads as `state` at `now`, as one predicate: deleted outranks suspended, and a
|
|
46
|
+
* suspension ends at the instant its `suspendedUntil` names.
|
|
47
|
+
*/
|
|
48
|
+
function standingPredicate(state, now) {
|
|
49
|
+
const at = SQLiteDate.encode(now);
|
|
50
|
+
return (eb) => {
|
|
51
|
+
if (state === "deleted") return eb("deletedAt", "is not", null);
|
|
52
|
+
const inForce = eb.and([eb("suspendedAt", "is not", null), eb.or([eb("suspendedUntil", "is", null), eb("suspendedUntil", ">", at)])]);
|
|
53
|
+
return eb.and([eb("deletedAt", "is", null), state === "suspended" ? inForce : eb.not(inForce)]);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
44
57
|
* Users, newest first, optionally filtered by a free-text term over email and display name.
|
|
45
58
|
*
|
|
46
59
|
* Keyset-paginated on `(createdAt, id)` — never an offset. The users table is written to constantly
|
|
@@ -58,6 +71,10 @@ async function listUsers(db, options = {}) {
|
|
|
58
71
|
const pattern = likePattern(term);
|
|
59
72
|
query = query.where(sql`(email like ${pattern} escape '\\' or name like ${pattern} escape '\\')`);
|
|
60
73
|
}
|
|
74
|
+
if (options.state !== void 0) query = query.where(standingPredicate(options.state, options.now ?? /* @__PURE__ */ new Date()));
|
|
75
|
+
if (options.verified !== void 0) query = query.where("emailVerified", "=", SQLiteBoolean.encode(options.verified));
|
|
76
|
+
if (options.since !== void 0) query = query.where("createdAt", ">=", options.since.toISOString());
|
|
77
|
+
if (options.until !== void 0) query = query.where("createdAt", "<", options.until.toISOString());
|
|
61
78
|
const cursor = decodeCursor(options.cursor);
|
|
62
79
|
if (cursor) {
|
|
63
80
|
const at = String(cursor.sort);
|
|
@@ -204,4 +221,4 @@ async function userSessionTokens(db, userId) {
|
|
|
204
221
|
return (await db.selectFrom("pithyAuthSessions").select("token").where("userId", "=", userId).execute()).map((row) => row.token);
|
|
205
222
|
}
|
|
206
223
|
//#endregion
|
|
207
|
-
export { MAX_USER_LOOKUP, USER_LOOKUP_FIXED_PARAMETERS, findSessionById, getUser, getUsers, listDeviceRegistry, listUserDevices, listUserSessions, listUsers, userProviders, userSessionTokens };
|
|
224
|
+
export { MAX_USER_LOOKUP, USER_LOOKUP_FIXED_PARAMETERS, findSessionById, getUser, getUsers, listDeviceRegistry, listUserDevices, listUserSessions, listUsers, standingPredicate, userProviders, userSessionTokens };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adminRoutes.d.ts","sourceRoot":"","sources":["../../src/http/adminRoutes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAS7E,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAe1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"adminRoutes.d.ts","sourceRoot":"","sources":["../../src/http/adminRoutes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAS7E,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAe1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAgUhD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,UAAU,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,CA4hB7F"}
|
package/dist/http/adminRoutes.js
CHANGED
|
@@ -15,7 +15,7 @@ import { auditedLifecycleCall, recordLifecycleRefusal } from "../lifecycle/audit
|
|
|
15
15
|
import { AUTH_PURGE_BINDING } from "../purge/specs.js";
|
|
16
16
|
import { startPurgeInstance } from "../purge/start.js";
|
|
17
17
|
import { AdminDeviceRevokeResponse, AdminDevicesResponse, AdminRevokeResponse, AdminUserDeleteResponse, AdminUserExportResponse, AdminUserReinstateResponse, AdminUserResponse, AdminUserRestoreResponse, AdminUserSuspendResponse, AdminUsersResponse, AdminVerificationsResponse } from "./responses.js";
|
|
18
|
-
import { DeleteUserBody,
|
|
18
|
+
import { DeleteUserBody, ExportUserBody, ListDevicesQuery, ListUsersQuery, ListVerificationsQuery, ReinstateUserBody, RestoreUserBody, RevokeDeviceBody, RevokeSessionBody, SearchUsersBody, SuspendUserBody, UserIdParam } from "./schemas.js";
|
|
19
19
|
import { deletionView, deviceView, exportView, reinstatementView, restorationView, sessionView, suspensionView, userView, verificationView } from "./views.js";
|
|
20
20
|
import { purgeExports } from "@pithy-sh/core/src/capability/purge";
|
|
21
21
|
import { InternalError, NotFoundError } from "@pithy-sh/core/src/error/pithyError";
|
|
@@ -30,6 +30,7 @@ import { workflowBindingFor } from "@pithy-sh/core/src/workflow/dispatch";
|
|
|
30
30
|
* revocations an incident costs.
|
|
31
31
|
*
|
|
32
32
|
* GET {base}/admin/users auth:users:read query: ListUsersQuery
|
|
33
|
+
* POST {base}/admin/users/search auth:users:read json: SearchUsersBody
|
|
33
34
|
* GET {base}/admin/users/:userId auth:users:read param: UserIdParam
|
|
34
35
|
* GET {base}/admin/devices auth:devices:read query: ListDevicesQuery
|
|
35
36
|
* GET {base}/admin/verifications auth:verifications:read query: ListVerificationsQuery
|
|
@@ -40,7 +41,7 @@ import { workflowBindingFor } from "@pithy-sh/core/src/workflow/dispatch";
|
|
|
40
41
|
* POST {base}/admin/users/:userId/reinstate auth:users:suspend param + json: ReinstateUserBody
|
|
41
42
|
* DELETE {base}/admin/users/:userId auth:users:delete param + json: DeleteUserBody
|
|
42
43
|
* POST {base}/admin/users/:userId/restore auth:users:delete param + json: RestoreUserBody
|
|
43
|
-
*
|
|
44
|
+
* POST {base}/admin/users/:userId/export auth:users:export param + json: ExportUserBody
|
|
44
45
|
*
|
|
45
46
|
* ## Registered before the catch-all, or dead
|
|
46
47
|
*
|
|
@@ -81,11 +82,11 @@ function db(c, wiring) {
|
|
|
81
82
|
return authDatabase(resolveDb(c.env, wiring.config.database));
|
|
82
83
|
}
|
|
83
84
|
/**
|
|
84
|
-
* One of the user pane's sub-reads, guarded and projected in one step
|
|
85
|
+
* One of the user pane's sub-reads, guarded and projected in one step.
|
|
85
86
|
*
|
|
86
87
|
* **`try`/`catch` inside an `async` function, never `.catch()`.** The read is *called* inside the `try`,
|
|
87
88
|
* so a seam that throws before it returns a promise is caught too — a rejected promise is not the only
|
|
88
|
-
* way a D1 read fails, and a `.catch()` guard
|
|
89
|
+
* way a D1 read fails, and a `.catch()` guard is escaped by exactly that.
|
|
89
90
|
*
|
|
90
91
|
* **The guard takes no binding.** The state is the whole of what travels; what the read threw names a
|
|
91
92
|
* query and a table, and this response goes to a management client across a trust boundary.
|
|
@@ -175,7 +176,7 @@ function lifecycleCall(c, wiring, caller, userId, reason) {
|
|
|
175
176
|
};
|
|
176
177
|
}
|
|
177
178
|
/**
|
|
178
|
-
* A lifecycle route's body validator, which audits the bodies it refuses
|
|
179
|
+
* A lifecycle route's body validator, which audits the bodies it refuses. Every call is on the trail,
|
|
179
180
|
* a refusal included, and a body the validator turns away never reaches `auditedLifecycleCall`. So it is
|
|
180
181
|
* recorded here, as `denied` under the route's own action, with whatever reason the body carried — cut to the
|
|
181
182
|
* reason's own limit, so a refused essay is not stored whole — and the 400 is thrown as before.
|
|
@@ -221,7 +222,7 @@ async function endSessions(c, wiring, caller, userId, cause) {
|
|
|
221
222
|
return revoked;
|
|
222
223
|
}
|
|
223
224
|
/**
|
|
224
|
-
* Start the purge of one account now
|
|
225
|
+
* Start the purge of one account now: `started` when this Worker binds the purge Workflow and it took the
|
|
225
226
|
* instance — or already held it — and `pending` when it binds none or the start failed; the account is due
|
|
226
227
|
* either way, and the daily pass starts it. A failed start is not this call's failure: the deletion is already
|
|
227
228
|
* written, and a 500 over it would invite a retry that finds the account deleted and says nothing new.
|
|
@@ -263,15 +264,14 @@ function scheduledOrDue(result) {
|
|
|
263
264
|
function registerAuthAdminRoutes(wiring) {
|
|
264
265
|
return (app) => {
|
|
265
266
|
const base = wiring.config.basePath;
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
verification: "control-plane",
|
|
269
|
-
scopes: [AUTH_USERS_READ_SCOPE],
|
|
270
|
-
responses: { 200: AdminUsersResponse }
|
|
271
|
-
}), requireControlPlane(AUTH_USERS_READ_SCOPE), validate("query", ListUsersQuery), async (c) => {
|
|
272
|
-
const query = c.req.valid("query");
|
|
267
|
+
/** One page of users, audited as a listing: whether it was a search and how much came back, never the term. */
|
|
268
|
+
const pageOfUsers = async (c, query) => {
|
|
273
269
|
const caller = controlPlaneCaller(c);
|
|
274
|
-
const
|
|
270
|
+
const now = /* @__PURE__ */ new Date();
|
|
271
|
+
const page = await listUsers(db(c, wiring), {
|
|
272
|
+
...query,
|
|
273
|
+
now
|
|
274
|
+
});
|
|
275
275
|
await emitControlPlaneAction(c.var.emit, {
|
|
276
276
|
action: AuthAuditActions.adminUsersListed,
|
|
277
277
|
subject: caller.subject,
|
|
@@ -279,16 +279,34 @@ function registerAuthAdminRoutes(wiring) {
|
|
|
279
279
|
resourceType: "user",
|
|
280
280
|
...context(c),
|
|
281
281
|
metadata: {
|
|
282
|
-
searched:
|
|
283
|
-
returned: page.items.length
|
|
282
|
+
searched: "search" in query,
|
|
283
|
+
returned: page.items.length,
|
|
284
|
+
filters: {
|
|
285
|
+
state: query.state ?? null,
|
|
286
|
+
verified: query.verified ?? null,
|
|
287
|
+
since: query.since?.toISOString() ?? null,
|
|
288
|
+
until: query.until?.toISOString() ?? null
|
|
289
|
+
}
|
|
284
290
|
}
|
|
285
291
|
});
|
|
286
|
-
const now = /* @__PURE__ */ new Date();
|
|
287
292
|
return c.json({
|
|
288
293
|
users: page.items.map((user) => userView(user, now)),
|
|
289
294
|
nextCursor: page.nextCursor
|
|
290
295
|
});
|
|
291
|
-
}
|
|
296
|
+
};
|
|
297
|
+
app.get(`${base}/admin/users`, describeRoute({
|
|
298
|
+
summary: "Page through the users, newest first, narrowing by standing, verification or signup window. A search by address or name is `POST /admin/users/search`.",
|
|
299
|
+
verification: "control-plane",
|
|
300
|
+
scopes: [AUTH_USERS_READ_SCOPE],
|
|
301
|
+
responses: { 200: AdminUsersResponse }
|
|
302
|
+
}), requireControlPlane(AUTH_USERS_READ_SCOPE), validate("query", ListUsersQuery), async (c) => pageOfUsers(c, c.req.valid("query")));
|
|
303
|
+
app.post(`${base}/admin/users/search`, describeRoute({
|
|
304
|
+
summary: "Search the users by email or name, newest first, with the listing's filters, paged on its cursor.",
|
|
305
|
+
description: "The term travels in the body, because a query string is written to every request log between the client and the Worker and a search term is usually somebody's address. Answers the listing's envelope. Audited as a listing that searched, never with the term. Read-only.",
|
|
306
|
+
verification: "control-plane",
|
|
307
|
+
scopes: [AUTH_USERS_READ_SCOPE],
|
|
308
|
+
responses: { 200: AdminUsersResponse }
|
|
309
|
+
}), requireControlPlane(AUTH_USERS_READ_SCOPE), validate("json", SearchUsersBody), async (c) => pageOfUsers(c, c.req.valid("json")));
|
|
292
310
|
app.get(`${base}/admin/users/:userId`, describeRoute({
|
|
293
311
|
summary: "Read one user with their sessions, devices and linked providers.",
|
|
294
312
|
verification: "control-plane",
|
|
@@ -570,15 +588,15 @@ function registerAuthAdminRoutes(wiring) {
|
|
|
570
588
|
}), (outcome) => !outcome.changed);
|
|
571
589
|
return c.json(restorationView(userId, result));
|
|
572
590
|
});
|
|
573
|
-
app.
|
|
591
|
+
app.post(`${base}/admin/users/:userId/export`, describeRoute({
|
|
574
592
|
summary: "Export everything the kit holds about one user, from every composed capability, as one document.",
|
|
575
|
-
description: "The answer to an access request. One entry per composed capability that declares a purge contribution, in the order the purge erases them. Audited as a disclosure, with the reason.",
|
|
593
|
+
description: "The answer to an access request. One entry per composed capability that declares a purge contribution, in the order the purge erases them. Audited as a disclosure, with the reason, which travels in the body because a reason often names the person who asked and a URL is written to every request log. Changes nothing.",
|
|
576
594
|
verification: "control-plane",
|
|
577
595
|
scopes: [AUTH_USERS_EXPORT_SCOPE],
|
|
578
596
|
responses: { 200: AdminUserExportResponse }
|
|
579
|
-
}), requireControlPlane(AUTH_USERS_EXPORT_SCOPE), validate("param", UserIdParam), validate("
|
|
597
|
+
}), requireControlPlane(AUTH_USERS_EXPORT_SCOPE), validate("param", UserIdParam), validate("json", ExportUserBody), async (c) => {
|
|
580
598
|
const { userId } = c.req.valid("param");
|
|
581
|
-
const { reason } = c.req.valid("
|
|
599
|
+
const { reason } = c.req.valid("json");
|
|
582
600
|
const caller = controlPlaneCaller(c);
|
|
583
601
|
const call = lifecycleCall(c, wiring, caller, userId, reason);
|
|
584
602
|
const exportedAt = /* @__PURE__ */ new Date();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../src/http/guards.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sDAAsD,CAAC;AAClG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,iBAAqC,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,iBAAuC,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,iBAA0C,CAAC;AAEpF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,iBAAuC,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,iBAAyC,CAAC;AAElF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,iBAAwC,CAAC;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,iBAAuC,CAAC;AA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gB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,EAAE,CA+GzE"}
|
package/dist/http/guards.js
CHANGED
|
@@ -145,7 +145,16 @@ function authAdminRoutes(basePath) {
|
|
|
145
145
|
path: `${basePath}/admin/users`,
|
|
146
146
|
scope: AUTH_USERS_READ_SCOPE,
|
|
147
147
|
kind: "reads",
|
|
148
|
-
summary: "
|
|
148
|
+
summary: "List the users newest first, narrowed by standing, verification or signup window."
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
method: "POST",
|
|
152
|
+
operation: "users.search",
|
|
153
|
+
path: `${basePath}/admin/users/search`,
|
|
154
|
+
scope: AUTH_USERS_READ_SCOPE,
|
|
155
|
+
kind: "reads",
|
|
156
|
+
readInBody: true,
|
|
157
|
+
summary: "Find a user by email or display name, the term in the body so it never reaches a request log."
|
|
149
158
|
},
|
|
150
159
|
{
|
|
151
160
|
method: "GET",
|
|
@@ -228,11 +237,12 @@ function authAdminRoutes(basePath) {
|
|
|
228
237
|
summary: "Every sign-in link and code sent over a window: used, expired or still waiting, and the mail that carried it."
|
|
229
238
|
},
|
|
230
239
|
{
|
|
231
|
-
method: "
|
|
240
|
+
method: "POST",
|
|
232
241
|
operation: "users.export",
|
|
233
242
|
path: `${basePath}/admin/users/:userId/export`,
|
|
234
243
|
scope: AUTH_USERS_EXPORT_SCOPE,
|
|
235
244
|
kind: "reads",
|
|
245
|
+
readInBody: true,
|
|
236
246
|
summary: "Everything the kit holds about one user, from every capability — the answer to an access request."
|
|
237
247
|
}
|
|
238
248
|
];
|
package/dist/http/responses.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export declare const AdminDeviceView: z.ZodObject<{
|
|
|
49
49
|
createdAt: z.ZodISODateTime;
|
|
50
50
|
}, z.core.$strip>;
|
|
51
51
|
export type AdminDeviceView = z.output<typeof AdminDeviceView>;
|
|
52
|
-
/** `GET {base}/admin/users`. */
|
|
52
|
+
/** `GET {base}/admin/users` and `POST {base}/admin/users/search`. */
|
|
53
53
|
export declare const AdminUsersResponse: z.ZodObject<{
|
|
54
54
|
users: z.ZodArray<z.ZodObject<{
|
|
55
55
|
id: z.ZodString;
|
|
@@ -156,7 +156,7 @@ export declare const AdminDevicesResponse: z.ZodObject<{
|
|
|
156
156
|
}, z.core.$strip>;
|
|
157
157
|
export type AdminDevicesResponse = z.output<typeof AdminDevicesResponse>;
|
|
158
158
|
/**
|
|
159
|
-
* One sign-in link or code from the verification ledger
|
|
159
|
+
* One sign-in link or code from the verification ledger, as a management client sees it.
|
|
160
160
|
*
|
|
161
161
|
* Never the token and never the address: the ledger holds neither. The mail is named by its job id, which is how
|
|
162
162
|
* a reader holding `email:jobs:read` joins this to a bounce, a deferral or a suppression.
|
|
@@ -192,7 +192,7 @@ export declare const VerificationTypeCounts: z.ZodObject<{
|
|
|
192
192
|
}, z.core.$strip>;
|
|
193
193
|
export type VerificationTypeCounts = z.output<typeof VerificationTypeCounts>;
|
|
194
194
|
/**
|
|
195
|
-
* `GET {base}/admin/verifications
|
|
195
|
+
* `GET {base}/admin/verifications`: the window it covered, the counts by type and state over all of it,
|
|
196
196
|
* and a page of its rows, newest issue first.
|
|
197
197
|
*
|
|
198
198
|
* The counts cover every row in the window whatever the page or the filters say, and every type, with zeros —
|
|
@@ -251,7 +251,7 @@ export declare const AdminDeviceRevokeResponse: z.ZodObject<{
|
|
|
251
251
|
}, z.core.$strip>;
|
|
252
252
|
export type AdminDeviceRevokeResponse = z.output<typeof AdminDeviceRevokeResponse>;
|
|
253
253
|
/**
|
|
254
|
-
* `POST {base}/admin/users/:userId/suspend
|
|
254
|
+
* `POST {base}/admin/users/:userId/suspend`.
|
|
255
255
|
*
|
|
256
256
|
* The suspension the account is now under, how many sessions ended with it, and whether the person was told.
|
|
257
257
|
* Not the reason: the caller wrote it, the trail keeps it, and echoing it back would put it in one more place
|
|
@@ -271,7 +271,7 @@ export declare const AdminUserSuspendResponse: z.ZodObject<{
|
|
|
271
271
|
}, z.core.$strip>;
|
|
272
272
|
export type AdminUserSuspendResponse = z.output<typeof AdminUserSuspendResponse>;
|
|
273
273
|
/**
|
|
274
|
-
* `POST {base}/admin/users/:userId/reinstate
|
|
274
|
+
* `POST {base}/admin/users/:userId/reinstate`.
|
|
275
275
|
*
|
|
276
276
|
* No session count: a reinstatement restores none. The person signs in again.
|
|
277
277
|
*/
|
|
@@ -286,7 +286,7 @@ export declare const AdminUserReinstateResponse: z.ZodObject<{
|
|
|
286
286
|
}, z.core.$strip>;
|
|
287
287
|
export type AdminUserReinstateResponse = z.output<typeof AdminUserReinstateResponse>;
|
|
288
288
|
/**
|
|
289
|
-
* `DELETE {base}/admin/users/:userId
|
|
289
|
+
* `DELETE {base}/admin/users/:userId`.
|
|
290
290
|
*
|
|
291
291
|
* What the deletion left in force, how many sessions ended with it, whether the person was told, and what
|
|
292
292
|
* became of the purge. Not the reason: the caller wrote it and the trail keeps it.
|
|
@@ -315,7 +315,7 @@ export declare const AdminUserDeleteResponse: z.ZodObject<{
|
|
|
315
315
|
}, z.core.$strip>;
|
|
316
316
|
export type AdminUserDeleteResponse = z.output<typeof AdminUserDeleteResponse>;
|
|
317
317
|
/**
|
|
318
|
-
* `POST {base}/admin/users/:userId/restore
|
|
318
|
+
* `POST {base}/admin/users/:userId/restore`. No session count: a restoration restores none.
|
|
319
319
|
*/
|
|
320
320
|
export declare const AdminUserRestoreResponse: z.ZodObject<{
|
|
321
321
|
userId: z.ZodString;
|
|
@@ -330,7 +330,7 @@ export declare const AdminUserRestoreResponse: z.ZodObject<{
|
|
|
330
330
|
}, z.core.$strip>;
|
|
331
331
|
export type AdminUserRestoreResponse = z.output<typeof AdminUserRestoreResponse>;
|
|
332
332
|
/**
|
|
333
|
-
* What `@pithy-sh/auth` holds about one account, as its purge contribution exports it
|
|
333
|
+
* What `@pithy-sh/auth` holds about one account, as its purge contribution exports it — the `data` of
|
|
334
334
|
* the `auth` entry in an export.
|
|
335
335
|
*
|
|
336
336
|
* The person's own data and none of their credentials: no session token, no provider token, no push token.
|
|
@@ -414,7 +414,7 @@ export declare const AuthUserExport: z.ZodObject<{
|
|
|
414
414
|
}, z.core.$strip>;
|
|
415
415
|
export type AuthUserExport = z.output<typeof AuthUserExport>;
|
|
416
416
|
/**
|
|
417
|
-
* `
|
|
417
|
+
* `POST {base}/admin/users/:userId/export`.
|
|
418
418
|
*
|
|
419
419
|
* Everything the kit holds about one account — the answer to an access request. One entry per composed
|
|
420
420
|
* capability that declares a purge contribution, in the order the purge runs them, each read on its own so
|
|
@@ -516,7 +516,7 @@ export declare const MyDeviceRevokeResponse: z.ZodObject<{
|
|
|
516
516
|
}, z.core.$strip>;
|
|
517
517
|
export type MyDeviceRevokeResponse = z.output<typeof MyDeviceRevokeResponse>;
|
|
518
518
|
/**
|
|
519
|
-
* `DELETE {base}/account`
|
|
519
|
+
* `DELETE {base}/account` — the signed-in person deleted their own account. Always soft, on the
|
|
520
520
|
* configured window. Their sessions end with it, this one included.
|
|
521
521
|
*/
|
|
522
522
|
export declare const AccountDeleteResponse: z.ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/http/responses.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyCxB,kDAAkD;AAClD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;iBAuCsF,CAAC;AACjH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAE3D,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB;;;;;;;;iBAUiF,CAAC;AAC/G,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEjE,0GAA0G;AAC1G,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;iBAawF,CAAC;AACrH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe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AAM,qBAAqB;;;;iBAU2E,CAAC;AAC9G,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
package/dist/http/responses.js
CHANGED
|
@@ -25,7 +25,7 @@ import { Locale } from "@pithy-sh/core/src/i18n/locale";
|
|
|
25
25
|
* **A field added here later is `.optional()`, not merely `.nullable()`.** This module is read across a
|
|
26
26
|
* version boundary — a management client validates a response with this schema against a customer's
|
|
27
27
|
* Worker at whatever kit version it is on — so an additive required key fails `safeParse` for everyone
|
|
28
|
-
* below that release and takes the whole pane with it
|
|
28
|
+
* below that release and takes the whole pane with it. Absent then means *this Worker cannot
|
|
29
29
|
* say*, which is a different fact from `null`.
|
|
30
30
|
*/
|
|
31
31
|
/** Where a page resumes, or the end of the list. */
|
|
@@ -73,14 +73,14 @@ const AdminDeviceView = z.object({
|
|
|
73
73
|
lastSeenAt: z.iso.datetime().describe("When it was last seen, ISO-8601."),
|
|
74
74
|
createdAt: z.iso.datetime().describe("When it first registered, ISO-8601.")
|
|
75
75
|
}).describe("One registered device as a management client sees it — without the push token, which is a credential.");
|
|
76
|
-
/** `GET {base}/admin/users`. */
|
|
76
|
+
/** `GET {base}/admin/users` and `POST {base}/admin/users/search`. */
|
|
77
77
|
const AdminUsersResponse = z.object({
|
|
78
78
|
users: z.array(AdminUserView).describe("The page, newest first."),
|
|
79
79
|
nextCursor: NextCursor
|
|
80
80
|
}).describe("A page of the user list.");
|
|
81
81
|
/** `GET {base}/admin/users/:userId`. */
|
|
82
82
|
/**
|
|
83
|
-
* A sub-read of the user pane that could not be made
|
|
83
|
+
* A sub-read of the user pane that could not be made.
|
|
84
84
|
*
|
|
85
85
|
* The pane fans out over three independent tables and this route used to `Promise.all` them: one D1 read
|
|
86
86
|
* failing took the whole page down, so a support agent looking at a locked-out account saw a 500 instead
|
|
@@ -115,7 +115,7 @@ const AdminDevicesResponse = z.object({
|
|
|
115
115
|
nextCursor: NextCursor
|
|
116
116
|
}).describe("A page of the device registry.");
|
|
117
117
|
/**
|
|
118
|
-
* One sign-in link or code from the verification ledger
|
|
118
|
+
* One sign-in link or code from the verification ledger, as a management client sees it.
|
|
119
119
|
*
|
|
120
120
|
* Never the token and never the address: the ledger holds neither. The mail is named by its job id, which is how
|
|
121
121
|
* a reader holding `email:jobs:read` joins this to a bounce, a deferral or a suppression.
|
|
@@ -139,7 +139,7 @@ const VerificationTypeCounts = z.object({
|
|
|
139
139
|
pending: z.number().int().min(0).describe("How many are unused and still work. The three add up to `issued`.")
|
|
140
140
|
}).describe("One type's counts over the window, by state.");
|
|
141
141
|
/**
|
|
142
|
-
* `GET {base}/admin/verifications
|
|
142
|
+
* `GET {base}/admin/verifications`: the window it covered, the counts by type and state over all of it,
|
|
143
143
|
* and a page of its rows, newest issue first.
|
|
144
144
|
*
|
|
145
145
|
* The counts cover every row in the window whatever the page or the filters say, and every type, with zeros —
|
|
@@ -168,7 +168,7 @@ const AdminDeviceRevokeResponse = z.object({
|
|
|
168
168
|
removed: z.boolean().describe("Whether a device row was deleted. False when the user had no such device.")
|
|
169
169
|
}).describe("How many sessions the device revocation ended, and whether the registry row went with them.");
|
|
170
170
|
/**
|
|
171
|
-
* `POST {base}/admin/users/:userId/suspend
|
|
171
|
+
* `POST {base}/admin/users/:userId/suspend`.
|
|
172
172
|
*
|
|
173
173
|
* The suspension the account is now under, how many sessions ended with it, and whether the person was told.
|
|
174
174
|
* Not the reason: the caller wrote it, the trail keeps it, and echoing it back would put it in one more place
|
|
@@ -184,7 +184,7 @@ const AdminUserSuspendResponse = z.object({
|
|
|
184
184
|
mailed: z.boolean().describe("Whether the account-suspended mail was enqueued. False for `notify: false`, when the config turns it off, or when no email capability is composed.")
|
|
185
185
|
}).describe("A suspended account: since when, until when, how many sessions it cost, and whether the person was told.");
|
|
186
186
|
/**
|
|
187
|
-
* `POST {base}/admin/users/:userId/reinstate
|
|
187
|
+
* `POST {base}/admin/users/:userId/reinstate`.
|
|
188
188
|
*
|
|
189
189
|
* No session count: a reinstatement restores none. The person signs in again.
|
|
190
190
|
*/
|
|
@@ -197,7 +197,7 @@ const AdminUserReinstateResponse = z.object({
|
|
|
197
197
|
/** When the purge may erase a deleted account, ISO-8601. */
|
|
198
198
|
const PurgeAfter = z.iso.datetime().describe("When the purge may erase the account, ISO-8601. It can be restored until then; a hard deletion's is the moment it was deleted.");
|
|
199
199
|
/**
|
|
200
|
-
* `DELETE {base}/admin/users/:userId
|
|
200
|
+
* `DELETE {base}/admin/users/:userId`.
|
|
201
201
|
*
|
|
202
202
|
* What the deletion left in force, how many sessions ended with it, whether the person was told, and what
|
|
203
203
|
* became of the purge. Not the reason: the caller wrote it and the trail keeps it.
|
|
@@ -222,7 +222,7 @@ const AdminUserDeleteResponse = z.object({
|
|
|
222
222
|
mailed: z.boolean().describe("Whether the deletion-scheduled mail was enqueued. Always false for `hard`, whose mail the purge sends, for `notify: false`, and when the config turns it off.")
|
|
223
223
|
}).describe("A deleted account: when, until when it can be restored, what became of the purge, and its sessions.");
|
|
224
224
|
/**
|
|
225
|
-
* `POST {base}/admin/users/:userId/restore
|
|
225
|
+
* `POST {base}/admin/users/:userId/restore`. No session count: a restoration restores none.
|
|
226
226
|
*/
|
|
227
227
|
const AdminUserRestoreResponse = z.object({
|
|
228
228
|
userId: z.string().describe("The account restored, as `pithy_auth_users.id` stores it."),
|
|
@@ -243,7 +243,7 @@ const AuthExportTransition = z.object({
|
|
|
243
243
|
createdAt: z.iso.datetime().describe("When it happened, ISO-8601.")
|
|
244
244
|
}).describe("One transition in the account's history. The operator's identity is theirs, not the person's, so it is not here.");
|
|
245
245
|
/**
|
|
246
|
-
* What `@pithy-sh/auth` holds about one account, as its purge contribution exports it
|
|
246
|
+
* What `@pithy-sh/auth` holds about one account, as its purge contribution exports it — the `data` of
|
|
247
247
|
* the `auth` entry in an export.
|
|
248
248
|
*
|
|
249
249
|
* The person's own data and none of their credentials: no session token, no provider token, no push token.
|
|
@@ -288,7 +288,7 @@ const AdminUserExportEntry = z.discriminatedUnion("state", [
|
|
|
288
288
|
}).describe("Nothing was established about this capability's rows. Deliberately empty — it is not 'none'.")
|
|
289
289
|
]).describe("One capability's part of an export, behind a state, so an unread part cannot be taken for an empty one.");
|
|
290
290
|
/**
|
|
291
|
-
* `
|
|
291
|
+
* `POST {base}/admin/users/:userId/export`.
|
|
292
292
|
*
|
|
293
293
|
* Everything the kit holds about one account — the answer to an access request. One entry per composed
|
|
294
294
|
* capability that declares a purge contribution, in the order the purge runs them, each read on its own so
|
|
@@ -332,7 +332,7 @@ const MyDevicesResponse = z.object({ devices: z.array(MyDeviceView).describe("Ev
|
|
|
332
332
|
/** `POST {base}/devices/revoke`. */
|
|
333
333
|
const MyDeviceRevokeResponse = z.object({ revoked: RevokedCount }).describe("How many of the device's sessions the revocation signed out. The device's row goes with them.");
|
|
334
334
|
/**
|
|
335
|
-
* `DELETE {base}/account`
|
|
335
|
+
* `DELETE {base}/account` — the signed-in person deleted their own account. Always soft, on the
|
|
336
336
|
* configured window. Their sessions end with it, this one included.
|
|
337
337
|
*/
|
|
338
338
|
const AccountDeleteResponse = z.object({
|
package/dist/http/schemas.d.ts
CHANGED
|
@@ -70,13 +70,46 @@ export declare const UserIdParam: z.ZodObject<{
|
|
|
70
70
|
userId: z.ZodString;
|
|
71
71
|
}, z.core.$strip>;
|
|
72
72
|
export type UserIdParam = z.output<typeof UserIdParam>;
|
|
73
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* The user listing query. Strict, and there is no `search`: a search term is usually somebody's address, and
|
|
75
|
+
* a query string is written to every request log, so a search is {@link SearchUsersBody}, in a body. A
|
|
76
|
+
* client still sending `?search=` is refused as `validation/invalid_input` rather than handed every user as
|
|
77
|
+
* though they were the match.
|
|
78
|
+
*/
|
|
74
79
|
export declare const ListUsersQuery: z.ZodObject<{
|
|
75
|
-
|
|
80
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
81
|
+
active: "active";
|
|
82
|
+
deleted: "deleted";
|
|
83
|
+
suspended: "suspended";
|
|
84
|
+
}>>;
|
|
85
|
+
since: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>;
|
|
86
|
+
until: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>;
|
|
76
87
|
cursor: z.ZodOptional<z.ZodString>;
|
|
88
|
+
verified: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
|
|
89
|
+
false: "false";
|
|
90
|
+
true: "true";
|
|
91
|
+
}>, z.ZodTransform<boolean, "false" | "true">>>;
|
|
77
92
|
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
78
|
-
}, z.core.$
|
|
93
|
+
}, z.core.$strict>;
|
|
79
94
|
export type ListUsersQuery = z.output<typeof ListUsersQuery>;
|
|
95
|
+
/**
|
|
96
|
+
* The body of `POST {base}/admin/users/search`: the term, the listing's filters, and the cursor, all in a body
|
|
97
|
+
* so the term never reaches a request log. Pages exactly as the listing does.
|
|
98
|
+
*/
|
|
99
|
+
export declare const SearchUsersBody: z.ZodObject<{
|
|
100
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
101
|
+
active: "active";
|
|
102
|
+
deleted: "deleted";
|
|
103
|
+
suspended: "suspended";
|
|
104
|
+
}>>;
|
|
105
|
+
since: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>;
|
|
106
|
+
until: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>;
|
|
107
|
+
search: z.ZodString;
|
|
108
|
+
cursor: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
109
|
+
verified: z.ZodOptional<z.ZodBoolean>;
|
|
110
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
111
|
+
}, z.core.$strict>;
|
|
112
|
+
export type SearchUsersBody = z.output<typeof SearchUsersBody>;
|
|
80
113
|
/** The device-registry listing query. */
|
|
81
114
|
export declare const ListDevicesQuery: z.ZodObject<{
|
|
82
115
|
userId: z.ZodOptional<z.ZodString>;
|
|
@@ -90,7 +123,7 @@ export declare const ListDevicesQuery: z.ZodObject<{
|
|
|
90
123
|
}, z.core.$strip>;
|
|
91
124
|
export type ListDevicesQuery = z.output<typeof ListDevicesQuery>;
|
|
92
125
|
/**
|
|
93
|
-
* The verification ledger read's query
|
|
126
|
+
* The verification ledger read's query: a window of issue times, what to narrow it to, and where to resume.
|
|
94
127
|
* Both bounds are optional — the last 30 days, ending now — and a window that ends before it starts is refused by
|
|
95
128
|
* the handler, which is where the default is known.
|
|
96
129
|
*/
|
|
@@ -136,7 +169,7 @@ export declare const ReinstateUserBody: z.ZodObject<{
|
|
|
136
169
|
}, z.core.$strip>;
|
|
137
170
|
export type ReinstateUserBody = z.output<typeof ReinstateUserBody>;
|
|
138
171
|
/**
|
|
139
|
-
* How a deletion runs
|
|
172
|
+
* How a deletion runs. `soft` is the default and the only thing an omission reaches: the account is shut
|
|
140
173
|
* now and erased once the window closes, restorable until then. `hard` starts the purge at once, with no
|
|
141
174
|
* window, and is reached only by naming it — a typo is a 400, never either mode.
|
|
142
175
|
*/
|
|
@@ -161,15 +194,16 @@ export declare const RestoreUserBody: z.ZodObject<{
|
|
|
161
194
|
}, z.core.$strip>;
|
|
162
195
|
export type RestoreUserBody = z.output<typeof RestoreUserBody>;
|
|
163
196
|
/**
|
|
164
|
-
* The
|
|
165
|
-
* says why, like every lifecycle call: the reason goes on the trail beside who asked
|
|
197
|
+
* The body of `POST /admin/users/:userId/export`. A disclosure of everything the kit holds about one person
|
|
198
|
+
* says why, like every lifecycle call: the reason goes on the trail beside who asked, and in a body, never a
|
|
199
|
+
* URL, because a reason names the request it answers and often the person who made it.
|
|
166
200
|
*/
|
|
167
|
-
export declare const
|
|
201
|
+
export declare const ExportUserBody: z.ZodObject<{
|
|
168
202
|
reason: z.ZodString;
|
|
169
|
-
}, z.core.$
|
|
170
|
-
export type
|
|
203
|
+
}, z.core.$strict>;
|
|
204
|
+
export type ExportUserBody = z.output<typeof ExportUserBody>;
|
|
171
205
|
/**
|
|
172
|
-
* The body of `DELETE /account`, the signed-in person deleting their own account
|
|
206
|
+
* The body of `DELETE /account`, the signed-in person deleting their own account.
|
|
173
207
|
*
|
|
174
208
|
* The confirmation is the literal `true`, so a client must say it on purpose: a stray `DELETE` with an empty
|
|
175
209
|
* body, or a form posting `"false"`, deletes nothing. There is no field naming an account — the subject is the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/http/schemas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/http/schemas.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;iBAQ2E,CAAC;AACzG,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEjE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;iBAesF,CAAC;AACvH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEvE,mHAAmH;AACnH,eAAO,MAAM,gBAAgB;;;;;;EAI1B,CAAC;AACJ,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEjE;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;iBAqBhC,CAAC;AACJ,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE7E;;;;;;GAMG;AACH,eAAO,MAAM,WAAW;;iBAIoD,CAAC;AAC7E,MAAM,MAAM,WAAW,GAAG,CAAC,C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