@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
package/README.md CHANGED
@@ -41,6 +41,21 @@ type AppAuth = AuthInstance<[ReturnType<typeof organization>]>;
41
41
 
42
42
  **This section stays here.** `src/http/routes.ts` and `src/client/api.ts` both explain a design decision by pointing a reader at it by name — the flat response shape is read rather than rewritten precisely because `createAuthClient` is a first-class surface, and that argument is only checkable against the client this documents.
43
43
 
44
+ ## Provider sign-in is identity-based, by design
45
+
46
+ Pressing a provider button while signed out is not a claim on an address. It is a claim on an identity. Four outcomes, and they are the whole of it:
47
+
48
+ | # | Situation | Outcome |
49
+ |---|---|---|
50
+ | 1 | The provider identity is already attached to an account | Signs in |
51
+ | 2 | Not attached, and the provider's **verified** address matches an account | Links and signs in |
52
+ | 3 | Not attached, address unverified at the provider, an account exists there | Refused |
53
+ | 4 | Not attached, no account at that address | Refused |
54
+
55
+ **Rows 3 and 4 answer identically**, and that is a security property rather than a rough edge. They differ only in whether an account exists at an address the caller chose, and telling a stranger which one they hit is an account-enumeration oracle: one provider account, none on the target, unlimited queries. The decision is made in `src/instance/providerSignInGate.ts`, before Better Auth branches, so the two codes that used to answer it are never produced. The true reason goes to the audit trail, where an operator can read it and a browser cannot.
56
+
57
+ So: **do not "improve" this by matching more addresses, and do not make the refusal more helpful.** An address is not a credential — a provider hands over whatever primary happens to be set, chosen years ago for unrelated reasons — and every sentence that separates "you have no account here" from "you have one and this provider is not attached to it" is the oracle back. The remedy for a refused sign-in is the same either way: sign in with a magic link, then connect the provider from the account. Linking from inside the account is a different flow with both sides already proven, and it is deliberately unconstrained by the address.
58
+
44
59
  ## License
45
60
 
46
61
  MIT — adopter-side app value. The root `LICENSE` covers it.
