@pithy-sh/auth 0.6.2 → 0.6.4

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 (69) hide show
  1. package/README.md +15 -0
  2. package/dist/audit/actions.d.ts +78 -5
  3. package/dist/audit/actions.d.ts.map +1 -1
  4. package/dist/audit/actions.js +78 -5
  5. package/dist/audit/emit.d.ts +223 -2
  6. package/dist/audit/emit.d.ts.map +1 -1
  7. package/dist/audit/emit.js +251 -20
  8. package/dist/audit/evidence.d.ts +207 -0
  9. package/dist/audit/evidence.d.ts.map +1 -0
  10. package/dist/audit/evidence.js +162 -0
  11. package/dist/capability.d.ts +7 -0
  12. package/dist/capability.d.ts.map +1 -1
  13. package/dist/capability.js +7 -2
  14. package/dist/client/api.d.ts +8 -0
  15. package/dist/client/api.d.ts.map +1 -1
  16. package/dist/client/api.js +8 -0
  17. package/dist/email/send.d.ts +10 -2
  18. package/dist/email/send.d.ts.map +1 -1
  19. package/dist/email/send.js +36 -14
  20. package/dist/http/errorCallbackUrl.d.ts +40 -0
  21. package/dist/http/errorCallbackUrl.d.ts.map +1 -0
  22. package/dist/http/errorCallbackUrl.js +395 -0
  23. package/dist/http/providerRefusal.d.ts +181 -0
  24. package/dist/http/providerRefusal.d.ts.map +1 -0
  25. package/dist/http/providerRefusal.js +363 -0
  26. package/dist/http/resolve.js +1 -0
  27. package/dist/http/routes.d.ts.map +1 -1
  28. package/dist/http/routes.js +12 -1
  29. package/dist/instance/auth.d.ts +132 -26
  30. package/dist/instance/auth.d.ts.map +1 -1
  31. package/dist/instance/auth.js +118 -13
  32. package/dist/instance/githubUserInfo.d.ts +13 -7
  33. package/dist/instance/githubUserInfo.d.ts.map +1 -1
  34. package/dist/instance/githubUserInfo.js +13 -7
  35. package/dist/instance/plugins.d.ts +41 -13
  36. package/dist/instance/plugins.d.ts.map +1 -1
  37. package/dist/instance/plugins.js +95 -18
  38. package/dist/instance/providerSignInGate.d.ts +130 -0
  39. package/dist/instance/providerSignInGate.d.ts.map +1 -0
  40. package/dist/instance/providerSignInGate.js +230 -0
  41. package/dist/instance/refusalTransport.d.ts +91 -0
  42. package/dist/instance/refusalTransport.d.ts.map +1 -0
  43. package/dist/instance/refusalTransport.js +32 -0
  44. package/dist/migrations/pluginTables.d.ts.map +1 -1
  45. package/dist/migrations/pluginTables.js +2 -1
  46. package/dist/peer.d.ts +54 -0
  47. package/dist/peer.d.ts.map +1 -0
  48. package/dist/peer.js +31 -0
  49. package/dist/version.generated.d.ts +1 -1
  50. package/dist/version.generated.js +1 -1
  51. package/package.json +5 -5
  52. package/src/audit/actions.ts +78 -5
  53. package/src/audit/emit.ts +340 -25
  54. package/src/audit/evidence.ts +297 -0
  55. package/src/capability.ts +19 -7
  56. package/src/client/api.ts +8 -0
  57. package/src/email/send.ts +51 -14
  58. package/src/http/errorCallbackUrl.ts +463 -0
  59. package/src/http/providerRefusal.ts +424 -0
  60. package/src/http/resolve.ts +3 -0
  61. package/src/http/routes.ts +38 -1
  62. package/src/instance/auth.ts +167 -19
  63. package/src/instance/githubUserInfo.ts +13 -7
  64. package/src/instance/plugins.ts +119 -18
  65. package/src/instance/providerSignInGate.ts +323 -0
  66. package/src/instance/refusalTransport.ts +119 -0
  67. package/src/migrations/pluginTables.ts +4 -1
  68. package/src/peer.ts +29 -0
  69. package/src/version.generated.ts +1 -1
