@memberjunction/server 6.1.0-edge.2 → 6.1.0-edge.3
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/LICENSE +180 -4
- package/dist/auth/AuthProviderCatalogRouter.d.ts +31 -0
- package/dist/auth/AuthProviderCatalogRouter.d.ts.map +1 -0
- package/dist/auth/AuthProviderCatalogRouter.js +69 -0
- package/dist/auth/AuthProviderCatalogRouter.js.map +1 -0
- package/dist/auth/AuthProviderEngine.d.ts +96 -0
- package/dist/auth/AuthProviderEngine.d.ts.map +1 -0
- package/dist/auth/AuthProviderEngine.js +245 -0
- package/dist/auth/AuthProviderEngine.js.map +1 -0
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +56 -13
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/initializeProviders.d.ts +64 -1
- package/dist/auth/initializeProviders.d.ts.map +1 -1
- package/dist/auth/initializeProviders.js +117 -5
- package/dist/auth/initializeProviders.js.map +1 -1
- package/dist/config.d.ts +89 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +52 -35
- package/dist/config.js.map +1 -1
- package/dist/generated/generated.d.ts +501 -1597
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js +2711 -17021
- package/dist/generated/generated.js.map +1 -1
- package/dist/generic/ResolverBase.d.ts +1 -1
- package/dist/generic/ResolverBase.d.ts.map +1 -1
- package/dist/generic/ResolverBase.js +7 -4
- package/dist/generic/ResolverBase.js.map +1 -1
- package/dist/generic/RunViewResolver.d.ts +4 -0
- package/dist/generic/RunViewResolver.d.ts.map +1 -1
- package/dist/generic/RunViewResolver.js +31 -0
- package/dist/generic/RunViewResolver.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +99 -14
- package/dist/index.js.map +1 -1
- package/dist/integration/RSUProgressBridge.d.ts +83 -0
- package/dist/integration/RSUProgressBridge.d.ts.map +1 -0
- package/dist/integration/RSUProgressBridge.js +230 -0
- package/dist/integration/RSUProgressBridge.js.map +1 -0
- package/dist/integration/SchemaRefreshLaunch.d.ts +52 -0
- package/dist/integration/SchemaRefreshLaunch.d.ts.map +1 -0
- package/dist/integration/SchemaRefreshLaunch.js +50 -0
- package/dist/integration/SchemaRefreshLaunch.js.map +1 -0
- package/dist/providerConfigUnits.d.ts +20 -0
- package/dist/providerConfigUnits.d.ts.map +1 -0
- package/dist/providerConfigUnits.js +22 -0
- package/dist/providerConfigUnits.js.map +1 -0
- package/dist/resolvers/FileResolver.d.ts +34 -4
- package/dist/resolvers/FileResolver.d.ts.map +1 -1
- package/dist/resolvers/FileResolver.js +218 -28
- package/dist/resolvers/FileResolver.js.map +1 -1
- package/dist/resolvers/IntegrationDiscoveryResolver.d.ts +76 -3
- package/dist/resolvers/IntegrationDiscoveryResolver.d.ts.map +1 -1
- package/dist/resolvers/IntegrationDiscoveryResolver.js +299 -81
- package/dist/resolvers/IntegrationDiscoveryResolver.js.map +1 -1
- package/dist/resolvers/QueryResolver.d.ts +5 -4
- package/dist/resolvers/QueryResolver.d.ts.map +1 -1
- package/dist/resolvers/QueryResolver.js +29 -14
- package/dist/resolvers/QueryResolver.js.map +1 -1
- package/dist/resolvers/QuerySystemUserResolver.d.ts +12 -3
- package/dist/resolvers/QuerySystemUserResolver.d.ts.map +1 -1
- package/dist/resolvers/QuerySystemUserResolver.js +33 -14
- package/dist/resolvers/QuerySystemUserResolver.js.map +1 -1
- package/dist/resolvers/RunAIAgentResolver.d.ts +3 -1
- package/dist/resolvers/RunAIAgentResolver.d.ts.map +1 -1
- package/dist/resolvers/RunAIAgentResolver.js +20 -7
- package/dist/resolvers/RunAIAgentResolver.js.map +1 -1
- package/dist/resolvers/TaskGraphFrameResolver.d.ts +18 -0
- package/dist/resolvers/TaskGraphFrameResolver.d.ts.map +1 -1
- package/dist/resolvers/TaskGraphFrameResolver.js +75 -0
- package/dist/resolvers/TaskGraphFrameResolver.js.map +1 -1
- package/dist/resolvers/UserResolver.d.ts +19 -17
- package/dist/resolvers/UserResolver.d.ts.map +1 -1
- package/dist/resolvers/UserResolver.js +66 -67
- package/dist/resolvers/UserResolver.js.map +1 -1
- package/dist/resolvers/currentUserRoles.d.ts +19 -0
- package/dist/resolvers/currentUserRoles.d.ts.map +1 -0
- package/dist/resolvers/currentUserRoles.js +36 -0
- package/dist/resolvers/currentUserRoles.js.map +1 -0
- package/dist/rest/MediaAccessKeys.d.ts +17 -0
- package/dist/rest/MediaAccessKeys.d.ts.map +1 -1
- package/dist/rest/MediaAccessKeys.js +42 -1
- package/dist/rest/MediaAccessKeys.js.map +1 -1
- package/dist/rest/MediaStreamHandler.d.ts +3 -2
- package/dist/rest/MediaStreamHandler.d.ts.map +1 -1
- package/dist/rest/MediaStreamHandler.js +83 -2
- package/dist/rest/MediaStreamHandler.js.map +1 -1
- package/dist/rest/OAuthCallbackHandler.d.ts +49 -1
- package/dist/rest/OAuthCallbackHandler.d.ts.map +1 -1
- package/dist/rest/OAuthCallbackHandler.js +129 -43
- package/dist/rest/OAuthCallbackHandler.js.map +1 -1
- package/dist/rest/UploadTokenManager.d.ts +90 -0
- package/dist/rest/UploadTokenManager.d.ts.map +1 -0
- package/dist/rest/UploadTokenManager.js +156 -0
- package/dist/rest/UploadTokenManager.js.map +1 -0
- package/dist/services/IntegrationSyncWorkerService.d.ts +48 -0
- package/dist/services/IntegrationSyncWorkerService.d.ts.map +1 -0
- package/dist/services/IntegrationSyncWorkerService.js +132 -0
- package/dist/services/IntegrationSyncWorkerService.js.map +1 -0
- package/dist/services/StartTaskGraphDispatcher.d.ts +0 -10
- package/dist/services/StartTaskGraphDispatcher.d.ts.map +1 -1
- package/dist/services/StartTaskGraphDispatcher.js +21 -1
- package/dist/services/StartTaskGraphDispatcher.js.map +1 -1
- package/dist/services/TaskGraphAgentRunner.d.ts +7 -0
- package/dist/services/TaskGraphAgentRunner.d.ts.map +1 -1
- package/dist/services/TaskGraphAgentRunner.js +23 -0
- package/dist/services/TaskGraphAgentRunner.js.map +1 -1
- package/dist/services/TaskGraphContinuationDeliverer.d.ts.map +1 -1
- package/dist/services/TaskGraphContinuationDeliverer.js +12 -1
- package/dist/services/TaskGraphContinuationDeliverer.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +91 -91
- package/src/__tests__/APIKeyScopeAuth.test.ts +475 -0
- package/src/__tests__/AuthProviderEngine.test.ts +278 -0
- package/src/__tests__/EntityCRUDHandler.test.ts +378 -0
- package/src/__tests__/IntegrationSyncWorkerService.test.ts +275 -0
- package/src/__tests__/OAuthCallbackHandler.openRedirect.test.ts +117 -0
- package/src/__tests__/OAuthCallbackHandler.xss.test.ts +4 -1
- package/src/__tests__/RESTEndpointHandler.test.ts +672 -0
- package/src/__tests__/RSUProgressBridge.test.ts +250 -0
- package/src/__tests__/RealtimeBridgeResolver.test.ts +10 -2
- package/src/__tests__/SchemaRefreshLaunch.test.ts +114 -0
- package/src/__tests__/UserResolver.currentUser.test.ts +87 -0
- package/src/__tests__/ViewOperationsHandler.test.ts +277 -0
- package/src/__tests__/config-units.test.ts +74 -0
- package/src/__tests__/initializeProviders.refresh.test.ts +146 -0
- package/src/__tests__/mjapi-bootstrap.test.ts +0 -6
- package/src/__tests__/newUsers.test.ts +726 -0
- package/src/__tests__/uploadTokenManager.test.ts +159 -0
- package/src/auth/AuthProviderCatalogRouter.ts +76 -0
- package/src/auth/AuthProviderEngine.ts +253 -0
- package/src/auth/index.ts +59 -15
- package/src/auth/initializeProviders.ts +128 -7
- package/src/config.ts +55 -36
- package/src/generated/generated.ts +1911 -10551
- package/src/generic/ResolverBase.ts +11 -4
- package/src/generic/RunViewResolver.ts +31 -0
- package/src/index.ts +108 -15
- package/src/integration/RSUProgressBridge.ts +248 -0
- package/src/integration/SchemaRefreshLaunch.ts +77 -0
- package/src/providerConfigUnits.ts +21 -0
- package/src/resolvers/FileResolver.ts +200 -40
- package/src/resolvers/IntegrationDiscoveryResolver.ts +316 -68
- package/src/resolvers/QueryResolver.ts +25 -11
- package/src/resolvers/QuerySystemUserResolver.ts +28 -13
- package/src/resolvers/RunAIAgentResolver.ts +21 -6
- package/src/resolvers/TaskGraphFrameResolver.ts +67 -0
- package/src/resolvers/UserResolver.ts +99 -60
- package/src/resolvers/currentUserRoles.ts +47 -0
- package/src/rest/MediaAccessKeys.ts +47 -1
- package/src/rest/MediaStreamHandler.ts +98 -3
- package/src/rest/OAuthCallbackHandler.ts +149 -41
- package/src/rest/UploadTokenManager.ts +211 -0
- package/src/services/IntegrationSyncWorkerService.ts +141 -0
- package/src/services/StartTaskGraphDispatcher.ts +21 -1
- package/src/services/TaskGraphAgentRunner.ts +23 -0
- package/src/services/TaskGraphContinuationDeliverer.ts +11 -1
- package/src/types.ts +6 -0
package/dist/auth/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import sql from 'mssql';
|
|
|
3
3
|
import { UserInfo } from '@memberjunction/core';
|
|
4
4
|
export * from './APIKeyScopeAuth.js';
|
|
5
5
|
export * from './actingContextResolver.js';
|
|
6
|
+
export * from './AuthProviderEngine.js';
|
|
7
|
+
export * from './AuthProviderCatalogRouter.js';
|
|
8
|
+
export { initializeAuthProviders, initializeAuthProvidersFromMetadata, refreshAuthProviders, validateAuthProvidersRegistered } from './initializeProviders.js';
|
|
6
9
|
/**
|
|
7
10
|
* Gets validation options for a specific issuer.
|
|
8
11
|
* When multiple providers share the same issuer (e.g. two Auth0 apps on
|
|
@@ -57,5 +60,13 @@ export declare const extractUserInfoFromPayload: (payload: JwtPayload) => {
|
|
|
57
60
|
preferredUsername?: string;
|
|
58
61
|
};
|
|
59
62
|
export declare const getSystemUser: (dataSource?: sql.ConnectionPool, attemptCacheUpdateIfNeeded?: boolean) => Promise<UserInfo>;
|
|
63
|
+
/**
|
|
64
|
+
* Resolves a verified identity to an MJ `UserInfo`, optionally auto-provisioning a new user.
|
|
65
|
+
*
|
|
66
|
+
* @param requestDomain the hostname parsed from the request's `Origin` header. **Not used for any
|
|
67
|
+
* authorization decision** — it is spoofable on non-browser requests, and new-user domain
|
|
68
|
+
* authorization runs against the verified JWT's email domain instead. Retained for audit
|
|
69
|
+
* logging and for the recursive retry call.
|
|
70
|
+
*/
|
|
60
71
|
export declare const verifyUserRecord: (email?: string, firstName?: string, lastName?: string, requestDomain?: string, dataSource?: sql.ConnectionPool, attemptCacheUpdateIfNeeded?: boolean) => Promise<UserInfo | undefined>;
|
|
61
72
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/auth/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGzE,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,EAA4C,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAO1F,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGzE,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,EAA4C,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAO1F,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,mCAAmC,EAAE,oBAAoB,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAC;AAsC/J;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,KAAG;IAAE,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CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAiC5B,CAAC;AAEF,eAAO,MAAM,aAAa,GAAU,aAAa,GAAG,CAAC,cAAc,EAAE,6BAA4B,OAAc,KAAG,OAAO,CAAC,QAAQ,CAYjI,CAAC;AA8BF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,MAAM,EACd,YAAY,MAAM,EAClB,WAAW,MAAM,EACjB,gBAAgB,MAAM,EACtB,aAAa,GAAG,CAAC,cAAc,EAC/B,6BAA4B,OAAc,KACzC,OAAO,CAAC,QAAQ,GAAG,SAAS,CA8E9B,CAAC"}
|
package/dist/auth/index.js
CHANGED
|
@@ -7,6 +7,9 @@ import { AuthProviderFactory } from '@memberjunction/auth-providers';
|
|
|
7
7
|
import { initializeAuthProviders } from './initializeProviders.js';
|
|
8
8
|
export * from './APIKeyScopeAuth.js';
|
|
9
9
|
export * from './actingContextResolver.js';
|
|
10
|
+
export * from './AuthProviderEngine.js';
|
|
11
|
+
export * from './AuthProviderCatalogRouter.js';
|
|
12
|
+
export { initializeAuthProviders, initializeAuthProvidersFromMetadata, refreshAuthProviders, validateAuthProvidersRegistered } from './initializeProviders.js';
|
|
10
13
|
// This is a hard-coded forever constant due to internal migrations
|
|
11
14
|
class MissingAuthError extends Error {
|
|
12
15
|
constructor() {
|
|
@@ -136,6 +139,40 @@ export const getSystemUser = async (dataSource, attemptCacheUpdateIfNeeded = tru
|
|
|
136
139
|
}
|
|
137
140
|
return systemUser;
|
|
138
141
|
};
|
|
142
|
+
/**
|
|
143
|
+
* Extracts the lowercased domain portion of an email address.
|
|
144
|
+
*
|
|
145
|
+
* @returns the domain, or an empty string when the value is not an email address (e.g. an IdP that
|
|
146
|
+
* issues a bare username). Callers MUST treat an empty result as "cannot be authorized"
|
|
147
|
+
* rather than as a wildcard.
|
|
148
|
+
*/
|
|
149
|
+
const extractEmailDomain = (email) => {
|
|
150
|
+
const parts = email.split('@');
|
|
151
|
+
// Reject anything that isn't exactly local@domain — a value with 0 or 2+ '@' is not an address we
|
|
152
|
+
// can make a trust decision about.
|
|
153
|
+
if (parts.length !== 2)
|
|
154
|
+
return '';
|
|
155
|
+
return parts[1].toLowerCase().trim();
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Tests a domain against `userHandling.newUserAuthorizedDomains`, honoring `*` wildcards.
|
|
159
|
+
*
|
|
160
|
+
* Note that a pattern is matched in full, so `*.example.com` matches `mail.example.com` but NOT
|
|
161
|
+
* `example.com` — list both if you need both.
|
|
162
|
+
*/
|
|
163
|
+
const isDomainAuthorized = (domain) => configInfo.userHandling.newUserAuthorizedDomains.some((pattern) => {
|
|
164
|
+
// Convert wildcard domain patterns to regular expressions
|
|
165
|
+
const regex = new RegExp('^' + pattern.toLowerCase().trim().replace(/\./g, '\\.').replace(/\*/g, '.*') + '$');
|
|
166
|
+
return regex.test(domain);
|
|
167
|
+
});
|
|
168
|
+
/**
|
|
169
|
+
* Resolves a verified identity to an MJ `UserInfo`, optionally auto-provisioning a new user.
|
|
170
|
+
*
|
|
171
|
+
* @param requestDomain the hostname parsed from the request's `Origin` header. **Not used for any
|
|
172
|
+
* authorization decision** — it is spoofable on non-browser requests, and new-user domain
|
|
173
|
+
* authorization runs against the verified JWT's email domain instead. Retained for audit
|
|
174
|
+
* logging and for the recursive retry call.
|
|
175
|
+
*/
|
|
139
176
|
export const verifyUserRecord = async (email, firstName, lastName, requestDomain, dataSource, attemptCacheUpdateIfNeeded = true) => {
|
|
140
177
|
if (!email)
|
|
141
178
|
return undefined;
|
|
@@ -150,20 +187,20 @@ export const verifyUserRecord = async (email, firstName, lastName, requestDomain
|
|
|
150
187
|
return u.Email.toLowerCase().trim() === email.toLowerCase().trim();
|
|
151
188
|
});
|
|
152
189
|
if (!user) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
190
|
+
// NOTE: `requestDomain` (parsed from the spoofable `Origin` header) is deliberately NOT part of
|
|
191
|
+
// this condition. It was previously required here, which meant a non-browser client sending no
|
|
192
|
+
// Origin could never auto-provision while an attacker simply forged one — it gated entry without
|
|
193
|
+
// authorizing anything. Authorization happens below, against the verified identity's email domain.
|
|
194
|
+
if (configInfo.userHandling.autoCreateNewUsers && firstName && lastName) {
|
|
195
|
+
// SECURITY: authorize against the EMAIL DOMAIN of the cryptographically-verified identity,
|
|
196
|
+
// NOT the request `Origin` header. Origin is trivially spoofable on non-browser / bearer-token
|
|
197
|
+
// requests, so gating on it let a holder of any valid IdP token auto-provision an account under
|
|
198
|
+
// an authorized domain by sending a forged Origin. The email comes from the verified JWT.
|
|
199
|
+
const emailDomain = extractEmailDomain(email);
|
|
158
200
|
let passesDomainCheck = configInfo.userHandling.newUserLimitedToAuthorizedDomains ===
|
|
159
201
|
false; /*in this first condition, we are set up to NOT care about domain */
|
|
160
|
-
if (!passesDomainCheck
|
|
161
|
-
|
|
162
|
-
passesDomainCheck = configInfo.userHandling.newUserAuthorizedDomains.some((pattern) => {
|
|
163
|
-
// Convert wildcard domain patterns to regular expressions
|
|
164
|
-
const regex = new RegExp('^' + pattern.toLowerCase().trim().replace(/\./g, '\\.').replace(/\*/g, '.*') + '$');
|
|
165
|
-
return regex.test(requestDomain?.toLowerCase().trim());
|
|
166
|
-
});
|
|
202
|
+
if (!passesDomainCheck) {
|
|
203
|
+
passesDomainCheck = emailDomain.length > 0 && isDomainAuthorized(emailDomain);
|
|
167
204
|
}
|
|
168
205
|
if (passesDomainCheck) {
|
|
169
206
|
// we have a domain from the request that matches one of the domains provided by the configuration, so we will create a new user
|
|
@@ -185,8 +222,14 @@ export const verifyUserRecord = async (email, firstName, lastName, requestDomain
|
|
|
185
222
|
console.warn(` >>> New user ${email} created successfully!`);
|
|
186
223
|
}
|
|
187
224
|
}
|
|
225
|
+
else if (emailDomain.length === 0) {
|
|
226
|
+
// The verified identity carries no email domain at all — typically an IdP that issues a bare
|
|
227
|
+
// `preferred_username` with no `email` claim. There is nothing to match against, so the gate
|
|
228
|
+
// denies rather than falling back to anything spoofable.
|
|
229
|
+
console.warn(`User ${email} not found in cache and will NOT be auto-created: the verified identity has no email domain (no '@'), so it cannot be matched against newUserAuthorizedDomains. This usually means the identity provider issues a username rather than an email address — configure it to emit an 'email' claim, or set newUserLimitedToAuthorizedDomains to false to disable domain checking.`);
|
|
230
|
+
}
|
|
188
231
|
else {
|
|
189
|
-
console.warn(`User ${email} not found in cache.
|
|
232
|
+
console.warn(`User ${email} not found in cache. Email domain '${emailDomain}' does not match any of the domains in the newUserAuthorizedDomains setting. NOTE: this check is against the EMAIL DOMAIN of the verified identity, NOT the browser Origin — if newUserAuthorizedDomains lists frontend hostnames (e.g. 'app.example.com'), replace them with email domains (e.g. 'example.com'). To ignore domain, make sure you set the newUserLimitedToAuthorizedDomains setting to false. In this case we are NOT creating a new user.`);
|
|
190
233
|
}
|
|
191
234
|
}
|
|
192
235
|
if (!user && configInfo.userHandling.updateCacheWhenNotFound && dataSource && attemptCacheUpdateIfNeeded) {
|
package/dist/auth/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAEtE,OAAO,EAAwB,QAAQ,EAAY,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,C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,IAAI,CAAC,mBAAmB,KAAK,wBAAwB,CAAC,CAAC;gBACjE,CAAC;YACH,CAAC;iBAAM,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACpC,6FAA6F;gBAC7F,6FAA6F;gBAC7F,yDAAyD;gBACzD,OAAO,CAAC,IAAI,CACV,QAAQ,KAAK,gXAAgX,CAC9X,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CACV,QAAQ,KAAK,sCAAsC,WAAW,4bAA4b,CAC3f,CAAC;YACJ,CAAC;QACH,CAAC;QAED,IAAI,CAAC,IAAI,IAAI,UAAU,CAAC,YAAY,CAAC,uBAAuB,IAAI,UAAU,IAAI,0BAA0B,EAAE,CAAC;YACzG,yLAAyL;YACzL,OAAO,CAAC,IAAI,CAAC,QAAQ,KAAK,oEAAoE,CAAC,CAAC;YAEhG,MAAM,gBAAgB,EAAE,CAAC;YAEzB,OAAO,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,mEAAmE;QAC5J,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,sCAAsC;AACtC,uBAAuB,EAAE,CAAC"}
|
|
@@ -1,5 +1,68 @@
|
|
|
1
|
+
import { UserInfo, type IMetadataProvider } from '@memberjunction/core';
|
|
1
2
|
/**
|
|
2
|
-
* Initialize authentication providers from configuration
|
|
3
|
+
* Initialize authentication providers from configuration.
|
|
4
|
+
*
|
|
5
|
+
* Registers everything declared in `mj.config.cjs`'s `authProviders` array. This remains the
|
|
6
|
+
* baseline path and runs on every boot: it needs no database, so it is what lets the server
|
|
7
|
+
* authenticate even when metadata is unreachable.
|
|
8
|
+
*
|
|
9
|
+
* Providers defined in the `MJ: Authentication Providers` catalog are layered on top by
|
|
10
|
+
* {@link initializeAuthProvidersFromMetadata}, which runs later in startup once a database
|
|
11
|
+
* connection and a system user exist.
|
|
3
12
|
*/
|
|
4
13
|
export declare function initializeAuthProviders(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Layers the metadata provider catalog on top of the config-declared providers.
|
|
16
|
+
*
|
|
17
|
+
* Called after the data provider and system user are available. Metadata rows are registered in
|
|
18
|
+
* addition to — not instead of — the config-declared ones: a deployment mid-migration may
|
|
19
|
+
* legitimately have both, and a name collision resolves to the metadata row because it registers
|
|
20
|
+
* last and `AuthProviderFactory.register` keys by provider name.
|
|
21
|
+
*
|
|
22
|
+
* Never throws. An unreachable or empty catalog leaves the config-declared providers exactly as
|
|
23
|
+
* they were, which is what makes adopting this feature a no-op for existing deployments and keeps
|
|
24
|
+
* a metadata problem from turning into a lockout.
|
|
25
|
+
*
|
|
26
|
+
* @returns the number of providers registered from metadata.
|
|
27
|
+
*/
|
|
28
|
+
export declare function initializeAuthProvidersFromMetadata(contextUser?: UserInfo, provider?: IMetadataProvider): Promise<number>;
|
|
29
|
+
/**
|
|
30
|
+
* Rebuilds the provider registry from scratch: config-declared providers first, then the
|
|
31
|
+
* metadata catalog layered on top — the same two-source order as startup.
|
|
32
|
+
*
|
|
33
|
+
* This is THE entry point for reacting to a catalog edit at runtime (an admin page's Save
|
|
34
|
+
* button, a future invalidation hook). A full rebuild is required because the factory caches
|
|
35
|
+
* issuer→provider resolutions, so an edited row would otherwise keep serving its old
|
|
36
|
+
* configuration until the process restarted. It lives here rather than on `AuthProviderEngine`
|
|
37
|
+
* because a bare `factory.clear()` + metadata re-registration would silently drop everything
|
|
38
|
+
* the config path registered — magic-link included — and no caller should have to know to put
|
|
39
|
+
* those back. `initializeAuthProviders()` clears the factory itself, so no separate clear step
|
|
40
|
+
* exists for a caller to forget.
|
|
41
|
+
*
|
|
42
|
+
* **Failure policy: abort-before-mutate.** Everything that can throw — the catalog reload and
|
|
43
|
+
* the permission probe on its result — runs BEFORE the factory is touched, so a failed refresh
|
|
44
|
+
* leaves the registry serving the previous (stale but complete) provider set and surfaces the
|
|
45
|
+
* error to the caller. This is deliberately the opposite of `initializeAuthProvidersFromMetadata`,
|
|
46
|
+
* which swallows metadata failures: at boot there is no previous registry to preserve and a
|
|
47
|
+
* metadata problem must not become a lockout, while at refresh time there is one and the caller
|
|
48
|
+
* (an admin UI) wants the error. That difference in failure policy is why this function does not
|
|
49
|
+
* simply delegate to its sibling.
|
|
50
|
+
*
|
|
51
|
+
* Known limitation, acceptable for an admin-triggered operation: metadata providers are absent
|
|
52
|
+
* from the registry for the duration of `RegisterAll`'s per-row config builds (config-declared
|
|
53
|
+
* providers are restored synchronously). A request bearing a metadata-declared IdP's token in
|
|
54
|
+
* that window is rejected. If a caller ever needs an atomic swap, build the configs first and
|
|
55
|
+
* register them in one synchronous pass.
|
|
56
|
+
*
|
|
57
|
+
* @returns the number of providers registered from metadata after the refresh.
|
|
58
|
+
*/
|
|
59
|
+
export declare function refreshAuthProviders(contextUser?: UserInfo, provider?: IMetadataProvider): Promise<number>;
|
|
60
|
+
/**
|
|
61
|
+
* Reports whether any provider is registered, from either source, and logs a diagnostic when none
|
|
62
|
+
* is.
|
|
63
|
+
*
|
|
64
|
+
* Split out from {@link initializeAuthProviders} because "no providers" is only genuinely wrong
|
|
65
|
+
* once BOTH sources have had their turn.
|
|
66
|
+
*/
|
|
67
|
+
export declare function validateAuthProvidersRegistered(): boolean;
|
|
5
68
|
//# sourceMappingURL=initializeProviders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializeProviders.d.ts","sourceRoot":"","sources":["../../src/auth/initializeProviders.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initializeProviders.d.ts","sourceRoot":"","sources":["../../src/auth/initializeProviders.ts"],"names":[],"mappings":"AACA,OAAO,EAAwD,QAAQ,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAI9H;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CA4C9C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mCAAmC,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAa/H;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,oBAAoB,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAchH;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,IAAI,OAAO,CASzD"}
|
|
@@ -1,13 +1,41 @@
|
|
|
1
1
|
import { configInfo } from '../config.js';
|
|
2
|
-
import { LogError } from '@memberjunction/core';
|
|
2
|
+
import { LogError, LogStatus, LogStatusEx } from '@memberjunction/core';
|
|
3
3
|
import { AuthProviderFactory } from '@memberjunction/auth-providers';
|
|
4
|
+
import { AuthProviderEngine } from './AuthProviderEngine.js';
|
|
4
5
|
/**
|
|
5
|
-
* Initialize authentication providers from configuration
|
|
6
|
+
* Initialize authentication providers from configuration.
|
|
7
|
+
*
|
|
8
|
+
* Registers everything declared in `mj.config.cjs`'s `authProviders` array. This remains the
|
|
9
|
+
* baseline path and runs on every boot: it needs no database, so it is what lets the server
|
|
10
|
+
* authenticate even when metadata is unreachable.
|
|
11
|
+
*
|
|
12
|
+
* Providers defined in the `MJ: Authentication Providers` catalog are layered on top by
|
|
13
|
+
* {@link initializeAuthProvidersFromMetadata}, which runs later in startup once a database
|
|
14
|
+
* connection and a system user exist.
|
|
6
15
|
*/
|
|
7
16
|
export function initializeAuthProviders() {
|
|
8
17
|
const factory = AuthProviderFactory.Instance;
|
|
9
18
|
// Clear any existing providers
|
|
10
19
|
factory.clear();
|
|
20
|
+
// Environment-derived providers are DEFAULTS: each provider class maps its own variables via
|
|
21
|
+
// the ConfigFromEnvironment hook, and they apply only when the config file declares no
|
|
22
|
+
// providers of its own. That mirrors the previous behaviour exactly — the env block used to sit
|
|
23
|
+
// in DEFAULT_SERVER_CONFIG, and mergeConfigs replaces (rather than concatenates) arrays, so an
|
|
24
|
+
// explicit `authProviders` in mj.config.cjs has always suppressed the env-derived set.
|
|
25
|
+
//
|
|
26
|
+
// Written back into configInfo.authProviders rather than kept local because that array is the
|
|
27
|
+
// live registry other code reads and appends to (registerMagicLinkAuthProvider pushes into it so
|
|
28
|
+
// a later re-initialize keeps magic-link).
|
|
29
|
+
if (!configInfo.authProviders || configInfo.authProviders.length === 0) {
|
|
30
|
+
const discovered = AuthProviderFactory.DiscoverFromEnvironment();
|
|
31
|
+
if (discovered.length > 0) {
|
|
32
|
+
configInfo.authProviders = discovered;
|
|
33
|
+
LogStatusEx({
|
|
34
|
+
message: `[Auth] Configured ${discovered.length} provider(s) from environment variables: ${discovered.map((p) => p.name).join(', ')}`,
|
|
35
|
+
verboseOnly: true
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
11
39
|
// Initialize providers from authProviders config
|
|
12
40
|
if (configInfo.authProviders && configInfo.authProviders.length > 0) {
|
|
13
41
|
for (const providerConfig of configInfo.authProviders) {
|
|
@@ -23,9 +51,93 @@ export function initializeAuthProviders() {
|
|
|
23
51
|
}
|
|
24
52
|
}
|
|
25
53
|
}
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
54
|
+
// NOTE: the "no providers configured" check deliberately does NOT live here any more — see
|
|
55
|
+
// validateAuthProvidersRegistered(). A metadata-only deployment legitimately has an empty
|
|
56
|
+
// authProviders array at this point, and erroring here would cry wolf on every boot.
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Layers the metadata provider catalog on top of the config-declared providers.
|
|
60
|
+
*
|
|
61
|
+
* Called after the data provider and system user are available. Metadata rows are registered in
|
|
62
|
+
* addition to — not instead of — the config-declared ones: a deployment mid-migration may
|
|
63
|
+
* legitimately have both, and a name collision resolves to the metadata row because it registers
|
|
64
|
+
* last and `AuthProviderFactory.register` keys by provider name.
|
|
65
|
+
*
|
|
66
|
+
* Never throws. An unreachable or empty catalog leaves the config-declared providers exactly as
|
|
67
|
+
* they were, which is what makes adopting this feature a no-op for existing deployments and keeps
|
|
68
|
+
* a metadata problem from turning into a lockout.
|
|
69
|
+
*
|
|
70
|
+
* @returns the number of providers registered from metadata.
|
|
71
|
+
*/
|
|
72
|
+
export async function initializeAuthProvidersFromMetadata(contextUser, provider) {
|
|
73
|
+
try {
|
|
74
|
+
await AuthProviderEngine.Instance.Config(false, contextUser, provider);
|
|
75
|
+
const count = await AuthProviderEngine.Instance.RegisterAll(contextUser);
|
|
76
|
+
if (count > 0) {
|
|
77
|
+
LogStatus(`[Auth] ${count} authentication provider(s) registered from metadata.`);
|
|
78
|
+
}
|
|
79
|
+
return count;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
83
|
+
LogError(`[Auth] Could not load the authentication provider catalog from metadata (${message}). Continuing with providers from mj.config.cjs.`);
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Rebuilds the provider registry from scratch: config-declared providers first, then the
|
|
89
|
+
* metadata catalog layered on top — the same two-source order as startup.
|
|
90
|
+
*
|
|
91
|
+
* This is THE entry point for reacting to a catalog edit at runtime (an admin page's Save
|
|
92
|
+
* button, a future invalidation hook). A full rebuild is required because the factory caches
|
|
93
|
+
* issuer→provider resolutions, so an edited row would otherwise keep serving its old
|
|
94
|
+
* configuration until the process restarted. It lives here rather than on `AuthProviderEngine`
|
|
95
|
+
* because a bare `factory.clear()` + metadata re-registration would silently drop everything
|
|
96
|
+
* the config path registered — magic-link included — and no caller should have to know to put
|
|
97
|
+
* those back. `initializeAuthProviders()` clears the factory itself, so no separate clear step
|
|
98
|
+
* exists for a caller to forget.
|
|
99
|
+
*
|
|
100
|
+
* **Failure policy: abort-before-mutate.** Everything that can throw — the catalog reload and
|
|
101
|
+
* the permission probe on its result — runs BEFORE the factory is touched, so a failed refresh
|
|
102
|
+
* leaves the registry serving the previous (stale but complete) provider set and surfaces the
|
|
103
|
+
* error to the caller. This is deliberately the opposite of `initializeAuthProvidersFromMetadata`,
|
|
104
|
+
* which swallows metadata failures: at boot there is no previous registry to preserve and a
|
|
105
|
+
* metadata problem must not become a lockout, while at refresh time there is one and the caller
|
|
106
|
+
* (an admin UI) wants the error. That difference in failure policy is why this function does not
|
|
107
|
+
* simply delegate to its sibling.
|
|
108
|
+
*
|
|
109
|
+
* Known limitation, acceptable for an admin-triggered operation: metadata providers are absent
|
|
110
|
+
* from the registry for the duration of `RegisterAll`'s per-row config builds (config-declared
|
|
111
|
+
* providers are restored synchronously). A request bearing a metadata-declared IdP's token in
|
|
112
|
+
* that window is rejected. If a caller ever needs an atomic swap, build the configs first and
|
|
113
|
+
* register them in one synchronous pass.
|
|
114
|
+
*
|
|
115
|
+
* @returns the number of providers registered from metadata after the refresh.
|
|
116
|
+
*/
|
|
117
|
+
export async function refreshAuthProviders(contextUser, provider) {
|
|
118
|
+
await AuthProviderEngine.Instance.Config(true, contextUser, provider);
|
|
119
|
+
// Probe the reloaded catalog BEFORE clearing anything: reading Providers throws
|
|
120
|
+
// PermissionConstrainedError when the load was skipped for permission reasons, and that
|
|
121
|
+
// failure must abort the refresh while the registry is still intact.
|
|
122
|
+
const pendingRows = AuthProviderEngine.Instance.Providers.length;
|
|
123
|
+
initializeAuthProviders();
|
|
124
|
+
const count = await AuthProviderEngine.Instance.RegisterAll(contextUser);
|
|
125
|
+
LogStatus(`[Auth] Provider registry refreshed — ${count} of ${pendingRows} metadata provider(s) registered on top of the config-declared set.`);
|
|
126
|
+
return count;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Reports whether any provider is registered, from either source, and logs a diagnostic when none
|
|
130
|
+
* is.
|
|
131
|
+
*
|
|
132
|
+
* Split out from {@link initializeAuthProviders} because "no providers" is only genuinely wrong
|
|
133
|
+
* once BOTH sources have had their turn.
|
|
134
|
+
*/
|
|
135
|
+
export function validateAuthProvidersRegistered() {
|
|
136
|
+
const hasProviders = AuthProviderFactory.Instance.hasProviders();
|
|
137
|
+
if (!hasProviders) {
|
|
138
|
+
LogError('No authentication providers are configured. Define them in the "MJ: Authentication Providers" metadata entity, ' +
|
|
139
|
+
'or in the authProviders array in mj.config.cjs.');
|
|
29
140
|
}
|
|
141
|
+
return hasProviders;
|
|
30
142
|
}
|
|
31
143
|
//# sourceMappingURL=initializeProviders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializeProviders.js","sourceRoot":"","sources":["../../src/auth/initializeProviders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAsB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"initializeProviders.js","sourceRoot":"","sources":["../../src/auth/initializeProviders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAsB,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAoC,MAAM,sBAAsB,CAAC;AAC9H,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB;IACrC,MAAM,OAAO,GAAG,mBAAmB,CAAC,QAAQ,CAAC;IAE7C,+BAA+B;IAC/B,OAAO,CAAC,KAAK,EAAE,CAAC;IAEhB,6FAA6F;IAC7F,uFAAuF;IACvF,gGAAgG;IAChG,+FAA+F;IAC/F,uFAAuF;IACvF,EAAE;IACF,8FAA8F;IAC9F,iGAAiG;IACjG,2CAA2C;IAC3C,IAAI,CAAC,UAAU,CAAC,aAAa,IAAI,UAAU,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvE,MAAM,UAAU,GAAG,mBA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|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
declare const userHandlingInfoSchema: z.ZodObject<{
|
|
3
3
|
autoCreateNewUsers: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
4
|
+
/** When true, auto-provisioning is restricted to the domains in `newUserAuthorizedDomains`. */
|
|
4
5
|
newUserLimitedToAuthorizedDomains: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
6
|
+
/**
|
|
7
|
+
* Authorized **email domains** for auto-provisioned users — e.g. `['example.com', '*.example.org']`.
|
|
8
|
+
*
|
|
9
|
+
* These are matched against the domain of the email address in the verified identity token, NOT
|
|
10
|
+
* against the browser `Origin` / frontend hostname. If you are upgrading from a build that
|
|
11
|
+
* compared these to the request origin, replace any frontend hostnames here (`app.example.com`,
|
|
12
|
+
* `localhost`) with the email domains your users actually sign in with.
|
|
13
|
+
*
|
|
14
|
+
* `*` wildcards are supported and match in full: `*.example.com` matches `mail.example.com` but
|
|
15
|
+
* NOT `example.com` — list both if you need both.
|
|
16
|
+
*/
|
|
5
17
|
newUserAuthorizedDomains: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
6
18
|
newUserRoles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
7
19
|
updateCacheWhenNotFound: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -332,6 +344,32 @@ declare const scheduledJobsSchema: z.ZodObject<{
|
|
|
332
344
|
defaultLockTimeout?: number;
|
|
333
345
|
staleLockCleanupInterval?: number;
|
|
334
346
|
}>;
|
|
347
|
+
/**
|
|
348
|
+
* Integration sync worker (PR 1 item 8). When enabled, this process polls
|
|
349
|
+
* `CompanyIntegrationRun` for `Status='Queued'` rows, atomically claims them, executes
|
|
350
|
+
* the sync, and releases. The claim sproc is the mutual exclusion, so any number of
|
|
351
|
+
* processes may run a worker against the same database.
|
|
352
|
+
*/
|
|
353
|
+
declare const integrationSyncWorkerSchema: z.ZodObject<{
|
|
354
|
+
/** Master switch — off by default so existing deployments keep running syncs inline. */
|
|
355
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
356
|
+
/** Email of the user the worker executes syncs as. */
|
|
357
|
+
systemUserEmail: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
358
|
+
/** How often to poll the queue, in ms. */
|
|
359
|
+
pollingIntervalMs: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
360
|
+
/** Maximum runs this worker executes concurrently. */
|
|
361
|
+
maxConcurrentRuns: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
362
|
+
}, "strip", z.ZodTypeAny, {
|
|
363
|
+
enabled?: boolean;
|
|
364
|
+
systemUserEmail?: string;
|
|
365
|
+
pollingIntervalMs?: number;
|
|
366
|
+
maxConcurrentRuns?: number;
|
|
367
|
+
}, {
|
|
368
|
+
enabled?: boolean;
|
|
369
|
+
systemUserEmail?: string;
|
|
370
|
+
pollingIntervalMs?: number;
|
|
371
|
+
maxConcurrentRuns?: number;
|
|
372
|
+
}>;
|
|
335
373
|
declare const queryDialectSchema: z.ZodObject<{
|
|
336
374
|
/** When true, saving a Query entity auto-generates QuerySQL entries for configured target dialects */
|
|
337
375
|
autoConvertOnSave: z.ZodDefault<z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodNumber]>>>, boolean, string | number | boolean>>;
|
|
@@ -1764,7 +1802,19 @@ declare const telephonySchema: z.ZodObject<{
|
|
|
1764
1802
|
declare const configInfoSchema: z.ZodObject<{
|
|
1765
1803
|
userHandling: z.ZodObject<{
|
|
1766
1804
|
autoCreateNewUsers: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
1805
|
+
/** When true, auto-provisioning is restricted to the domains in `newUserAuthorizedDomains`. */
|
|
1767
1806
|
newUserLimitedToAuthorizedDomains: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
1807
|
+
/**
|
|
1808
|
+
* Authorized **email domains** for auto-provisioned users — e.g. `['example.com', '*.example.org']`.
|
|
1809
|
+
*
|
|
1810
|
+
* These are matched against the domain of the email address in the verified identity token, NOT
|
|
1811
|
+
* against the browser `Origin` / frontend hostname. If you are upgrading from a build that
|
|
1812
|
+
* compared these to the request origin, replace any frontend hostnames here (`app.example.com`,
|
|
1813
|
+
* `localhost`) with the email domains your users actually sign in with.
|
|
1814
|
+
*
|
|
1815
|
+
* `*` wildcards are supported and match in full: `*.example.com` matches `mail.example.com` but
|
|
1816
|
+
* NOT `example.com` — list both if you need both.
|
|
1817
|
+
*/
|
|
1768
1818
|
newUserAuthorizedDomains: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
1769
1819
|
newUserRoles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
1770
1820
|
updateCacheWhenNotFound: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -2963,6 +3013,26 @@ declare const configInfoSchema: z.ZodObject<{
|
|
|
2963
3013
|
defaultLockTimeout?: number;
|
|
2964
3014
|
staleLockCleanupInterval?: number;
|
|
2965
3015
|
}>>>;
|
|
3016
|
+
integrationSyncWorker: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
3017
|
+
/** Master switch — off by default so existing deployments keep running syncs inline. */
|
|
3018
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
3019
|
+
/** Email of the user the worker executes syncs as. */
|
|
3020
|
+
systemUserEmail: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
3021
|
+
/** How often to poll the queue, in ms. */
|
|
3022
|
+
pollingIntervalMs: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
3023
|
+
/** Maximum runs this worker executes concurrently. */
|
|
3024
|
+
maxConcurrentRuns: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
3025
|
+
}, "strip", z.ZodTypeAny, {
|
|
3026
|
+
enabled?: boolean;
|
|
3027
|
+
systemUserEmail?: string;
|
|
3028
|
+
pollingIntervalMs?: number;
|
|
3029
|
+
maxConcurrentRuns?: number;
|
|
3030
|
+
}, {
|
|
3031
|
+
enabled?: boolean;
|
|
3032
|
+
systemUserEmail?: string;
|
|
3033
|
+
pollingIntervalMs?: number;
|
|
3034
|
+
maxConcurrentRuns?: number;
|
|
3035
|
+
}>>>;
|
|
2966
3036
|
telemetry: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
2967
3037
|
enabled: z.ZodDefault<z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodNumber]>>>, boolean, string | number | boolean>>;
|
|
2968
3038
|
level: z.ZodDefault<z.ZodOptional<z.ZodEnum<["minimal", "standard", "verbose", "debug"]>>>;
|
|
@@ -3452,6 +3522,12 @@ declare const configInfoSchema: z.ZodObject<{
|
|
|
3452
3522
|
defaultLockTimeout?: number;
|
|
3453
3523
|
staleLockCleanupInterval?: number;
|
|
3454
3524
|
};
|
|
3525
|
+
integrationSyncWorker?: {
|
|
3526
|
+
enabled?: boolean;
|
|
3527
|
+
systemUserEmail?: string;
|
|
3528
|
+
pollingIntervalMs?: number;
|
|
3529
|
+
maxConcurrentRuns?: number;
|
|
3530
|
+
};
|
|
3455
3531
|
telemetry?: {
|
|
3456
3532
|
enabled?: boolean;
|
|
3457
3533
|
level?: "minimal" | "standard" | "verbose" | "debug";
|
|
@@ -3727,6 +3803,12 @@ declare const configInfoSchema: z.ZodObject<{
|
|
|
3727
3803
|
defaultLockTimeout?: number;
|
|
3728
3804
|
staleLockCleanupInterval?: number;
|
|
3729
3805
|
};
|
|
3806
|
+
integrationSyncWorker?: {
|
|
3807
|
+
enabled?: boolean;
|
|
3808
|
+
systemUserEmail?: string;
|
|
3809
|
+
pollingIntervalMs?: number;
|
|
3810
|
+
maxConcurrentRuns?: number;
|
|
3811
|
+
};
|
|
3730
3812
|
telemetry?: {
|
|
3731
3813
|
enabled?: string | number | boolean;
|
|
3732
3814
|
level?: "minimal" | "standard" | "verbose" | "debug";
|
|
@@ -3835,6 +3917,7 @@ export type SqlLoggingInfo = z.infer<typeof sqlLoggingSchema>;
|
|
|
3835
3917
|
export type AuthProviderConfig = z.infer<typeof authProviderSchema>;
|
|
3836
3918
|
export type ComponentRegistryConfig = z.infer<typeof componentRegistrySchema>;
|
|
3837
3919
|
export type ScheduledJobsConfig = z.infer<typeof scheduledJobsSchema>;
|
|
3920
|
+
export type IntegrationSyncWorkerConfig = z.infer<typeof integrationSyncWorkerSchema>;
|
|
3838
3921
|
export type TelemetryConfig = z.infer<typeof telemetrySchema>;
|
|
3839
3922
|
export type QueryDialectConfig = z.infer<typeof queryDialectSchema>;
|
|
3840
3923
|
export type MultiTenancyConfig = z.infer<typeof multiTenancySchema>;
|
|
@@ -4059,6 +4142,12 @@ export declare function loadConfig(): {
|
|
|
4059
4142
|
defaultLockTimeout?: number;
|
|
4060
4143
|
staleLockCleanupInterval?: number;
|
|
4061
4144
|
};
|
|
4145
|
+
integrationSyncWorker?: {
|
|
4146
|
+
enabled?: boolean;
|
|
4147
|
+
systemUserEmail?: string;
|
|
4148
|
+
pollingIntervalMs?: number;
|
|
4149
|
+
maxConcurrentRuns?: number;
|
|
4150
|
+
};
|
|
4062
4151
|
telemetry?: {
|
|
4063
4152
|
enabled?: boolean;
|
|
4064
4153
|
level?: "minimal" | "standard" | "verbose" | "debug";
|