@beignet/provider-auth-better-auth 0.0.51 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +39 -9
- package/package.json +4 -4
- package/skills/auth-provider/SKILL.md +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @beignet/provider-auth-better-auth
|
|
2
2
|
|
|
3
|
+
## 0.0.52
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b39bb6e: Clarify that Beignet applications require Node.js 22.12 or newer and can use
|
|
8
|
+
npm, pnpm, Yarn, or Bun for package management and framework commands.
|
|
9
|
+
- c12b995: Correct repository-port examples in provider documentation and direct app
|
|
10
|
+
creation users to the public CLI reference.
|
|
11
|
+
- 06eb712: Support Better Auth 1.7, scaffold its issuer-scoped account identity schema, and warn when upgraded Drizzle apps still need the account migration.
|
|
12
|
+
|
|
3
13
|
## 0.0.51
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# @beignet/provider-auth-better-auth
|
|
2
2
|
|
|
3
|
-
> **Runtime:** Beignet requires Node.js 22.12 or newer. Bun
|
|
4
|
-
> supported for Beignet commands.
|
|
3
|
+
> **Runtime:** Beignet requires Node.js 22.12 or newer. Bun is optional.
|
|
5
4
|
|
|
6
5
|
> [!CAUTION]
|
|
7
6
|
> Beignet is experimental alpha software. The `0.0.x` package line is for early
|
|
@@ -35,11 +34,11 @@ schema, and auth routes.
|
|
|
35
34
|
## Install
|
|
36
35
|
|
|
37
36
|
```bash
|
|
38
|
-
bun add @beignet/core @beignet/provider-auth-better-auth better-auth@1.
|
|
37
|
+
bun add @beignet/core @beignet/provider-auth-better-auth better-auth@1.7.1
|
|
39
38
|
```
|
|
40
39
|
|
|
41
|
-
The provider supports Better Auth `>=1.3.26 <1.
|
|
42
|
-
starter pins Better Auth to `1.
|
|
40
|
+
The provider supports Better Auth `>=1.3.26 <1.8.0`. The standard Beignet
|
|
41
|
+
starter pins Better Auth to `1.7.1` so clean installs use the version Beignet
|
|
43
42
|
validates in generated apps.
|
|
44
43
|
|
|
45
44
|
## Agent skills
|
|
@@ -98,6 +97,7 @@ export type AuthSession = BeignetAuthSession<AuthUser, AuthSessionMetadata>;
|
|
|
98
97
|
```ts
|
|
99
98
|
// ports/index.ts
|
|
100
99
|
import type { ActivityActor, GatePort } from "@beignet/core/ports";
|
|
100
|
+
import type { UserRepository } from "@/features/users/ports";
|
|
101
101
|
import type { AuthPort } from "./auth";
|
|
102
102
|
|
|
103
103
|
export type AppAuthorizationContext = {
|
|
@@ -107,6 +107,7 @@ export type AppAuthorizationContext = {
|
|
|
107
107
|
export type AppPorts = {
|
|
108
108
|
auth: AuthPort;
|
|
109
109
|
gate: GatePort<AppAuthorizationContext, []>;
|
|
110
|
+
users: UserRepository;
|
|
110
111
|
// ...other ports (db, mailer, eventBus, etc.)
|
|
111
112
|
};
|
|
112
113
|
```
|
|
@@ -238,17 +239,15 @@ You can also check authentication in use cases:
|
|
|
238
239
|
|
|
239
240
|
```ts
|
|
240
241
|
// features/users/use-cases/get-profile.ts
|
|
241
|
-
import { createUseCase } from "@beignet/core/application";
|
|
242
242
|
import { z } from "zod";
|
|
243
243
|
import { requireUser } from "@/lib/auth";
|
|
244
|
+
import { useCase } from "@/lib/use-case";
|
|
244
245
|
|
|
245
246
|
const UserProfileSchema = z.object({
|
|
246
247
|
id: z.string(),
|
|
247
248
|
email: z.string().email(),
|
|
248
249
|
});
|
|
249
250
|
|
|
250
|
-
const useCase = createUseCase<AppContext>();
|
|
251
|
-
|
|
252
251
|
export const getUserProfile = useCase
|
|
253
252
|
.query("users.profile")
|
|
254
253
|
.input(z.object({ userId: z.string() }))
|
|
@@ -256,7 +255,7 @@ export const getUserProfile = useCase
|
|
|
256
255
|
.run(async ({ ctx, input }) => {
|
|
257
256
|
requireUser(ctx);
|
|
258
257
|
|
|
259
|
-
return ctx.ports.
|
|
258
|
+
return ctx.ports.users.getProfile(input.userId);
|
|
260
259
|
});
|
|
261
260
|
```
|
|
262
261
|
|
|
@@ -266,6 +265,10 @@ request once with
|
|
|
266
265
|
then call an app-owned helper such as `requireUser(ctx)` instead of depending
|
|
267
266
|
on the raw request.
|
|
268
267
|
|
|
268
|
+
`ctx.ports.users` is an app-owned feature repository. The database provider's
|
|
269
|
+
`ctx.ports.db` entry exposes the database client and health check; it does not
|
|
270
|
+
contain feature repositories.
|
|
271
|
+
|
|
269
272
|
`beignet doctor --strict` checks that installed Better Auth providers are
|
|
270
273
|
registered in `server/providers.ts`. The provider does not declare Beignet-owned
|
|
271
274
|
env vars because Better Auth configuration, secrets, database adapter options,
|
|
@@ -337,6 +340,33 @@ plugin's current `failedVerificationCount` and `lockedUntil` fields. The
|
|
|
337
340
|
standard Beignet starter does not enable two-factor authentication, so its
|
|
338
341
|
default auth configuration does not require those fields.
|
|
339
342
|
|
|
343
|
+
### Upgrading an existing app to Better Auth 1.7
|
|
344
|
+
|
|
345
|
+
Better Auth 1.7 adds a required `issuer` field to `account` and a unique
|
|
346
|
+
compound index across `issuer` and `accountId`. Fresh Beignet starters include
|
|
347
|
+
both. Existing databases require a reviewed data migration before the 1.7
|
|
348
|
+
runtime is deployed:
|
|
349
|
+
|
|
350
|
+
1. Back up the auth tables and stop authentication writes.
|
|
351
|
+
2. Add `issuer` as nullable, then populate it from a trusted provider mapping.
|
|
352
|
+
Credential accounts use `local:credential`, with `accountId` equal to the
|
|
353
|
+
linked user's stable ID.
|
|
354
|
+
3. Check for duplicate `(issuer, accountId)` identities and resolve any
|
|
355
|
+
collisions without merging users by email.
|
|
356
|
+
4. Make `issuer` non-nullable and add the
|
|
357
|
+
`account_issuer_accountId_uidx` unique index.
|
|
358
|
+
5. Run `bunx auth generate`, review the Drizzle or Prisma output, apply it with
|
|
359
|
+
the app's migration tooling, and deploy the schema and Better Auth packages
|
|
360
|
+
together.
|
|
361
|
+
|
|
362
|
+
SQLite requires a table rebuild to add the final `NOT NULL` constraint. Apps
|
|
363
|
+
created from an older Beignet MySQL starter must also convert `account_id` from
|
|
364
|
+
`text` to `varchar(255)` before creating the compound index. Social, SSO,
|
|
365
|
+
SIWE, One Tap, and custom OAuth accounts need provider-specific issuer mapping;
|
|
366
|
+
do not infer issuers from email or another mutable profile field. Follow Better
|
|
367
|
+
Auth's [1.7 account identity migration](https://better-auth.com/docs/guides/1-7-upgrade-guide#account-identity-is-scoped-by-issuer)
|
|
368
|
+
for the authoritative mapping and cutover sequence.
|
|
369
|
+
|
|
340
370
|
Keep business authorization in feature policies and use Beignet auth hooks only
|
|
341
371
|
for HTTP-boundary authentication.
|
|
342
372
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beignet/provider-auth-better-auth",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.52",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Better Auth provider for Beignet - adds auth port for authentication and session management",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@beignet/core": ">=0.0.3 <1.0.0",
|
|
61
|
-
"better-auth": ">=1.3.26 <1.
|
|
61
|
+
"better-auth": ">=1.3.26 <1.8.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@beignet/core": "*",
|
|
65
65
|
"@beignet/devtools": "*",
|
|
66
|
-
"@types/bun": "^1.
|
|
66
|
+
"@types/bun": "^1.4.0",
|
|
67
67
|
"@types/node": "^22.0.0",
|
|
68
|
-
"better-auth": "1.
|
|
68
|
+
"better-auth": "1.7.1",
|
|
69
69
|
"typescript": "^5.3.0"
|
|
70
70
|
},
|
|
71
71
|
"beignet": {
|
|
@@ -144,7 +144,13 @@ action.
|
|
|
144
144
|
out of devtools, audit metadata, and error reports.
|
|
145
145
|
- After upgrading Better Auth or changing its plugins, regenerate the schema
|
|
146
146
|
for the app's database adapter and apply the resulting migration before
|
|
147
|
-
deployment.
|
|
147
|
+
deployment. Better Auth 1.7 requires `account.issuer` plus a unique
|
|
148
|
+
`(issuer, accountId)` index. Existing apps must pause auth writes, backfill
|
|
149
|
+
issuers from trusted provider identities, check collisions, then make
|
|
150
|
+
`issuer` non-nullable before deploying 1.7. Credential accounts use
|
|
151
|
+
`local:credential`; never derive a social issuer from email. Older Beignet
|
|
152
|
+
MySQL starters must also change `account_id` from `text` to `varchar(255)` so
|
|
153
|
+
the index is valid. Apps using `twoFactor()` need the current
|
|
148
154
|
`failedVerificationCount` and `lockedUntil` fields. The standard Beignet
|
|
149
155
|
starter does not enable two-factor authentication.
|
|
150
156
|
|