@dyrected/core 2.5.41 → 2.5.42

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.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as Field, B as Block, D as DyrectedConfig, C as CollectionConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, W as WorkflowConfig, a as AuthenticatedUser, b as WorkflowTransition, L as LifecycleEventName, c as LifecycleEvent, d as BaseDocument, H as HookRequestContext, G as GlobalConfig } from './index-DfkPT4NR.cjs';
2
- export { e as AccessFunction, f as AdminAuthAccessResolution, g as AdminAuthClaimMapping, h as AdminAuthProvider, i as AdminAuthProvisioningMode, j as AdminAuthResolveAccessArgs, k as AdminAuthResolvedIdentity, l as AdminConfig, m as AdminDashboardComponentSlots, n as AdminIconName, o as ArrayField, p as BaseAdminAuthProvider, q as BlocksField, r as BooleanField, s as CharacterLimitFieldConfig, t as CollectionAfterChangeHook, u as CollectionAfterDeleteHook, v as CollectionAfterReadHook, w as CollectionAfterTransitionHook, x as CollectionBeforeChangeHook, y as CollectionBeforeDeleteHook, z as CollectionBeforeReadHook, E as CollectionBeforeTransitionHook, I as CollectionListComponentSlots, J as CustomAdminAuthProvider, K as DatabaseAdapter, M as DateField, N as DateTimeField, O as DynamicOptionItem, Q as DynamicOptionsConfig, R as DynamicOptionsResolver, S as DynamicOptionsResolverArgs, T as EmailField, U as FieldAdminOnChangeHook, V as FieldAdminOnChangeHookArgs, X as FieldAdminOptionsHook, Y as FieldAdminOptionsHookArgs, Z as FieldAdminOptionsHookResult, _ as FieldAfterReadHook, $ as FieldAfterReadHookArgs, a0 as FieldBeforeChangeHook, a1 as FieldBeforeChangeHookArgs, a2 as FieldHook, a3 as FieldType, a4 as FileData, a5 as GlobalAfterChangeHook, a6 as GlobalAfterReadHook, a7 as GlobalBeforeChangeHook, a8 as GlobalBeforeReadHook, a9 as HookFunction, aa as IconField, ab as ImageField, ac as ImageService, ad as JoinField, ae as JsonField, af as LIFECYCLE_EVENT_NAMES, ag as LifecycleEventHandler, ah as MultiSelectField, ai as NumberField, aj as OIDCAdminAuthProvider, ak as ObjectField, al as PaginatedResult, am as PublicAdminAuthProvider, an as RadioField, ao as ReadonlyDatabaseAdapter, ap as RelationshipField, aq as RichTextField, ar as RowField, as as SelectField, at as StorageAdapter, au as TextField, av as TextareaField, aw as TimeField, ax as UploadConfig, ay as UrlField, az as WordLimitFieldConfig, aA as WorkflowMetadata, aB as WorkflowRole, aC as WorkflowState, aD as WorkflowTransitionContext } from './index-DfkPT4NR.cjs';
1
+ import { F as Field, B as Block, D as DyrectedConfig, C as CollectionConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, W as WorkflowConfig, a as AuthenticatedUser, b as WorkflowTransition, L as LifecycleEventName, c as LifecycleEvent, d as BaseDocument, H as HookRequestContext, G as GlobalConfig } from './app-config-BLMX-9MN.cjs';
2
+ export { e as AccessFunction, f as AdminAuthAccessResolution, g as AdminAuthClaimMapping, h as AdminAuthProvider, i as AdminAuthProvisioningMode, j as AdminAuthResolveAccessArgs, k as AdminAuthResolvedIdentity, l as AdminConfig, m as AdminDashboardComponentSlots, n as AdminIconName, o as ArrayField, p as BaseAdminAuthProvider, q as BlocksField, r as BooleanField, s as CharacterLimitFieldConfig, t as CollectionAfterChangeHook, u as CollectionAfterDeleteHook, v as CollectionAfterReadHook, w as CollectionAfterTransitionHook, x as CollectionBeforeChangeHook, y as CollectionBeforeDeleteHook, z as CollectionBeforeReadHook, E as CollectionBeforeTransitionHook, I as CollectionListComponentSlots, J as CustomAdminAuthProvider, K as DatabaseAdapter, M as DateField, N as DateTimeField, O as DynamicOptionItem, Q as DynamicOptionsConfig, R as DynamicOptionsResolver, S as DynamicOptionsResolverArgs, T as EmailField, U as FieldAdminOnChangeHook, V as FieldAdminOnChangeHookArgs, X as FieldAdminOptionsHook, Y as FieldAdminOptionsHookArgs, Z as FieldAdminOptionsHookResult, _ as FieldAfterReadHook, $ as FieldAfterReadHookArgs, a0 as FieldBeforeChangeHook, a1 as FieldBeforeChangeHookArgs, a2 as FieldHook, a3 as FieldType, a4 as FileData, a5 as GlobalAfterChangeHook, a6 as GlobalAfterReadHook, a7 as GlobalBeforeChangeHook, a8 as GlobalBeforeReadHook, a9 as HookFunction, aa as IconField, ab as ImageField, ac as ImageService, ad as JoinField, ae as JsonField, af as LIFECYCLE_EVENT_NAMES, ag as LifecycleEventHandler, ah as MultiSelectField, ai as NumberField, aj as OIDCAdminAuthProvider, ak as ObjectField, al as PaginatedResult, am as PublicAdminAuthProvider, an as RadioField, ao as ReadonlyDatabaseAdapter, ap as RelationshipField, aq as RichTextField, ar as RowField, as as SelectField, at as StorageAdapter, au as TextField, av as TextareaField, aw as TimeField, ax as UploadConfig, ay as UrlField, az as WordLimitFieldConfig, aA as WorkflowMetadata, aB as WorkflowRole, aC as WorkflowState, aD as WorkflowTransitionContext } from './app-config-BLMX-9MN.cjs';
3
3
  import 'lucide-react';
