@memberjunction/server 5.14.0 → 5.16.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/auth/index.d.ts +0 -3
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +5 -7
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/initializeProviders.js +2 -2
- package/dist/auth/initializeProviders.js.map +1 -1
- package/dist/config.d.ts +37 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +3 -3
- package/dist/context.js.map +1 -1
- package/dist/generated/generated.d.ts +169 -0
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js +909 -1
- package/dist/generated/generated.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/resolvers/DatasetResolver.d.ts +5 -0
- package/dist/resolvers/DatasetResolver.d.ts.map +1 -1
- package/dist/resolvers/DatasetResolver.js +35 -0
- package/dist/resolvers/DatasetResolver.js.map +1 -1
- package/package.json +60 -59
- package/src/__tests__/unifiedAuth.test.ts +3 -2
- package/src/auth/__tests__/backward-compatibility.test.ts +2 -3
- package/src/auth/index.ts +5 -8
- package/src/auth/initializeProviders.ts +2 -2
- package/src/config.ts +8 -0
- package/src/context.ts +3 -3
- package/src/generated/generated.ts +635 -2
- package/src/index.ts +21 -3
- package/src/resolvers/DatasetResolver.ts +36 -0
- package/dist/auth/AuthProviderFactory.d.ts +0 -68
- package/dist/auth/AuthProviderFactory.d.ts.map +0 -1
- package/dist/auth/AuthProviderFactory.js +0 -155
- package/dist/auth/AuthProviderFactory.js.map +0 -1
- package/dist/auth/BaseAuthProvider.d.ts +0 -41
- package/dist/auth/BaseAuthProvider.d.ts.map +0 -1
- package/dist/auth/BaseAuthProvider.js +0 -102
- package/dist/auth/BaseAuthProvider.js.map +0 -1
- package/dist/auth/IAuthProvider.d.ts +0 -46
- package/dist/auth/IAuthProvider.d.ts.map +0 -1
- package/dist/auth/IAuthProvider.js +0 -2
- package/dist/auth/IAuthProvider.js.map +0 -1
- package/dist/auth/providers/Auth0Provider.d.ts +0 -18
- package/dist/auth/providers/Auth0Provider.d.ts.map +0 -1
- package/dist/auth/providers/Auth0Provider.js +0 -52
- package/dist/auth/providers/Auth0Provider.js.map +0 -1
- package/dist/auth/providers/CognitoProvider.d.ts +0 -18
- package/dist/auth/providers/CognitoProvider.d.ts.map +0 -1
- package/dist/auth/providers/CognitoProvider.js +0 -56
- package/dist/auth/providers/CognitoProvider.js.map +0 -1
- package/dist/auth/providers/GoogleProvider.d.ts +0 -18
- package/dist/auth/providers/GoogleProvider.d.ts.map +0 -1
- package/dist/auth/providers/GoogleProvider.js +0 -51
- package/dist/auth/providers/GoogleProvider.js.map +0 -1
- package/dist/auth/providers/MSALProvider.d.ts +0 -18
- package/dist/auth/providers/MSALProvider.d.ts.map +0 -1
- package/dist/auth/providers/MSALProvider.js +0 -52
- package/dist/auth/providers/MSALProvider.js.map +0 -1
- package/dist/auth/providers/OktaProvider.d.ts +0 -18
- package/dist/auth/providers/OktaProvider.d.ts.map +0 -1
- package/dist/auth/providers/OktaProvider.js +0 -52
- package/dist/auth/providers/OktaProvider.js.map +0 -1
- package/dist/auth/tokenExpiredError.d.ts +0 -5
- package/dist/auth/tokenExpiredError.d.ts.map +0 -1
- package/dist/auth/tokenExpiredError.js +0 -12
- package/dist/auth/tokenExpiredError.js.map +0 -1
- package/src/auth/AuthProviderFactory.ts +0 -182
- package/src/auth/BaseAuthProvider.ts +0 -137
- package/src/auth/IAuthProvider.ts +0 -54
- package/src/auth/providers/Auth0Provider.ts +0 -45
- package/src/auth/providers/CognitoProvider.ts +0 -50
- package/src/auth/providers/GoogleProvider.ts +0 -45
- package/src/auth/providers/MSALProvider.ts +0 -45
- package/src/auth/providers/OktaProvider.ts +0 -46
- package/src/auth/tokenExpiredError.ts +0 -12
package/src/index.ts
CHANGED
|
@@ -66,13 +66,10 @@ export * from './directives/index.js';
|
|
|
66
66
|
export * from './entitySubclasses/MJEntityPermissionEntityServer.server.js';
|
|
67
67
|
export * from './types.js';
|
|
68
68
|
export {
|
|
69
|
-
TokenExpiredError,
|
|
70
69
|
getSystemUser,
|
|
71
70
|
getSigningKeys,
|
|
72
71
|
extractUserInfoFromPayload,
|
|
73
72
|
verifyUserRecord,
|
|
74
|
-
AuthProviderFactory,
|
|
75
|
-
IAuthProvider,
|
|
76
73
|
} from './auth/index.js';
|
|
77
74
|
export * from './auth/APIKeyScopeAuth.js';
|
|
78
75
|
|
|
@@ -152,6 +149,13 @@ const localPath = (p: string) => {
|
|
|
152
149
|
export const createApp = (): Application => express();
|
|
153
150
|
|
|
154
151
|
export const serve = async (resolverPaths: Array<string>, app: Application = createApp(), options?: MJServerOptions): Promise<void> => {
|
|
152
|
+
const t0 = performance.now();
|
|
153
|
+
const lap = (label: string, since: number) => {
|
|
154
|
+
const ms = performance.now() - since;
|
|
155
|
+
console.log(`⏱️ [Startup] ${label}: ${ms.toFixed(0)}ms`);
|
|
156
|
+
return performance.now();
|
|
157
|
+
};
|
|
158
|
+
|
|
155
159
|
const localResolverPaths = ['resolvers/**/*Resolver.{js,ts}', 'generic/*Resolver.{js,ts}', 'generated/generated.{js,ts}'].map(localPath);
|
|
156
160
|
|
|
157
161
|
const combinedResolverPaths = [...resolverPaths, ...localResolverPaths];
|
|
@@ -260,6 +264,7 @@ export const serve = async (resolverPaths: Array<string>, app: Application = cre
|
|
|
260
264
|
} else {
|
|
261
265
|
// ─── SQL Server Path (existing behavior) ───────────────────────
|
|
262
266
|
console.log('Database type: SQL Server');
|
|
267
|
+
let tPhase = performance.now();
|
|
263
268
|
const pool = new sql.ConnectionPool(createMSSQLConfig());
|
|
264
269
|
|
|
265
270
|
// Handle connection-level errors from dead/stale connections in the pool.
|
|
@@ -270,6 +275,7 @@ export const serve = async (resolverPaths: Array<string>, app: Application = cre
|
|
|
270
275
|
});
|
|
271
276
|
|
|
272
277
|
await pool.connect();
|
|
278
|
+
tPhase = lap('DB Pool Connect', tPhase);
|
|
273
279
|
|
|
274
280
|
dataSources.push(new DataSourceInfo({dataSource: pool, type: 'Read-Write', host: dbHost, port: dbPort, database: dbDatabase, userName: dbUsername}));
|
|
275
281
|
|
|
@@ -294,10 +300,13 @@ export const serve = async (resolverPaths: Array<string>, app: Application = cre
|
|
|
294
300
|
|
|
295
301
|
const config = new SQLServerProviderConfigData(pool, mj_core_schema, cacheRefreshInterval);
|
|
296
302
|
await setupSQLServerClient(config);
|
|
303
|
+
tPhase = lap('Metadata + Provider Setup', tPhase);
|
|
297
304
|
const md = new Metadata();
|
|
298
305
|
console.log(`Data Source has been initialized. ${md?.Entities ? md.Entities.length : 0} entities loaded.`);
|
|
299
306
|
}
|
|
300
307
|
|
|
308
|
+
let tServe = performance.now();
|
|
309
|
+
|
|
301
310
|
// Store queryDialects config in GlobalObjectStore so MJQueryEntityServer can
|
|
302
311
|
// read it without a circular dependency on MJServer
|
|
303
312
|
if (configInfo.queryDialects) {
|
|
@@ -387,6 +396,8 @@ export const serve = async (resolverPaths: Array<string>, app: Application = cre
|
|
|
387
396
|
/******TEST HARNESS FOR CHANGE DETECTION */
|
|
388
397
|
/******TEST HARNESS FOR CHANGE DETECTION */
|
|
389
398
|
|
|
399
|
+
tServe = lap('Telemetry + Cache + APIKey Init', tServe);
|
|
400
|
+
|
|
390
401
|
const dynamicModules = await Promise.all(
|
|
391
402
|
paths.map((modulePath) => {
|
|
392
403
|
try {
|
|
@@ -518,6 +529,8 @@ export const serve = async (resolverPaths: Array<string>, app: Application = cre
|
|
|
518
529
|
}
|
|
519
530
|
});
|
|
520
531
|
|
|
532
|
+
tServe = lap('Resolver + Middleware Discovery', tServe);
|
|
533
|
+
|
|
521
534
|
let schema = mergeSchemas({
|
|
522
535
|
schemas: [
|
|
523
536
|
buildSchemaSync({
|
|
@@ -538,6 +551,8 @@ export const serve = async (resolverPaths: Array<string>, app: Application = cre
|
|
|
538
551
|
schema = transformer(schema);
|
|
539
552
|
}
|
|
540
553
|
|
|
554
|
+
tServe = lap('Schema Build', tServe);
|
|
555
|
+
|
|
541
556
|
const httpServer = createServer(app);
|
|
542
557
|
|
|
543
558
|
const webSocketServer = new WebSocketServer({ server: httpServer, path: graphqlRootPath });
|
|
@@ -723,7 +738,10 @@ export const serve = async (resolverPaths: Array<string>, app: Application = cre
|
|
|
723
738
|
await Promise.resolve(options.onBeforeServe());
|
|
724
739
|
}
|
|
725
740
|
|
|
741
|
+
tServe = lap('Apollo + Express Setup', tServe);
|
|
742
|
+
|
|
726
743
|
await new Promise<void>((resolve) => httpServer.listen({ port: graphqlPort }, resolve));
|
|
744
|
+
lap('Total Startup', t0);
|
|
727
745
|
console.log(`📦 Connected to database: ${dbHost}:${dbPort}/${dbDatabase}`);
|
|
728
746
|
console.log(`🚀 Server ready at http://localhost:${graphqlPort}/`);
|
|
729
747
|
|
|
@@ -120,4 +120,40 @@ export class DatasetStatusResolver extends ResolverBase {
|
|
|
120
120
|
throw new Error('Error retrieving Dataset Status: ' + DatasetName + '\n\n' + err);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Batch version: fetch status for multiple datasets in a single round-trip.
|
|
126
|
+
* Reduces N separate GetDatasetStatusByName calls to 1 network request.
|
|
127
|
+
*/
|
|
128
|
+
@Query(() => [DatasetStatusResultType])
|
|
129
|
+
async GetMultipleDatasetStatusByName(
|
|
130
|
+
@Arg('DatasetNames', () => [String]) DatasetNames: string[],
|
|
131
|
+
@Ctx() { providers, userPayload }: AppContext,
|
|
132
|
+
): Promise<DatasetStatusResultType[]> {
|
|
133
|
+
const md = GetReadOnlyProvider(providers, {allowFallbackToReadWrite: true});
|
|
134
|
+
const results: DatasetStatusResultType[] = [];
|
|
135
|
+
|
|
136
|
+
// Execute all status checks in parallel
|
|
137
|
+
const statusPromises = DatasetNames.map(async (name) => {
|
|
138
|
+
await this.CheckAPIKeyScopeAuthorization('dataset:read', name, userPayload);
|
|
139
|
+
return md.GetDatasetStatusByName(name);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const statuses = await Promise.all(statusPromises);
|
|
143
|
+
|
|
144
|
+
for (const result of statuses) {
|
|
145
|
+
if (result) {
|
|
146
|
+
results.push({
|
|
147
|
+
DatasetID: result.DatasetID,
|
|
148
|
+
DatasetName: result.DatasetName,
|
|
149
|
+
Success: result.Success,
|
|
150
|
+
Status: result.Status,
|
|
151
|
+
LatestUpdateDate: result.LatestUpdateDate,
|
|
152
|
+
EntityUpdateDates: JSON.stringify(result.EntityUpdateDates),
|
|
153
|
+
} as DatasetStatusResultType);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return results;
|
|
158
|
+
}
|
|
123
159
|
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { AuthProviderConfig } from '@memberjunction/core';
|
|
2
|
-
import { IAuthProvider } from './IAuthProvider.js';
|
|
3
|
-
import './providers/Auth0Provider.js';
|
|
4
|
-
import './providers/MSALProvider.js';
|
|
5
|
-
import './providers/OktaProvider.js';
|
|
6
|
-
import './providers/CognitoProvider.js';
|
|
7
|
-
import './providers/GoogleProvider.js';
|
|
8
|
-
/**
|
|
9
|
-
* Factory and registry for managing authentication providers
|
|
10
|
-
* Combines provider creation and lifecycle management in a single class
|
|
11
|
-
*/
|
|
12
|
-
export declare class AuthProviderFactory {
|
|
13
|
-
private static instance;
|
|
14
|
-
private providers;
|
|
15
|
-
private issuerCache;
|
|
16
|
-
private issuerMultiCache;
|
|
17
|
-
private constructor();
|
|
18
|
-
/**
|
|
19
|
-
* Gets the singleton instance of the factory
|
|
20
|
-
*/
|
|
21
|
-
static getInstance(): AuthProviderFactory;
|
|
22
|
-
/**
|
|
23
|
-
* Creates an authentication provider instance based on configuration
|
|
24
|
-
* Uses MJGlobal ClassFactory to instantiate the correct provider class
|
|
25
|
-
*/
|
|
26
|
-
static createProvider(config: AuthProviderConfig): IAuthProvider;
|
|
27
|
-
/**
|
|
28
|
-
* Registers a new authentication provider
|
|
29
|
-
*/
|
|
30
|
-
register(provider: IAuthProvider): void;
|
|
31
|
-
/**
|
|
32
|
-
* Gets a provider by its issuer URL
|
|
33
|
-
*/
|
|
34
|
-
getByIssuer(issuer: string): IAuthProvider | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* Gets all providers matching an issuer URL.
|
|
37
|
-
* Unlike getByIssuer() which returns only the first match, this returns
|
|
38
|
-
* all providers for a given issuer. This is needed when multiple apps
|
|
39
|
-
* (e.g. MJExplorer + MJCentral) share the same Auth0 domain but have
|
|
40
|
-
* different audiences (client IDs).
|
|
41
|
-
*/
|
|
42
|
-
getAllByIssuer(issuer: string): IAuthProvider[];
|
|
43
|
-
/**
|
|
44
|
-
* Gets a provider by its name
|
|
45
|
-
*/
|
|
46
|
-
getByName(name: string): IAuthProvider | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* Gets all registered providers
|
|
49
|
-
*/
|
|
50
|
-
getAllProviders(): IAuthProvider[];
|
|
51
|
-
/**
|
|
52
|
-
* Checks if any providers are registered
|
|
53
|
-
*/
|
|
54
|
-
hasProviders(): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Clears all registered providers (useful for testing)
|
|
57
|
-
*/
|
|
58
|
-
clear(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Gets all registered provider types from the ClassFactory
|
|
61
|
-
*/
|
|
62
|
-
static getRegisteredProviderTypes(): string[];
|
|
63
|
-
/**
|
|
64
|
-
* Checks if a provider type is registered
|
|
65
|
-
*/
|
|
66
|
-
static isProviderTypeRegistered(type: string): boolean;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=AuthProviderFactory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuthProviderFactory.d.ts","sourceRoot":"","sources":["../../src/auth/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@memberjunction/global';
|
|
3
|
-
// Import providers to ensure they're registered
|
|
4
|
-
import './providers/Auth0Provider.js';
|
|
5
|
-
import './providers/MSALProvider.js';
|
|
6
|
-
import './providers/OktaProvider.js';
|
|
7
|
-
import './providers/CognitoProvider.js';
|
|
8
|
-
import './providers/GoogleProvider.js';
|
|
9
|
-
/**
|
|
10
|
-
* Factory and registry for managing authentication providers
|
|
11
|
-
* Combines provider creation and lifecycle management in a single class
|
|
12
|
-
*/
|
|
13
|
-
export class AuthProviderFactory {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.providers = new Map();
|
|
16
|
-
this.issuerCache = new Map();
|
|
17
|
-
this.issuerMultiCache = new Map();
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Gets the singleton instance of the factory
|
|
21
|
-
*/
|
|
22
|
-
static getInstance() {
|
|
23
|
-
if (!AuthProviderFactory.instance) {
|
|
24
|
-
AuthProviderFactory.instance = new AuthProviderFactory();
|
|
25
|
-
}
|
|
26
|
-
return AuthProviderFactory.instance;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Creates an authentication provider instance based on configuration
|
|
30
|
-
* Uses MJGlobal ClassFactory to instantiate the correct provider class
|
|
31
|
-
*/
|
|
32
|
-
static createProvider(config) {
|
|
33
|
-
try {
|
|
34
|
-
// Use MJGlobal ClassFactory to create the provider instance
|
|
35
|
-
// The provider type in config should match the key used in @RegisterClass
|
|
36
|
-
// The config is passed as a constructor parameter via the spread operator
|
|
37
|
-
const provider = MJGlobal.Instance.ClassFactory.CreateInstance(BaseAuthProvider, config.type.toLowerCase(), config);
|
|
38
|
-
if (!provider) {
|
|
39
|
-
throw new Error(`No provider registered for type: ${config.type}`);
|
|
40
|
-
}
|
|
41
|
-
return provider;
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
45
|
-
throw new Error(`Failed to create authentication provider for type '${config.type}': ${message}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Registers a new authentication provider
|
|
50
|
-
*/
|
|
51
|
-
register(provider) {
|
|
52
|
-
if (!provider.validateConfig()) {
|
|
53
|
-
throw new Error(`Invalid configuration for provider: ${provider.name}`);
|
|
54
|
-
}
|
|
55
|
-
this.providers.set(provider.name, provider);
|
|
56
|
-
// Clear issuer caches when registering new provider
|
|
57
|
-
this.issuerCache.clear();
|
|
58
|
-
this.issuerMultiCache.clear();
|
|
59
|
-
console.log(`Registered auth provider: ${provider.name} with issuer: ${provider.issuer}`);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Gets a provider by its issuer URL
|
|
63
|
-
*/
|
|
64
|
-
getByIssuer(issuer) {
|
|
65
|
-
// Check cache first
|
|
66
|
-
if (this.issuerCache.has(issuer)) {
|
|
67
|
-
return this.issuerCache.get(issuer);
|
|
68
|
-
}
|
|
69
|
-
// Search through providers
|
|
70
|
-
for (const provider of this.providers.values()) {
|
|
71
|
-
if (provider.matchesIssuer(issuer)) {
|
|
72
|
-
// Cache for future lookups
|
|
73
|
-
this.issuerCache.set(issuer, provider);
|
|
74
|
-
return provider;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Gets all providers matching an issuer URL.
|
|
81
|
-
* Unlike getByIssuer() which returns only the first match, this returns
|
|
82
|
-
* all providers for a given issuer. This is needed when multiple apps
|
|
83
|
-
* (e.g. MJExplorer + MJCentral) share the same Auth0 domain but have
|
|
84
|
-
* different audiences (client IDs).
|
|
85
|
-
*/
|
|
86
|
-
getAllByIssuer(issuer) {
|
|
87
|
-
// Check multi-provider cache first
|
|
88
|
-
if (this.issuerMultiCache.has(issuer)) {
|
|
89
|
-
return this.issuerMultiCache.get(issuer);
|
|
90
|
-
}
|
|
91
|
-
const matches = [];
|
|
92
|
-
for (const provider of this.providers.values()) {
|
|
93
|
-
if (provider.matchesIssuer(issuer)) {
|
|
94
|
-
matches.push(provider);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (matches.length > 0) {
|
|
98
|
-
this.issuerMultiCache.set(issuer, matches);
|
|
99
|
-
}
|
|
100
|
-
return matches;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Gets a provider by its name
|
|
104
|
-
*/
|
|
105
|
-
getByName(name) {
|
|
106
|
-
return this.providers.get(name);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Gets all registered providers
|
|
110
|
-
*/
|
|
111
|
-
getAllProviders() {
|
|
112
|
-
return Array.from(this.providers.values());
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Checks if any providers are registered
|
|
116
|
-
*/
|
|
117
|
-
hasProviders() {
|
|
118
|
-
return this.providers.size > 0;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Clears all registered providers (useful for testing)
|
|
122
|
-
*/
|
|
123
|
-
clear() {
|
|
124
|
-
this.providers.clear();
|
|
125
|
-
this.issuerCache.clear();
|
|
126
|
-
this.issuerMultiCache.clear();
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Gets all registered provider types from the ClassFactory
|
|
130
|
-
*/
|
|
131
|
-
static getRegisteredProviderTypes() {
|
|
132
|
-
// Get all registrations for BaseAuthProvider from ClassFactory
|
|
133
|
-
const registrations = MJGlobal.Instance.ClassFactory.GetAllRegistrations(BaseAuthProvider);
|
|
134
|
-
// Extract unique keys (provider types) from registrations
|
|
135
|
-
const providerTypes = registrations
|
|
136
|
-
.map(reg => reg.Key)
|
|
137
|
-
.filter((key) => key !== null && key !== undefined);
|
|
138
|
-
// Return unique provider types
|
|
139
|
-
return Array.from(new Set(providerTypes));
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Checks if a provider type is registered
|
|
143
|
-
*/
|
|
144
|
-
static isProviderTypeRegistered(type) {
|
|
145
|
-
try {
|
|
146
|
-
// Try to get the registration for this specific type
|
|
147
|
-
const registration = MJGlobal.Instance.ClassFactory.GetRegistration(BaseAuthProvider, type.toLowerCase());
|
|
148
|
-
return registration !== null && registration !== undefined;
|
|
149
|
-
}
|
|
150
|
-
catch {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
//# sourceMappingURL=AuthProviderFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuthProviderFactory.js","sourceRoot":"","sources":["../../src/auth/AuthProviderFactory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,gDAAgD;AAChD,OAAO,8BAA8B,CAAC;AACtC,OAAO,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;AACrC,OAAO,gCAAgC,CAAC;AACxC,OAAO,+BAA+B,CAAC;AAEvC;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAM9B;QAJQ,cAAS,GAA+B,IAAI,GAAG,EAAE,CAAC;QAClD,gBAAW,GAA+B,IAAI,GAAG,EAAE,CAAC;QACpD,qBAAgB,GAAiC,IAAI,GAAG,EAAE,CAAC;IAE5C,CAAC;IAExB;;OAEG;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAAC;YAClC,mBAAmB,CAAC,QAAQ,GAAG,IAAI,mBAAmB,EAAE,CAAC;QAC3D,CAAC;QACD,OAAO,mBAAmB,CAAC,QAAQ,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,MAA0B;QAC9C,IAAI,CAAC;YACH,4DAA4D;YAC5D,0EAA0E;YAC1E,0EAA0E;YAC1E,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAC5D,gBAAgB,EAChB,MAAM,C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ACjC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,0BAA0B;QAC/B,+DAA+D;QAC/D,MAAM,aAAa,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;QAC3F,0DAA0D;QAC1D,MAAM,aAAa,GAAG,aAAa;aAChC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC;aACnB,MAAM,CAAC,CAAC,GAAG,EAAiB,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,CAAC,CAAC;QACrE,+BAA+B;QAC/B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,wBAAwB,CAAC,IAAY;QAC1C,IAAI,CAAC;YACH,qDAAqD;YACrD,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,eAAe,CAAC,gBAAgB,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;YAC1G,OAAO,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,SAAS,CAAC;QAC7D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { JwtHeader, JwtPayload, SigningKeyCallback } from 'jsonwebtoken';
|
|
2
|
-
import jwksClient from 'jwks-rsa';
|
|
3
|
-
import { AuthProviderConfig, AuthUserInfo } from '@memberjunction/core';
|
|
4
|
-
import { IAuthProvider } from './IAuthProvider.js';
|
|
5
|
-
/**
|
|
6
|
-
* Base implementation of IAuthProvider with common functionality
|
|
7
|
-
* Concrete providers should extend this class and use @RegisterClass decorator
|
|
8
|
-
* with BaseAuthProvider as the base class
|
|
9
|
-
*/
|
|
10
|
-
export declare abstract class BaseAuthProvider implements IAuthProvider {
|
|
11
|
-
name: string;
|
|
12
|
-
issuer: string;
|
|
13
|
-
audience: string;
|
|
14
|
-
jwksUri: string;
|
|
15
|
-
/** OAuth client ID for this provider (used by OAuth proxy for upstream auth) */
|
|
16
|
-
clientId?: string;
|
|
17
|
-
protected config: AuthProviderConfig;
|
|
18
|
-
protected jwksClient: jwksClient.JwksClient;
|
|
19
|
-
constructor(config: AuthProviderConfig);
|
|
20
|
-
/**
|
|
21
|
-
* Validates that required configuration is present
|
|
22
|
-
*/
|
|
23
|
-
validateConfig(): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Gets the signing key for token verification with retry logic
|
|
26
|
-
*/
|
|
27
|
-
getSigningKey(header: JwtHeader, callback: SigningKeyCallback): void;
|
|
28
|
-
/**
|
|
29
|
-
* Retrieves signing key with exponential backoff retry logic
|
|
30
|
-
*/
|
|
31
|
-
private getSigningKeyWithRetry;
|
|
32
|
-
/**
|
|
33
|
-
* Checks if a given issuer URL belongs to this provider
|
|
34
|
-
*/
|
|
35
|
-
matchesIssuer(issuer: string): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Abstract method for extracting user info - must be implemented by each provider
|
|
38
|
-
*/
|
|
39
|
-
abstract extractUserInfo(payload: JwtPayload): AuthUserInfo;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=BaseAuthProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseAuthProvider.d.ts","sourceRoot":"","sources":["../../src/auth/BaseAuthProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,UAAU,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD;;;;GAIG;AACH,8BAAsB,gBAAiB,YAAW,aAAa;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACrC,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC;gBAEhC,MAAM,EAAE,kBAAkB;IAoCtC;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAYpE;;OAEG;YACW,sBAAsB;IAuCpC;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAOtC;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,YAAY;CAC5D"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import jwksClient from 'jwks-rsa';
|
|
2
|
-
import https from 'https';
|
|
3
|
-
import http from 'http';
|
|
4
|
-
/**
|
|
5
|
-
* Base implementation of IAuthProvider with common functionality
|
|
6
|
-
* Concrete providers should extend this class and use @RegisterClass decorator
|
|
7
|
-
* with BaseAuthProvider as the base class
|
|
8
|
-
*/
|
|
9
|
-
export class BaseAuthProvider {
|
|
10
|
-
constructor(config) {
|
|
11
|
-
this.config = config;
|
|
12
|
-
this.name = config.name;
|
|
13
|
-
this.issuer = config.issuer;
|
|
14
|
-
this.audience = config.audience;
|
|
15
|
-
this.jwksUri = config.jwksUri;
|
|
16
|
-
this.clientId = config.clientId;
|
|
17
|
-
// Create HTTP agent with keep-alive to prevent socket hangups
|
|
18
|
-
const agent = this.jwksUri.startsWith('https')
|
|
19
|
-
? new https.Agent({
|
|
20
|
-
keepAlive: true,
|
|
21
|
-
keepAliveMsecs: 30000,
|
|
22
|
-
maxSockets: 50,
|
|
23
|
-
maxFreeSockets: 10,
|
|
24
|
-
timeout: 60000
|
|
25
|
-
})
|
|
26
|
-
: new http.Agent({
|
|
27
|
-
keepAlive: true,
|
|
28
|
-
keepAliveMsecs: 30000,
|
|
29
|
-
maxSockets: 50,
|
|
30
|
-
maxFreeSockets: 10,
|
|
31
|
-
timeout: 60000
|
|
32
|
-
});
|
|
33
|
-
// Initialize JWKS client with connection pooling and extended timeout
|
|
34
|
-
this.jwksClient = jwksClient({
|
|
35
|
-
jwksUri: this.jwksUri,
|
|
36
|
-
cache: true,
|
|
37
|
-
cacheMaxEntries: 5,
|
|
38
|
-
cacheMaxAge: 600000, // 10 minutes
|
|
39
|
-
timeout: 60000, // 60 seconds (increased from default 30s)
|
|
40
|
-
requestAgent: agent
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Validates that required configuration is present
|
|
45
|
-
*/
|
|
46
|
-
validateConfig() {
|
|
47
|
-
return !!(this.name && this.issuer && this.audience && this.jwksUri);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Gets the signing key for token verification with retry logic
|
|
51
|
-
*/
|
|
52
|
-
getSigningKey(header, callback) {
|
|
53
|
-
this.getSigningKeyWithRetry(header, 3, 1000)
|
|
54
|
-
.then((key) => {
|
|
55
|
-
const signingKey = 'publicKey' in key ? key.publicKey : key.rsaPublicKey;
|
|
56
|
-
callback(null, signingKey);
|
|
57
|
-
})
|
|
58
|
-
.catch((err) => {
|
|
59
|
-
console.error(`Error getting signing key for provider ${this.name} after retries:`, err);
|
|
60
|
-
callback(err);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Retrieves signing key with exponential backoff retry logic
|
|
65
|
-
*/
|
|
66
|
-
async getSigningKeyWithRetry(header, maxRetries, initialDelayMs) {
|
|
67
|
-
let lastError;
|
|
68
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
69
|
-
try {
|
|
70
|
-
return await this.jwksClient.getSigningKey(header.kid);
|
|
71
|
-
}
|
|
72
|
-
catch (err) {
|
|
73
|
-
lastError = err instanceof Error ? err : new Error(String(err));
|
|
74
|
-
// Check if this is a connection error that's worth retrying
|
|
75
|
-
const isRetryableError = lastError.message.includes('socket hang up') ||
|
|
76
|
-
lastError.message.includes('ECONNRESET') ||
|
|
77
|
-
lastError.message.includes('ETIMEDOUT') ||
|
|
78
|
-
lastError.message.includes('ENOTFOUND') ||
|
|
79
|
-
lastError.message.includes('EAI_AGAIN');
|
|
80
|
-
if (!isRetryableError || attempt === maxRetries) {
|
|
81
|
-
throw lastError;
|
|
82
|
-
}
|
|
83
|
-
// Exponential backoff: wait longer between each retry
|
|
84
|
-
const delayMs = initialDelayMs * Math.pow(2, attempt);
|
|
85
|
-
console.warn(`Attempt ${attempt + 1}/${maxRetries + 1} failed for provider ${this.name}. ` +
|
|
86
|
-
`Retrying in ${delayMs}ms... Error: ${lastError.message}`);
|
|
87
|
-
await new Promise(resolve => setTimeout(resolve, delayMs));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
throw lastError || new Error('Failed to retrieve signing key');
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Checks if a given issuer URL belongs to this provider
|
|
94
|
-
*/
|
|
95
|
-
matchesIssuer(issuer) {
|
|
96
|
-
// Handle trailing slashes and case sensitivity
|
|
97
|
-
const normalizedIssuer = issuer.toLowerCase().replace(/\/$/, '');
|
|
98
|
-
const normalizedProviderIssuer = this.issuer.toLowerCase().replace(/\/$/, '');
|
|
99
|
-
return normalizedIssuer === normalizedProviderIssuer;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=Ba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K,EAAE,EAAE,CAAC,CAAC;QAC9E,OAAO,gBAAgB,KAAK,wBAAwB,CAAC;IACvD,CAAC;CAMF"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { JwtHeader, JwtPayload, SigningKeyCallback } from 'jsonwebtoken';
|
|
2
|
-
import { AuthUserInfo } from '@memberjunction/core';
|
|
3
|
-
/**
|
|
4
|
-
* Interface for authentication providers in MemberJunction
|
|
5
|
-
* Enables support for any OAuth 2.0/OIDC compliant provider
|
|
6
|
-
*/
|
|
7
|
-
export interface IAuthProvider {
|
|
8
|
-
/**
|
|
9
|
-
* Unique name identifier for this provider
|
|
10
|
-
*/
|
|
11
|
-
name: string;
|
|
12
|
-
/**
|
|
13
|
-
* The issuer URL for this provider (must match the 'iss' claim in tokens)
|
|
14
|
-
*/
|
|
15
|
-
issuer: string;
|
|
16
|
-
/**
|
|
17
|
-
* The expected audience for tokens from this provider
|
|
18
|
-
*/
|
|
19
|
-
audience: string;
|
|
20
|
-
/**
|
|
21
|
-
* The JWKS endpoint URL for retrieving signing keys
|
|
22
|
-
*/
|
|
23
|
-
jwksUri: string;
|
|
24
|
-
/**
|
|
25
|
-
* OAuth client ID for this provider (optional, used by OAuth proxy for upstream authentication)
|
|
26
|
-
*/
|
|
27
|
-
clientId?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Validates that the provider configuration is complete and valid
|
|
30
|
-
*/
|
|
31
|
-
validateConfig(): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Gets the signing key for token verification
|
|
34
|
-
*/
|
|
35
|
-
getSigningKey(header: JwtHeader, callback: SigningKeyCallback): void;
|
|
36
|
-
/**
|
|
37
|
-
* Extracts user information from the JWT payload
|
|
38
|
-
* Different providers use different claim names
|
|
39
|
-
*/
|
|
40
|
-
extractUserInfo(payload: JwtPayload): AuthUserInfo;
|
|
41
|
-
/**
|
|
42
|
-
* Checks if a given issuer URL belongs to this provider
|
|
43
|
-
*/
|
|
44
|
-
matchesIssuer(issuer: string): boolean;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=IAuthProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IAuthProvider.d.ts","sourceRoot":"","sources":["../../src/auth/IAuthProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAsB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,cAAc,IAAI,OAAO,CAAC;IAE1B;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAErE;;;OAGG;IACH,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,YAAY,CAAC;IAEnD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;CACxC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IAuthProvider.js","sourceRoot":"","sources":["../../src/auth/IAuthProvider.ts"],"names":[],"mappings":""}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { JwtPayload } from 'jsonwebtoken';
|
|
2
|
-
import { AuthProviderConfig, AuthUserInfo } from '@memberjunction/core';
|
|
3
|
-
import { BaseAuthProvider } from '../BaseAuthProvider.js';
|
|
4
|
-
/**
|
|
5
|
-
* Auth0 authentication provider implementation
|
|
6
|
-
*/
|
|
7
|
-
export declare class Auth0Provider extends BaseAuthProvider {
|
|
8
|
-
constructor(config: AuthProviderConfig);
|
|
9
|
-
/**
|
|
10
|
-
* Extracts user information from Auth0 JWT payload
|
|
11
|
-
*/
|
|
12
|
-
extractUserInfo(payload: JwtPayload): AuthUserInfo;
|
|
13
|
-
/**
|
|
14
|
-
* Validates Auth0-specific configuration
|
|
15
|
-
*/
|
|
16
|
-
validateConfig(): boolean;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=Auth0Provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Auth0Provider.d.ts","sourceRoot":"","sources":["../../../src/auth/providers/Auth0Provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;GAEG;AACH,qBACa,aAAc,SAAQ,gBAAgB;gBACrC,MAAM,EAAE,kBAAkB;IAItC;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,YAAY;IAiBlD;;OAEG;IACH,cAAc,IAAI,OAAO;CAO1B"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { RegisterClass } from '@memberjunction/global';
|
|
11
|
-
import { BaseAuthProvider } from '../BaseAuthProvider.js';
|
|
12
|
-
/**
|
|
13
|
-
* Auth0 authentication provider implementation
|
|
14
|
-
*/
|
|
15
|
-
let Auth0Provider = class Auth0Provider extends BaseAuthProvider {
|
|
16
|
-
constructor(config) {
|
|
17
|
-
super(config);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Extracts user information from Auth0 JWT payload
|
|
21
|
-
*/
|
|
22
|
-
extractUserInfo(payload) {
|
|
23
|
-
// Auth0 uses standard OIDC claims
|
|
24
|
-
const email = payload.email;
|
|
25
|
-
const fullName = payload.name;
|
|
26
|
-
const firstName = payload.given_name;
|
|
27
|
-
const lastName = payload.family_name;
|
|
28
|
-
const preferredUsername = payload.preferred_username || email;
|
|
29
|
-
return {
|
|
30
|
-
email,
|
|
31
|
-
firstName: firstName || fullName?.split(' ')[0],
|
|
32
|
-
lastName: lastName || fullName?.split(' ')[1] || fullName?.split(' ')[0],
|
|
33
|
-
fullName,
|
|
34
|
-
preferredUsername
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Validates Auth0-specific configuration
|
|
39
|
-
*/
|
|
40
|
-
validateConfig() {
|
|
41
|
-
const baseValid = super.validateConfig();
|
|
42
|
-
const hasClientId = !!this.config.clientId;
|
|
43
|
-
const hasDomain = !!this.config.domain;
|
|
44
|
-
return baseValid && hasClientId && hasDomain;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
Auth0Provider = __decorate([
|
|
48
|
-
RegisterClass(BaseAuthProvider, 'auth0'),
|
|
49
|
-
__metadata("design:paramtypes", [Object])
|
|
50
|
-
], Auth0Provider);
|
|
51
|
-
export { Auth0Provider };
|
|
52
|
-
//# sourceMappingURL=Auth0Provider.js.map
|