@@ -0,0 +1,363 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ //#region src/http/providerRefusal.ts
4
+ /**
5
+ * One answer for every refusal the user table decided, on every transport the kit can hold (#625).
6
+ *
7
+ * ## This is the second line now, and the first one is upstream
8
+ *
9
+ * `../instance/providerSignInGate` decides a refused provider sign-in **before** Better Auth branches,
10
+ * so `account_not_linked` and `signup_disabled` — the pair this module was written for — are no longer
11
+ * produced anywhere on the redirect callback. The roster below still carries them, because a roster
12
+ * whose completeness is gated against the dependency's own error tables has to name every code the
13
+ * dependency can emit, not every code the kit can currently reach.
14
+ *
15
+ * **What is left for this module is the rest of the roster**, and it is not nothing: `unable_to_create_user`
16
+ * and `validation_context_missing` are raised inside `createUser`, which is the no-row side, and
17
+ * `INVALID_PROFILE_FIELD` on the matched-row side — all three downstream of a gate decision the gate
18
+ * passed through, because passing through is what it does whenever Better Auth might have succeeded.
19
+ * So both ends stay: the gate stops the pair being produced, and this checks what the dependency
20
+ * answered against the roster.
21
+ *
22
+ * ## Reach, stated before the argument, because six rounds have turned on this
23
+ *
24
+ * This module reads exactly one thing: the `Location` header of the Response `instance.handler()`
25
+ * returned. So the guarantee is **a refusal that leaves this Worker through that header is collapsed** —
26
+ * which covers the kit's own routes, because Better Auth's social callback answers that way, and covers
27
+ * any composed plugin that answers refusals through `Location` too.
28
+ *
29
+ * It does not cover a plugin that replaces the callback's response with something else. There is no way
30
+ * for a header rewrite to reach a code that is now in a body, so the guarantee is bounded at the other
31
+ * end instead: `../instance/refusalTransport` refuses such a plugin at composition, by a reviewed roster
32
+ * whose completeness is gated against the dependency's own sources. `oauthPopup()` is the shipped
33
+ * instance and is refused. **An adopter's own plugin doing the same thing is not detectable at `auth()`
34
+ * and is not covered** — that residue is named here rather than left for a seventh round to find.
35
+ *
36
+ * ## The defect
37
+ *
38
+ * A refused social sign-in redirects to the adopter's `errorCallbackURL` with `?error=<code>`, and two
39
+ * of those codes are decided by **whether a row exists at the address the provider handed over**:
40
+ *
41
+ * | Code | Emitted only when |
42
+ * | --- | --- |
43
+ * | `account_not_linked` | a user row **did** match (`better-auth/dist/oauth2/link-account.mjs:86`) |
44
+ * | `signup_disabled` | **no** row matched (`:202`) |
45
+ *
46
+ * Both leave through one line — `redirectOnError(result.error.split(" ").join("_"))`,
47
+ * `dist/api/routes/callback.mjs:245` — so from outside the Worker they are one question with two
48
+ * answers. Press the provider button, read the `Location` header, repeat: an account-enumeration oracle
49
+ * needing one GitHub account, no account on the target, and no page render. It works against the
50
+ * configuration the kit's own security guidance recommends (`allowSignUp: false`, #554), so the
51
+ * projects that followed the advice are the exposed ones.
52
+ *
53
+ * ## Two more producers, found by asking the question instead of reading the issue
54
+ *
55
+ * The issue named two codes and cleared `EMAIL_NOT_VERIFIED` as "the provider's own state". The *text*
56
+ * is the provider's state; its **reachability** is not. The kit throws it from `user.create.before`
57
+ * (`instance/auth.ts`), and creating a user is something the callback only ever attempts when no row
58
+ * matched. So with sign-up permitted — the default — the pair is `account_not_linked` against
59
+ * `EMAIL_NOT_VERIFIED`, and it is the same oracle wearing a different name. Measured, not reasoned:
60
+ * `providerRefusal.workers.test.ts` drives both sign-up policies. `unable_to_create_user` sits on the
61
+ * same side of the same branch and joins them.
62
+ *
63
+ * That is why this module is a **roster with a verdict per code** rather than a pair of strings. The
64
+ * question a code has to answer is not "is this sentence sensitive" but "could the Worker have produced
65
+ * it without looking in its own user table".
66
+ *
67
+ * ## Why this is the kit's job and not an adopter's
68
+ *
69
+ * An adopter can only put middleware in front of the same Response and rewrite the header — collapsing
70
+ * the code *and losing the reason with it*. Held here, at the one place the capability hands a Better
71
+ * Auth response back, both halves survive: the browser gets one code, and {@link CollapsedRefusal}'s
72
+ * `reason` says which refusal it really was, for `handleBetterAuth` to put on the audit trail.
73
+ * Composing `auth` is the whole of what an adopter does to get it, and there is no option to forget.
74
+ *
75
+ * ## This module is the second line of defense, not the only one
76
+ *
77
+ * It reads the `Location` a refused callback answered with — which is the output of
78
+ * `redirectOnError`'s raw string concatenation (`callback.mjs:78`), performed on a value the caller
79
+ * supplied. It was walked around twice that way, and the second bypass was the diagnosis: **every input
80
+ * shape where that concatenation and this parsing disagree is another one**, so patching the parsing
81
+ * again only moves the report later. `./errorCallbackUrl` therefore guards the value on the way *in*,
82
+ * and by the time this module runs the string being parsed is one the kit produced.
83
+ *
84
+ * **Both stay.** That module decides what the dependency is handed; this one still checks what it
85
+ * answered. An input guard that depends on out-guessing a dependency's string handling is exactly what
86
+ * round 3 exists to stop relying on — so the guess is made once, about a value the kit then owns, and
87
+ * checked again here against the roster. Neither is asked to carry the whole load.
88
+ *
89
+ * ## And the third line is not a guard at all
90
+ *
91
+ * Round 6 found a refusal that needs no malformed input: a composed `oauthPopup()` turns the callback's
92
+ * redirect into a 200 HTML page carrying the code in its body, and neither guard above can see a header
93
+ * that was never sent. Guarding a sixth channel would have been the same move a sixth time. Instead the
94
+ * composition is refused — `../instance/refusalTransport` — and this module's claim is bounded to what it
95
+ * can actually hold. See the reach section at the top; it is the contract, not a caveat.
96
+ */
97
+ /**
98
+ * The one code a refused social sign-in redirects with, whatever the Worker actually found.
99
+ *
100
+ * Named for the outcome the reader may know — the provider did not sign them in — rather than the
101
+ * reason they may not. **Do not make this more helpful.** Every sentence that distinguishes "you have
102
+ * no account here" from "you have one and this provider is not attached to it" is the oracle back, and
103
+ * the adopter screen reading this code is where the (identical, deliberately unspecific) copy lives.
104
+ */
105
+ const NEUTRAL_PROVIDER_REFUSAL = "provider_sign_in_refused";
106
+ /**
107
+ * Every `error` code reachable on the social callback's redirect, with its verdict.
108
+ *
109
+ * **Completeness is gated, which is what keeps this from being a list of forbidden strings.**
110
+ * `providerRefusal.test.ts` reads Better Auth's own `OAUTH_CALLBACK_ERROR_CODES`, scans the
111
+ * `result.error` literals out of `link-account.mjs`, and scans the `new APIError(…, { code })` sites in
112
+ * both codebases — `better-auth`'s on the callback's path and the kit's across this whole package,
113
+ * because `callback.mjs:239` re-emits *anything* thrown inside `handleOAuthUserInfo` as `?error=`. Every
114
+ * code any of them can produce must appear here. A dependency bump that adds one turns that red, and
115
+ * somebody writes a verdict for it. So the roster records a *review*, and the review cannot silently fall
116
+ * behind the thing it reviews.
117
+ *
118
+ * **Off-roster codes travel, and that is a decision rather than an oversight.** Collapsing the unknown
119
+ * would be the safer default for our own codes and the wrong one overall: `callback.mjs:85` forwards the
120
+ * provider's own `error` parameter verbatim, and RFC 6749 §4.1.2.1 leaves that an open set. A reader who
121
+ * pressed Cancel at GitHub would get `provider_sign_in_refused` — "we could not sign you in" for an act
122
+ * they know perfectly well they performed — and every adopter screen that reads `access_denied` would go
123
+ * quiet. Nothing in that set can be decided by our user table, because it is decided before this Worker
124
+ * looks at anything. The completeness gate is what covers the half that can.
125
+ */
126
+ const PROVIDER_REFUSAL_VERDICTS = {
127
+ account_not_linked: {
128
+ collapse: true,
129
+ why: "link-account.mjs:86 — returned only inside `if (dbUser)`, so it is literally the statement that a row matched."
130
+ },
131
+ signup_disabled: {
132
+ collapse: true,
133
+ why: "link-account.mjs:202 — the `else` of that same branch, so it is literally the statement that none did."
134
+ },
135
+ EMAIL_NOT_VERIFIED: {
136
+ collapse: true,
137
+ why: "The kit's own `user.create.before` hook (instance/auth.ts). A user is only ever created when no row matched, so this code cannot be observed against an address that has an account — which makes it the other half of `account_not_linked` whenever sign-up is permitted. The sentence is about the provider; the fact that you are reading it is about us."
138
+ },
139
+ unable_to_create_user: {
140
+ collapse: true,
141
+ why: "link-account.mjs:254 — the create path only, so it sits on the no-row side exactly as `signup_disabled` does. A fault rather than a refusal, and still an answer to the question being asked."
142
+ },
143
+ INVALID_PROFILE_FIELD: {
144
+ collapse: true,
145
+ why: "The kit's `user.update.before` hook, and **the branch it sits on was read wrong the first time.** `if (dbUser) {` opens at link-account.mjs:77 and the `if (!linkedAccount) {…} else {…}` pair sits *inside* it, so the ownership argument that carries `unable_to_update_account` does not reach here: the `updateUser` that can carry a provider's `name`/`image` is the `overrideUserInfo` write at :185, which runs after **either** sub-branch — including the one that has just linked an account that did not exist a line earlier. What every path to it does share is `if (dbUser)`: a matched row. The other side of that branch calls `createUser`, where the kit's `user.create.before` **sanitizes** the same two fields instead of refusing them. So a hostile provider display name answers `?error=INVALID_PROFILE_FIELD` against an address that has a row and a completed sign-in against one that does not, which is the oracle with a different name on it."
146
+ },
147
+ validation_context_missing: {
148
+ collapse: true,
149
+ why: "internal-adapter.mjs:160 — raised when `getCurrentAuthContext()` fails inside `createUser`, and `createUser` is the no-row side. `updateUser` runs no such check (internal-adapter.mjs:599), so this code cannot be observed against an address that has a row: it is `signup_disabled`'s shape reached through the adopter's `validateUserInfo` option rather than through the sign-up policy."
150
+ },
151
+ no_code: {
152
+ collapse: false,
153
+ why: "The provider came back without a code. The shape of the request itself, settled before any lookup."
154
+ },
155
+ invalid_code: {
156
+ collapse: false,
157
+ why: "The code would not exchange at the provider's token endpoint. Settled before any lookup."
158
+ },
159
+ invalid_callback_request: {
160
+ collapse: false,
161
+ why: "callback.mjs:55 — the callback's own query or body would not parse. Raised before `parseState`, so nothing had been read from anywhere yet."
162
+ },
163
+ oauth_provider_not_found: {
164
+ collapse: false,
165
+ why: "This deployment does not serve that provider. A fact about the configuration, and `providers.ts` already draws the one distinction that matters here."
166
+ },
167
+ issuer_missing: {
168
+ collapse: false,
169
+ why: "The provider's own response did not name an issuer. Nothing was looked up."
170
+ },
171
+ issuer_mismatch: {
172
+ collapse: false,
173
+ why: "The provider's response named the wrong issuer. Nothing was looked up."
174
+ },
175
+ nonce_binding_missing: {
176
+ collapse: false,
177
+ why: "The request's own nonce binding. Checked against the state, never against a user row."
178
+ },
179
+ unable_to_get_user_info: {
180
+ collapse: false,
181
+ why: "The provider would not say who this is. Decided before any lookup — and the kit's resolver fails closed to exactly here, so collapsing it would render a GitHub outage as a refusal (githubUserInfo.ts)."
182
+ },
183
+ no_callback_url: {
184
+ collapse: false,
185
+ why: "No `callbackURL` was carried in the state. The adopter's own configuration, and the same answer for everybody."
186
+ },
187
+ email_not_found: {
188
+ collapse: false,
189
+ why: "The provider returned no address at all. Its state, and reached before this Worker looks anything up."
190
+ },
191
+ email_not_verified: {
192
+ collapse: false,
193
+ why: "Better Auth's lower-case code, from `requireEmailVerification` (link-account.mjs:263) — which the kit does not set. Reachable for a registering and a returning user alike, so it names no row either way. Not to be confused with the kit's upper-case `EMAIL_NOT_VERIFIED` above; the two are different strings from different places and only one of them is the oracle."
194
+ },
195
+ unable_to_create_session: {
196
+ collapse: false,
197
+ why: "link-account.mjs:269 — after the user is resolved, so it is reached from both sides of the branch equally."
198
+ },
199
+ state_not_found: {
200
+ collapse: false,
201
+ why: "The request carried no state to parse. Raised at state.mjs:90, before any lookup."
202
+ },
203
+ state_mismatch: {
204
+ collapse: false,
205
+ why: "The request's own state did not match what was stored. Nothing about a user was read to decide it."
206
+ },
207
+ state_security_mismatch: {
208
+ collapse: false,
209
+ why: "The same fact as `state_mismatch`, which is what `oauth2/state.mjs` remaps it to before it reaches a browser. Rostered under its own name because the remap is the dependency's internal detail, not a promise."
210
+ },
211
+ state_invalid: {
212
+ collapse: false,
213
+ why: "The state would not decrypt or parse. The request's own credential, and nothing else."
214
+ },
215
+ state_generation_error: {
216
+ collapse: false,
217
+ why: "Minting the state failed on the way out. A fault on this Worker's own side, raised before there is a callback to answer, let alone a row to read."
218
+ },
219
+ internal_server_error: {
220
+ collapse: false,
221
+ why: "A fault, raised in place of the lookup it would otherwise have reported on — so it says a lookup did not finish, never what one found."
222
+ },
223
+ account_hook_binding_conflict: {
224
+ collapse: false,
225
+ why: "link-account.mjs:120/176/237 — a hook moved the account binding out from under the write that had just been made. Raised on the link path, the sign-in path *and* the create path, so it is reached from both sides of `if (dbUser)` equally and names neither."
226
+ },
227
+ validation_source_missing: {
228
+ collapse: false,
229
+ why: "validate-user-info.mjs:5/9/13 — the `source` handed to the adopter's `validateUserInfo` gate did not name a method or a provider. A fact about the call Better Auth just built, identical on both sides of the branch, and settled before the gate is even asked."
230
+ },
231
+ validation_failed: {
232
+ collapse: false,
233
+ why: "validate-user-info.mjs:34 — the adopter's own `validateUserInfo` callback threw, and Better Auth fails closed. Called on the link path (link-account.mjs:92), the sign-in path (:137) and the create path (internal-adapter.mjs:164), so it is reachable whether or not a row matched. What that callback *returns* is the adopter's own code and travels off-roster, which is the same decision as for the provider's own `error` values."
234
+ },
235
+ unable_to_link_account: {
236
+ collapse: false,
237
+ why: "callback.mjs:173/198, inside `if (link)` — reachable only on `/link-social`, where the caller is signed in as the user being changed. Telling somebody about their own account is not enumeration."
238
+ },
239
+ email_does_not_match: {
240
+ collapse: false,
241
+ why: "The link flow, and the address compared against is the signed-in caller's own. The caller's account, as above."
242
+ },
243
+ account_already_linked_to_different_user: {
244
+ collapse: false,
245
+ why: "The link flow. The caller's own account, as above — and the other user is named by nothing here."
246
+ },
247
+ unable_to_update_account: {
248
+ collapse: false,
249
+ why: "link-account.mjs:172, inside `if (linkedAccount)` — reaching it requires an account row already binding this provider identity to this user, and the caller proved control of that identity at the provider to get here. Ownership, not a matched row. (This is the argument `INVALID_PROFILE_FIELD` was wrongly given: that code's write sits outside this branch.)"
250
+ },
251
+ account_ownership_conflict: {
252
+ collapse: false,
253
+ why: "link-account.mjs:38, inside `if (opts.selectedUser && …)`. The lookup it reports on is keyed by the *provider* identity the caller has just proved control of, not by an address handed over — and the social callback passes no `selectedUser`, so this never reaches that redirect at all."
254
+ },
255
+ account_provider_conflict: {
256
+ collapse: false,
257
+ why: "link-account.mjs:42, guarded by `requireExactAccountBinding`, which is `opts.selectedUser || opts.requireExactAccountBinding` — neither of which `callback.mjs` passes. Keyed by the caller's own provider identity, as above."
258
+ },
259
+ user_not_found: {
260
+ collapse: false,
261
+ why: "link-account.mjs:54 — `findUserById(opts.selectedUser.userId)`, so it answers about a user id the caller was already handed, on a flow the social callback does not enter. It reads a row by id, never by a provider-resolved address."
262
+ },
263
+ user_hook_selection_conflict: {
264
+ collapse: false,
265
+ why: "link-account.mjs:195, inside `if (opts.selectedUser …)`. A hook returned a different user than the one the caller picked from a list they had already been shown, and the social callback never picks one."
266
+ },
267
+ session_hook_user_conflict: {
268
+ collapse: false,
269
+ why: "link-account.mjs:275 — after the user is resolved and the session minted, under the same `requireExactAccountBinding` gate. Reached from both sides of `if (dbUser)` when it is reached at all, which on the social callback is never."
270
+ }
271
+ };
272
+ /** The codes this module refuses to let out. Derived from the roster, so the two cannot disagree. */
273
+ const PROVIDER_REFUSAL_CODES = Object.entries(PROVIDER_REFUSAL_VERDICTS).filter(([, verdict]) => verdict.collapse).map(([code]) => code);
274
+ /** The roster, for the completeness gate. Not part of the package's surface. */
275
+ const PROVIDER_REFUSAL_ROSTER = PROVIDER_REFUSAL_VERDICTS;
276
+ /**
277
+ * Collapse a social-callback refusal that our own user table decided, or answer `undefined`.
278
+ *
279
+ * `undefined` for every response that is not a redirect off the callback path carrying a rostered,
280
+ * collapsing `error` — which is nearly all of them, including every successful sign-in, since a
281
+ * completed callback redirects to `callbackURL` with no `error` at all.
282
+ *
283
+ * **`undefined` also for a callback answered with no `Location` at all**, which is what a composed plugin
284
+ * that replaced the response leaves behind. That is not this function failing open by oversight: a code
285
+ * moved into a body is not reachable from a header rewrite, so the composition is refused at `auth()`
286
+ * instead (`../instance/refusalTransport`). The module docblock's reach section is the whole claim.
287
+ *
288
+ * **`error_description` goes with it.** Nothing sets one for these today, and a description is a whole
289
+ * sentence written by whoever raises the code next — so it is dropped rather than carried past a header
290
+ * that was just made deliberately uninformative.
291
+ *
292
+ * **Set-Cookie is re-attached one header at a time.** A callback response expires the state cookie, and
293
+ * folding several cookies into one comma-joined header is how a browser that would have accepted them
294
+ * silently keeps them instead.
295
+ *
296
+ * ## Two things the caller chooses, and neither may choose the answer
297
+ *
298
+ * The `Location` this reads is built from `errorCallbackURL`, which arrives in the body of
299
+ * `POST /sign-in/social`. An earlier draft read it as though Better Auth had built the whole thing, and
300
+ * both halves of that assumption were wrong:
301
+ *
302
+ * - **It need not be absolute.** `api/middlewares/origin-check.mjs` passes `allowRelativePaths: true`,
303
+ * `matchesOriginPattern` admits `/path?query`, `oauth2/state.mjs` stores the value as a bare
304
+ * `z.string().optional()`, and `redirectOnError` concatenates it raw. So a relative `Location` is a
305
+ * supported answer, and returning `undefined` to one sent the true code to the browser and wrote no
306
+ * audit row.
307
+ * - **`error` need not be the only one.** `redirectOnError` *appends* `&error=<code>`. An
308
+ * `errorCallbackURL` ending `?error=access_denied` therefore answers
309
+ * `?error=access_denied&error=account_not_linked`, and `searchParams.get` reads the planted value.
310
+ *
311
+ * So: a relative target is resolved against the request the way a browser resolves it, and **every**
312
+ * `error` value is put to the roster rather than the first.
313
+ *
314
+ * **Both of those shapes are now refused or normalized before the flow starts** (`./errorCallbackUrl`),
315
+ * and this handling stays anyway — the collapse still has to work on a `Location` whose `errorURL`
316
+ * came from `defaultErrorURL` rather than from a caller, and on whatever a future dependency writes
317
+ * there. What it cannot do is be the only guard: the third bypass was a fragment, and a fragment is
318
+ * precisely the shape a query parser cannot see. That is the whole argument for the other end.
319
+ *
320
+ * @param requestUrl The absolute URL of the request being answered — the callback's own, which a relative
321
+ * `Location` resolves against. Callers pass `c.req.raw.url`.
322
+ */
323
+ function collapseProviderRefusal(requestUrl, response) {
324
+ let request;
325
+ try {
326
+ request = new URL(requestUrl);
327
+ } catch {
328
+ return;
329
+ }
330
+ if (!request.pathname.includes("/callback/")) return void 0;
331
+ if (response.status < 300 || response.status >= 400) return void 0;
332
+ const location = response.headers.get("location");
333
+ if (!location) return void 0;
334
+ let target;
335
+ try {
336
+ target = new URL(location);
337
+ } catch {
338
+ try {
339
+ target = new URL(location, request);
340
+ } catch {
341
+ return;
342
+ }
343
+ }
344
+ const collapsing = target.searchParams.getAll("error").filter((code) => PROVIDER_REFUSAL_VERDICTS[code]?.collapse === true);
345
+ if (collapsing.length === 0) return void 0;
346
+ target.searchParams.set("error", NEUTRAL_PROVIDER_REFUSAL);
347
+ target.searchParams.delete("error_description");
348
+ const headers = new Headers();
349
+ for (const [name, value] of response.headers) if (name.toLowerCase() !== "set-cookie") headers.append(name, value);
350
+ for (const cookie of response.headers.getSetCookie()) headers.append("set-cookie", cookie);
351
+ const rootRelative = location.startsWith("/") && !location.startsWith("//");
352
+ headers.set("location", rootRelative ? `${target.pathname}${target.search}${target.hash}` : target.toString());
353
+ return {
354
+ response: new Response(response.body, {
355
+ status: response.status,
356
+ statusText: response.statusText,
357
+ headers
358
+ }),
359
+ reason: collapsing.join(" ")
360
+ };
361
+ }
362
+ //#endregion
363
+ export { NEUTRAL_PROVIDER_REFUSAL, PROVIDER_REFUSAL_CODES, PROVIDER_REFUSAL_ROSTER, collapseProviderRefusal };
@@ -97,6 +97,7 @@ async function buildAuthInstance(c, wiring) {
97
97
  },