4
4
 
5
5
  type Prettify<T> = {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as Field, B as Block, D as DyrectedConfig, C as CollectionConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, W as WorkflowConfig, a as AuthenticatedUser, b as WorkflowTransition, L as LifecycleEventName, c as LifecycleEvent, d as BaseDocument, H as HookRequestContext, G as GlobalConfig } from './index-DfkPT4NR.js';
2
- export { e as AccessFunction, f as AdminAuthAccessResolution, g as AdminAuthClaimMapping, h as AdminAuthProvider, i as AdminAuthProvisioningMode, j as AdminAuthResolveAccessArgs, k as AdminAuthResolvedIdentity, l as AdminConfig, m as AdminDashboardComponentSlots, n as AdminIconName, o as ArrayField, p as BaseAdminAuthProvider, q as BlocksField, r as BooleanField, s as CharacterLimitFieldConfig, t as CollectionAfterChangeHook, u as CollectionAfterDeleteHook, v as CollectionAfterReadHook, w as CollectionAfterTransitionHook, x as CollectionBeforeChangeHook, y as CollectionBeforeDeleteHook, z as CollectionBeforeReadHook, E as CollectionBeforeTransitionHook, I as CollectionListComponentSlots, J as CustomAdminAuthProvider, K as DatabaseAdapter, M as DateField, N as DateTimeField, O as DynamicOptionItem, Q as DynamicOptionsConfig, R as DynamicOptionsResolver, S as DynamicOptionsResolverArgs, T as EmailField, U as FieldAdminOnChangeHook, V as FieldAdminOnChangeHookArgs, X as FieldAdminOptionsHook, Y as FieldAdminOptionsHookArgs, Z as FieldAdminOptionsHookResult, _ as FieldAfterReadHook, $ as FieldAfterReadHookArgs, a0 as FieldBeforeChangeHook, a1 as FieldBeforeChangeHookArgs, a2 as FieldHook, a3 as FieldType, a4 as FileData, a5 as GlobalAfterChangeHook, a6 as GlobalAfterReadHook, a7 as GlobalBeforeChangeHook, a8 as GlobalBeforeReadHook, a9 as HookFunction, aa as IconField, ab as ImageField, ac as ImageService, ad as JoinField, ae as JsonField, af as LIFECYCLE_EVENT_NAMES, ag as LifecycleEventHandler, ah as MultiSelectField, ai as NumberField, aj as OIDCAdminAuthProvider, ak as ObjectField, al as PaginatedResult, am as PublicAdminAuthProvider, an as RadioField, ao as ReadonlyDatabaseAdapter, ap as RelationshipField, aq as RichTextField, ar as RowField, as as SelectField, at as StorageAdapter, au as TextField, av as TextareaField, aw as TimeField, ax as UploadConfig, ay as UrlField, az as WordLimitFieldConfig, aA as WorkflowMetadata, aB as WorkflowRole, aC as WorkflowState, aD as WorkflowTransitionContext } from './index-DfkPT4NR.js';
1
+ import { F as Field, B as Block, D as DyrectedConfig, C as CollectionConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, W as WorkflowConfig, a as AuthenticatedUser, b as WorkflowTransition, L as LifecycleEventName, c as LifecycleEvent, d as BaseDocument, H as HookRequestContext, G as GlobalConfig } from './app-config-BLMX-9MN.js';
2
+ export { e as AccessFunction, f as AdminAuthAccessResolution, g as AdminAuthClaimMapping, h as AdminAuthProvider, i as AdminAuthProvisioningMode, j as AdminAuthResolveAccessArgs, k as AdminAuthResolvedIdentity, l as AdminConfig, m as AdminDashboardComponentSlots, n as AdminIconName, o as ArrayField, p as BaseAdminAuthProvider, q as BlocksField, r as BooleanField, s as CharacterLimitFieldConfig, t as CollectionAfterChangeHook, u as CollectionAfterDeleteHook, v as CollectionAfterReadHook, w as CollectionAfterTransitionHook, x as CollectionBeforeChangeHook, y as CollectionBeforeDeleteHook, z as CollectionBeforeReadHook, E as CollectionBeforeTransitionHook, I as CollectionListComponentSlots, J as CustomAdminAuthProvider, K as DatabaseAdapter, M as DateField, N as DateTimeField, O as DynamicOptionItem, Q as DynamicOptionsConfig, R as DynamicOptionsResolver, S as DynamicOptionsResolverArgs, T as EmailField, U as FieldAdminOnChangeHook, V as FieldAdminOnChangeHookArgs, X as FieldAdminOptionsHook, Y as FieldAdminOptionsHookArgs, Z as FieldAdminOptionsHookResult, _ as FieldAfterReadHook, $ as FieldAfterReadHookArgs, a0 as FieldBeforeChangeHook, a1 as FieldBeforeChangeHookArgs, a2 as FieldHook, a3 as FieldType, a4 as FileData, a5 as GlobalAfterChangeHook, a6 as GlobalAfterReadHook, a7 as GlobalBeforeChangeHook, a8 as GlobalBeforeReadHook, a9 as HookFunction, aa as IconField, ab as ImageField, ac as ImageService, ad as JoinField, ae as JsonField, af as LIFECYCLE_EVENT_NAMES, ag as LifecycleEventHandler, ah as MultiSelectField, ai as NumberField, aj as OIDCAdminAuthProvider, ak as ObjectField, al as PaginatedResult, am as PublicAdminAuthProvider, an as RadioField, ao as ReadonlyDatabaseAdapter, ap as RelationshipField, aq as RichTextField, ar as RowField, as as SelectField, at as StorageAdapter, au as TextField, av as TextareaField, aw as TimeField, ax as UploadConfig, ay as UrlField, az as WordLimitFieldConfig, aA as WorkflowMetadata, aB as WorkflowRole, aC as WorkflowState, aD as WorkflowTransitionContext } from './app-config-BLMX-9MN.js';
3
3
  import 'lucide-react';
