@pithy-sh/auth 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/admin/users.d.ts +155 -0
  2. package/dist/admin/users.d.ts.map +1 -0
  3. package/dist/admin/users.js +205 -0
  4. package/dist/audit/actions.d.ts +66 -0
  5. package/dist/audit/actions.d.ts.map +1 -0
  6. package/dist/audit/actions.js +66 -0
  7. package/dist/audit/emit.d.ts +101 -0
  8. package/dist/audit/emit.d.ts.map +1 -0
  9. package/dist/audit/emit.js +170 -0
  10. package/dist/capability.d.ts +60 -0
  11. package/dist/capability.d.ts.map +1 -0
  12. package/dist/capability.js +169 -0
  13. package/dist/client/api.d.ts +299 -0
  14. package/dist/client/api.d.ts.map +1 -0
  15. package/dist/client/api.js +385 -0
  16. package/dist/client/projection.d.ts +51 -0
  17. package/dist/client/projection.d.ts.map +1 -0
  18. package/dist/client/projection.js +0 -0
  19. package/dist/data/betterAuth.d.ts +75 -0
  20. package/dist/data/betterAuth.d.ts.map +1 -0
  21. package/dist/data/betterAuth.js +92 -0
  22. package/dist/data/device.d.ts +36 -0
  23. package/dist/data/device.d.ts.map +1 -0
  24. package/dist/data/device.js +33 -0
  25. package/dist/data/kitFields.d.ts +78 -0
  26. package/dist/data/kitFields.d.ts.map +1 -0
  27. package/dist/data/kitFields.js +77 -0
  28. package/dist/data/rotatedToken.d.ts +20 -0
  29. package/dist/data/rotatedToken.d.ts.map +1 -0
  30. package/dist/data/rotatedToken.js +22 -0
  31. package/dist/data/tables.d.ts +104 -0
  32. package/dist/data/tables.d.ts.map +1 -0
  33. package/dist/data/tables.js +30 -0
  34. package/dist/device/registry.d.ts +54 -0
  35. package/dist/device/registry.d.ts.map +1 -0
  36. package/dist/device/registry.js +85 -0
  37. package/dist/email/send.d.ts +38 -0
  38. package/dist/email/send.d.ts.map +1 -0
  39. package/dist/email/send.js +48 -0
  40. package/dist/http/adminRoutes.d.ts +9 -0
  41. package/dist/http/adminRoutes.d.ts.map +1 -0
  42. package/dist/http/adminRoutes.js +274 -0
  43. package/dist/http/baseUrl.d.ts +41 -0
  44. package/dist/http/baseUrl.d.ts.map +1 -0
  45. package/dist/http/baseUrl.js +96 -0
  46. package/dist/http/csrf.d.ts +18 -0
  47. package/dist/http/csrf.d.ts.map +1 -0
  48. package/dist/http/csrf.js +81 -0
  49. package/dist/http/devLoginRoute.d.ts +42 -0
  50. package/dist/http/devLoginRoute.d.ts.map +1 -0
  51. package/dist/http/devLoginRoute.js +112 -0
  52. package/dist/http/errors.d.ts +24 -0
  53. package/dist/http/errors.d.ts.map +1 -0
  54. package/dist/http/errors.js +67 -0
  55. package/dist/http/guards.d.ts +103 -0
  56. package/dist/http/guards.d.ts.map +1 -0
  57. package/dist/http/guards.js +148 -0
  58. package/dist/http/middleware.d.ts +17 -0
  59. package/dist/http/middleware.d.ts.map +1 -0
  60. package/dist/http/middleware.js +47 -0
  61. package/dist/http/rateLimit.d.ts +17 -0
  62. package/dist/http/rateLimit.d.ts.map +1 -0
  63. package/dist/http/rateLimit.js +31 -0
  64. package/dist/http/resolve.d.ts +9 -0
  65. package/dist/http/resolve.d.ts.map +1 -0
  66. package/dist/http/resolve.js +92 -0
  67. package/dist/http/responses.d.ts +152 -0
  68. package/dist/http/responses.d.ts.map +1 -0
  69. package/dist/http/responses.js +121 -0
  70. package/dist/http/routes.d.ts +34 -0
  71. package/dist/http/routes.d.ts.map +1 -0
  72. package/dist/http/routes.js +268 -0
  73. package/dist/http/schemas.d.ts +66 -0
  74. package/dist/http/schemas.d.ts.map +1 -0
  75. package/dist/http/schemas.js +59 -0
  76. package/dist/http/views.d.ts +53 -0
  77. package/dist/http/views.d.ts.map +1 -0
  78. package/dist/http/views.js +86 -0
  79. package/dist/i18n/errorCopy.d.ts +24 -0
  80. package/dist/i18n/errorCopy.d.ts.map +1 -0
  81. package/dist/i18n/errorCopy.es.d.ts +31 -0
  82. package/dist/i18n/errorCopy.es.d.ts.map +1 -0
  83. package/dist/i18n/errorCopy.es.js +33 -0
  84. package/dist/i18n/errorCopy.js +91 -0
  85. package/dist/index.d.ts +14 -0
  86. package/dist/index.d.ts.map +1 -0
  87. package/dist/index.js +8 -0
  88. package/dist/instance/auth.d.ts +1122 -0
  89. package/dist/instance/auth.d.ts.map +1 -0
  90. package/dist/instance/auth.js +176 -0
  91. package/dist/instance/plugins.d.ts +87 -0
  92. package/dist/instance/plugins.d.ts.map +1 -0
  93. package/dist/instance/plugins.js +116 -0
  94. package/dist/instance/providers.d.ts +117 -0
  95. package/dist/instance/providers.d.ts.map +1 -0
  96. package/dist/instance/providers.js +111 -0
  97. package/dist/instance/secrets.d.ts +163 -0
  98. package/dist/instance/secrets.d.ts.map +1 -0
  99. package/dist/instance/secrets.js +169 -0
  100. package/dist/migrations/0001_init.d.ts +33 -0
  101. package/dist/migrations/0001_init.d.ts.map +1 -0
  102. package/dist/migrations/0001_init.js +77 -0
  103. package/dist/migrations/pluginTables.d.ts +126 -0
  104. package/dist/migrations/pluginTables.d.ts.map +1 -0
  105. package/dist/migrations/pluginTables.js +233 -0
  106. package/dist/seeds/devSession.d.ts +124 -0
  107. package/dist/seeds/devSession.d.ts.map +1 -0
  108. package/dist/seeds/devSession.js +211 -0
  109. package/dist/seeds/example.d.ts +12 -0
  110. package/dist/seeds/example.d.ts.map +1 -0
  111. package/dist/seeds/example.js +30 -0
  112. package/dist/test-utils/liveApp.d.ts +227 -0
  113. package/dist/test-utils/liveApp.d.ts.map +1 -0
  114. package/dist/test-utils/liveApp.js +240 -0
  115. package/dist/token/rotation.d.ts +56 -0
  116. package/dist/token/rotation.d.ts.map +1 -0
  117. package/dist/token/rotation.js +68 -0
  118. package/dist/version.generated.d.ts +5 -0
  119. package/dist/version.generated.d.ts.map +1 -0
  120. package/dist/version.generated.js +7 -0
  121. package/package.json +24 -13
  122. package/src/version.generated.ts +1 -1
