@objectstack/plugin-auth 5.0.0 → 5.2.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/dist/index.d.mts +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Plugin, PluginContext, IDataEngine } from '@objectstack/core';
|
|
2
|
+
import * as better_auth from 'better-auth';
|
|
3
|
+
import { BetterAuthOptions, Auth } from 'better-auth';
|
|
2
4
|
import { AuthConfig, OidcProvidersConfig } from '@objectstack/spec/system';
|
|
3
5
|
export { AuthConfig, AuthPluginConfig, AuthProviderConfig } from '@objectstack/spec/system';
|
|
4
|
-
import * as better_auth from 'better-auth';
|
|
5
|
-
import { Auth } from 'better-auth';
|
|
6
6
|
import { IEmailService } from '@objectstack/spec/contracts';
|
|
7
7
|
import * as better_auth_adapters from 'better-auth/adapters';
|
|
8
8
|
import { CleanedWhere } from 'better-auth/adapters';
|
|
@@ -39,6 +39,16 @@ interface AuthPluginOptions extends Partial<AuthConfig> {
|
|
|
39
39
|
* {@link AuthManagerOptions.additionalOrgRoles} for details.
|
|
40
40
|
*/
|
|
41
41
|
additionalOrgRoles?: string[];
|
|
42
|
+
/**
|
|
43
|
+
* Pass-through to better-auth's `databaseHooks` option. Used by
|
|
44
|
+
* platform consumers (objectos kernel) to attach a
|
|
45
|
+
* `user.create.after` hook that auto-provisions a personal
|
|
46
|
+
* organization for JIT-created SSO users — better-auth's adapter
|
|
47
|
+
* bypasses kernel-level ObjectQL middleware, so this is the only
|
|
48
|
+
* hook point that fires for every user creation path (email signup,
|
|
49
|
+
* social/OIDC sign-in, admin-created accounts).
|
|
50
|
+
*/
|
|
51
|
+
databaseHooks?: BetterAuthOptions['databaseHooks'];
|
|
42
52
|
}
|
|
43
53
|
/**
|
|
44
54
|
* Authentication Plugin
|
|
@@ -163,6 +173,20 @@ interface AuthManagerOptions extends Partial<AuthConfig> {
|
|
|
163
173
|
* placeholder). Defaults to `'ObjectStack'` when omitted.
|
|
164
174
|
*/
|
|
165
175
|
appName?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Pass-through to better-auth's `databaseHooks` option. better-auth fires
|
|
178
|
+
* these around its own adapter writes (e.g. when `genericOAuth` creates
|
|
179
|
+
* a JIT user during SSO login), which the kernel-level ObjectQL
|
|
180
|
+
* middleware does NOT observe — better-auth's adapter goes through
|
|
181
|
+
* `dataEngine` directly, bypassing the `ql.registerMiddleware` chain.
|
|
182
|
+
*
|
|
183
|
+
* The platform uses this to attach a `user.create.after` hook that
|
|
184
|
+
* auto-provisions a personal organization for every newly-created user
|
|
185
|
+
* (mirroring what SecurityPlugin's middleware does for direct
|
|
186
|
+
* ObjectQL inserts) so SSO-arriving users don't land on the empty
|
|
187
|
+
* "create organization" screen.
|
|
188
|
+
*/
|
|
189
|
+
databaseHooks?: BetterAuthOptions['databaseHooks'];
|
|
166
190
|
}
|
|
167
191
|
/**
|
|
168
192
|
* Authentication Manager
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Plugin, PluginContext, IDataEngine } from '@objectstack/core';
|
|
2
|
+
import * as better_auth from 'better-auth';
|
|
3
|
+
import { BetterAuthOptions, Auth } from 'better-auth';
|
|
2
4
|
import { AuthConfig, OidcProvidersConfig } from '@objectstack/spec/system';
|
|
3
5
|
export { AuthConfig, AuthPluginConfig, AuthProviderConfig } from '@objectstack/spec/system';
|
|
4
|
-
import * as better_auth from 'better-auth';
|
|
5
|
-
import { Auth } from 'better-auth';
|
|
6
6
|
import { IEmailService } from '@objectstack/spec/contracts';
|
|
7
7
|
import * as better_auth_adapters from 'better-auth/adapters';
|
|
8
8
|
import { CleanedWhere } from 'better-auth/adapters';
|
|
@@ -39,6 +39,16 @@ interface AuthPluginOptions extends Partial<AuthConfig> {
|
|
|
39
39
|
* {@link AuthManagerOptions.additionalOrgRoles} for details.
|
|
40
40
|
*/
|
|
41
41
|
additionalOrgRoles?: string[];
|
|
42
|
+
/**
|
|
43
|
+
* Pass-through to better-auth's `databaseHooks` option. Used by
|
|
44
|
+
* platform consumers (objectos kernel) to attach a
|
|
45
|
+
* `user.create.after` hook that auto-provisions a personal
|
|
46
|
+
* organization for JIT-created SSO users — better-auth's adapter
|
|
47
|
+
* bypasses kernel-level ObjectQL middleware, so this is the only
|
|
48
|
+
* hook point that fires for every user creation path (email signup,
|
|
49
|
+
* social/OIDC sign-in, admin-created accounts).
|
|
50
|
+
*/
|
|
51
|
+
databaseHooks?: BetterAuthOptions['databaseHooks'];
|
|
42
52
|
}
|
|
43
53
|
/**
|
|
44
54
|
* Authentication Plugin
|
|
@@ -163,6 +173,20 @@ interface AuthManagerOptions extends Partial<AuthConfig> {
|
|
|
163
173
|
* placeholder). Defaults to `'ObjectStack'` when omitted.
|
|
164
174
|
*/
|
|
165
175
|
appName?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Pass-through to better-auth's `databaseHooks` option. better-auth fires
|
|
178
|
+
* these around its own adapter writes (e.g. when `genericOAuth` creates
|
|
179
|
+
* a JIT user during SSO login), which the kernel-level ObjectQL
|
|
180
|
+
* middleware does NOT observe — better-auth's adapter goes through
|
|
181
|
+
* `dataEngine` directly, bypassing the `ql.registerMiddleware` chain.
|
|
182
|
+
*
|
|
183
|
+
* The platform uses this to attach a `user.create.after` hook that
|
|
184
|
+
* auto-provisions a personal organization for every newly-created user
|
|
185
|
+
* (mirroring what SecurityPlugin's middleware does for direct
|
|
186
|
+
* ObjectQL inserts) so SSO-arriving users don't land on the empty
|
|
187
|
+
* "create organization" screen.
|
|
188
|
+
*/
|
|
189
|
+
databaseHooks?: BetterAuthOptions['databaseHooks'];
|
|
166
190
|
}
|
|
167
191
|
/**
|
|
168
192
|
* Authentication Manager
|
package/dist/index.js
CHANGED
|
@@ -689,6 +689,10 @@ var AuthManager = class {
|
|
|
689
689
|
},
|
|
690
690
|
// better-auth plugins — registered based on AuthPluginConfig flags
|
|
691
691
|
plugins,
|
|
692
|
+
// Database hooks (fired by better-auth's adapter writes — these run
|
|
693
|
+
// for SSO JIT-provisioning too, unlike kernel-level ObjectQL
|
|
694
|
+
// middleware which better-auth's adapter bypasses).
|
|
695
|
+
...this.config.databaseHooks ? { databaseHooks: this.config.databaseHooks } : {},
|
|
692
696
|
// Trusted origins for CSRF protection (supports wildcards like "https://*.example.com")
|
|
693
697
|
// Auto-includes origins from CORS_ORIGIN env var so CORS and CSRF stay in sync.
|
|
694
698
|
...(() => {
|