@opensaas/stack-auth 0.20.0 → 0.21.0
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +34 -0
- package/CLAUDE.md +17 -17
- package/INTEGRATION_SUMMARY.md +21 -20
- package/README.md +49 -48
- package/dist/config/plugin.d.ts +1 -1
- package/dist/config/plugin.d.ts.map +1 -1
- package/dist/lists/index.d.ts +1 -1
- package/dist/lists/index.js +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/schema-converter.d.ts +1 -1
- package/dist/server/schema-converter.js +1 -1
- package/package.json +5 -5
- package/src/config/plugin.ts +1 -1
- package/src/lists/index.ts +1 -1
- package/src/server/index.ts +2 -1
- package/src/server/schema-converter.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @opensaas/stack-auth
|
|
2
2
|
|
|
3
|
+
## 0.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#415](https://github.com/OpenSaasAU/stack/pull/415) [`8980ff3`](https://github.com/OpenSaasAU/stack/commit/8980ff36ffb0879d8f4409740493dd940572cc9d) Thanks [@borisno2](https://github.com/borisno2)! - Curate the `@opensaas/stack-core` public surface into clearly-scoped entry points
|
|
8
|
+
|
|
9
|
+
The root entry point now exposes only the everyday consumer surface — `config`,
|
|
10
|
+
`list`, `getContext`, the naming helpers (`getDbKey`, `getUrlKey`,
|
|
11
|
+
`getListKeyFromUrl`), `ValidationError`, and the config/access types you annotate
|
|
12
|
+
with. Plugin and field authoring contracts move to a new `/extend` path, and the
|
|
13
|
+
plumbing shared with sibling packages and generated code moves to `/internal`.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
// Everyday usage (unchanged)
|
|
17
|
+
import { config, list, getContext } from '@opensaas/stack-core'
|
|
18
|
+
|
|
19
|
+
// Authoring a plugin or a third-party field package
|
|
20
|
+
import type { Plugin, BaseFieldConfig, TypeInfo } from '@opensaas/stack-core/extend'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`@opensaas/stack-core/internal` carries no semver guarantees; application code
|
|
24
|
+
should never import from it. `Session` stays on the root entry point because it is
|
|
25
|
+
the module-augmentation target.
|
|
26
|
+
|
|
27
|
+
Removed from the public surface (zero callers): the nine `*HookArgs` types and the
|
|
28
|
+
callerless typed-query runtime types. The other `@opensaas/*` packages and the CLI
|
|
29
|
+
generator are updated to import from the new paths.
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- [#414](https://github.com/OpenSaasAU/stack/pull/414) [`f03e5ac`](https://github.com/OpenSaasAU/stack/commit/f03e5ac32d5a38ef31c895b200b1a4f7a5e50c9c) Thanks [@borisno2](https://github.com/borisno2)! - Fix docs to use the canonical `authPlugin()`/`ragPlugin()` config pattern instead of the non-existent `withAuth()`/`authConfig()`/`withRAG()`/`ragConfig()` wrappers
|
|
34
|
+
|
|
35
|
+
## 0.20.1
|
|
36
|
+
|
|
3
37
|
## 0.20.0
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/CLAUDE.md
CHANGED
|
@@ -13,10 +13,9 @@ Adds complete authentication to OpenSaas Stack apps with minimal configuration.
|
|
|
13
13
|
|
|
14
14
|
## Key Files & Exports
|
|
15
15
|
|
|
16
|
-
### Config (`src/config/
|
|
16
|
+
### Config (`src/config/plugin.ts`)
|
|
17
17
|
|
|
18
|
-
- `
|
|
19
|
-
- `authConfig({ ... })` - Configures Better-auth plugins and session
|
|
18
|
+
- `authPlugin({ ... })` - Plugin added to a config's `plugins` array; merges auth lists, configures Better-auth plugins and session. This is the only configuration entry point.
|
|
20
19
|
|
|
21
20
|
### Lists (`src/lists/index.ts`)
|
|
22
21
|
|
|
@@ -53,13 +52,13 @@ Pre-built forms (client components):
|
|
|
53
52
|
|
|
54
53
|
### Config Merging
|
|
55
54
|
|
|
56
|
-
`
|
|
55
|
+
`authPlugin()` merges auth lists into your config:
|
|
57
56
|
|
|
58
57
|
```typescript
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
)
|
|
58
|
+
config({
|
|
59
|
+
lists: { Post: list({...}) },
|
|
60
|
+
plugins: [authPlugin({ emailAndPassword: { enabled: true } })],
|
|
61
|
+
})
|
|
63
62
|
// Result: { lists: { User, Session, Account, Verification, Post } }
|
|
64
63
|
```
|
|
65
64
|
|
|
@@ -78,7 +77,7 @@ const context = createContext(config, prisma, session)
|
|
|
78
77
|
Control which User fields appear in session:
|
|
79
78
|
|
|
80
79
|
```typescript
|
|
81
|
-
|
|
80
|
+
authPlugin({ sessionFields: ['userId', 'email', 'name', 'role'] })
|
|
82
81
|
// Access in access control:
|
|
83
82
|
access: {
|
|
84
83
|
operation: {
|
|
@@ -110,7 +109,7 @@ declare module '@opensaas/stack-core' {
|
|
|
110
109
|
**Step 2: Ensure fields match your sessionFields configuration**
|
|
111
110
|
|
|
112
111
|
```typescript
|
|
113
|
-
|
|
112
|
+
authPlugin({
|
|
114
113
|
sessionFields: ['userId', 'email', 'name', 'role'],
|
|
115
114
|
extendUserList: {
|
|
116
115
|
fields: {
|
|
@@ -153,7 +152,7 @@ if (context.session?.email) {
|
|
|
153
152
|
Add custom fields to User:
|
|
154
153
|
|
|
155
154
|
```typescript
|
|
156
|
-
|
|
155
|
+
authPlugin({
|
|
157
156
|
extendUserList: {
|
|
158
157
|
fields: {
|
|
159
158
|
role: select({ options: [{ label: 'User', value: 'user' }] }),
|
|
@@ -196,10 +195,11 @@ export const auth = createAuth(config, rawOpensaasContext)
|
|
|
196
195
|
|
|
197
196
|
```typescript
|
|
198
197
|
// 1. Config
|
|
199
|
-
export default
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
)
|
|
198
|
+
export default config({
|
|
199
|
+
db: {...},
|
|
200
|
+
lists: {...},
|
|
201
|
+
plugins: [authPlugin({ emailAndPassword: { enabled: true } })],
|
|
202
|
+
})
|
|
203
203
|
|
|
204
204
|
// 2. Server (lib/auth.ts)
|
|
205
205
|
export const auth = createAuth(config)
|
|
@@ -235,7 +235,7 @@ Post: list({
|
|
|
235
235
|
### OAuth Providers
|
|
236
236
|
|
|
237
237
|
```typescript
|
|
238
|
-
|
|
238
|
+
authPlugin({
|
|
239
239
|
socialProviders: {
|
|
240
240
|
github: {
|
|
241
241
|
clientId: process.env.GITHUB_CLIENT_ID!,
|
|
@@ -253,7 +253,7 @@ authConfig({
|
|
|
253
253
|
Session type is inferred from `sessionFields`:
|
|
254
254
|
|
|
255
255
|
```typescript
|
|
256
|
-
|
|
256
|
+
authPlugin({ sessionFields: ['userId', 'email', 'role'] })
|
|
257
257
|
// session: { userId: string, email: string, role: string } | null
|
|
258
258
|
```
|
|
259
259
|
|
package/INTEGRATION_SUMMARY.md
CHANGED
|
@@ -11,8 +11,7 @@ This document summarizes the complete better-auth integration for the OpenSaas S
|
|
|
11
11
|
**Exports:**
|
|
12
12
|
|
|
13
13
|
- **Main** (`@opensaas/stack-auth`):
|
|
14
|
-
- `
|
|
15
|
-
- `authConfig()` - Auth configuration builder
|
|
14
|
+
- `authPlugin()` - Plugin added to `config({ plugins: [...] })` that adds auth lists and configures Better-auth
|
|
16
15
|
- `getAuthLists()` - Get all auth list definitions
|
|
17
16
|
|
|
18
17
|
- **Server** (`@opensaas/stack-auth/server`):
|
|
@@ -112,20 +111,21 @@ A complete working example showing:
|
|
|
112
111
|
|
|
113
112
|
```typescript
|
|
114
113
|
// opensaas.config.ts
|
|
115
|
-
import {
|
|
114
|
+
import { config } from '@opensaas/stack-core'
|
|
115
|
+
import { authPlugin } from '@opensaas/stack-auth'
|
|
116
116
|
|
|
117
|
-
export default
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
lists
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
)
|
|
117
|
+
export default config({
|
|
118
|
+
db: { provider: 'sqlite', url: 'file:./dev.db' },
|
|
119
|
+
lists: {
|
|
120
|
+
/* your custom lists */
|
|
121
|
+
},
|
|
122
|
+
plugins: [
|
|
123
|
+
authPlugin({
|
|
124
|
+
emailAndPassword: { enabled: true },
|
|
125
|
+
sessionFields: ['userId', 'email', 'name'],
|
|
126
|
+
}),
|
|
127
|
+
],
|
|
128
|
+
})
|
|
129
129
|
```
|
|
130
130
|
|
|
131
131
|
### Step 2: Generate
|
|
@@ -194,7 +194,7 @@ No manual User model, no manual session handling, no manual auth routes. Everyth
|
|
|
194
194
|
### 2. Type-Safe Sessions
|
|
195
195
|
|
|
196
196
|
```typescript
|
|
197
|
-
|
|
197
|
+
authPlugin({
|
|
198
198
|
sessionFields: ['userId', 'email', 'name', 'role'],
|
|
199
199
|
})
|
|
200
200
|
|
|
@@ -205,7 +205,7 @@ authConfig({
|
|
|
205
205
|
### 3. Extensible User Model
|
|
206
206
|
|
|
207
207
|
```typescript
|
|
208
|
-
|
|
208
|
+
authPlugin({
|
|
209
209
|
extendUserList: {
|
|
210
210
|
fields: {
|
|
211
211
|
role: select({ options: [...] }),
|
|
@@ -236,7 +236,7 @@ All forms accept custom props and callbacks:
|
|
|
236
236
|
Configure what you need:
|
|
237
237
|
|
|
238
238
|
```typescript
|
|
239
|
-
|
|
239
|
+
authPlugin({
|
|
240
240
|
emailAndPassword: { enabled: true },
|
|
241
241
|
emailVerification: { enabled: true },
|
|
242
242
|
passwordReset: { enabled: true },
|
|
@@ -325,7 +325,8 @@ Potential additions:
|
|
|
325
325
|
packages/auth/
|
|
326
326
|
├── src/
|
|
327
327
|
│ ├── config/
|
|
328
|
-
│ │ ├── index.ts #
|
|
328
|
+
│ │ ├── index.ts # normalizeAuthConfig()
|
|
329
|
+
│ │ ├── plugin.ts # authPlugin()
|
|
329
330
|
│ │ └── types.ts # Auth config types
|
|
330
331
|
│ ├── lists/
|
|
331
332
|
│ │ └── index.ts # User, Session, Account, Verification
|
|
@@ -366,7 +367,7 @@ Better-auth supports cookie caching to reduce database queries:
|
|
|
366
367
|
|
|
367
368
|
```typescript
|
|
368
369
|
// Future enhancement
|
|
369
|
-
|
|
370
|
+
authPlugin({
|
|
370
371
|
session: {
|
|
371
372
|
cookieCaching: true, // Validate at cookie level
|
|
372
373
|
},
|
package/README.md
CHANGED
|
@@ -23,30 +23,30 @@ pnpm add @opensaas/stack-auth better-auth
|
|
|
23
23
|
|
|
24
24
|
### 1. Update Your Config
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Add `authPlugin()` to your config's `plugins` array:
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
29
|
// opensaas.config.ts
|
|
30
30
|
import { config } from '@opensaas/stack-core'
|
|
31
|
-
import {
|
|
31
|
+
import { authPlugin } from '@opensaas/stack-auth'
|
|
32
32
|
|
|
33
|
-
export default
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
lists
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
)
|
|
33
|
+
export default config({
|
|
34
|
+
db: {
|
|
35
|
+
provider: 'sqlite',
|
|
36
|
+
url: process.env.DATABASE_URL || 'file:./dev.db',
|
|
37
|
+
},
|
|
38
|
+
lists: {
|
|
39
|
+
// Your custom lists here
|
|
40
|
+
},
|
|
41
|
+
plugins: [
|
|
42
|
+
authPlugin({
|
|
43
|
+
emailAndPassword: { enabled: true },
|
|
44
|
+
emailVerification: { enabled: true },
|
|
45
|
+
passwordReset: { enabled: true },
|
|
46
|
+
sessionFields: ['userId', 'email', 'name'],
|
|
47
|
+
}),
|
|
48
|
+
],
|
|
49
|
+
})
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
### 2. Generate Schema and Push to Database
|
|
@@ -112,32 +112,33 @@ Sessions are now automatically available in your access control functions:
|
|
|
112
112
|
|
|
113
113
|
```typescript
|
|
114
114
|
// opensaas.config.ts
|
|
115
|
-
import {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
},
|
|
115
|
+
import { config } from '@opensaas/stack-core'
|
|
116
|
+
import { authPlugin } from '@opensaas/stack-auth'
|
|
117
|
+
|
|
118
|
+
export default config({
|
|
119
|
+
lists: {
|
|
120
|
+
Post: list({
|
|
121
|
+
fields: { title: text(), content: text() },
|
|
122
|
+
access: {
|
|
123
|
+
operation: {
|
|
124
|
+
// Session is automatically populated from better-auth
|
|
125
|
+
create: ({ session }) => !!session,
|
|
126
|
+
update: ({ session, item }) => {
|
|
127
|
+
if (!session) return false
|
|
128
|
+
return { authorId: { equals: session.userId } }
|
|
130
129
|
},
|
|
131
130
|
},
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
)
|
|
131
|
+
},
|
|
132
|
+
}),
|
|
133
|
+
},
|
|
134
|
+
plugins: [
|
|
135
|
+
authPlugin({
|
|
136
|
+
emailAndPassword: { enabled: true },
|
|
137
|
+
// Session will contain: { userId, email, name }
|
|
138
|
+
sessionFields: ['userId', 'email', 'name'],
|
|
139
|
+
}),
|
|
140
|
+
],
|
|
141
|
+
})
|
|
141
142
|
```
|
|
142
143
|
|
|
143
144
|
## Configuration
|
|
@@ -145,7 +146,7 @@ export default withAuth(
|
|
|
145
146
|
### Auth Config Options
|
|
146
147
|
|
|
147
148
|
```typescript
|
|
148
|
-
|
|
149
|
+
authPlugin({
|
|
149
150
|
// Email/password authentication
|
|
150
151
|
emailAndPassword: {
|
|
151
152
|
enabled: true,
|
|
@@ -248,7 +249,7 @@ import { authClient } from '@/lib/auth-client'
|
|
|
248
249
|
|
|
249
250
|
## Auto-Generated Lists
|
|
250
251
|
|
|
251
|
-
The following lists are automatically created when you use `
|
|
252
|
+
The following lists are automatically created when you use `authPlugin()`:
|
|
252
253
|
|
|
253
254
|
### User
|
|
254
255
|
|
|
@@ -322,7 +323,7 @@ The following lists are automatically created when you use `withAuth()`:
|
|
|
322
323
|
Add custom fields to the User model:
|
|
323
324
|
|
|
324
325
|
```typescript
|
|
325
|
-
|
|
326
|
+
authPlugin({
|
|
326
327
|
extendUserList: {
|
|
327
328
|
fields: {
|
|
328
329
|
role: select({
|
|
@@ -353,7 +354,7 @@ authConfig({
|
|
|
353
354
|
Control which user fields are included in the session object:
|
|
354
355
|
|
|
355
356
|
```typescript
|
|
356
|
-
|
|
357
|
+
authPlugin({
|
|
357
358
|
sessionFields: ['userId', 'email', 'name', 'role'],
|
|
358
359
|
})
|
|
359
360
|
|
|
@@ -434,7 +435,7 @@ See `examples/auth-demo` for a complete working example.
|
|
|
434
435
|
|
|
435
436
|
## How It Works
|
|
436
437
|
|
|
437
|
-
1. **
|
|
438
|
+
1. **authPlugin()** merges auth lists (User, Session, Account, Verification) with your config
|
|
438
439
|
2. **Generator** creates Prisma schema with all auth tables
|
|
439
440
|
3. **Session Provider** uses better-auth to get current session
|
|
440
441
|
4. **Context** includes session automatically in all access control functions
|
package/dist/config/plugin.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/config/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/config/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAwB,MAAM,YAAY,CAAA;AAKlE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CA6FrD"}
|
package/dist/lists/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export declare function createAccountList(): ListConfig<any>;
|
|
|
40
40
|
export declare function createVerificationList(): ListConfig<any>;
|
|
41
41
|
/**
|
|
42
42
|
* Get all auth lists required by better-auth
|
|
43
|
-
* This is the main export used by
|
|
43
|
+
* This is the main export used by authPlugin()
|
|
44
44
|
*/
|
|
45
45
|
export declare function getAuthLists(userConfig?: ExtendUserListConfig): Record<string, ListConfig<any>>;
|
|
46
46
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/lists/index.js
CHANGED
|
@@ -217,7 +217,7 @@ export function createVerificationList() {
|
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
219
219
|
* Get all auth lists required by better-auth
|
|
220
|
-
* This is the main export used by
|
|
220
|
+
* This is the main export used by authPlugin()
|
|
221
221
|
*/
|
|
222
222
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
|
|
223
223
|
export function getAuthLists(userConfig) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAgBzE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CACxB,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,EACxD,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,iDAmIhD;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,EACnC,aAAa,EAAE,MAAM,EAAE,2CA0BxB;AAED,YAAY,EAAE,iBAAiB,EAAE,CAAA"}
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAM3D;;GAEG;AACH,SAAS,iBAAiB,CACxB,QAAwB,EACxB,OAAsB;IAEtB,OAAO,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE;QACnC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;KAC5B,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,UAAU,CACxB,cAAwD,EACxD,OAA+C;IAE/C,4CAA4C;IAC5C,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IACrD,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAE/C,0CAA0C;IAC1C,IAAI,YAAY,GAAyC,IAAI,CAAA;IAC7D,IAAI,WAAW,GAAkD,IAAI,CAAA;IAErE,KAAK,UAAU,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I,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;YACnB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,6CAA6C;QAC7C,MAAM,MAAM,GAA4B,EAAE,CAAA;QAE1C,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;YAClC,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACvB,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;YACjC,CAAC;iBAAM,IAAI,KAAK,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAkC,CAAC,CAAA;YAClE,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
|
@@ -33,7 +33,7 @@ type BetterAuthTableSchema = {
|
|
|
33
33
|
export declare function convertTableToList(tableName: string, tableSchema: BetterAuthTableSchema): ListConfig<any>;
|
|
34
34
|
/**
|
|
35
35
|
* Convert all Better Auth tables to OpenSaaS list configs
|
|
36
|
-
* This is called by
|
|
36
|
+
* This is called by authPlugin() to generate lists from Better Auth + plugins
|
|
37
37
|
*/
|
|
38
38
|
export declare function convertBetterAuthSchema(tables: Record<string, BetterAuthTableSchema>): Record<string, ListConfig<any>>;
|
|
39
39
|
export {};
|
|
@@ -237,7 +237,7 @@ export function convertTableToList(tableName, tableSchema) {
|
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
239
239
|
* Convert all Better Auth tables to OpenSaaS list configs
|
|
240
|
-
* This is called by
|
|
240
|
+
* This is called by authPlugin() to generate lists from Better Auth + plugins
|
|
241
241
|
*/
|
|
242
242
|
export function convertBetterAuthSchema(tables) {
|
|
243
243
|
const lists = {}; // eslint-disable-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensaas/stack-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Better-auth integration for OpenSaas Stack",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -55,16 +55,16 @@
|
|
|
55
55
|
"react": "^18.0.0 || ^19.0.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@types/node": "^
|
|
58
|
+
"@types/node": "^25.9.1",
|
|
59
59
|
"@types/react": "^19.2.14",
|
|
60
60
|
"@vitest/coverage-v8": "^4.0.18",
|
|
61
61
|
"@vitest/ui": "^4.0.18",
|
|
62
|
-
"better-auth": "^1.5.
|
|
62
|
+
"better-auth": "^1.5.5",
|
|
63
63
|
"next": "^16.1.6",
|
|
64
64
|
"react": "^19.2.4",
|
|
65
65
|
"typescript": "^5.9.3",
|
|
66
|
-
"vitest": "^4.0
|
|
67
|
-
"@opensaas/stack-core": "0.
|
|
66
|
+
"vitest": "^4.1.0",
|
|
67
|
+
"@opensaas/stack-core": "0.21.0"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "tsc",
|
package/src/config/plugin.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Plugin } from '@opensaas/stack-core'
|
|
1
|
+
import type { Plugin } from '@opensaas/stack-core/extend'
|
|
2
2
|
import type { AuthConfig, NormalizedAuthConfig } from './types.js'
|
|
3
3
|
import { normalizeAuthConfig } from './index.js'
|
|
4
4
|
import { getAuthLists } from '../lists/index.js'
|
package/src/lists/index.ts
CHANGED
|
@@ -240,7 +240,7 @@ export function createVerificationList(): ListConfig<any> {
|
|
|
240
240
|
|
|
241
241
|
/**
|
|
242
242
|
* Get all auth lists required by better-auth
|
|
243
|
-
* This is the main export used by
|
|
243
|
+
* This is the main export used by authPlugin()
|
|
244
244
|
*/
|
|
245
245
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ListConfig must accept any TypeInfo
|
|
246
246
|
export function getAuthLists(userConfig?: ExtendUserListConfig): Record<string, ListConfig<any>> {
|
package/src/server/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { betterAuth } from 'better-auth'
|
|
2
2
|
import { prismaAdapter } from 'better-auth/adapters/prisma'
|
|
3
3
|
import type { BetterAuthOptions } from 'better-auth'
|
|
4
|
-
import type { OpenSaasConfig,
|
|
4
|
+
import type { OpenSaasConfig, AccessContext } from '@opensaas/stack-core'
|
|
5
|
+
import type { DatabaseConfig } from '@opensaas/stack-core/internal'
|
|
5
6
|
import type { NormalizedAuthConfig } from '../config/types.js'
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -283,7 +283,7 @@ export function convertTableToList(
|
|
|
283
283
|
|
|
284
284
|
/**
|
|
285
285
|
* Convert all Better Auth tables to OpenSaaS list configs
|
|
286
|
-
* This is called by
|
|
286
|
+
* This is called by authPlugin() to generate lists from Better Auth + plugins
|
|
287
287
|
*/
|
|
288
288
|
export function convertBetterAuthSchema(
|
|
289
289
|
tables: Record<string, BetterAuthTableSchema>,
|