@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.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/auth-plugin.ts
2
2
  import {
3
3
  SETUP_APP,
4
+ SETUP_NAV_CONTRIBUTIONS,
4
5
  STUDIO_APP,
5
6
  ACCOUNT_APP,
6
7
  SystemOverviewDashboard
@@ -1170,9 +1171,23 @@ var AuthManager = class {
1170
1171
  getEmailService() {
1171
1172
  return this.config.emailService;
1172
1173
  }
1174
+ /**
1175
+ * Override the brand name surfaced in built-in auth emails (`{{appName}}`),
1176
+ * sourced from the live `branding.workspace_name` setting.
1177
+ *
1178
+ * AuthPlugin calls this on `kernel:ready` (and again whenever the setting
1179
+ * changes) once the `settings` service resolves. Passing `undefined` clears
1180
+ * the override so resolution falls back to the configured `appName`. The
1181
+ * value only reflects an *explicitly set* setting — when the operator has
1182
+ * not customised it, AuthPlugin passes `undefined` so a deployment's
1183
+ * configured `appName` (e.g. `OS_APP_NAME`) keeps precedence.
1184
+ */
1185
+ setAppName(name) {
1186
+ this.appNameOverride = name?.trim() || void 0;
1187
+ }
1173
1188
  /** @internal `{{appName}}` placeholder value for built-in templates. */
1174
1189
  getAppName() {
1175
- return this.config.appName ?? "ObjectStack";
1190
+ return this.appNameOverride ?? this.config.appName ?? "ObjectStack";
1176
1191
  }
1177
1192
  /**
1178
1193
  * Get the underlying better-auth instance
@@ -1416,6 +1431,10 @@ var AuthPlugin = class {
1416
1431
  // owner of its registration since it loads first among the trio
1417
1432
  // (auth + security + audit) that supplies the underlying objects.
1418
1433
  apps: [SETUP_APP, STUDIO_APP, ACCOUNT_APP],
1434
+ // ADR-0029 D7 — the Setup App is a shell of group anchors; its entries
1435
+ // for platform-objects-owned objects are contributed here. Capability
1436
+ // plugins (e.g. plugin-webhooks) contribute their own slots' entries.
1437
+ navigationContributions: SETUP_NAV_CONTRIBUTIONS,
1419
1438
  // Slotted record-detail pages for system objects — currently
1420
1439
  // sys_organization gets a Members / Invitations / Teams tab strip
1421
1440
  // (see SysOrganizationDetailPage for the rationale and the
@@ -1451,6 +1470,32 @@ var AuthPlugin = class {
1451
1470
  } catch {
1452
1471
  ctx.logger.info("Auth: no email service registered \u2014 auth callbacks will log instead of sending");
1453
1472
  }
1473
+ try {
1474
+ const settings = ctx.getService("settings");
1475
+ if (settings && typeof settings.get === "function") {
1476
+ const applyBrand = async () => {
1477
+ try {
1478
+ const resolved = await settings.get("branding", "workspace_name", {});
1479
+ const explicit = resolved && resolved.source !== "default" ? resolved.value : void 0;
1480
+ this.authManager?.setAppName(
1481
+ typeof explicit === "string" ? explicit : void 0
1482
+ );
1483
+ } catch (err) {
1484
+ ctx.logger.warn(
1485
+ "Auth: failed to apply branding.workspace_name: " + (err?.message ?? err)
1486
+ );
1487
+ }
1488
+ };
1489
+ await applyBrand();
1490
+ if (typeof settings.subscribe === "function") {
1491
+ settings.subscribe("branding", () => {
1492
+ void applyBrand();
1493
+ });
1494
+ ctx.logger.info("Auth: bound appName to settings namespace=branding");
1495
+ }
1496
+ }
1497
+ } catch {
1498
+ }
1454
1499
  }
1455
1500
  let httpServer = null;
1456
1501
  try {