@@ -11,18 +11,91 @@
11
11
  export declare const AuthAuditActions: {
12
12
  /** A sign-in completed (magic link, OTP, or OAuth). Outcome `denied` for a blocked attempt. */
13
13
  readonly signin: "auth/signin";
14
- /** A sign-out / session revocation completed. */
14
+ /**
15
+ * A sign-out / session revocation completed — and **completed** is the load-bearing word.
16
+ *
17
+ * `/sign-out` answers `200 {"success":true}` whether or not it found a session to delete: an expired
18
+ * cookie, a bearer token (which it does not read) or a bare `curl` all get the same body. Recorded off
19
+ * the path, every one of them wrote a sign-out that signed nobody out. The evidence is a session row
20
+ * disappearing, which `../instance/auth.ts`'s `session.delete.after` observes and `../audit/evidence.ts`
21
+ * carries to the emitter; with no session gone there is no event, because nothing happened.
22
+ */
15
23
  readonly signout: "auth/signout";
16
- /** A session was exchanged for a fresh access token, rotating the refresh credential. */
24
+ /**
25
+ * A session was exchanged for a fresh access token, rotating the refresh credential. The evidence is
26
+ * the token in the response — an endpoint's own payload is what it claims to have made — rather than
27
+ * the 200 around it.
28
+ */
17
29
  readonly tokenRefresh: "auth/token_refresh";
18
30
  /** A consumed (already-rotated) refresh token was replayed — reuse detected, the family revoked. Outcome `denied`. */
19
31
  readonly tokenReuseDetected: "auth/token_reuse_detected";
20
- /** A magic link was requested and enqueued for delivery. */
32
+ /**
33
+ * A magic link was requested and **enqueued for delivery** — the second half is the claim, and it is
34
+ * not what the status says. Both send endpoints answer 200 whether or not a message was made, so the
35
+ * evidence is the email seam's own answer about the message; with none, the row is `denied`, because a
36
+ * send this deployment declined to make is an attempt worth counting and never a send.
37
+ */
21
38
  readonly magicLinkSent: "auth/magic_link_sent";
22
- /** An email OTP was requested and enqueued for delivery. */
39
+ /**
40
+ * An email OTP was requested and enqueued for delivery. Same claim, same evidence — and this is the
41
+ * endpoint that made the point (#627).
42
+ *
43
+ * It declines twice over and answers `200 {"success":true}` both times. Better Auth drops the
44
+ * verification row and returns success rather than confirm that an address is registered, which is the
45
+ * whole reason the response is shaped that way; and the kit's own `sendVerificationOTP` returns without
46
+ * queuing for any `type` but `sign-in`, because an OTP is a sign-in credential here. Read off the
47
+ * status, every one of those wrote a send that never happened.
48
+ *
49
+ * **Two more declines sit under the send callback rather than over it, and they are not the same
50
+ * thing as each other.** `@pithy-sh/email` withholds a message to a suppressed address — a hard bounce,
51
+ * a complaint — which is that capability working exactly as designed, so the row is `denied` and carries
52
+ * the reason in `metadata.reason`. An enqueue that *fails* is `failure`, severity `warning`: nothing
53
+ * declined it, something broke, and `runInBackgroundOrAwait` swallows the error so the endpoint answers
54
+ * `200 {"success":true}` over it. Recording a fault as a decline sends an operator hunting an abuser
55
+ * when a binding is missing.
56
+ *
57
+ * **The trail records all of it; the response still does not.** None of these outcomes changes anything
58
+ * a caller can see — the status, the body and the headers are the endpoint's — and the row names an
59
+ * action, an outcome, an actor, a correlation and at most a reason from a closed vocabulary, never an
60
+ * address. The enumeration guard survives the audit trail knowing better.
61
+ */
23
62
  readonly otpSent: "auth/otp_sent";
24
- /** A social account (Google) was linked to a user. */
63
+ /**
64
+ * A social account row was created — from here on that provider can sign in as this user.
65
+ *
66
+ * **Emitted from the row, not from `/link-social`, and that is the whole of #627.** Minting the
67
+ * provider redirect is a request; the account row is created later at `/callback/:id` and may never be
68
+ * created at all — the person abandons the consent screen, the provider refuses, the linking gate
69
+ * rejects it. Recorded at the request, every one of those wrote a success row for a link that never
70
+ * happened, which makes "which providers can sign in as this account today" unanswerable from the
71
+ * trail that exists to answer it.
72
+ *
73
+ * **A first social sign-up writes this too, deliberately.** The endpoint wiring this replaced refused
74
+ * to map `/callback/:id` because doing so "would mislabel every first sign-up as a link" — true of a
75
+ * *path*, which cannot tell a sign-up from a link. From the row it stops mattering: this event claims a
76
+ * provider can now sign in as this user, and a first social sign-up is exactly when that becomes true.
77
+ * Pinned by `emit.workers.test.ts`, so the decision is asserted rather than inferred from the absence
78
+ * of a branch.
79
+ */
25
80
  readonly oauthLinked: "auth/oauth_linked";
81
+ /**
82
+ * A social account row was removed — that provider can no longer sign in as this user.
83
+ *
84
+ * The other half of the same question, and it emitted nothing at all until #627: a provider was
85
+ * detached and the trail was silent. Emitted from the row for the same reason its twin is, which also
86
+ * means it covers every way a link ends — `/unlink-account`, and the cascade when a user is deleted —
87
+ * rather than the one endpoint somebody remembered to wire. Both are driven in `emit.workers.test.ts`:
88
+ * a sentence claiming a class is covered is not the same as a test that reddens when it stops being.
89
+ *
90
+ * **The actor is whoever caused it, which on a cascade is whoever drove the cascade.** `delete.after`
91
+ * fires for the cascade as readily as for an unlink, so attributing the row to the account's owner
92
+ * would say that person detached their own providers when an operator deleted them — from the
93
+ * operator's address. The owner is the *subject* and rides in `metadata.userId`; `actorId` is the
94
+ * caller. An operator reaching the cascade through an endpoint **is** that caller and is named, which
95
+ * is right, and is what `../audit/emit.ts`'s three cases mean: `system` is the row with no request
96
+ * behind it at all, not the row a cascade wrote.
97
+ */
98
+ readonly oauthUnlinked: "auth/oauth_unlinked";
26
99
  /** A device was registered or updated from sign-in metadata. */
27
100
  readonly deviceRegistered: "auth/device_registered";
28
101
  /** A device was revoked (its session(s) signed out). */
@@ -1 +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;IAChD;;;;;;;;;;OAUG;aACH,eAAe,EAAE,wBAAwB;IAEzC;;;;;;;;;;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"}
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;;;;;;;;OAQG;aACH,OAAO,EAAE,cAAc;IACvB;;;;OAIG;aACH,YAAY,EAAE,oBAAoB;IAClC,sHAAsH;aACtH,kBAAkB,EAAE,2BAA2B;IAC/C;;;;;OAKG;aACH,aAAa,EAAE,sBAAsB;IACrC;;;;;;;;;;;;;;;;;;;;;;OAsBG;aACH,OAAO,EAAE,eAAe;IACxB;;;;;;;;;;;;;;;;OAgBG;aACH,WAAW,EAAE,mBAAmB;IAChC;;;;;;;;;;;;;;;;OAgBG;aACH,aAAa,EAAE,qBAAqB;IACpC,gEAAgE;aAChE,gBAAgB,EAAE,wBAAwB;IAC1C,wDAAwD;aACxD,aAAa,EAAE,qBAAqB;IACpC;;;;;;;;;;OAUG;aACH,mBAAmB,EAAE,2BAA2B;IAChD;;;;;;;;;;OAUG;aACH,eAAe,EAAE,wBAAwB;IAEzC;;;;;;;;;;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"}
@@ -12,18 +12,91 @@
12
12
  const AuthAuditActions = {
13
13
  /** A sign-in completed (magic link, OTP, or OAuth). Outcome `denied` for a blocked attempt. */
14
14
  signin: "auth/signin",
15
- /** A sign-out / session revocation completed. */
15
+ /**
16
+ * A sign-out / session revocation completed — and **completed** is the load-bearing word.
17
+ *
18
+ * `/sign-out` answers `200 {"success":true}` whether or not it found a session to delete: an expired
19
+ * cookie, a bearer token (which it does not read) or a bare `curl` all get the same body. Recorded off
20
+ * the path, every one of them wrote a sign-out that signed nobody out. The evidence is a session row
21
+ * disappearing, which `../instance/auth.ts`'s `session.delete.after` observes and `../audit/evidence.ts`
22
+ * carries to the emitter; with no session gone there is no event, because nothing happened.
23
+ */
16
24
  signout: "auth/signout",
17
- /** A session was exchanged for a fresh access token, rotating the refresh credential. */
25
+ /**
26
+ * A session was exchanged for a fresh access token, rotating the refresh credential. The evidence is
27
+ * the token in the response — an endpoint's own payload is what it claims to have made — rather than
28
+ * the 200 around it.
29
+ */
18
30
  tokenRefresh: "auth/token_refresh",
19
31
  /** A consumed (already-rotated) refresh token was replayed — reuse detected, the family revoked. Outcome `denied`. */
20
32
  tokenReuseDetected: "auth/token_reuse_detected",
21
- /** A magic link was requested and enqueued for delivery. */
33
+ /**
34
+ * A magic link was requested and **enqueued for delivery** — the second half is the claim, and it is
35
+ * not what the status says. Both send endpoints answer 200 whether or not a message was made, so the
36
+ * evidence is the email seam's own answer about the message; with none, the row is `denied`, because a
37
+ * send this deployment declined to make is an attempt worth counting and never a send.
38
+ */
22
39
  magicLinkSent: "auth/magic_link_sent",
23
- /** An email OTP was requested and enqueued for delivery. */
40
+ /**
41
+ * An email OTP was requested and enqueued for delivery. Same claim, same evidence — and this is the
42
+ * endpoint that made the point (#627).
43
+ *
44
+ * It declines twice over and answers `200 {"success":true}` both times. Better Auth drops the
45
+ * verification row and returns success rather than confirm that an address is registered, which is the
46
+ * whole reason the response is shaped that way; and the kit's own `sendVerificationOTP` returns without
47
+ * queuing for any `type` but `sign-in`, because an OTP is a sign-in credential here. Read off the
48
+ * status, every one of those wrote a send that never happened.
49
+ *
50
+ * **Two more declines sit under the send callback rather than over it, and they are not the same
51
+ * thing as each other.** `@pithy-sh/email` withholds a message to a suppressed address — a hard bounce,
52
+ * a complaint — which is that capability working exactly as designed, so the row is `denied` and carries
53
+ * the reason in `metadata.reason`. An enqueue that *fails* is `failure`, severity `warning`: nothing
54
+ * declined it, something broke, and `runInBackgroundOrAwait` swallows the error so the endpoint answers
55
+ * `200 {"success":true}` over it. Recording a fault as a decline sends an operator hunting an abuser
56
+ * when a binding is missing.
57
+ *
58
+ * **The trail records all of it; the response still does not.** None of these outcomes changes anything
59
+ * a caller can see — the status, the body and the headers are the endpoint's — and the row names an
60
+ * action, an outcome, an actor, a correlation and at most a reason from a closed vocabulary, never an
61
+ * address. The enumeration guard survives the audit trail knowing better.
62
+ */
24
63
  otpSent: "auth/otp_sent",
25
- /** A social account (Google) was linked to a user. */
64
+ /**
65
+ * A social account row was created — from here on that provider can sign in as this user.
66
+ *
67
+ * **Emitted from the row, not from `/link-social`, and that is the whole of #627.** Minting the
68
+ * provider redirect is a request; the account row is created later at `/callback/:id` and may never be
69
+ * created at all — the person abandons the consent screen, the provider refuses, the linking gate
70
+ * rejects it. Recorded at the request, every one of those wrote a success row for a link that never
71
+ * happened, which makes "which providers can sign in as this account today" unanswerable from the
72
+ * trail that exists to answer it.
73
+ *
74
+ * **A first social sign-up writes this too, deliberately.** The endpoint wiring this replaced refused
75
+ * to map `/callback/:id` because doing so "would mislabel every first sign-up as a link" — true of a
76
+ * *path*, which cannot tell a sign-up from a link. From the row it stops mattering: this event claims a
77
+ * provider can now sign in as this user, and a first social sign-up is exactly when that becomes true.
78
+ * Pinned by `emit.workers.test.ts`, so the decision is asserted rather than inferred from the absence
79
+ * of a branch.
80
+ */
26
81
  oauthLinked: "auth/oauth_linked",
82
+ /**
83
+ * A social account row was removed — that provider can no longer sign in as this user.
84
+ *
85
+ * The other half of the same question, and it emitted nothing at all until #627: a provider was
86
+ * detached and the trail was silent. Emitted from the row for the same reason its twin is, which also
87
+ * means it covers every way a link ends — `/unlink-account`, and the cascade when a user is deleted —
88
+ * rather than the one endpoint somebody remembered to wire. Both are driven in `emit.workers.test.ts`:
89
+ * a sentence claiming a class is covered is not the same as a test that reddens when it stops being.
90
+ *
91
+ * **The actor is whoever caused it, which on a cascade is whoever drove the cascade.** `delete.after`
92
+ * fires for the cascade as readily as for an unlink, so attributing the row to the account's owner
93
+ * would say that person detached their own providers when an operator deleted them — from the
94
+ * operator's address. The owner is the *subject* and rides in `metadata.userId`; `actorId` is the
95
+ * caller. An operator reaching the cascade through an endpoint **is** that caller and is named, which
96
+ * is right, and is what `../audit/emit.ts`'s three cases mean: `system` is the row with no request
97
+ * behind it at all, not the row a cascade wrote.
98
+ */
99
+ oauthUnlinked: "auth/oauth_unlinked",
27
100
  /** A device was registered or updated from sign-in metadata. */
28
101
  deviceRegistered: "auth/device_registered",
29
102
  /** A device was revoked (its session(s) signed out). */
@@ -1,6 +1,9 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
3
  import type { AuditEmit } from "@pithy-sh/core/src/audit/recorder";
4
+ import { z } from "zod";
5
+ import { type AuthAuditAction } from "./actions";
6
+ import type { AuthEmailDelivery, EndedSession } from "./evidence";
4
7
  /**
5
8
  * Audit emission helpers, kept out of the instance so the hook wiring stays legible. Every helper goes
6
9
  * through core's `emit` seam (a no-op when audit is absent) and swallows its own failure — an audit
@@ -14,6 +17,75 @@ export declare function correlation(headers: Headers | undefined): {
14
17
  ip?: string;
15
18
  userAgent?: string;
16
19
  };
20
+ /**
21
+ * What an endpoint must have *done* for its path event to be a success.
22
+ *
23
+ * **There is no "the response is its own evidence" member, and its removal is #627's last half.** A
24
+ * non-2xx is sufficient evidence of a refusal and is nowhere near necessary: `/sign-out` answers
25
+ * `200 {"success":true}` having deleted nothing, and `/email-otp/send-verification-otp` answers
26
+ * `200 {"success":true}` having declined to send — Better Auth drops the verification row and returns
27
+ * success rather than confirm that an address is registered (`plugins/email-otp/routes.mjs`), and the
28
+ * kit's own `sendVerificationOTP` returns without queuing for any `type` but `sign-in`. Both are
29
+ * deliberate; neither is visible from the status or the body. So every entry names something that must
30
+ * have *happened*, and `emitAfterRequest` writes `success` only when it did.
31
+ *
32
+ * Each member is observed by {@link EVIDENCE_OBSERVERS}, and a member added here does not compile until
33
+ * that record names how to see it.
34
+ *
35
+ * - `"session-ended"` — a session row disappeared, which `session.delete.after` observes. `/sign-out`
36
+ * reads no session of its own, so this is also the only actor it can name.
37
+ * - `"message-queued"` — the email seam answered that a message reached the queue, which the send callback
38
+ * in `../instance/plugins.ts` observes. Its *absence* is two different facts and the observer reports
39
+ * which: a message the capability withheld is a decline, a send that threw is a fault.
40
+ * - `"token-minted"` — the response actually carries a token, which is readable from `returned` because
41
+ * an endpoint's own payload is what it claims to have made.
42
+ */
43
+ export type PathEvidence = "session-ended" | "message-queued" | "token-minted";
44
+ /**
45
+ * What a *completed* response with no evidence behind it means, and therefore what to record for it.
46
+ *
47
+ * `"denied"` where a rule this deployment holds declined to act — the enumeration guard, a send the kit
48
+ * will not make. Those are the rows an abuse count is made of, and `denied` is core's word for "an
49
+ * authorization gate blocked it".
50
+ *
51
+ * `"silent"` where nothing was attempted and nothing refused: `/sign-out` with no session confirms a
52
+ * state that already held. There is no event, because nothing happened. (A *refused* request still
53
+ * writes `denied` on every path, silent ones included — the attempt was made and turned away.)
54
+ */
55
+ export type WithoutEvidence = "denied" | "silent";
56
+ /** One audited endpoint: the action its path means, and what must have happened for that to be true. */
57
+ export interface PathEvent {
58
+ /** The action code this path writes. */
59
+ action: AuthAuditAction;
60
+ /** What must be observably true for the action to have happened. Required: there is no unevidenced claim. */
61
+ evidence: PathEvidence;
62
+ /** What a completed response with that evidence absent is, and therefore what is recorded for it. */
63
+ withoutEvidence: WithoutEvidence;
64
+ }
65
+ /**
66
+ * The endpoints whose *path* names an audit action, what "success" means for each, and what a completed
67
+ * response without it means instead.
68
+ *
69
+ * **A table rather than a chain of `if`s so the rule can be asserted over all of it.** #627's second
70
+ * half was that every entry here wrote `outcome: "success"` for a request the endpoint had refused:
71
+ * Better Auth catches an endpoint's `APIError` into a result and runs the `after` hooks over it anyway
72
+ * (`better-auth/dist/api/dispatch.mjs`), so a 401 `/token` and a 400 `/email-otp/send-verification-otp`
73
+ * both looked, from here, exactly like a request that worked. Naming the two paths somebody happened to
74
+ * probe would have fixed those two; the exposure was every entry, including ones added later. So the
75
+ * rule is `emitAfterRequest` reading the outcome, and the gate walks this table.
76
+ *
77
+ * **Its third half was that a refusal can answer 200**, which the first fix could not see, and the
78
+ * correction is the same shape: not a fifth branch for the endpoint somebody probed, but a column every
79
+ * entry must fill. `evidence` has no "the response says so" member, so an entry that claims an outcome
80
+ * it cannot evidence does not compile, and `emit.test.ts` walks the table asserting that an entry whose
81
+ * evidence is absent never writes `success`.
82
+ *
83
+ * **No path maps to `oauth_linked`, and that is the correction #627 made first.** `/link-social` mints
84
+ * a redirect, which is a request rather than an outcome; `/callback/:id` completes a sign-in *or* a link
85
+ * and cannot be told apart by its path. The event that means "this provider can sign in as this user" is
86
+ * the account row, so it is emitted from the row — see `emitProviderAccountChanged`.
87
+ */
88
+ export declare const PATH_EVENTS: Readonly<Record<string, PathEvent>>;
17
89
  /** The session just created on a sign-in endpoint, plus the (already-authenticated) caller, if any. */
18
90
  export interface AfterRequest {
19
91
  path: string;
@@ -24,8 +96,91 @@ export interface AfterRequest {
24
96
  deviceId: string | null;
25
97
  } | null;
26
98
  currentUserId: string | null;
99
+ /**
100
+ * What the endpoint handed back — `ctx.context.returned`. An `APIError` here means the request was
101
+ * refused; the `after` hook runs over it regardless, so this is the only thing that tells the two
102
+ * apart. Passed raw rather than pre-judged so the judgment is `wasRefused`'s, where it is asserted.
103
+ */
104
+ returned: unknown;
105
+ /**
106
+ * The session row that actually disappeared during this request — the evidence `/sign-out` needs, and
107
+ * the only actor it can name, since it declares no session middleware and reads the cookie itself.
108
+ */
109
+ endedSession: EndedSession | null;
110
+ /**
111
+ * What the email seam did with this request's magic link or OTP, or null where it was never reached —
112
+ * the evidence the two send paths need, since both answer `200 {"success":true}` whether or not a
113
+ * message exists. The answer rather than the attempt: see `./evidence.ts`.
114
+ */
115
+ messageDelivery: AuthEmailDelivery | null;
116
+ }
117
+ /**
118
+ * What one observer saw, and — where it knows — what the absence of it was.
119
+ *
120
+ * Most observers know only "it did not happen", and for those the path entry's {@link PathEvent.withoutEvidence}
121
+ * is the whole answer. The send paths know more, because the email capability told them: a **withheld**
122
+ * message is a rule declining to act, a **failed** enqueue is a fault, and recording the two alike would
123
+ * wake somebody looking for an abuser when a binding is missing, or bury a broken seam among the rows an
124
+ * abuse count is made of.
125
+ */
126
+ export interface EvidenceReading {
127
+ /** Whether the thing the action claims was actually observed. */
128
+ observed: boolean;
129
+ /** What the absence was, where the observer knows more than "not seen". Null leaves it to the entry. */
130
+ absence: {
131
+ outcome: "denied" | "failure";
132
+ reason: string;
133
+ } | null;
27
134
  }
28
- /** Emit the audit events for a completed auth request: sign-in (+device) from a new session, then any path event. */
135
+ /**
136
+ * How each kind of evidence is seen, one observer per {@link PathEvidence} member.
137
+ *
138
+ * **A total record, so the union cannot outgrow it.** A new kind of evidence added to the type without
139
+ * a way to observe it is a compile error here, and a new entry in {@link PATH_EVENTS} cannot name a kind
140
+ * that is not in the union. That is the whole gate: an entry that claims an outcome it cannot evidence
141
+ * does not exist.
142
+ */
143
+ export declare const EVIDENCE_OBSERVERS: Readonly<Record<PathEvidence, (req: AfterRequest) => EvidenceReading>>;
144
+ /**
145
+ * Whether the endpoint refused this request.
146
+ *
147
+ * `instanceof` first, then the shape. Better Auth is a single instance in this bundle so the class
148
+ * identity holds today, but an audit rule that silently degrades to "everything succeeded" when a
149
+ * duplicated module breaks `instanceof` is the defect this function exists to end — so a numeric
150
+ * `statusCode` at or above 400 is refusal too, whoever constructed it.
151
+ */
152
+ export declare function wasRefused(returned: unknown): boolean;
153
+ /**
154
+ * Emit the audit events for an auth request: sign-in (+device) from a new session, then the path event.
155
+ *
156
+ * **Outcome first, because the hook runs either way.** A refused request writes its path event as
157
+ * `denied` rather than `success` — the attempt is still worth a row (counting refused OTP sends per IP
158
+ * is how abuse becomes visible), and `denied` is first-class in core's schema for exactly this. It never
159
+ * writes the sign-in pair: a refusal created no session, and `newSession` being set at all would be a
160
+ * contradiction rather than something to record.
161
+ *
162
+ * **Then evidence, because a completed response is not the same as a completed action.** A path event is
163
+ * `success` only when its declared evidence is there; without it the entry's `withoutEvidence` says what
164
+ * a completed-but-empty response is, and `denied` or nothing is written instead.
165
+ *
166
+ * **An observer that knows why outranks both.** The email seam answers whether it queued a message, and
167
+ * where it did not, whether it *withheld* one or *failed* to make one. A withheld message is that
168
+ * capability working correctly, so the row is `denied` and carries the reason; a failed enqueue is
169
+ * `failure`, `warning`, and the same reason column. It outranks the refusal branch on purpose:
170
+ * `/sign-in/magic-link` answers 500 when the enqueue throws, and "the request was denied" is not what
171
+ * happened there.
172
+ *
173
+ * **`metadata.reason` is a closed vocabulary and never an address.** A suppression reason from
174
+ * `@pithy-sh/email`, or `SEND_FAULT`. The row still names an action, an outcome, an actor and a
175
+ * correlation, and nothing about who was being mailed.
176
+ *
177
+ * **Nothing here changes what the caller is told, and on one path that is load-bearing.**
178
+ * `/email-otp/send-verification-otp` answers 200 for an address it declined precisely so that a caller
179
+ * cannot tell a registered address from an unregistered one; this function is an `after` hook that
180
+ * writes an audit row and returns, so the status, the body and the headers are whatever the endpoint
181
+ * decided. The row names no address either — action, outcome, actor and correlation, as every other path
182
+ * event does. The trail may know; the response does not say.
183
+ */
29
184
  export declare function emitAfterRequest(emit: AuditEmit, req: AfterRequest): Promise<void>;
30
185
  /** Emit a `token_refresh` event for a session rotation (the custom rotate route). */
31
186
  export declare function emitTokenRefresh(emit: AuditEmit, context: {
@@ -94,8 +249,74 @@ export declare function emitProviderUnavailable(emit: AuditEmit, context: {
94
249
  provider: string;
95
250
  headers: Headers | undefined;
96
251
  }): Promise<void>;
97
- /** Which direction of provider change was refused — the two read very differently in a trail. */
252
+ /** Which direction the provider change went — the two read very differently in a trail. */
98
253
  export type ProviderChange = "link" | "unlink";
254
+ /**
255
+ * The account-row columns the provider-change events are built from, and **only** those.
256
+ *
257
+ * **A Zod object rather than a cast, for the strip rather than for the types.** The row Better Auth
258
+ * hands a database hook carries `accessToken`, `refreshToken`, `idToken` and `scope` alongside these
259
+ * three. Parsing it into a named shape means the emitter below is holding a value that never contained
260
+ * a provider token, so no later edit spreading "the account" into `metadata` can leak one — the guard
261
+ * is structural instead of a rule somebody has to remember. The provider-asserted email is not here
262
+ * either, and is not stored on this row to begin with: #627 does not widen what is retained.
263
+ */
264
+ export declare const ProviderAccount: z.ZodObject<{
265
+ id: z.ZodString;
266
+ userId: z.ZodString;
267
+ providerId: z.ZodString;
268
+ }, z.core.$strip>;
269
+ export type ProviderAccount = z.output<typeof ProviderAccount>;
270
+ /**
271
+ * Emit `oauth_linked` / `oauth_unlinked` for an account row that was just created or just removed.
272
+ *
273
+ * **Called from the `account` database hooks, and the row is the point.** An operator's question is
274
+ * "which providers can sign in as this account today, and when did that change"; the account table is
275
+ * the answer to the first half, so the second half has to be recorded where that table changes. Wiring
276
+ * this to an endpoint instead is what #627 was: `/link-social` recorded an intention as an outcome, and
277
+ * `/unlink-account` recorded nothing. From the row, an abandoned consent screen emits nothing because
278
+ * nothing happened, and every path that ends a link — the unlink endpoint, and the cascade when a user
279
+ * is deleted — is covered without naming any of them.
280
+ *
281
+ * One emitter for both directions so the two rows are structurally identical: a timeline that alternates
282
+ * between them is read by diffing, and a field one carries and the other does not is a field nobody can
283
+ * filter on.
284
+ *
285
+ * **The actor is whoever caused the change, never the account it concerns.** The row's `userId` says
286
+ * *whose* link it was, which is not the same question and is carried in `metadata.userId` instead. The
287
+ * first cut of #627 conflated them: `delete.after` fires on every removal, the user-deletion cascade
288
+ * included, so an operator deleting somebody's account wrote rows saying that person had detached their
289
+ * own providers — from the operator's IP. A trail that misattributes an actor is worse than one that is
290
+ * silent, because it reads as evidence. Three cases, and only three:
291
+ *
292
+ * - An authenticated caller — `/unlink-account`, a link from a signed-in session, an operator's console
293
+ * endpoint — is `user`, named.
294
+ * - A request with no session — a first social sign-up completing at `/callback/:id`, a server-to-server
295
+ * call holding no credential — is `anonymous`: an address, and no identity.
296
+ * - No request at all is `system`, with no actor id and no ip: there is no caller to name and nothing to
297
+ * borrow one from.
298
+ *
299
+ * **A cascade is not a fourth case, and an earlier revision of this list said it was.** `deleteWithHooks`
300
+ * resolves its context from `getCurrentAuthContext()`, which is async-scoped to the dispatch, so the
301
+ * cascade `internalAdapter.deleteUser` runs carries whatever context reached it: an operator deleting
302
+ * somebody through an endpoint is named as the actor of every row it writes, with their address, because
303
+ * they caused every one of them. `system` is what *no request* looks like — a queue consumer, a script,
304
+ * a migration — not what a cascade looks like, and the two were written down here as the same thing. The
305
+ * rule that does hold everywhere is the one above it: the account's owner is never the actor merely for
306
+ * owning the row. Both shapes are driven in `emit.workers.test.ts` rather than asserted here.
307
+ *
308
+ * Unparseable input is dropped rather than thrown. The write it describes has already happened, and an
309
+ * audit failure must never break the action it records — the same contract `safeEmit` holds.
310
+ */
311
+ export declare function emitProviderAccountChanged(emit: AuditEmit, context: {
312
+ change: ProviderChange;
313
+ account: unknown;
314
+ /** The authenticated caller's user id, when the change came from a request holding a session. */
315
+ callerId: string | null;
316
+ /** Whether a request drove this change at all; false for the cascade and other internal callers. */
317
+ fromRequest: boolean;
318
+ headers: Headers | undefined;
319
+ }): Promise<void>;
99
320
  /**
100
321
  * Emit a `session_not_fresh` event — an attempt to change connected accounts on an authentic but stale
101
322
  * credential.
@@ -1 +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,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