98
98
  ...wiring.resolveGithubUserInfo ? { resolveGithubUserInfo: wiring.resolveGithubUserInfo } : {},
99
99
  emit: (event) => c.var.emit(event),
100
+ requestHeaders: c.req.raw.headers,
100
101
  plugins: cfg.plugins
101
102
  });
102
103
  }
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/http/routes.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAO7E,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAwBhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,CA4CtF"}
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/http/routes.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAO7E,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA0BhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,CA4CtF"}
@@ -5,11 +5,13 @@ import { correlation, emitDenied, emitDeviceRevoked, emitTokenRefresh, emitToken
5
5
  import { deleteDevice, deviceSessionTokens, listDevices } from "../device/registry.js";
6
6
  import { requireFreshAuthentication } from "./providerFreshness.js";
7
7
  import { PROFILE_IMAGE_PATH } from "../profile/profile.js";
8
+ import { collapseProviderRefusal } from "./providerRefusal.js";
8
9
  import { getAuthInstance, resolveDb } from "./resolve.js";
9
10
  import { requireAuth } from "./middleware.js";
10
11
  import { consumeSession, findConsumedToken, pruneConsumedTokens, recordConsumedToken, revokeFamily } from "../token/rotation.js";
11
12
  import { RevokeDeviceBody } from "./schemas.js";
12
13
  import { registerAuthAdminRoutes } from "./adminRoutes.js";
14
+ import { guardErrorCallbackURL } from "./errorCallbackUrl.js";
13
15
  import { apiErrorToPithy } from "./errors.js";
14
16
  import { NotFoundError, UnauthorizedError } from "@pithy-sh/core/src/error/pithyError";
15
17
  import { TURNSTILE_LOGIN_ACTION } from "@pithy-sh/turnstile/src/config/config";
@@ -144,12 +146,21 @@ async function auditRefusal(c, response) {
144
146
  */
145
147
  async function handleBetterAuth(c, wiring) {
146
148
  const instance = await getAuthInstance(c, wiring);
149
+ const request = await guardErrorCallbackURL(c.req.raw, c.req.raw.url);
147
150
  let response;
148
151
  try {
149
- response = await instance.handler(c.req.raw);
152
+ response = await instance.handler(request);
150
153
  } catch (error) {
151
154
  throw apiErrorToPithy(error);
152
155
  }
156
+ const collapsed = collapseProviderRefusal(c.req.raw.url, response);
157
+ if (collapsed) {
158
+ await emitDenied(c.var.emit, {
159
+ ...correlation(c.req.raw.headers),
160
+ detail: collapsed.reason
161
+ });
162
+ return collapsed.response;
163
+ }
153
164
  await auditRefusal(c, response);
154
165
  return response;
155
166
  }
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  import type { AuditEmit } from "@pithy-sh/core/src/audit/recorder";
4
4
  import { type BetterAuthPlugin } from "better-auth";
5
+ import { type AuthEmailDelivery } from "../audit/evidence";
5
6
  import type { AuthDatabase } from "../data/tables";
6
7
  import { type GithubUserInfoResolver } from "./githubUserInfo";
7
8
  import { type ResolvedProviders, type SocialProviderId } from "./providers";
@@ -19,6 +20,17 @@ export declare function socialProviders(deps: AuthInstanceDeps): Record<string,
19
20
  export declare function isUnverifiedSignup(user: {
20
21
  emailVerified?: boolean | null;
21
22
  }): boolean;
23
+ /** The endpoint context a database hook is handed, narrowed to the two things attribution needs. */
24
+ interface HookContext {
25
+ headers?: Headers;
26
+ context?: {
27
+ session?: {
28
+ user?: {
29
+ id?: string;
30
+ };
31
+ } | null;
32
+ };
33
+ }
22
34
  /**
23
35
  * What the instance hands to Pithy's email seam to deliver. The route never sends inline — the hook
24
36
  * enqueues an `@pithy-sh/email` job (`magicLink`/`otp` template) which a Workflow delivers.
@@ -33,8 +45,23 @@ export type AuthEmailMessage = {
33
45
  template: "otp";
34
46
  code: string;
35
47
  };
36
- /** The email-delivery seam: enqueue (never send inline). Injected so the instance stays I/O-agnostic. */
37
- export type SendAuthEmail = (message: AuthEmailMessage) => Promise<void>;
48
+ /**
49
+ * The email-delivery seam: enqueue (never send inline). Injected so the instance stays I/O-agnostic.
50
+ *
51
+ * **It answers what happened, and that answer is the evidence behind two audit events.** Returning
52
+ * `Promise<void>` made the seam structurally blind: `auth/magic_link_sent` and `auth/otp_sent` claim a
53
+ * message, `@pithy-sh/email` decides whether there is one, and nothing carried that decision back — so a
54
+ * recipient the suppression list withheld, and an enqueue that threw, both wrote `outcome: "success"`
55
+ * (#627). {@link AuthEmailDelivery} is the narrowest thing that closes it: queued, withheld with a
56
+ * reason, or failed. The instance still knows nothing about email infrastructure — `withheld` and
57
+ * `failed` are facts about a message, not about a binding.
58
+ *
59
+ * **Internal.** It is produced by `../email/send.ts`'s `makeSendAuthEmail`, consumed by
60
+ * `./plugins.ts`, and wired by `../http/resolve.ts` from the composed email capability's own `enqueue`.
61
+ * An adopter never supplies one — `AuthWiring.enqueueEmail` is filled by `compose` — and it is not
62
+ * exported from `../index.ts`, so widening the return type breaks nothing they can hold.
63
+ */
64
+ export type SendAuthEmail = (message: AuthEmailMessage) => Promise<AuthEmailDelivery>;
38
65
  /**
39
66
  * Everything the Better-Auth instance needs, resolved per invocation from config + request env.
40
67
  *
@@ -91,6 +118,15 @@ export interface AuthInstanceDeps<Plugins extends readonly BetterAuthPlugin[] =
91
118
  resolveGithubUserInfo?: GithubUserInfoResolver;
92
119
  /** Audit seam — emits `auth/*` events. A no-op when the audit capability is absent. */
93
120
  emit: AuditEmit;
121
+ /**
122
+ * This request's headers, threaded for the one seam that cannot reach them itself.
123
+ *
124
+ * `./providerSignInGate` decides a refused provider sign-in from inside `getUserInfo`, which Better
125
+ * Auth hands the OAuth tokens and nothing else — so the `ip` and `user-agent` every other denial row
126
+ * carries have to arrive from here. Optional, because `makeAuth` is also called where there is no
127
+ * request: the seeds, `../test-utils/liveApp.ts`, an adopter building an instance by hand.
128
+ */
129
+ requestHeaders?: Headers;
94
130
  /**
95
131
  * Called when a session row is deleted — a sign-out, a revoke, an admin ending somebody's devices.
96
132
  *
@@ -191,6 +227,56 @@ export declare function makeAuth<const Plugins extends readonly BetterAuthPlugin
191
227
  }> & Record<string, unknown>) => Promise<void>;
192
228
  };
193
229
  };
230
+ account: {
231
+ /**
232
+ * **The provider-link trail, recorded where the account table changes.**
233
+ *
234
+ * An account row is what lets a provider sign in as somebody, so its creation and its removal
235
+ * are the two account-security events — and the row is the only place both are visible. Better
236
+ * Auth reaches it from several directions: `/callback/:id` on a first social sign-up and on a
237
+ * link, `linkAccount` from the OAuth linking path, `/unlink-account`, and the cascade that drops
238
+ * every account when a user is deleted. All of them go through `createWithHooks` /
239
+ * `deleteWithHooks` on the `account` model (`better-auth/dist/db/internal-adapter.mjs`), so one
240
+ * pair of hooks covers what four endpoint wirings would have had to enumerate and keep current.
241
+ *
242
+ * **This is the seam `session.delete.after` below already argues for**, applied to the other
243
+ * table: a handler wired to one endpoint misses the others, and the row is what the fact is
244
+ * keyed by. #627 is what that costs — `/link-social` was wired, so a link recorded the request
245
+ * rather than the result, and an unlink recorded nothing.
246
+ *
247
+ * **After, not before, in both directions.** The write has happened by the time these run, so a
248
+ * slow or failing audit seam can neither hold up nor refuse a link or an unlink — and
249
+ * `emitProviderAccountChanged` swallows its own failure for the same reason.
250
+ */
251
+ create: {
252
+ after: (account: {
253
+ id: string;
254
+ createdAt: Date;
255
+ updatedAt: Date;
256
+ providerId: string;
257
+ issuer: string;
258
+ accountId: string;
259
+ userId: string;
260
+ accessToken?: string | null | undefined;
261
+ refreshToken?: string | null | undefined;
262
+ idToken?: string | null | undefined;
263
+ accessTokenExpiresAt?: Date | null | undefined;
264
+ refreshTokenExpiresAt?: Date | null | undefined;
265
+ scope?: string | null | undefined;
266
+ password?: string | null | undefined;
267
+ }, ctx: import("better-auth").GenericEndpointContext | null) => Promise<void>;
268
+ };
269
+ /**
270
+ * **Through `claimedDelete`, because `delete.after` fires on the row that was read.** Two
271
+ * concurrent unlinks of one account both reach `after` and the trail double-counts one removal.
272
+ * The pair below issues the delete in `before` and runs this body only for the caller whose
273
+ * statement removed the row — see `../audit/evidence.ts` for the primitive, its two
274
+ * preconditions, and why every `delete.after` here goes through it rather than two of them.
275
+ */
276
+ delete: import("../audit/evidence").ClaimedDelete<{
277
+ id: unknown;
278
+ }, HookContext | null | undefined>;
279
+ };
194
280
  session: {
195
281
  create: {
196
282
  /**
@@ -250,29 +336,28 @@ export declare function makeAuth<const Plugins extends readonly BetterAuthPlugin
250
336
  };
251
337
  }>;
252
338
  };
253
- delete: {
254
- /**
255
- * Tell whoever keyed state on this session that it has gone.
256
- *
257
- * A sign-out, a revoke, an admin ending somebody's devices — all of them land here, which is
258
- * why the seam is on the row rather than on the sign-out endpoint. A handler wired to one
259
- * endpoint would miss the other three, and the row is what the state was keyed by.
260
- *
261
- * **After, not before.** The session is already gone when this runs, so a slow or failing
262
- * listener cannot hold up or refuse a sign-out — and it swallows its own failure for the same
263
- * reason the audit emit does: the thing it reports has already happened.
264
- */
265
- after: (session: {
266
- id: string;
267
- createdAt: Date;
268
- updatedAt: Date;
269
- userId: string;
270
- expiresAt: Date;
271
- token: string;
272
- ipAddress?: string | null | undefined;
273
- userAgent?: string | null | undefined;
274
- } & Record<string, unknown>) => Promise<void>;
275
- };
339
+ /**
340
+ * Tell whoever keyed state on this session that it has gone, and record that it did.
341
+ *
342
+ * A sign-out, a revoke, an admin ending somebody's devices — all of them land here, which is
343
+ * why the seam is on the row rather than on the sign-out endpoint. A handler wired to one
344
+ * endpoint would miss the other three, and the row is what the state was keyed by.
345
+ *
346
+ * **After, not before.** The session is already gone when this runs, so a slow or failing
347
+ * listener cannot hold up or refuse a sign-out — and it swallows its own failure for the same
348
+ * reason the audit emit does: the thing it reports has already happened.
349
+ *
350
+ * **Through `claimedDelete`, and that is the second half of #627's last hole.** `/sign-out`
351
+ * reaches `internalAdapter.deleteSession(token)`, so concurrent sign-outs on one cookie all find
352
+ * the row, all issue a delete, exactly one removes anything — and all of them reached this body.
353
+ * `markSessionEnded` ran for each, and `emitAfterRequest` wrote `auth/signout outcome=success`
354
+ * for callers that signed nobody out. The same primitive the account hooks use covers it,
355
+ * because the defect is `deleteWithHooks`'s rather than either table's.
356
+ */
357
+ delete: import("../audit/evidence").ClaimedDelete<{
358
+ id: unknown;
359
+ userId: unknown;
360
+ }, HookContext | null | undefined>;
276
361
  };
277
362
  };
