@objectstack/plugin-auth 3.2.6 → 3.2.7

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @objectstack/plugin-auth@3.2.6 build /home/runner/work/spec/spec/packages/plugins/plugin-auth
2
+ > @objectstack/plugin-auth@3.2.7 build /home/runner/work/spec/spec/packages/plugins/plugin-auth
3
3
  > tsup --config ../../../tsup.config.ts
4
4
 
5
5
  ▲ [WARNING] The condition "types" here will never be used as it comes after both "import" and "require" [package.json]
@@ -66,13 +66,13 @@
66
66
  ╵ ~~~~~~~~~
67
67
 
68
68
 
69
- ESM dist/index.mjs 37.46 KB
70
- ESM dist/index.mjs.map 85.74 KB
71
- ESM ⚡️ Build success in 68ms
72
- CJS dist/index.js 40.94 KB
73
- CJS dist/index.js.map 86.26 KB
74
- CJS ⚡️ Build success in 67ms
69
+ CJS dist/index.js 45.05 KB
70
+ CJS dist/index.js.map 93.22 KB
71
+ CJS ⚡️ Build success in 95ms
72
+ ESM dist/index.mjs 41.57 KB
73
+ ESM dist/index.mjs.map 92.69 KB
74
+ ESM ⚡️ Build success in 95ms
75
75
  DTS Build start
