|
5 | 5 | Add `evlog/better-auth` integration for automatic user identification from [Better Auth](https://better-auth.com/) sessions. |
6 | 6 |
|
7 | 7 | **New exports** (`evlog/better-auth`): |
8 | | -- `identifyUser(log, session, options?)` — sets `userId`, `user`, and `session` fields on a wide event from a Better Auth session |
9 | | -- `createAuthIdentifier(auth, options?)` — Nitro `request` hook factory that auto-identifies users on every request (skips `/api/auth/**` by default) |
10 | | -- `createAuthMiddleware(auth, options?)` — framework-agnostic function `(log, headers) => Promise<void>` for Express, Hono, Fastify, etc. |
| 8 | +- `identifyUser(log, session, options?)` — sets `userId`, `user`, and `session` fields on a wide event. Returns `true` if identified |
| 9 | +- `createAuthMiddleware(auth, options?)` — framework-agnostic `(log, headers, path?) => Promise<boolean>` with route filtering, timing capture, and lifecycle hooks |
| 10 | +- `createAuthIdentifier(auth, options?)` — Nitro `request` hook factory for standalone Nitro apps |
11 | 11 | - `maskEmail(email)` — utility to mask emails for safe logging (`h***@example.com`) |
| 12 | +- `BetterAuthInstance` — reusable type for the auth parameter |
12 | 13 |
|
13 | | -Options: `maskEmail`, `session` (include session metadata), `fields` (user field whitelist), `exclude`/`include` (route patterns for `createAuthIdentifier`). |
| 14 | +**Features:** |
| 15 | +- `include`/`exclude` route pattern filtering on `createAuthMiddleware` |
| 16 | +- `extend` callback for Better Auth plugin fields (organizations, roles, etc.) |
| 17 | +- `auth.resolvedIn` timing in every wide event |
| 18 | +- `auth.identified` boolean in every wide event |
| 19 | +- `session.userAgent` captured by default |
| 20 | +- `onIdentify`/`onAnonymous` lifecycle hooks |
| 21 | +- `console.warn` in development when session resolution fails |
0 commit comments