278
363
  hooks: {
@@ -293,6 +378,26 @@ export declare function makeAuth<const Plugins extends readonly BetterAuthPlugin
293
378
  * schema, and this reads one field out of it.
294
379
  */
295
380
  before: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>;
381
+ /**
382
+ * Emit audit events for an auth request: sign-in (+device) from the new session, plus the
383
+ * send/sign-out/token event by path. Endpoint-scoped, so a rotation never emits.
384
+ *
385
+ * **`returned` is passed because this hook runs on refusals too.** Better Auth catches an
386
+ * endpoint's `APIError` into a result and dispatches the `after` hooks over it
387
+ * (`better-auth/dist/api/dispatch.mjs`), so a 401 `/token` reaches here looking exactly like one
388
+ * that minted a token — and wrote `auth/token_refresh outcome=success` for a request that was
389
+ * refused. `ctx.context.returned` is the only thing that tells them apart, and the judgment is
390
+ * `emitAfterRequest`'s so it is made once for every path rather than per wiring.
391
+ *
392
+ * **The two markers are passed because a refusal can answer 200.** `/sign-out` deletes nothing and
393
+ * says so cheerfully; `/email-otp/send-verification-otp` declines to send and answers
394
+ * `{"success":true}` on purpose, so a caller cannot tell a registered address from a stranger's.
395
+ * Neither decline is visible from anything this hook holds, so each audited path names what must
396
+ * have *happened* and `../audit/evidence.ts` carries it here from the place that saw it — the
397
+ * session row going away, and the email seam's own answer about the message, which is the send
398
+ * paths' evidence rather than the fact that a callback was entered. Reading them is all this does:
399
+ * the response has already been decided and is not touched.
400
+ */
296
401
  after: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>;
297
402
  };
298
403
  rateLimit: {
@@ -1275,6 +1380,7 @@ export declare function makeAuth<const Plugins extends readonly BetterAuthPlugin
1275
1380
  INVALID_OTP: import("better-auth").RawError<"INVALID_OTP">;
1276
1381
  TOO_MANY_ATTEMPTS: import("better-auth").RawError<"TOO_MANY_ATTEMPTS">;
1277
1382
  };
1278
- }, ...Plugins];
1383
+ }, BetterAuthPlugin, ...Plugins];
1279
1384
  }>;
1385
+ export {};
1280
1386
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/instance/auth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,KAAK,gBAAgB,EAAc,MAAM,aAAa,CAAC;AAIhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAInD,OAAO,EAAyB,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAEtF,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAEtB,MAAM,aAAa,CAAC;AA6BrB,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAA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