76
- DTS ⚡️ Build success in 8794ms
77
- DTS dist/index.d.mts 866.35 KB
78
- DTS dist/index.d.ts 866.35 KB
76
+ DTS ⚡️ Build success in 9346ms
77
+ DTS dist/index.d.mts 866.76 KB
78
+ DTS dist/index.d.ts 866.76 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 35a1ebb: fix auth
8
+ - @objectstack/spec@3.2.7
9
+ - @objectstack/core@3.2.7
10
+
3
11
  ## 3.2.6
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -148,6 +148,17 @@ declare class AuthManager {
148
148
  * Generate a secure secret if not provided
149
149
  */
150
150
  private generateSecret;
151
+ /**
152
+ * Update the base URL at runtime.
153
+ *
154
+ * This **must** be called before the first request triggers lazy
155
+ * initialisation of the better-auth instance — typically from a
156
+ * `kernel:ready` hook where the actual server port is known.
157
+ *
158
+ * If the auth instance has already been created this is a no-op and
159
+ * a warning is emitted.
160
+ */
161
+ setRuntimeBaseUrl(url: string): void;
151
162
  /**
152
163
  * Get the underlying better-auth instance
153
164
  * Useful for advanced use cases
package/dist/index.d.ts CHANGED
@@ -148,6 +148,17 @@ declare class AuthManager {
148
148
  * Generate a secure secret if not provided
149
149
  */
150
150
  private generateSecret;
151
+ /**
152
+ * Update the base URL at runtime.
153
+ *
154
+ * This **must** be called before the first request triggers lazy
155
+ * initialisation of the better-auth instance — typically from a
156
+ * `kernel:ready` hook where the actual server port is known.
157
+ *
158
+ * If the auth instance has already been created this is a no-op and
159
+ * a warning is emitted.
160
+ */
161
+ setRuntimeBaseUrl(url: string): void;
151
162
  /**
152
163
  * Get the underlying better-auth instance
153
164
  * Useful for advanced use cases
package/dist/index.js CHANGED
@@ -399,10 +399,28 @@ var AuthManager = class {
399
399
  verification: {
400
400
  ...AUTH_VERIFICATION_CONFIG
401
401
  },
402
- // Email configuration
402
+ // Social / OAuth providers
403
+ ...this.config.socialProviders ? { socialProviders: this.config.socialProviders } : {},
404
+ // Email and password configuration
403
405
  emailAndPassword: {
404
- enabled: true
406
+ enabled: this.config.emailAndPassword?.enabled ?? true,
407
+ ...this.config.emailAndPassword?.disableSignUp != null ? { disableSignUp: this.config.emailAndPassword.disableSignUp } : {},
408
+ ...this.config.emailAndPassword?.requireEmailVerification != null ? { requireEmailVerification: this.config.emailAndPassword.requireEmailVerification } : {},
409
+ ...this.config.emailAndPassword?.minPasswordLength != null ? { minPasswordLength: this.config.emailAndPassword.minPasswordLength } : {},
410
+ ...this.config.emailAndPassword?.maxPasswordLength != null ? { maxPasswordLength: this.config.emailAndPassword.maxPasswordLength } : {},
411
+ ...this.config.emailAndPassword?.resetPasswordTokenExpiresIn != null ? { resetPasswordTokenExpiresIn: this.config.emailAndPassword.resetPasswordTokenExpiresIn } : {},
412
+ ...this.config.emailAndPassword?.autoSignIn != null ? { autoSignIn: this.config.emailAndPassword.autoSignIn } : {},
413
+ ...this.config.emailAndPassword?.revokeSessionsOnPasswordReset != null ? { revokeSessionsOnPasswordReset: this.config.emailAndPassword.revokeSessionsOnPasswordReset } : {}
405
414
  },
415
+ // Email verification
416
+ ...this.config.emailVerification ? {
417
+ emailVerification: {
418
+ ...this.config.emailVerification.sendOnSignUp != null ? { sendOnSignUp: this.config.emailVerification.sendOnSignUp } : {},
419
+ ...this.config.emailVerification.sendOnSignIn != null ? { sendOnSignIn: this.config.emailVerification.sendOnSignIn } : {},
420
+ ...this.config.emailVerification.autoSignInAfterVerification != null ? { autoSignInAfterVerification: this.config.emailVerification.autoSignInAfterVerification } : {},
421
+ ...this.config.emailVerification.expiresIn != null ? { expiresIn: this.config.emailVerification.expiresIn } : {}
422
+ }
423
+ } : {},
406
424
  // Session configuration
407
425
  session: {
408
426
  ...AUTH_SESSION_CONFIG,
@@ -412,7 +430,18 @@ var AuthManager = class {
412
430
  // 1 day default
413
431
  },
414
432
  // better-auth plugins — registered based on AuthPluginConfig flags
415
- plugins: this.buildPluginList()
433
+ plugins: this.buildPluginList(),
434
+ // Trusted origins for CSRF protection (supports wildcards like "https://*.example.com")
435
+ ...this.config.trustedOrigins?.length ? { trustedOrigins: this.config.trustedOrigins } : {},
436
+ // Advanced options (cross-subdomain cookies, secure cookies, CSRF, etc.)
437
+ ...this.config.advanced ? {
438
+ advanced: {
439
+ ...this.config.advanced.crossSubDomainCookies ? { crossSubDomainCookies: this.config.advanced.crossSubDomainCookies } : {},
440
+ ...this.config.advanced.useSecureCookies != null ? { useSecureCookies: this.config.advanced.useSecureCookies } : {},
441
+ ...this.config.advanced.disableCSRFCheck != null ? { disableCSRFCheck: this.config.advanced.disableCSRFCheck } : {},
442
+ ...this.config.advanced.cookiePrefix != null ? { cookiePrefix: this.config.advanced.cookiePrefix } : {}
443
+ }
444
+ } : {}
416
445
  };
417
446
  return (0, import_better_auth.betterAuth)(betterAuthConfig);
418
447
  }
@@ -482,6 +511,25 @@ var AuthManager = class {
482
511
  }
483
512
  return envSecret;
484
513
  }
514
+ /**
515
+ * Update the base URL at runtime.
516
+ *
517
+ * This **must** be called before the first request triggers lazy
518
+ * initialisation of the better-auth instance — typically from a
519
+ * `kernel:ready` hook where the actual server port is known.
520
+ *
521
+ * If the auth instance has already been created this is a no-op and
522
+ * a warning is emitted.
523
+ */
524
+ setRuntimeBaseUrl(url) {
525
+ if (this.auth) {
526
+ console.warn(
527
+ "[AuthManager] setRuntimeBaseUrl() called after the auth instance was already created \u2014 ignoring. Ensure this method is called before the first request."
528
+ );
529
+ return;
530
+ }
531
+ this.config = { ...this.config, baseUrl: url };
532
+ }
485
533
  /**
486
534
  * Get the underlying better-auth instance
487
535
  * Useful for advanced use cases
@@ -565,6 +613,21 @@ var AuthPlugin = class {
565
613
  } catch {
566
614
  }
567
615
  if (httpServer) {
616
+ const serverWithPort = httpServer;
617
+ if (this.authManager && typeof serverWithPort.getPort === "function") {
618
+ const actualPort = serverWithPort.getPort();
619
+ if (actualPort) {
620
+ const configuredUrl = this.options.baseUrl || "http://localhost:3000";
621
+ const configuredOrigin = new URL(configuredUrl).origin;
622
+ const actualUrl = `http://localhost:${actualPort}`;
623
+ if (configuredOrigin !== actualUrl) {
624
+ this.authManager.setRuntimeBaseUrl(actualUrl);
625
+ ctx.logger.info(
626
+ `Auth baseUrl auto-updated to ${actualUrl} (configured: ${configuredUrl})`
627
+ );
628
+ }
629
+ }
630
+ }
568
631
  this.registerAuthRoutes(httpServer, ctx);
569
632
  ctx.logger.info(`Auth routes registered at ${this.options.basePath}`);
570
633
  } else {