4
4
 
5
5
  type Prettify<T> = {
package/dist/server.cjs CHANGED
@@ -2137,11 +2137,12 @@ var AdminAuthController = class {
2137
2137
  return c.json(getPublicAdminAuthConfig(this.config.adminAuth));
2138
2138
  }
2139
2139
  async start(c) {
2140
- const provider = this.getProvider(c.req.param("provider"));
2140
+ const requestConfig = await this.getRequestConfig(c);
2141
+ const provider = this.getProvider(requestConfig, c.req.param("provider"));
2141
2142
  if (!provider) {
2142
2143
  return c.json({ error: true, message: "Admin auth provider not found." }, 404);
2143
2144
  }
2144
- const siteId = c.req.header("X-Site-Id") || c.get("siteId");
2145
+ const siteId = this.getSiteId(c);
2145
2146
  const returnTo = this.normalizeReturnTo(c.req.query("returnTo"), c);
2146
2147
  if (provider.type === "oidc") {
2147
2148
  const redirectUrl = await this.buildOidcStartUrl(
@@ -2162,12 +2163,13 @@ var AdminAuthController = class {
2162
2163
  return c.redirect(url.toString(), 302);
2163
2164
  }
2164
2165
  async callback(c) {
2165
- const provider = this.getProvider(c.req.param("provider"));
2166
+ const requestConfig = await this.getRequestConfig(c);
2167
+ const provider = this.getProvider(requestConfig, c.req.param("provider"));
2166
2168
  if (!provider) {
2167
2169
  return c.json({ error: true, message: "Admin auth provider not found." }, 404);
2168
2170
  }
2169
2171
  try {
2170
- const exchange = await this.completeProviderAuth(provider, c);
2172
+ const exchange = await this.completeProviderAuth(requestConfig, provider, c);
2171
2173
  const redirectUrl = new URL(exchange.returnTo);
2172
2174
  redirectUrl.searchParams.set("dyrectedExternalToken", exchange.token);
2173
2175
  redirectUrl.searchParams.set("dyrectedAdminCollection", exchange.collectionSlug);
@@ -2181,12 +2183,13 @@ var AdminAuthController = class {
2181
2183
  }
2182
2184
  }
2183
2185
  async exchange(c) {
2184
- const provider = this.getProvider(c.req.param("provider"));
2186
+ const requestConfig = await this.getRequestConfig(c);
2187
+ const provider = this.getProvider(requestConfig, c.req.param("provider"));
2185
2188
  if (!provider) {
2186
2189
  return c.json({ error: true, message: "Admin auth provider not found." }, 404);
2187
2190
  }
2188
2191
  try {
2189
- const exchange = await this.completeProviderAuth(provider, c);
2192
+ const exchange = await this.completeProviderAuth(requestConfig, provider, c);
2190
2193
  return c.json({
2191
2194
  token: exchange.token,
2192
2195
  collectionSlug: exchange.collectionSlug,
@@ -2201,15 +2204,15 @@ var AdminAuthController = class {
2201
2204
  async logout(c) {
2202
2205
  return c.json({ success: true, message: "Logged out. Discard your token." });
2203
2206
  }
2204
- getProvider(id) {
2205
- if (this.config.adminAuth?.mode !== "external") return void 0;
2206
- return this.config.adminAuth.providers.find((provider) => provider.id === id);
2207
+ getProvider(config, id) {
2208
+ if (config.adminAuth?.mode !== "external") return void 0;
2209
+ return config.adminAuth.providers.find((provider) => provider.id === id);
2207
2210
  }
2208
- async completeProviderAuth(provider, c) {
2211
+ async completeProviderAuth(requestConfig, provider, c) {
2209
2212
  const resolved = provider.type === "oidc" ? await this.resolveOidcIdentity(provider, c) : await this.resolveCustomIdentity(provider, c);
2210
2213
  const identity = resolved.identity;
2211
- const siteId = c.req.header("X-Site-Id") || c.get("siteId");
2212
- const adminCollection = getAdminAuthCollection(this.config);
2214
+ const siteId = this.getSiteId(c);
2215
+ const adminCollection = getAdminAuthCollection(requestConfig);
2213
2216
  if (!adminCollection?.auth) {
2214
2217
  throw new Error("Admin auth collection is not configured.");
2215
2218
  }
@@ -2220,12 +2223,12 @@ var AdminAuthController = class {
2220
2223
  where: { email: identity.email },
2221
2224
  limit: 1
2222
2225
  })).docs[0] : null);
2223
- const provisioningMode = this.config.adminAuth?.provisioningMode ?? "jit_plus_membership_management";
2226
+ const provisioningMode = requestConfig.adminAuth?.provisioningMode ?? "jit_plus_membership_management";
2224
2227
  const allowJitProvisioning = provisioningMode !== "preprovisioned_only" && provider.allowJitProvisioning !== false;
2225
2228
  if (!user && !allowJitProvisioning) {
2226
2229
  throw new Error("This account has not been provisioned for admin access.");
2227
2230
  }
2228
- const access = await this.resolveAccess(identity, provider.id, siteId, c, user);
2231
+ const access = await this.resolveAccess(requestConfig, identity, provider.id, siteId, c, user);
2229
2232
  if (!access.allowed) {
2230
2233
  throw new Error("Access denied for this site.");
2231
2234
  }
@@ -2260,8 +2263,8 @@ var AdminAuthController = class {
2260
2263
  returnTo: resolved.returnTo
2261
2264
  };
2262
2265
  }
2263
- async resolveAccess(identity, providerId, siteId, c, user) {
2264
- const resolved = await this.config.adminAuth?.resolveAccess?.({
2266
+ async resolveAccess(requestConfig, identity, providerId, siteId, c, user) {
2267
+ const resolved = await requestConfig.adminAuth?.resolveAccess?.({
2265
2268
  identity,
2266
2269
  providerId,
2267
2270
  siteId,
@@ -2300,6 +2303,21 @@ var AdminAuthController = class {
2300
2303
  });
2301
2304
  return result.docs[0] ?? null;
2302
2305
  }
2306
+ getSiteId(c) {
2307
+ return c.req.header("X-Site-Id") || c.get("siteId");
2308
+ }
2309
+ async getRequestConfig(c) {
2310
+ const siteId = this.getSiteId(c);
2311
+ if (!siteId || !this.config.onSchemaFetch) return this.config;
2312
+ const dynamic = await this.config.onSchemaFetch(siteId);
2313
+ return {
2314
+ ...this.config,
2315
+ ...dynamic.admin ? { admin: { ...this.config.admin, ...dynamic.admin } } : {},
2316
+ ...dynamic.adminAuth ? { adminAuth: { ...this.config.adminAuth, ...dynamic.adminAuth } } : {},
2317
+ collections: dynamic.collections ? [...this.config.collections, ...dynamic.collections] : this.config.collections,
2318
+ globals: dynamic.globals ? [...this.config.globals, ...dynamic.globals] : this.config.globals
2319
+ };
2320
+ }
2303
2321
  async buildOidcStartUrl(provider, returnTo, siteId, origin) {
2304
2322
  const discovery = await this.getOidcDiscovery(provider);
2305
2323
  const nonce = (0, import_node_crypto2.randomBytes)(16).toString("hex");
package/dist/server.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as hono_types from 'hono/types';
2
2
  import * as hono from 'hono';
3
3
  import { Hono, Context } from 'hono';
4
- import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './index-DfkPT4NR.cjs';
4
+ import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './app-config-BLMX-9MN.cjs';
5
5
  import * as hono_utils_http_status from 'hono/utils/http-status';
6
6
  import * as hono_utils_types from 'hono/utils/types';
7
7
  import 'lucide-react';
package/dist/server.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as hono_types from 'hono/types';
2
2
  import * as hono from 'hono';
3
3
  import { Hono, Context } from 'hono';
4
- import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './index-DfkPT4NR.js';
4
+ import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './app-config-BLMX-9MN.js';
5
5
  import * as hono_utils_http_status from 'hono/utils/http-status';
6
6
  import * as hono_utils_types from 'hono/utils/types';
7
7
  import 'lucide-react';
package/dist/server.js CHANGED
@@ -1636,11 +1636,12 @@ var AdminAuthController = class {
1636
1636
  return c.json(getPublicAdminAuthConfig(this.config.adminAuth));
1637
1637
  }
1638
1638
  async start(c) {
1639
- const provider = this.getProvider(c.req.param("provider"));
1639
+ const requestConfig = await this.getRequestConfig(c);
1640
+ const provider = this.getProvider(requestConfig, c.req.param("provider"));
1640
1641
  if (!provider) {
1641
1642
  return c.json({ error: true, message: "Admin auth provider not found." }, 404);
1642
1643
  }
1643
- const siteId = c.req.header("X-Site-Id") || c.get("siteId");
1644
+ const siteId = this.getSiteId(c);
1644
1645
  const returnTo = this.normalizeReturnTo(c.req.query("returnTo"), c);
1645
1646
  if (provider.type === "oidc") {
1646
1647
  const redirectUrl = await this.buildOidcStartUrl(
@@ -1661,12 +1662,13 @@ var AdminAuthController = class {
1661
1662
  return c.redirect(url.toString(), 302);
1662
1663
  }
1663
1664
  async callback(c) {
1664
- const provider = this.getProvider(c.req.param("provider"));
1665
+ const requestConfig = await this.getRequestConfig(c);
1666
+ const provider = this.getProvider(requestConfig, c.req.param("provider"));
1665
1667
  if (!provider) {
1666
1668
  return c.json({ error: true, message: "Admin auth provider not found." }, 404);
1667
1669
  }
1668
1670
  try {
1669
- const exchange = await this.completeProviderAuth(provider, c);
1671
+ const exchange = await this.completeProviderAuth(requestConfig, provider, c);
1670
1672
  const redirectUrl = new URL(exchange.returnTo);
1671
1673
  redirectUrl.searchParams.set("dyrectedExternalToken", exchange.token);
1672
1674
  redirectUrl.searchParams.set("dyrectedAdminCollection", exchange.collectionSlug);
@@ -1680,12 +1682,13 @@ var AdminAuthController = class {
1680
1682
  }
1681
1683
  }
1682
1684
  async exchange(c) {
1683
- const provider = this.getProvider(c.req.param("provider"));
1685
+ const requestConfig = await this.getRequestConfig(c);
1686
+ const provider = this.getProvider(requestConfig, c.req.param("provider"));
1684
1687
  if (!provider) {
1685
1688
  return c.json({ error: true, message: "Admin auth provider not found." }, 404);
1686
1689
  }
1687
1690
  try {
1688
- const exchange = await this.completeProviderAuth(provider, c);
1691
+ const exchange = await this.completeProviderAuth(requestConfig, provider, c);
1689
1692
  return c.json({
1690
1693
  token: exchange.token,
1691
1694
  collectionSlug: exchange.collectionSlug,
@@ -1700,15 +1703,15 @@ var AdminAuthController = class {
1700
1703
  async logout(c) {
1701
1704
  return c.json({ success: true, message: "Logged out. Discard your token." });
1702
1705
  }
1703
- getProvider(id) {
1704
- if (this.config.adminAuth?.mode !== "external") return void 0;
1705
- return this.config.adminAuth.providers.find((provider) => provider.id === id);
1706
+ getProvider(config, id) {
1707
+ if (config.adminAuth?.mode !== "external") return void 0;
1708
+ return config.adminAuth.providers.find((provider) => provider.id === id);
1706
1709
  }
1707
- async completeProviderAuth(provider, c) {
1710
+ async completeProviderAuth(requestConfig, provider, c) {
1708
1711
  const resolved = provider.type === "oidc" ? await this.resolveOidcIdentity(provider, c) : await this.resolveCustomIdentity(provider, c);
1709
1712
  const identity = resolved.identity;
1710
- const siteId = c.req.header("X-Site-Id") || c.get("siteId");
1711
- const adminCollection = getAdminAuthCollection(this.config);
1713
+ const siteId = this.getSiteId(c);
1714
+ const adminCollection = getAdminAuthCollection(requestConfig);
1712
1715
  if (!adminCollection?.auth) {
1713
1716
  throw new Error("Admin auth collection is not configured.");
1714
1717
  }
@@ -1719,12 +1722,12 @@ var AdminAuthController = class {
1719
1722
  where: { email: identity.email },
1720
1723
  limit: 1
1721
1724
  })).docs[0] : null);
1722
- const provisioningMode = this.config.adminAuth?.provisioningMode ?? "jit_plus_membership_management";
1725
+ const provisioningMode = requestConfig.adminAuth?.provisioningMode ?? "jit_plus_membership_management";
1723
1726
  const allowJitProvisioning = provisioningMode !== "preprovisioned_only" && provider.allowJitProvisioning !== false;
1724
1727
  if (!user && !allowJitProvisioning) {
1725
1728
  throw new Error("This account has not been provisioned for admin access.");
1726
1729
  }
1727
- const access = await this.resolveAccess(identity, provider.id, siteId, c, user);
1730
+ const access = await this.resolveAccess(requestConfig, identity, provider.id, siteId, c, user);
1728
1731
  if (!access.allowed) {
1729
1732
  throw new Error("Access denied for this site.");
1730
1733
  }
@@ -1759,8 +1762,8 @@ var AdminAuthController = class {
1759
1762
  returnTo: resolved.returnTo
1760
1763
  };
1761
1764
  }
1762
- async resolveAccess(identity, providerId, siteId, c, user) {
1763
- const resolved = await this.config.adminAuth?.resolveAccess?.({
1765
+ async resolveAccess(requestConfig, identity, providerId, siteId, c, user) {
1766
+ const resolved = await requestConfig.adminAuth?.resolveAccess?.({
1764
1767
  identity,
1765
1768
  providerId,
1766
1769
  siteId,
@@ -1799,6 +1802,21 @@ var AdminAuthController = class {
1799
1802
  });
1800
1803
  return result.docs[0] ?? null;
1801
1804
  }
1805
+ getSiteId(c) {
1806
+ return c.req.header("X-Site-Id") || c.get("siteId");
1807
+ }
1808
+ async getRequestConfig(c) {
1809
+ const siteId = this.getSiteId(c);
1810
+ if (!siteId || !this.config.onSchemaFetch) return this.config;
1811
+ const dynamic = await this.config.onSchemaFetch(siteId);
1812
+ return {
1813
+ ...this.config,
1814
+ ...dynamic.admin ? { admin: { ...this.config.admin, ...dynamic.admin } } : {},
1815
+ ...dynamic.adminAuth ? { adminAuth: { ...this.config.adminAuth, ...dynamic.adminAuth } } : {},
1816
+ collections: dynamic.collections ? [...this.config.collections, ...dynamic.collections] : this.config.collections,
1817
+ globals: dynamic.globals ? [...this.config.globals, ...dynamic.globals] : this.config.globals
1818
+ };
1819
+ }
1802
1820
  async buildOidcStartUrl(provider, returnTo, siteId, origin) {
1803
1821
  const discovery = await this.getOidcDiscovery(provider);
1804
1822
  const nonce = randomBytes2(16).toString("hex");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyrected/core",
3
- "version": "2.5.41",
3
+ "version": "2.5.42",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",