@@ -0,0 +1,155 @@
1
+ import { Session, User } from "../data/betterAuth";
2
+ import { Device, type DevicePlatform } from "../data/device";
3
+ import type { AuthDatabase } from "../data/tables";
4
+ /**
5
+ * The reads a management dashboard's user panes resolve to, and the lookups its revocations need.
6
+ *
7
+ * Deliberately **not** under `src/http/`: nothing here knows about a request, a scope, or a caller, so
8
+ * the projections that decide what a management client may see stay in one place (`http/adminRoutes.ts`)
9
+ * and these stay directly testable against a real D1. Everything takes the shared {@link AuthDatabase},
10
+ * so the Better-Auth-managed tables and Pithy's own device registry are read through the one Kysely
11
+ * with `CamelCasePlugin` — query code never types a `pithy_auth_` name.
12
+ *
13
+ * ## Two date representations, and getting it wrong is silent
14
+ *
15
+ * The Better-Auth tables store dates as **ISO-8601 text** (`BetterAuthDate`); `pithy_auth_devices`
16
+ * stores them as Pithy's house **ms-epoch numbers** (`SQLiteDate`). A cursor carries the sort column's
17
+ * *stored* value, so the users cursor holds a string and the devices cursor holds a number. Handing
18
+ * SQLite the other one does not throw — it compares across storage classes and quietly returns the
19
+ * wrong page — so each cursor is built from the parsed row and converted back to the column's own
20
+ * representation rather than copied from whatever the row object happened to hold.
21
+ *
22
+ * ## Everything is bounded, including the sub-lists
23
+ *
24
+ * A device id is client-generated (`x-pithy-device-id`), so a single user can mint as many device rows
25
+ * as they like, and sessions accumulate per sign-in. Reading "this user's devices" unbounded would let
26
+ * any end user decide how much work an admin pane does. Every list here takes a limit and over-fetches
27
+ * by one to report whether there is more.
28
+ */
29
+ /** One page of rows plus where the next one starts. `nextCursor` is null at the end of the list. */
30
+ export interface AdminPage<T> {
31
+ /** The rows in this page, already decoded through their table schema. */
32
+ items: T[];
33
+ /** The opaque cursor the next request should send, or null when this was the last page. */
34
+ nextCursor: string | null;
35
+ }
36
+ /** A bounded sub-list inside a single-user view, and whether the bound cut it short. */
37
+ export interface AdminSubList<T> {
38
+ /** The rows, most recent first, at most the requested limit. */
39
+ items: T[];
40
+ /** True when more rows exist than the limit allowed — the pane should say so rather than imply a total. */
41
+ truncated: boolean;
42
+ }
43
+ /** What a user listing may filter and page by. */
44
+ export interface ListUsersOptions {
45
+ /** Free text matched against email and display name. Absent lists everyone, newest first. */
46
+ search?: string;
47
+ /** The previous page's `nextCursor`. A malformed one is a first page, never an error. */
48
+ cursor?: string;
49
+ /** How many rows to return, clamped into `[1, MAX_PAGE_SIZE]` by `pageLimit`. */
50
+ limit?: number;
51
+ }
52
+ /**
53
+ * Users, newest first, optionally filtered by a free-text term over email and display name.
54
+ *
55
+ * Keyset-paginated on `(createdAt, id)` — never an offset. The users table is written to constantly
56
+ * while somebody is paging through it, and under `OFFSET` a sign-up at the head pushes a row from page
57
+ * one onto page two, so a client paging through sees it twice and misses another by the same amount.
58
+ *
59
+ * The search is a substring `LIKE` over two columns and no index can serve it; the request schema bounds
60
+ * the term and `pageLimit` bounds the page, which is what keeps the scan a bounded one.
61
+ */
62
+ export declare function listUsers(db: AuthDatabase, options?: ListUsersOptions): Promise<AdminPage<User>>;
63
+ /** One user, or null when no row carries that id. The 404 is the caller's decision, not this one's. */
64
+ export declare function getUser(db: AuthDatabase, userId: string): Promise<User | null>;
65
+ /**
66
+ * What the bulk lookup binds besides the ids themselves: nothing. Named anyway, because it is the number
67
+ * {@link MAX_USER_LOOKUP} is derived against — adding a `where` here is then an edit to both, next to
68
+ * each other, rather than a cap nobody re-derived.
69
+ */
70
+ export declare const USER_LOOKUP_FIXED_PARAMETERS = 0;
71
+ /**
72
+ * The most ids one {@link getUsers} call may name.
73
+ *
74
+ * Two numbers meet at 100 and both matter. D1 accepts `MAX_BOUND_PARAMETERS` in one statement and this
75
+ * one spends `USER_LOOKUP_FIXED_PARAMETERS` before the first id, so the ceiling is the budget. And a
76
+ * caller's ids come from a page of *their* rows, which `pageLimit` clamps at `MAX_PAGE_SIZE` — a cap
77
+ * below that would refuse to resolve the largest page the kit itself hands out, which is the first thing
78
+ * an adopter would hit.
79
+ */
80
+ export declare const MAX_USER_LOOKUP = 100;
81
+ /**
82
+ * The users behind a list of ids, in one query, keyed by id.
83
+ *
84
+ * The read an adopter with its own membership or team table needs: it holds ids and has to render names
85
+ * beside them. Without this the only by-id read is {@link getUser}, so a twelve-person roster is twelve
86
+ * queries — and the alternatives are worse, since querying `pithy_auth_users` directly is a second
87
+ * definition of this capability's schema and paging {@link listUsers} to find twelve people scans a
88
+ * table that grows without bound.
89
+ *
90
+ * **A `Map`, not an array.** The caller already has the order — it is holding the id list — and what it
91
+ * lacks is the lookup. An array makes every caller rebuild this index, and an array in *input order*
92
+ * would quietly imply that a missing user leaves a hole in it.
93
+ *
94
+ * **A missing id is an absence, not an error.** A membership can outlive the user row it names, and the
95
+ * pane has to render that gap rather than fail the screen. Ids collapse to their distinct set first: two
96
+ * memberships naming the same person are one lookup, and duplicates cost the statement nothing.
97
+ *
98
+ * **Bounded, and a refusal rather than a truncation** — the same rule the sub-lists here follow, for the
99
+ * same reason. Quietly answering for 100 of somebody's 140 members would be a wrong roster presented as
100
+ * a right one, so past the cap this throws and names it. An empty list issues no query at all.
101
+ *
102
+ * Rows go through the `User` codec, exactly as {@link getUser}'s do, which is both the date conversion
103
+ * and the projection: the schema names the columns an adopter gets, so nothing this table later gains
104
+ * arrives here unannounced.
105
+ */
106
+ export declare function getUsers(db: AuthDatabase, userIds: readonly string[]): Promise<Map<string, User>>;
107
+ /**
108
+ * The provider slugs a user can sign in with — `["google"]`, `["google", "apple"]`, or empty for a
109
+ * passwordless-only account.
110
+ *
111
+ * **Selects `providerId` and nothing else, and that is the security property rather than an
112
+ * optimization.** `pithy_auth_accounts` also holds the provider's `accessToken`, `refreshToken`, and
113
+ * `idToken` — live credentials against a third party, on the user's behalf. Those must never reach a
114
+ * management client, and the strongest way to guarantee it is for them never to be loaded: a projection
115
+ * cannot leak a column that was not selected, however the view function is later edited.
116
+ */
117
+ export declare function userProviders(db: AuthDatabase, userId: string): Promise<string[]>;
118
+ /** A user's live sessions, newest first, bounded. */
119
+ export declare function listUserSessions(db: AuthDatabase, userId: string, limit: number): Promise<AdminSubList<Session>>;
120
+ /** A user's registered devices, most-recently-seen first, bounded. */
121
+ export declare function listUserDevices(db: AuthDatabase, userId: string, limit: number): Promise<AdminSubList<Device>>;
122
+ /** What a device-registry listing may filter and page by. */
123
+ export interface ListDeviceRegistryOptions {
124
+ /** Narrow to one user's devices. Absent reads the whole fleet, most-recently-seen first. */
125
+ userId?: string;
126
+ /** Narrow to one platform. Typed as the enum, so a filter the column cannot hold is a compile error. */
127
+ platform?: DevicePlatform;
128
+ /** The previous page's `nextCursor`. A malformed one is a first page, never an error. */
129
+ cursor?: string;
130
+ /** How many rows to return, clamped into `[1, MAX_PAGE_SIZE]` by `pageLimit`. */
131
+ limit?: number;
132
+ }
133
+ /**
134
+ * The device registry across users, most-recently-seen first.
135
+ *
136
+ * Keyset-paginated on `(lastSeenAt, userId, id)`. `lastSeenAt` is a **ms-epoch number** here, not the
137
+ * ISO-8601 text the Better-Auth tables use — this is Pithy's own table, on Pithy's house codec.
138
+ */
139
+ export declare function listDeviceRegistry(db: AuthDatabase, options?: ListDeviceRegistryOptions): Promise<AdminPage<Device>>;
140
+ /**
141
+ * The session a management client named, or null.
142
+ *
143
+ * Returns the session's **token** because that is what Better Auth's `internalAdapter.deleteSession`
144
+ * keys on — a revocation must go through it so the adapter's own bookkeeping stays consistent, exactly
145
+ * as the user-facing device revoke does. The token is a live credential and stops here: it is looked up
146
+ * and handed to the delete, and no projection in `http/adminRoutes.ts` ever carries it out to a caller.
147
+ */
148
+ export declare function findSessionById(db: AuthDatabase, sessionId: string): Promise<{
149
+ id: string;
150
+ token: string;
151
+ userId: string;
152
+ } | null>;
153
+ /** Every live session token a user holds — the set a sign-out-everywhere has to revoke. */
154
+ export declare function userSessionTokens(db: AuthDatabase, userId: string): Promise<string[]>;
155
+ //# sourceMappingURL=users.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/admin/users.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAA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G3F"}
@@ -0,0 +1,205 @@
1
+ import { Session, User } from "../data/betterAuth.js";
2
+ import { Device } from "../data/device.js";
3
+ import { ValidationError } from "@pithy-sh/core/src/error/pithyError";
4
+ import { decodeCursor, pageLimit, toPage } from "@pithy-sh/core/src/data/cursor";
5
+ import { MAX_BOUND_PARAMETERS, boundParameterBudget } from "@pithy-sh/core/src/data/boundParameters";
6
+ import { sql } from "kysely";
7
+ //#region src/admin/users.ts
8
+ /**
9
+ * The separator joining `(userId, id)` into the device cursor's single tiebreak.
10
+ *
11
+ * `pithy_auth_devices` has a **composite** primary key, because `id` is a client-generated device id
12
+ * that is unique only per user. A cursor tiebreaking on `id` alone would therefore not name a unique
13
+ * row, and two users who happened to mint the same device id would straddle a page boundary — one of
14
+ * them skipped. A NUL byte is the separator because a user id is a Better-Auth UUID and cannot contain
15
+ * one, so splitting on the first occurrence recovers the pair exactly however the device id is written.
16
+ */
17
+ const DEVICE_KEY_SEPARATOR = "\0";
18
+ function deviceKey(userId, id) {
19
+ return `${userId}${DEVICE_KEY_SEPARATOR}${id}`;
20
+ }
21
+ function splitDeviceKey(key) {
22
+ const at = key.indexOf(DEVICE_KEY_SEPARATOR);
23
+ if (at < 0) return void 0;
24
+ return {
25
+ userId: key.slice(0, at),
26
+ id: key.slice(at + 1)
27
+ };
28
+ }
29
+ /**
30
+ * Escape a caller's search term for a `LIKE` pattern.
31
+ *
32
+ * Without this a term containing `%` or `_` silently becomes a wildcard, so a support agent searching
33
+ * for the very common `first_last@example.com` matches addresses that are not the one they typed and
34
+ * acts on the wrong person. It is a correctness fix rather than an authorization one — a caller holding
35
+ * `auth:users:read` may already list every user — which is why the bound on the term's length lives on
36
+ * the request schema instead.
37
+ */
38
+ function likePattern(term) {
39
+ return `%${term.replace(/[\\%_]/g, (char) => `\\${char}`)}%`;
40
+ }
41
+ /**
42
+ * Users, newest first, optionally filtered by a free-text term over email and display name.
43
+ *
44
+ * Keyset-paginated on `(createdAt, id)` — never an offset. The users table is written to constantly
45
+ * while somebody is paging through it, and under `OFFSET` a sign-up at the head pushes a row from page
46
+ * one onto page two, so a client paging through sees it twice and misses another by the same amount.
47
+ *
48
+ * The search is a substring `LIKE` over two columns and no index can serve it; the request schema bounds
49
+ * the term and `pageLimit` bounds the page, which is what keeps the scan a bounded one.
50
+ */
51
+ async function listUsers(db, options = {}) {
52
+ const limit = pageLimit(options.limit);
53
+ let query = db.selectFrom("pithyAuthUsers").selectAll().orderBy("createdAt", "desc").orderBy("id", "desc").limit(limit + 1);
54
+ const term = options.search?.trim();
55
+ if (term) {
56
+ const pattern = likePattern(term);
57
+ query = query.where(sql`(email like ${pattern} escape '\\' or name like ${pattern} escape '\\')`);
58
+ }
59
+ const cursor = decodeCursor(options.cursor);
60
+ if (cursor) {
61
+ const at = String(cursor.sort);
62
+ const id = String(cursor.id);
63
+ query = query.where((eb) => eb.or([eb("createdAt", "<", at), eb.and([eb("createdAt", "=", at), eb("id", "<", id)])]));
64
+ }
65
+ const rows = await query.execute();
66
+ return toPage(rows.map((row) => User.parse(row)), limit, (user) => ({
67
+ sort: user.createdAt.toISOString(),
68
+ id: user.id
69
+ }));
70
+ }
71
+ /** One user, or null when no row carries that id. The 404 is the caller's decision, not this one's. */
72
+ async function getUser(db, userId) {
73
+ const row = await db.selectFrom("pithyAuthUsers").selectAll().where("id", "=", userId).executeTakeFirst();
74
+ return row ? User.parse(row) : null;
75
+ }
76
+ /**
77
+ * What the bulk lookup binds besides the ids themselves: nothing. Named anyway, because it is the number
78
+ * {@link MAX_USER_LOOKUP} is derived against — adding a `where` here is then an edit to both, next to
79
+ * each other, rather than a cap nobody re-derived.
80
+ */
81
+ const USER_LOOKUP_FIXED_PARAMETERS = 0;
82
+ /**
83
+ * The most ids one {@link getUsers} call may name.
84
+ *
85
+ * Two numbers meet at 100 and both matter. D1 accepts `MAX_BOUND_PARAMETERS` in one statement and this
86
+ * one spends `USER_LOOKUP_FIXED_PARAMETERS` before the first id, so the ceiling is the budget. And a
87
+ * caller's ids come from a page of *their* rows, which `pageLimit` clamps at `MAX_PAGE_SIZE` — a cap
88
+ * below that would refuse to resolve the largest page the kit itself hands out, which is the first thing
89
+ * an adopter would hit.
90
+ */
91
+ const MAX_USER_LOOKUP = 100;
92
+ /**
93
+ * The users behind a list of ids, in one query, keyed by id.
94
+ *
95
+ * The read an adopter with its own membership or team table needs: it holds ids and has to render names
96
+ * beside them. Without this the only by-id read is {@link getUser}, so a twelve-person roster is twelve
97
+ * queries — and the alternatives are worse, since querying `pithy_auth_users` directly is a second
98
+ * definition of this capability's schema and paging {@link listUsers} to find twelve people scans a
99
+ * table that grows without bound.
100
+ *
101
+ * **A `Map`, not an array.** The caller already has the order — it is holding the id list — and what it
102
+ * lacks is the lookup. An array makes every caller rebuild this index, and an array in *input order*
103
+ * would quietly imply that a missing user leaves a hole in it.
104
+ *
105
+ * **A missing id is an absence, not an error.** A membership can outlive the user row it names, and the
106
+ * pane has to render that gap rather than fail the screen. Ids collapse to their distinct set first: two
107
+ * memberships naming the same person are one lookup, and duplicates cost the statement nothing.
108
+ *
109
+ * **Bounded, and a refusal rather than a truncation** — the same rule the sub-lists here follow, for the
110
+ * same reason. Quietly answering for 100 of somebody's 140 members would be a wrong roster presented as
111
+ * a right one, so past the cap this throws and names it. An empty list issues no query at all.
112
+ *
113
+ * Rows go through the `User` codec, exactly as {@link getUser}'s do, which is both the date conversion
114
+ * and the projection: the schema names the columns an adopter gets, so nothing this table later gains
115
+ * arrives here unannounced.
116
+ */
117
+ async function getUsers(db, userIds) {
118
+ const ids = [...new Set(userIds)];
119
+ if (ids.length === 0) return /* @__PURE__ */ new Map();
120
+ const cap = Math.min(100, boundParameterBudget(0));
121
+ if (ids.length > cap) throw new ValidationError({
122
+ message: `Look up at most 100 users at a time.`,
123
+ action: `Resolve the ids in pages of 100.`,
124
+ detail: `getUsers was given ${ids.length} distinct ids, over the cap of 100; D1 accepts ${MAX_BOUND_PARAMETERS} bound parameters and this statement spends 0 of them before the first id.`
125
+ });
126
+ const rows = await db.selectFrom("pithyAuthUsers").selectAll().where("id", "in", ids).execute();
127
+ const users = /* @__PURE__ */ new Map();
128
+ for (const row of rows) {
129
+ const user = User.parse(row);
130
+ users.set(user.id, user);
131
+ }
132
+ return users;
133
+ }
134
+ /**
135
+ * The provider slugs a user can sign in with — `["google"]`, `["google", "apple"]`, or empty for a
136
+ * passwordless-only account.
137
+ *
138
+ * **Selects `providerId` and nothing else, and that is the security property rather than an
139
+ * optimization.** `pithy_auth_accounts` also holds the provider's `accessToken`, `refreshToken`, and
140
+ * `idToken` — live credentials against a third party, on the user's behalf. Those must never reach a
141
+ * management client, and the strongest way to guarantee it is for them never to be loaded: a projection
142
+ * cannot leak a column that was not selected, however the view function is later edited.
143
+ */
144
+ async function userProviders(db, userId) {
145
+ const rows = await db.selectFrom("pithyAuthAccounts").select("providerId").where("userId", "=", userId).orderBy("providerId", "asc").execute();
146
+ return [...new Set(rows.map((row) => row.providerId))];
147
+ }
148
+ /** A user's live sessions, newest first, bounded. */
149
+ async function listUserSessions(db, userId, limit) {
150
+ const rows = await db.selectFrom("pithyAuthSessions").selectAll().where("userId", "=", userId).orderBy("createdAt", "desc").orderBy("id", "desc").limit(limit + 1).execute();
151
+ return {
152
+ items: rows.slice(0, limit).map((row) => Session.parse(row)),
153
+ truncated: rows.length > limit
154
+ };
155
+ }
156
+ /** A user's registered devices, most-recently-seen first, bounded. */
157
+ async function listUserDevices(db, userId, limit) {
158
+ const rows = await db.selectFrom("pithyAuthDevices").selectAll().where("userId", "=", userId).orderBy("lastSeenAt", "desc").orderBy("id", "desc").limit(limit + 1).execute();
159
+ return {
160
+ items: rows.slice(0, limit).map((row) => Device.parse(row)),
161
+ truncated: rows.length > limit
162
+ };
163
+ }
164
+ /**
165
+ * The device registry across users, most-recently-seen first.
166
+ *
167
+ * Keyset-paginated on `(lastSeenAt, userId, id)`. `lastSeenAt` is a **ms-epoch number** here, not the
168
+ * ISO-8601 text the Better-Auth tables use — this is Pithy's own table, on Pithy's house codec.
169
+ */
170
+ async function listDeviceRegistry(db, options = {}) {
171
+ const limit = pageLimit(options.limit);
172
+ let query = db.selectFrom("pithyAuthDevices").selectAll().orderBy("lastSeenAt", "desc").orderBy("userId", "desc").orderBy("id", "desc").limit(limit + 1);
173
+ if (options.userId) query = query.where("userId", "=", options.userId);
174
+ if (options.platform) query = query.where("platform", "=", options.platform);
175
+ const cursor = decodeCursor(options.cursor);
176
+ const key = cursor ? splitDeviceKey(String(cursor.id)) : void 0;
177
+ const at = cursor ? Number(cursor.sort) : NaN;
178
+ if (key && Number.isFinite(at)) query = query.where((eb) => eb.or([eb("lastSeenAt", "<", at), eb.and([eb("lastSeenAt", "=", at), eb.or([eb("userId", "<", key.userId), eb.and([eb("userId", "=", key.userId), eb("id", "<", key.id)])])])]));
179
+ const rows = await query.execute();
180
+ return toPage(rows.map((row) => Device.parse(row)), limit, (device) => ({
181
+ sort: device.lastSeenAt.getTime(),
182
+ id: deviceKey(device.userId, device.id)
183
+ }));
184
+ }
185
+ /**
186
+ * The session a management client named, or null.
187
+ *
188
+ * Returns the session's **token** because that is what Better Auth's `internalAdapter.deleteSession`
189
+ * keys on — a revocation must go through it so the adapter's own bookkeeping stays consistent, exactly
190
+ * as the user-facing device revoke does. The token is a live credential and stops here: it is looked up
191
+ * and handed to the delete, and no projection in `http/adminRoutes.ts` ever carries it out to a caller.
192
+ */
193
+ async function findSessionById(db, sessionId) {
194
+ return await db.selectFrom("pithyAuthSessions").select([
195
+ "id",
196
+ "token",
197
+ "userId"
198
+ ]).where("id", "=", sessionId).executeTakeFirst() ?? null;
199
+ }
200
+ /** Every live session token a user holds — the set a sign-out-everywhere has to revoke. */
201
+ async function userSessionTokens(db, userId) {
202
+ return (await db.selectFrom("pithyAuthSessions").select("token").where("userId", "=", userId).execute()).map((row) => row.token);
203
+ }
204
+ //#endregion
205
+ export { MAX_USER_LOOKUP, USER_LOOKUP_FIXED_PARAMETERS, findSessionById, getUser, getUsers, listDeviceRegistry, listUserDevices, listUserSessions, listUsers, userProviders, userSessionTokens };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The audit action codes `@pithy-sh/auth` emits, as `domain/reason` strings under the `auth` domain.
3
+ *
4
+ * Auth emits through core's `emit` seam (`c.var.emit`), so it never imports `@pithy-sh/audit` — audit
5
+ * is an optional capability (principle 4: depend on core seams, not other capabilities). When audit is
6
+ * absent the seam is a no-op; when present these land in `pithy_audit_events`. Every code matches core's
7
+ * `AuditAction` pattern; `actions.test.ts` asserts it.
8
+ */
9
+ export declare const AuthAuditActions: {
10
+ /** A sign-in completed (magic link, OTP, or OAuth). Outcome `denied` for a blocked attempt. */
11
+ readonly signin: "auth/signin";
12
+ /** A sign-out / session revocation completed. */
13
+ readonly signout: "auth/signout";
14
+ /** A session was exchanged for a fresh access token, rotating the refresh credential. */
15
+ readonly tokenRefresh: "auth/token_refresh";
16
+ /** A consumed (already-rotated) refresh token was replayed — reuse detected, the family revoked. Outcome `denied`. */
17
+ readonly tokenReuseDetected: "auth/token_reuse_detected";
18
+ /** A magic link was requested and enqueued for delivery. */
19
+ readonly magicLinkSent: "auth/magic_link_sent";
20
+ /** An email OTP was requested and enqueued for delivery. */
21
+ readonly otpSent: "auth/otp_sent";
22
+ /** A social account (Google) was linked to a user. */
23
+ readonly oauthLinked: "auth/oauth_linked";
24
+ /** A device was registered or updated from sign-in metadata. */
25
+ readonly deviceRegistered: "auth/device_registered";
26
+ /** A device was revoked (its session(s) signed out). */
27
+ readonly deviceRevoked: "auth/device_revoked";
28
+ /**
29
+ * Somebody tried to sign in with a provider this deployment enables and cannot serve — its credential
30
+ * would not resolve, so the instance was built without it (#381). Outcome `denied`, severity
31
+ * `warning`.
32
+ *
33
+ * **This is the operator's channel, and it is why degrading is not the same as degrading silently.**
34
+ * The refusal the caller gets names the provider, but a caller is not who fixes this; nobody at the
35
+ * adopter learns a sign-in method is down from a browser somebody else is holding. The trail carries
36
+ * one row per attempt, naming the provider, so the question "since when, and how many people has it
37
+ * cost" is answerable from the same place every other auth question is.
38
+ */
39
+ readonly providerUnavailable: "auth/provider_unavailable";
40
+ /**
41
+ * The admin actions, emitted only from the control-plane surface (`http/adminRoutes.ts`) and always
42
+ * with `actorType: "control-plane"` — a management client is not a user of the adopter's app, so its
43
+ * actions must be answerable separately from their users'.
44
+ *
45
+ * **The reads are audited too, and that is not padding.** Listing the user table hands a management
46
+ * client every customer's email address; reading one user hands over where they signed in from and on
47
+ * what. If only the writes were recorded, the trail would show a compromised dashboard credential
48
+ * revoking one session and say nothing at all about the customer list it walked on the way there —
49
+ * and the exfiltration is the larger incident.
50
+ */
51
+ /** The user table was listed or searched from the management surface. A read of other people's data. */
52
+ readonly adminUsersListed: "auth/admin_users_listed";
53
+ /** One user was read from the management surface, with their sessions and devices. */
54
+ readonly adminUserRead: "auth/admin_user_read";
55
+ /** The device registry was walked from the management surface. */
56
+ readonly adminDevicesListed: "auth/admin_devices_listed";
57
+ /** One named session was revoked from the management surface. */
58
+ readonly adminSessionRevoked: "auth/admin_session_revoked";
59
+ /** Every session a user held was revoked from the management surface — signed out everywhere. */
60
+ readonly adminUserSessionsRevoked: "auth/admin_user_sessions_revoked";
61
+ /** One of a user's devices was signed out and its registration dropped, from the management surface. */
62
+ readonly adminDeviceRevoked: "auth/admin_device_revoked";
63
+ };
64
+ /** One of the auth audit action codes. */
65
+ export type AuthAuditAction = (typeof AuthAuditActions)[keyof typeof AuthAuditActions];
66
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/audit/actions.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB;IAC3B,+FAA+F;aAC/F,MAAM,EAAE,aAAa;IACrB,iDAAiD;aACjD,OAAO,EAAE,cAAc;IACvB,yFAAyF;aACzF,YAAY,EAAE,oBAAoB;IAClC,sHAAsH;aACtH,kBAAkB,EAAE,2BAA2B;IAC/C,4DAA4D;aAC5D,aAAa,EAAE,sBAAsB;IACrC,4DAA4D;aAC5D,OAAO,EAAE,eAAe;IACxB,sDAAsD;aACtD,WAAW,EAAE,mBAAmB;IAChC,gEAAgE;aAChE,gBAAgB,EAAE,wBAAwB;IAC1C,wDAAwD;aACxD,aAAa,EAAE,qBAAqB;IACpC;;;;;;;;;;OAUG;aACH,mBAAmB,EAAE,2BAA2B;IAEhD;;;;;;;;;;OAUG;IAEH,wGAAwG;aACxG,gBAAgB,EAAE,yBAAyB;IAC3C,sFAAsF;aACtF,aAAa,EAAE,sBAAsB;IACrC,kEAAkE;aAClE,kBAAkB,EAAE,2BAA2B;IAC/C,iEAAiE;aACjE,mBAAmB,EAAE,4BAA4B;IACjD,iGAAiG;aACjG,wBAAwB,EAAE,kCAAkC;IAC5D,wGAAwG;aACxG,kBAAkB,EAAE,2BAA2B;CACvC,CAAC;AAEX,0CAA0C;AAC1C,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,66 @@
1
+ //#region src/audit/actions.ts
2
+ /**
3
+ * The audit action codes `@pithy-sh/auth` emits, as `domain/reason` strings under the `auth` domain.
4
+ *
5
+ * Auth emits through core's `emit` seam (`c.var.emit`), so it never imports `@pithy-sh/audit` — audit
6
+ * is an optional capability (principle 4: depend on core seams, not other capabilities). When audit is
7
+ * absent the seam is a no-op; when present these land in `pithy_audit_events`. Every code matches core's
8
+ * `AuditAction` pattern; `actions.test.ts` asserts it.
9
+ */
10
+ const AuthAuditActions = {
11
+ /** A sign-in completed (magic link, OTP, or OAuth). Outcome `denied` for a blocked attempt. */
12
+ signin: "auth/signin",
13
+ /** A sign-out / session revocation completed. */
14
+ signout: "auth/signout",
15
+ /** A session was exchanged for a fresh access token, rotating the refresh credential. */
16
+ tokenRefresh: "auth/token_refresh",
17
+ /** A consumed (already-rotated) refresh token was replayed — reuse detected, the family revoked. Outcome `denied`. */
18
+ tokenReuseDetected: "auth/token_reuse_detected",
19
+ /** A magic link was requested and enqueued for delivery. */
20
+ magicLinkSent: "auth/magic_link_sent",
21
+ /** An email OTP was requested and enqueued for delivery. */
22
+ otpSent: "auth/otp_sent",
23
+ /** A social account (Google) was linked to a user. */
24
+ oauthLinked: "auth/oauth_linked",
25
+ /** A device was registered or updated from sign-in metadata. */
26
+ deviceRegistered: "auth/device_registered",
27
+ /** A device was revoked (its session(s) signed out). */
28
+ deviceRevoked: "auth/device_revoked",
29
+ /**
30
+ * Somebody tried to sign in with a provider this deployment enables and cannot serve — its credential
31
+ * would not resolve, so the instance was built without it (#381). Outcome `denied`, severity
32
+ * `warning`.
33
+ *
34
+ * **This is the operator's channel, and it is why degrading is not the same as degrading silently.**
35
+ * The refusal the caller gets names the provider, but a caller is not who fixes this; nobody at the
36
+ * adopter learns a sign-in method is down from a browser somebody else is holding. The trail carries
37
+ * one row per attempt, naming the provider, so the question "since when, and how many people has it
38
+ * cost" is answerable from the same place every other auth question is.
39
+ */
40
+ providerUnavailable: "auth/provider_unavailable",
41
+ /**
42
+ * The admin actions, emitted only from the control-plane surface (`http/adminRoutes.ts`) and always
43
+ * with `actorType: "control-plane"` — a management client is not a user of the adopter's app, so its
44
+ * actions must be answerable separately from their users'.
45
+ *
46
+ * **The reads are audited too, and that is not padding.** Listing the user table hands a management
47
+ * client every customer's email address; reading one user hands over where they signed in from and on
48
+ * what. If only the writes were recorded, the trail would show a compromised dashboard credential
49
+ * revoking one session and say nothing at all about the customer list it walked on the way there —
50
+ * and the exfiltration is the larger incident.
51
+ */
52
+ /** The user table was listed or searched from the management surface. A read of other people's data. */
53
+ adminUsersListed: "auth/admin_users_listed",
54
+ /** One user was read from the management surface, with their sessions and devices. */
55
+ adminUserRead: "auth/admin_user_read",
56
+ /** The device registry was walked from the management surface. */
57
+ adminDevicesListed: "auth/admin_devices_listed",
58
+ /** One named session was revoked from the management surface. */
59
+ adminSessionRevoked: "auth/admin_session_revoked",
60
+ /** Every session a user held was revoked from the management surface — signed out everywhere. */
61
+ adminUserSessionsRevoked: "auth/admin_user_sessions_revoked",
62
+ /** One of a user's devices was signed out and its registration dropped, from the management surface. */
63
+ adminDeviceRevoked: "auth/admin_device_revoked"
64
+ };
65
+ //#endregion
66
+ export { AuthAuditActions };
@@ -0,0 +1,101 @@
1
+ import type { AuditEmit } from "@pithy-sh/core/src/audit/recorder";
2
+ /**
3
+ * Audit emission helpers, kept out of the instance so the hook wiring stays legible. Every helper goes
4
+ * through core's `emit` seam (a no-op when audit is absent) and swallows its own failure — an audit
5
+ * write must never break the auth action it records.
6
+ *
7
+ * Sign-in is emitted from the endpoint `after` hook (where `newSession` is set), not the DB hook — so
8
+ * the internal `createSession` a token rotation performs never looks like a fresh sign-in.
9
+ */
10
+ /** Pull request correlation from hook headers (no PII beyond ip/user-agent). */
11
+ export declare function correlation(headers: Headers | undefined): {
12
+ ip?: string;
13
+ userAgent?: string;
14
+ };
15
+ /** The session just created on a sign-in endpoint, plus the (already-authenticated) caller, if any. */
16
+ export interface AfterRequest {
17
+ path: string;
18
+ headers: Headers | undefined;
19
+ newSession: {
20
+ userId: string;
21
+ sessionId: string;
22
+ deviceId: string | null;
23
+ } | null;
24
+ currentUserId: string | null;
25
+ }
26
+ /** Emit the audit events for a completed auth request: sign-in (+device) from a new session, then any path event. */
27
+ export declare function emitAfterRequest(emit: AuditEmit, req: AfterRequest): Promise<void>;
28
+ /** Emit a `token_refresh` event for a session rotation (the custom rotate route). */
29
+ export declare function emitTokenRefresh(emit: AuditEmit, context: {
30
+ userId: string;
31
+ sessionId: string;
32
+ ip?: string;
33
+ userAgent?: string;
34
+ }): Promise<void>;
35
+ /**
36
+ * Emit a `token_reuse_detected` event — a replayed refresh token was caught and its family revoked.
37
+ * Recorded as `denied` and attributed to the compromised account (the family's owner), so the security
38
+ * trail names whose family was revoked, not the anonymous replayer.
39
+ */
40
+ export declare function emitTokenReuseDetected(emit: AuditEmit, context: {
41
+ userId: string;
42
+ familyId: string;
43
+ ip?: string;
44
+ userAgent?: string;
45
+ }): Promise<void>;
46
+ /** Emit a `device_revoked` event. */
47
+ export declare function emitDeviceRevoked(emit: AuditEmit, context: {
48
+ userId: string;
49
+ ip?: string;
50
+ userAgent?: string;
51
+ }): Promise<void>;
52
+ /**
53
+ * Emit one control-plane admin action.
54
+ *
55
+ * `actorType` is `control-plane` and never `user`: the caller holds no session and owns no user row, so
56
+ * recording it as a user would make "what did the management client do" unanswerable from the trail —
57
+ * and would put a dashboard operator's id in the same column as the adopter's own customers.
58
+ *
59
+ * `actorId` is the token's verified `sub` — *which person at the dashboard*, not merely which
60
+ * dashboard. `resourceId` is the user or session acted on, so the trail reads from both ends: every
61
+ * action one operator took, and everything ever done to one customer.
62
+ *
63
+ * No email address, no session token, no device push token reaches `metadata`. The trail is queryable
64
+ * and long-lived, and a management client that already saw the address does not need it copied into a
65
+ * second store with a different retention policy.
66
+ */
67
+ export declare function emitControlPlaneAction(emit: AuditEmit, event: {
68
+ action: string;
69
+ subject: string;
70
+ connectionId: string;
71
+ resourceType: string;
72
+ resourceId?: string | null;
73
+ ip?: string;
74
+ userAgent?: string;
75
+ requestId?: string;
76
+ metadata?: Record<string, unknown>;
77
+ }): Promise<void>;
78
+ /**
79
+ * Emit a `provider_unavailable` event — somebody asked for a sign-in method this deployment enables and
80
+ * could not serve.
81
+ *
82
+ * `anonymous`, because the caller has no session yet by definition. `denied` rather than `failure`: the
83
+ * request was refused deliberately by a rule this Worker holds, not lost to a fault. `warning` rather
84
+ * than `critical` — the other sign-in methods are working, which is the entire point of #381, so this is
85
+ * notable rather than alert-worthy.
86
+ *
87
+ * `metadata.provider` is the provider id and nothing else. The secret name is derivable from it and is
88
+ * still not written: an audit row is long-lived and queryable, and naming a store entry in one is a map
89
+ * for whoever reads the trail later.
90
+ */
91
+ export declare function emitProviderUnavailable(emit: AuditEmit, context: {
92
+ provider: string;
93
+ headers: Headers | undefined;
94
+ }): Promise<void>;
95
+ /** A blocked/failed auth attempt — recorded as `denied` (first-class). */
96
+ export declare function emitDenied(emit: AuditEmit, context: {
97
+ ip?: string;
98
+ userAgent?: string;
99
+ detail?: string;
100
+ }): Promise<void>;
101
+ //# sourceMappingURL=emit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/audit/emit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAGnE;;;;;;;GAOG;AAEH,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAK7F;AAUD,uGAAuG;AACvG,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,UAAU,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IAClF,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAcD,qHAAqH;AACrH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCxF;AAED,qFAAqF;AACrF,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9E,OAAO,CAAC,IAAI,CAAC,CAUf;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,SAAS,EACf,OAAO,EAAE;IAAE,MAAM,EAAE,M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