@objectstack/plugin-auth 7.3.0 → 7.4.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 CHANGED
@@ -280,6 +280,19 @@ declare class AuthManager {
280
280
  setEmailService(email: IEmailService | undefined): void;
281
281
  /** @internal Used by callback closures. */
282
282
  private getEmailService;
283
+ /**
284
+ * Override the brand name surfaced in built-in auth emails (`{{appName}}`),
285
+ * sourced from the live `branding.workspace_name` setting.
286
+ *
287
+ * AuthPlugin calls this on `kernel:ready` (and again whenever the setting
288
+ * changes) once the `settings` service resolves. Passing `undefined` clears
289
+ * the override so resolution falls back to the configured `appName`. The
290
+ * value only reflects an *explicitly set* setting — when the operator has
291
+ * not customised it, AuthPlugin passes `undefined` so a deployment's
292
+ * configured `appName` (e.g. `OS_APP_NAME`) keeps precedence.
293
+ */
294
+ setAppName(name: string | undefined): void;
295
+ private appNameOverride?;
283
296
  /** @internal `{{appName}}` placeholder value for built-in templates. */
284
297
  private getAppName;
285
298
  /**
package/dist/index.d.ts CHANGED
@@ -280,6 +280,19 @@ declare class AuthManager {
280
280
  setEmailService(email: IEmailService | undefined): void;
281
281
  /** @internal Used by callback closures. */
282
282
  private getEmailService;
283
+ /**
284
+ * Override the brand name surfaced in built-in auth emails (`{{appName}}`),
285
+ * sourced from the live `branding.workspace_name` setting.
286
+ *
287
+ * AuthPlugin calls this on `kernel:ready` (and again whenever the setting
288
+ * changes) once the `settings` service resolves. Passing `undefined` clears
289
+ * the override so resolution falls back to the configured `appName`. The
290
+ * value only reflects an *explicitly set* setting — when the operator has
291
+ * not customised it, AuthPlugin passes `undefined` so a deployment's
292
+ * configured `appName` (e.g. `OS_APP_NAME`) keeps precedence.
293
+ */
294
+ setAppName(name: string | undefined): void;
295
+ private appNameOverride?;
283
296
  /** @internal `{{appName}}` placeholder value for built-in templates. */
284
297
  private getAppName;
285
298
  /**
package/dist/index.js CHANGED
@@ -1234,9 +1234,23 @@ var AuthManager = class {
1234
1234
  getEmailService() {
1235
1235
  return this.config.emailService;
1236
1236
  }
1237
+ /**
1238
+ * Override the brand name surfaced in built-in auth emails (`{{appName}}`),
1239
+ * sourced from the live `branding.workspace_name` setting.
1240
+ *
1241
+ * AuthPlugin calls this on `kernel:ready` (and again whenever the setting
1242
+ * changes) once the `settings` service resolves. Passing `undefined` clears
1243
+ * the override so resolution falls back to the configured `appName`. The
1244
+ * value only reflects an *explicitly set* setting — when the operator has
1245
+ * not customised it, AuthPlugin passes `undefined` so a deployment's
1246
+ * configured `appName` (e.g. `OS_APP_NAME`) keeps precedence.
1247
+ */
1248
+ setAppName(name) {
1249
+ this.appNameOverride = name?.trim() || void 0;
1250
+ }
1237
1251
  /** @internal `{{appName}}` placeholder value for built-in templates. */
1238
1252
  getAppName() {
1239
- return this.config.appName ?? "ObjectStack";
1253
+ return this.appNameOverride ?? this.config.appName ?? "ObjectStack";
1240
1254
  }
1241
1255
  /**
1242
1256
  * Get the underlying better-auth instance
@@ -1461,6 +1475,10 @@ var AuthPlugin = class {
1461
1475
  // owner of its registration since it loads first among the trio
1462
1476
  // (auth + security + audit) that supplies the underlying objects.
1463
1477
  apps: [import_apps.SETUP_APP, import_apps.STUDIO_APP, import_apps.ACCOUNT_APP],
1478
+ // ADR-0029 D7 — the Setup App is a shell of group anchors; its entries
1479
+ // for platform-objects-owned objects are contributed here. Capability
1480
+ // plugins (e.g. plugin-webhooks) contribute their own slots' entries.
1481
+ navigationContributions: import_apps.SETUP_NAV_CONTRIBUTIONS,
1464
1482
  // Slotted record-detail pages for system objects — currently
1465
1483
  // sys_organization gets a Members / Invitations / Teams tab strip
1466
1484
  // (see SysOrganizationDetailPage for the rationale and the
@@ -1496,6 +1514,32 @@ var AuthPlugin = class {
1496
1514
  } catch {
1497
1515
  ctx.logger.info("Auth: no email service registered \u2014 auth callbacks will log instead of sending");
1498
1516
  }
1517
+ try {
1518
+ const settings = ctx.getService("settings");
1519
+ if (settings && typeof settings.get === "function") {
1520
+ const applyBrand = async () => {
1521
+ try {
1522
+ const resolved = await settings.get("branding", "workspace_name", {});
1523
+ const explicit = resolved && resolved.source !== "default" ? resolved.value : void 0;
1524
+ this.authManager?.setAppName(
1525
+ typeof explicit === "string" ? explicit : void 0
1526
+ );
1527
+ } catch (err) {
1528
+ ctx.logger.warn(
1529
+ "Auth: failed to apply branding.workspace_name: " + (err?.message ?? err)
1530
+ );
1531
+ }
1532
+ };
1533
+ await applyBrand();
1534
+ if (typeof settings.subscribe === "function") {
1535
+ settings.subscribe("branding", () => {
1536
+ void applyBrand();
1537
+ });
1538
+ ctx.logger.info("Auth: bound appName to settings namespace=branding");
1539
+ }
1540
+ }
1541
+ } catch {
1542
+ }
1499
1543
  }
1500
1544
  let httpServer = null;
1501
1545
  try {