@vexcms/better-auth 0.0.1 → 0.0.2
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/README.md +82 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# @vexcms/better-auth
|
|
2
|
+
|
|
3
|
+
[Better Auth](https://www.better-auth.com/) adapter for [VEX CMS](https://github.com/vexcms). Automatically extracts Better Auth's authentication tables and converts them into VEX collection definitions, enabling admin panel management of auth data.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @vexcms/better-auth
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { defineConfig } from "@vexcms/core"
|
|
15
|
+
import { vexBetterAuth } from "@vexcms/better-auth"
|
|
16
|
+
|
|
17
|
+
export default defineConfig({
|
|
18
|
+
auth: vexBetterAuth({
|
|
19
|
+
config: {
|
|
20
|
+
user: { modelName: "users" },
|
|
21
|
+
plugins: [admin()],
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
collections: [/* ... */],
|
|
25
|
+
})
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## What It Does
|
|
29
|
+
|
|
30
|
+
`vexBetterAuth()` takes your Better Auth configuration and:
|
|
31
|
+
|
|
32
|
+
1. **Extracts auth tables** — Uses Better Auth's `getAuthTables()` to resolve the complete schema including plugin-contributed fields
|
|
33
|
+
2. **Converts fields** — Maps Better Auth field types to VEX field types (string → text, boolean → checkbox, references → relationship, etc.)
|
|
34
|
+
3. **Configures admin UI** — Sets appropriate field visibility:
|
|
35
|
+
- **Editable**: user name, image, role, ban status
|
|
36
|
+
- **Hidden**: sensitive fields (tokens, secrets, verification values)
|
|
37
|
+
- **Read-only**: everything else
|
|
38
|
+
4. **Creates indexes** — Generates database indexes for indexed/unique fields
|
|
39
|
+
5. **Groups in sidebar** — All auth collections appear under the "Auth" group
|
|
40
|
+
|
|
41
|
+
## Supported Auth Tables
|
|
42
|
+
|
|
43
|
+
| Table | Description |
|
|
44
|
+
|-------|-------------|
|
|
45
|
+
| `user` | User accounts with profile data |
|
|
46
|
+
| `session` | Active sessions with tokens and metadata |
|
|
47
|
+
| `account` | OAuth/credential accounts linked to users |
|
|
48
|
+
| `verification` | Email verification and password reset tokens |
|
|
49
|
+
|
|
50
|
+
Plugin-contributed tables (e.g., from `admin()`, `apiKey()`) are automatically included.
|
|
51
|
+
|
|
52
|
+
## Plugin Support
|
|
53
|
+
|
|
54
|
+
Better Auth plugins that add fields or tables are fully supported:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { admin } from "better-auth/plugins"
|
|
58
|
+
|
|
59
|
+
vexBetterAuth({
|
|
60
|
+
config: {
|
|
61
|
+
plugins: [admin()], // Adds role, banned, banReason fields to user
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Custom Model Names
|
|
67
|
+
|
|
68
|
+
Custom `modelName` values are respected and propagated to relationship references:
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
vexBetterAuth({
|
|
72
|
+
config: {
|
|
73
|
+
user: { modelName: "users" },
|
|
74
|
+
session: { modelName: "sessions" },
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Peer Dependencies
|
|
80
|
+
|
|
81
|
+
- `@vexcms/core` — Core VEX CMS types
|
|
82
|
+
- `better-auth` — Better Auth (>=1.4.9 <1.5.0)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vexcms/better-auth",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"better-auth": ">=1.4.9 <1.5.0",
|
|
18
|
-
"@vexcms/core": "0.0.
|
|
18
|
+
"@vexcms/core": "0.0.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@vitest/coverage-v8": "^4.0.18",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"tsup": "^8.5.1",
|
|
24
24
|
"typescript": "^5.9.3",
|
|
25
25
|
"vitest": "^4.0.0",
|
|
26
|
-
"@vexcms/core": "0.0.
|
|
26
|
+
"@vexcms/core": "0.0.2",
|
|
27
27
|
"@vexcms/tsconfig": "0.0.0"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|