@memberjunction/ng-auth-services 6.2.0-edge.0 → 6.2.0-edge.1
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/lib/AngularAuthProviderFactory.d.ts +12 -0
- package/dist/lib/AngularAuthProviderFactory.d.ts.map +1 -1
- package/dist/lib/AngularAuthProviderFactory.js +31 -7
- package/dist/lib/AngularAuthProviderFactory.js.map +1 -1
- package/dist/lib/IAuthProvider.js.map +1 -1
- package/dist/lib/auth-services.module.d.ts +2 -0
- package/dist/lib/auth-services.module.d.ts.map +1 -1
- package/dist/lib/auth-services.module.js +7 -3
- package/dist/lib/auth-services.module.js.map +1 -1
- package/dist/lib/catalog-environment.d.ts +4 -0
- package/dist/lib/catalog-environment.d.ts.map +1 -1
- package/dist/lib/catalog-environment.js +11 -3
- package/dist/lib/catalog-environment.js.map +1 -1
- package/dist/lib/providers/mjexplorer-auth0-provider.service.d.ts +11 -3
- package/dist/lib/providers/mjexplorer-auth0-provider.service.d.ts.map +1 -1
- package/dist/lib/providers/mjexplorer-auth0-provider.service.js +32 -16
- package/dist/lib/providers/mjexplorer-auth0-provider.service.js.map +1 -1
- package/dist/lib/providers/mjexplorer-cognito-provider.service.d.ts +11 -1
- package/dist/lib/providers/mjexplorer-cognito-provider.service.d.ts.map +1 -1
- package/dist/lib/providers/mjexplorer-cognito-provider.service.js +9 -1
- package/dist/lib/providers/mjexplorer-cognito-provider.service.js.map +1 -1
- package/dist/lib/providers/mjexplorer-magic-link-provider.service.d.ts +2 -0
- package/dist/lib/providers/mjexplorer-magic-link-provider.service.d.ts.map +1 -1
- package/dist/lib/providers/mjexplorer-magic-link-provider.service.js +5 -1
- package/dist/lib/providers/mjexplorer-magic-link-provider.service.js.map +1 -1
- package/dist/lib/providers/mjexplorer-msal-provider.service.d.ts +49 -3
- package/dist/lib/providers/mjexplorer-msal-provider.service.d.ts.map +1 -1
- package/dist/lib/providers/mjexplorer-msal-provider.service.js +41 -25
- package/dist/lib/providers/mjexplorer-msal-provider.service.js.map +1 -1
- package/dist/lib/providers/mjexplorer-okta-provider.service.d.ts +23 -1
- package/dist/lib/providers/mjexplorer-okta-provider.service.d.ts.map +1 -1
- package/dist/lib/providers/mjexplorer-okta-provider.service.js +9 -1
- package/dist/lib/providers/mjexplorer-okta-provider.service.js.map +1 -1
- package/dist/lib/providers/mjexplorer-workos-provider.service.d.ts +21 -1
- package/dist/lib/providers/mjexplorer-workos-provider.service.d.ts.map +1 -1
- package/dist/lib/providers/mjexplorer-workos-provider.service.js +9 -1
- package/dist/lib/providers/mjexplorer-workos-provider.service.js.map +1 -1
- package/dist/lib/redirect.component.d.ts +5 -1
- package/dist/lib/redirect.component.d.ts.map +1 -1
- package/dist/lib/redirect.component.js +11 -3
- package/dist/lib/redirect.component.js.map +1 -1
- package/package.json +4 -4
|
@@ -18,27 +18,39 @@ export declare class AngularAuthProviderFactory {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a provider based on configuration
|
|
20
20
|
*/
|
|
21
|
+
CreateProvider(config: AngularAuthProviderConfig): IAngularAuthProvider;
|
|
22
|
+
/** @deprecated Use {@link CreateProvider}. */
|
|
21
23
|
createProvider(config: AngularAuthProviderConfig): IAngularAuthProvider;
|
|
22
24
|
/**
|
|
23
25
|
* Get a provider by type
|
|
24
26
|
*/
|
|
27
|
+
GetProvider(type: string): IAngularAuthProvider | undefined;
|
|
28
|
+
/** @deprecated Use {@link GetProvider}. */
|
|
25
29
|
getProvider(type: string): IAngularAuthProvider | undefined;
|
|
26
30
|
/**
|
|
27
31
|
* Get all registered provider types
|
|
28
32
|
*/
|
|
33
|
+
GetRegisteredTypes(): string[];
|
|
34
|
+
/** @deprecated Use {@link GetRegisteredTypes}. */
|
|
29
35
|
getRegisteredTypes(): string[];
|
|
30
36
|
/**
|
|
31
37
|
* Check if a provider type is registered
|
|
32
38
|
*/
|
|
39
|
+
IsTypeRegistered(type: string): boolean;
|
|
40
|
+
/** @deprecated Use {@link IsTypeRegistered}. */
|
|
33
41
|
isTypeRegistered(type: string): boolean;
|
|
34
42
|
/**
|
|
35
43
|
* Clear all providers (useful for testing)
|
|
36
44
|
*/
|
|
45
|
+
ClearProviders(): void;
|
|
46
|
+
/** @deprecated Use {@link ClearProviders}. */
|
|
37
47
|
clearProviders(): void;
|
|
38
48
|
/**
|
|
39
49
|
* Get provider-specific Angular services that need to be injected
|
|
40
50
|
* This uses the static angularProviderFactory property on each provider class for extensibility
|
|
41
51
|
*/
|
|
52
|
+
static GetProviderAngularServices(type: string, environment: any): any[];
|
|
53
|
+
/** @deprecated Use {@link GetProviderAngularServices}. */
|
|
42
54
|
static getProviderAngularServices(type: string, environment: any): any[];
|
|
43
55
|
static ɵfac: i0.ɵɵFactoryDeclaration<AngularAuthProviderFactory, never>;
|
|
44
56
|
static ɵprov: i0.ɵɵInjectableDeclaration<AngularAuthProviderFactory>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AngularAuthProviderFactory.d.ts","sourceRoot":"","sources":["../../src/lib/AngularAuthProviderFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;;AAElF;;;GAGG;AACH,qBAGa,0BAA0B;IAKzB,OAAO,CAAC,QAAQ;IAJ5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAA8C;IACrF,OAAO,CAAC,SAAS,CAAgD;IACjE,OAAO,CAAC,eAAe,CAA+B;gBAElC,QAAQ,EAAE,QAAQ;IAQtC;;OAEG;IACH,WAAkB,QAAQ,IAAI,0BAA0B,CAMvD;IAED;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,yBAAyB,GAAG,oBAAoB;IAoCvE;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS;IAI3D;;OAEG;IACH,kBA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O;IAIvC;;OAEG;IACH,cAAc,IAAI,IAAI;IAKtB,8CAA8C;IAC9C,cAAc,IAAI,IAAI;IAItB;;;OAGG;IACH,MAAM,CAAC,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,GAAG,GAAG,EAAE;IAiCxE,0DAA0D;IAC1D,MAAM,CAAC,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,GAAG,GAAG,EAAE;yCA9J7D,0BAA0B;6CAA1B,0BAA0B;CAkKtC"}
|
|
@@ -32,7 +32,7 @@ export class AngularAuthProviderFactory {
|
|
|
32
32
|
/**
|
|
33
33
|
* Create a provider based on configuration
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
CreateProvider(config) {
|
|
36
36
|
const existingProvider = this.providers.get(config.type);
|
|
37
37
|
if (existingProvider) {
|
|
38
38
|
return existingProvider;
|
|
@@ -43,7 +43,7 @@ export class AngularAuthProviderFactory {
|
|
|
43
43
|
const provider = MJGlobal.Instance.ClassFactory.CreateInstance(MJAuthBase, config.type, config // Pass config as constructor argument, not injector
|
|
44
44
|
);
|
|
45
45
|
if (!provider) {
|
|
46
|
-
throw new Error(`No provider registered for type: ${config.type}. Available types: ${this.
|
|
46
|
+
throw new Error(`No provider registered for type: ${config.type}. Available types: ${this.GetRegisteredTypes().join(', ')}`);
|
|
47
47
|
}
|
|
48
48
|
// Validate the configuration
|
|
49
49
|
if (!provider.validateConfig(config)) {
|
|
@@ -59,39 +59,59 @@ export class AngularAuthProviderFactory {
|
|
|
59
59
|
throw error;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
/** @deprecated Use {@link CreateProvider}. */
|
|
63
|
+
createProvider(config) {
|
|
64
|
+
return this.CreateProvider(config);
|
|
65
|
+
}
|
|
62
66
|
/**
|
|
63
67
|
* Get a provider by type
|
|
64
68
|
*/
|
|
65
|
-
|
|
69
|
+
GetProvider(type) {
|
|
66
70
|
return this.providers.get(type);
|
|
67
71
|
}
|
|
72
|
+
/** @deprecated Use {@link GetProvider}. */
|
|
73
|
+
getProvider(type) {
|
|
74
|
+
return this.GetProvider(type);
|
|
75
|
+
}
|
|
68
76
|
/**
|
|
69
77
|
* Get all registered provider types
|
|
70
78
|
*/
|
|
71
|
-
|
|
79
|
+
GetRegisteredTypes() {
|
|
72
80
|
const registrations = MJGlobal.Instance.ClassFactory.GetRegistrationsByRootClass(MJAuthBase);
|
|
73
81
|
const types = registrations.map(reg => reg.Key).filter((key) => key !== null);
|
|
74
82
|
// Return unique types only, as multiple classes can be registered with the same key
|
|
75
83
|
return [...new Set(types)];
|
|
76
84
|
}
|
|
85
|
+
/** @deprecated Use {@link GetRegisteredTypes}. */
|
|
86
|
+
getRegisteredTypes() {
|
|
87
|
+
return this.GetRegisteredTypes();
|
|
88
|
+
}
|
|
77
89
|
/**
|
|
78
90
|
* Check if a provider type is registered
|
|
79
91
|
*/
|
|
92
|
+
IsTypeRegistered(type) {
|
|
93
|
+
return this.GetRegisteredTypes().includes(type);
|
|
94
|
+
}
|
|
95
|
+
/** @deprecated Use {@link IsTypeRegistered}. */
|
|
80
96
|
isTypeRegistered(type) {
|
|
81
|
-
return this.
|
|
97
|
+
return this.IsTypeRegistered(type);
|
|
82
98
|
}
|
|
83
99
|
/**
|
|
84
100
|
* Clear all providers (useful for testing)
|
|
85
101
|
*/
|
|
86
|
-
|
|
102
|
+
ClearProviders() {
|
|
87
103
|
this.providers.clear();
|
|
88
104
|
this.providerConfigs.clear();
|
|
89
105
|
}
|
|
106
|
+
/** @deprecated Use {@link ClearProviders}. */
|
|
107
|
+
clearProviders() {
|
|
108
|
+
return this.ClearProviders();
|
|
109
|
+
}
|
|
90
110
|
/**
|
|
91
111
|
* Get provider-specific Angular services that need to be injected
|
|
92
112
|
* This uses the static angularProviderFactory property on each provider class for extensibility
|
|
93
113
|
*/
|
|
94
|
-
static
|
|
114
|
+
static GetProviderAngularServices(type, environment) {
|
|
95
115
|
const normalizedType = type?.toLowerCase();
|
|
96
116
|
// Get the provider class from the ClassFactory
|
|
97
117
|
const registration = MJGlobal.Instance.ClassFactory.GetRegistration(MJAuthBase, normalizedType);
|
|
@@ -116,6 +136,10 @@ export class AngularAuthProviderFactory {
|
|
|
116
136
|
return [];
|
|
117
137
|
}
|
|
118
138
|
}
|
|
139
|
+
/** @deprecated Use {@link GetProviderAngularServices}. */
|
|
140
|
+
static getProviderAngularServices(type, environment) {
|
|
141
|
+
return this.GetProviderAngularServices(type, environment);
|
|
142
|
+
}
|
|
119
143
|
static ɵfac = function AngularAuthProviderFactory_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AngularAuthProviderFactory)(i0.ɵɵinject(i0.Injector)); };
|
|
120
144
|
static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AngularAuthProviderFactory, factory: AngularAuthProviderFactory.ɵfac, providedIn: 'root' });
|
|
121
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AngularAuthProviderFactory.js","sourceRoot":"","sources":["../../src/lib/AngularAuthProviderFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;;AAG5D;;;GAGG;AAIH,MAAM,OAAO,0BAA0B;IAKjB;IAJZ,MAAM,CAAU,eAAe,GAAG,0CAA0C,CAAC;IAC7E,SAAS,GAAsC,IAAI,GAAG,EAAE,CAAC;IACzD,eAAe,GAAqB,IAAI,GAAG,EAAE,CAAC;IAEtD,YAAoB,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;QACpC,MAAM,CAAC,GAAG,oBAAoB,EAAG,CAAC;QAClC,IAAI,CAAC,CAAC,0BAA0B,CAAC,eAAe,CAAC,EAAE,CAAC;YAClD,OAAO,CAAC,CAAC,0BAA0B,C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E,CAAC;QACZ,CAAC;IACH,CAAC;IAED,0DAA0D;IAC1D,MAAM,CAAC,0BAA0B,CAAC,IAAY,EAAE,WAAgB;QAC9D,OAAO,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC5D,CAAC;oHAhKU,0BAA0B;gEAA1B,0BAA0B,WAA1B,0BAA0B,mBAFzB,MAAM;;iFAEP,0BAA0B;cAHtC,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB","sourcesContent":["import { Injectable, Injector } from '@angular/core';\nimport { MJGlobal, GetGlobalObjectStore } from '@memberjunction/global';\nimport { MJAuthBase } from './mjexplorer-auth-base.service';\nimport { IAngularAuthProvider, AngularAuthProviderConfig } from './IAuthProvider';\n\n/**\n * Factory for creating Angular authentication providers\n * Uses MJGlobal ClassFactory pattern for extensibility\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class AngularAuthProviderFactory {\n private static readonly _globalStoreKey = '___SINGLETON__AngularAuthProviderFactory';\n private providers: Map<string, IAngularAuthProvider> = new Map();\n private providerConfigs: Map<string, any> = new Map();\n\n constructor(private injector: Injector) {\n const g = GetGlobalObjectStore()!;\n if (g[AngularAuthProviderFactory._globalStoreKey]) {\n return g[AngularAuthProviderFactory._globalStoreKey] as AngularAuthProviderFactory;\n }\n g[AngularAuthProviderFactory._globalStoreKey] = this;\n }\n\n /**\n * Get singleton instance\n */\n public static get Instance(): AngularAuthProviderFactory {\n const instance = GetGlobalObjectStore()![AngularAuthProviderFactory._globalStoreKey] as AngularAuthProviderFactory;\n if (!instance) {\n throw new Error('AngularAuthProviderFactory not initialized. Ensure it is provided in your module.');\n }\n return instance;\n }\n\n /**\n * Create a provider based on configuration\n */\n CreateProvider(config: AngularAuthProviderConfig): IAngularAuthProvider {\n \n const existingProvider = this.providers.get(config.type);\n if (existingProvider) {\n return existingProvider;\n }\n\n try {\n // Use MJGlobal ClassFactory to create the provider instance\n // Pass config as the first constructor argument\n const provider = MJGlobal.Instance.ClassFactory.CreateInstance<MJAuthBase>(\n MJAuthBase, \n config.type,\n config // Pass config as constructor argument, not injector\n );\n\n if (!provider) {\n throw new Error(`No provider registered for type: ${config.type}. Available types: ${this.GetRegisteredTypes().join(', ')}`);\n }\n\n // Validate the configuration\n if (!provider.validateConfig(config)) {\n throw new Error(`Invalid configuration for provider type: ${config.type}`);\n }\n\n // Store the provider instance\n this.providers.set(config.type, provider);\n this.providerConfigs.set(config.type, config);\n\n return provider;\n } catch (error) {\n console.error(`Failed to create auth provider for type ${config.type}:`, error);\n throw error;\n }\n }\n\n /** @deprecated Use {@link CreateProvider}. */\n createProvider(config: AngularAuthProviderConfig): IAngularAuthProvider {\n return this.CreateProvider(config);\n }\n\n /**\n * Get a provider by type\n */\n GetProvider(type: string): IAngularAuthProvider | undefined {\n return this.providers.get(type);\n }\n\n /** @deprecated Use {@link GetProvider}. */\n getProvider(type: string): IAngularAuthProvider | undefined {\n return this.GetProvider(type);\n }\n\n /**\n * Get all registered provider types\n */\n GetRegisteredTypes(): string[] {\n const registrations = MJGlobal.Instance.ClassFactory.GetRegistrationsByRootClass(MJAuthBase);\n const types = registrations.map(reg => reg.Key).filter((key): key is string => key !== null);\n // Return unique types only, as multiple classes can be registered with the same key\n return [...new Set(types)];\n }\n\n /** @deprecated Use {@link GetRegisteredTypes}. */\n getRegisteredTypes(): string[] {\n return this.GetRegisteredTypes();\n }\n\n /**\n * Check if a provider type is registered\n */\n IsTypeRegistered(type: string): boolean {\n return this.GetRegisteredTypes().includes(type);\n }\n\n /** @deprecated Use {@link IsTypeRegistered}. */\n isTypeRegistered(type: string): boolean {\n return this.IsTypeRegistered(type);\n }\n\n /**\n * Clear all providers (useful for testing)\n */\n ClearProviders(): void {\n this.providers.clear();\n this.providerConfigs.clear();\n }\n\n /** @deprecated Use {@link ClearProviders}. */\n clearProviders(): void {\n return this.ClearProviders();\n }\n\n /**\n * Get provider-specific Angular services that need to be injected\n * This uses the static angularProviderFactory property on each provider class for extensibility\n */\n static GetProviderAngularServices(type: string, environment: any): any[] {\n \n const normalizedType = type?.toLowerCase();\n \n // Get the provider class from the ClassFactory\n const registration = MJGlobal.Instance.ClassFactory.GetRegistration(\n MJAuthBase, \n normalizedType\n );\n const providerClass = registration?.SubClass as any;\n \n if (!providerClass) {\n console.warn(`No provider class registered for type: ${type}`);\n return [];\n }\n \n // Check if the provider class has the factory property (new pattern)\n if (providerClass.angularProviderFactory) {\n // Call the factory function to get the required providers\n const services = providerClass.angularProviderFactory(environment);\n return services;\n } \n // Fallback to old method name for backward compatibility\n else if (typeof providerClass.getRequiredAngularProviders === 'function') {\n console.warn(`Provider ${type} uses deprecated getRequiredAngularProviders method. Please update to use angularProviderFactory property.`);\n return providerClass.getRequiredAngularProviders(environment);\n } \n else {\n // Provider doesn't define required Angular services (might not need any)\n return [];\n }\n }\n\n /** @deprecated Use {@link GetProviderAngularServices}. */\n static getProviderAngularServices(type: string, environment: any): any[] {\n return this.GetProviderAngularServices(type, environment);\n }\n\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IAuthProvider.js","sourceRoot":"","sources":["../../src/lib/IAuthProvider.ts"],"names":[],"mappings":"","sourcesContent":["import { Observable } from 'rxjs';\nimport { AuthProviderConfig } from '@memberjunction/core';\nimport {\n StandardUserInfo,\n StandardAuthToken,\n StandardAuthError,\n TokenRefreshResult\n} from './auth-types';\n\n// Create an alias for Angular-specific config that extends the base\nexport interface AngularAuthProviderConfig extends AuthProviderConfig {\n // Angular-specific extensions can be added here if needed\n}\n\n/**\n * Interface for Angular authentication providers - v3.0.0\n *\n * This interface defines the contract that all auth providers must implement.\n * It ensures consistent behavior across different OAuth providers while hiding\n * provider-specific implementation details.\n *\n * ## Breaking Changes from v2.x:\n * - Removed: getUserProfile() - Use getUserInfo() instead\n * - Removed: getUser() - Use getUserInfo() instead\n * - Removed: getUserClaims() - Use getTokenInfo() instead\n * - Removed: getToken() - Use getIdToken() instead\n * - Removed: refresh() - Use refreshToken() instead\n * - Removed: checkExpiredTokenError() - Use classifyError() instead\n *\n * @version 3.0.0\n */\nexport interface IAngularAuthProvider {\n /**\n * Provider type identifier (e.g., 'msal', 'auth0', 'okta')\n */\n readonly type: string;\n\n // ============================================================================\n // CORE AUTHENTICATION METHODS\n // ============================================================================\n\n /**\n * Initialize the authentication provider\n *\n * This should handle callback processing, session restoration, etc.\n * Called automatically during app startup.\n */\n initialize(): Promise<void>;\n\n /**\n * Initiate login flow\n *\n * @param options Optional provider-specific login options\n * @returns Observable for backward compatibility, can also return Promise\n *\n * @example\n * ```typescript\n * await this.authBase.login({ appState: { target: '/dashboard' } });\n * ```\n */\n login(options?: Record<string, unknown>): Observable<void> | Promise<void>;\n\n /**\n * Log out the current user\n *\n * Clears local session and redirects to provider's logout endpoint.\n *\n * @example\n * ```typescript\n * await this.authBase.logout();\n * ```\n */\n logout(): Promise<void>;\n\n /**\n * Handle OAuth callback after redirect\n *\n * This is called automatically by the redirect component.\n * Application code typically doesn't need to call this directly.\n */\n handleCallback(): Promise<void>;\n\n // ============================================================================\n // AUTHENTICATION STATE (Observable Streams)\n // ============================================================================\n\n /**\n * Observable stream of authentication state\n *\n * Emits true when user is authenticated, false otherwise.\n * Subscribe to this for reactive UI updates.\n *\n * @example\n * ```typescript\n * this.authBase.isAuthenticated().subscribe(isAuth => {\n * this.showLoginButton = !isAuth;\n * });\n * ```\n */\n isAuthenticated(): Observable<boolean>;\n\n /**\n * Observable stream of user profile information\n *\n * Emits StandardUserInfo when authenticated, null otherwise.\n * This replaces the old getUserProfile() which returned 'any'.\n *\n * @example\n * ```typescript\n * this.authBase.getUserInfo().subscribe(user => {\n * if (user) {\n * console.log(`Welcome ${user.name}!`);\n * }\n * });\n * ```\n */\n getUserInfo(): Observable<StandardUserInfo | null>;\n\n /**\n * Observable stream of user's email address\n *\n * Emits email string when authenticated, empty string otherwise.\n *\n * @example\n * ```typescript\n * this.userEmail$ = this.authBase.getUserEmail();\n * ```\n */\n getUserEmail(): Observable<string>;\n\n // ============================================================================\n // TOKEN MANAGEMENT (v3.0.0 - Fixes Leaky Abstraction)\n // ============================================================================\n\n /**\n * Get the current ID token as a string\n *\n * This is the primary method applications should use to get the token\n * for backend API calls. It abstracts away provider-specific token storage\n * (Auth0's __raw vs MSAL's idToken).\n *\n * @returns Promise resolving to the ID token string, or null if not authenticated\n *\n * @example\n * ```typescript\n * const token = await this.authBase.getIdToken();\n * if (token) {\n * // Use token for GraphQL or REST API calls\n * setupGraphQLClient(token, apiUrl);\n * }\n * ```\n */\n getIdToken(): Promise<string | null>;\n\n /**\n * Get complete token information\n *\n * Returns a standardized token object with ID token, access token, and expiration.\n * Use this when you need more than just the token string.\n *\n * @returns Promise resolving to StandardAuthToken or null if not authenticated\n *\n * @example\n * ```typescript\n * const tokenInfo = await this.authBase.getTokenInfo();\n * if (tokenInfo) {\n * console.log(`Token expires at: ${new Date(tokenInfo.expiresAt)}`);\n * }\n * ```\n */\n getTokenInfo(): Promise<StandardAuthToken | null>;\n\n /**\n * Refresh the current authentication token\n *\n * Attempts to obtain a fresh authentication token using the provider's\n * refresh mechanism. If silent refresh fails due to session expiry, the\n * provider will handle re-authentication automatically (which may involve\n * redirecting to the auth provider's login page).\n *\n * Returns a fresh token on success, or throws on complete failure.\n *\n * IMPORTANT: If the provider requires interactive re-authentication (redirect\n * or popup), this method may never return. The app will reload after\n * authentication completes and re-initialize with a fresh token.\n *\n * @returns Promise resolving to StandardAuthToken or throws on failure\n *\n * @example\n * ```typescript\n * const token = await this.authBase.refreshToken();\n * return token.idToken; // Always succeeds or throws\n * ```\n */\n refreshToken(): Promise<StandardAuthToken>;\n\n // ============================================================================\n // ERROR HANDLING (v3.0.0 - Fixes Error Type Leakage)\n // ============================================================================\n\n /**\n * Classify an error into a standard error type\n *\n * This method converts provider-specific errors into semantic error types\n * that application code can handle consistently. Eliminates the need for\n * consumers to check provider-specific error names like 'BrowserAuthError'.\n *\n * @param error The error to classify (can be any type)\n * @returns StandardAuthError with categorized error type\n *\n * @example\n * ```typescript\n * try {\n * await this.authBase.login();\n * } catch (err) {\n * const authError = this.authBase.classifyError(err);\n *\n * switch (authError.type) {\n * case AuthErrorType.TOKEN_EXPIRED:\n * // Show \"session expired\" message\n * break;\n * case AuthErrorType.USER_CANCELLED:\n * // User cancelled - don't show error\n * break;\n * default:\n * // Show generic error\n * alert(authError.userMessage);\n * }\n * }\n * ```\n */\n classifyError(error: unknown): StandardAuthError;\n\n // ============================================================================\n // CONFIGURATION & VALIDATION\n // ============================================================================\n\n /**\n * Get list of required configuration fields for this provider\n *\n * @returns Array of required config field names\n *\n * @example\n * ```typescript\n * // Auth0 requires: ['clientId', 'domain']\n * // MSAL requires: ['clientId', 'tenantId']\n * ```\n */\n getRequiredConfig(): string[];\n\n /**\n * Validate provider configuration\n *\n * @param config Configuration object to validate\n * @returns True if configuration is valid\n */\n validateConfig(config: Record<string, unknown>): boolean;\n}"]}
|
|
1
|
+
{"version":3,"file":"IAuthProvider.js","sourceRoot":"","sources":["../../src/lib/IAuthProvider.ts"],"names":[],"mappings":"","sourcesContent":["import { Observable } from 'rxjs';\nimport { AuthProviderConfig } from '@memberjunction/core';\nimport {\n StandardUserInfo,\n StandardAuthToken,\n StandardAuthError,\n TokenRefreshResult\n} from './auth-types';\n\n// Create an alias for Angular-specific config that extends the base\nexport interface AngularAuthProviderConfig extends AuthProviderConfig {\n // Angular-specific extensions can be added here if needed\n}\n\n/**\n * Interface for Angular authentication providers - v3.0.0\n *\n * This interface defines the contract that all auth providers must implement.\n * It ensures consistent behavior across different OAuth providers while hiding\n * provider-specific implementation details.\n *\n * ## Breaking Changes from v2.x:\n * - Removed: getUserProfile() - Use getUserInfo() instead\n * - Removed: getUser() - Use getUserInfo() instead\n * - Removed: getUserClaims() - Use getTokenInfo() instead\n * - Removed: getToken() - Use getIdToken() instead\n * - Removed: refresh() - Use refreshToken() instead\n * - Removed: checkExpiredTokenError() - Use classifyError() instead\n *\n * @version 3.0.0\n */\nexport interface IAngularAuthProvider {\n /**\n * Provider type identifier (e.g., 'msal', 'auth0', 'okta')\n */\n readonly type: string; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n\n // ============================================================================\n // CORE AUTHENTICATION METHODS\n // ============================================================================\n\n /**\n * Initialize the authentication provider\n *\n * This should handle callback processing, session restoration, etc.\n * Called automatically during app startup.\n */\n initialize(): Promise<void>; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n\n /**\n * Initiate login flow\n *\n * @param options Optional provider-specific login options\n * @returns Observable for backward compatibility, can also return Promise\n *\n * @example\n * ```typescript\n * await this.authBase.login({ appState: { target: '/dashboard' } });\n * ```\n */\n login(options?: Record<string, unknown>): Observable<void> | Promise<void>; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n\n /**\n * Log out the current user\n *\n * Clears local session and redirects to provider's logout endpoint.\n *\n * @example\n * ```typescript\n * await this.authBase.logout();\n * ```\n */\n logout(): Promise<void>; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n\n /**\n * Handle OAuth callback after redirect\n *\n * This is called automatically by the redirect component.\n * Application code typically doesn't need to call this directly.\n */\n handleCallback(): Promise<void>; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n\n // ============================================================================\n // AUTHENTICATION STATE (Observable Streams)\n // ============================================================================\n\n /**\n * Observable stream of authentication state\n *\n * Emits true when user is authenticated, false otherwise.\n * Subscribe to this for reactive UI updates.\n *\n * @example\n * ```typescript\n * this.authBase.isAuthenticated().subscribe(isAuth => {\n * this.showLoginButton = !isAuth;\n * });\n * ```\n */\n isAuthenticated(): Observable<boolean>; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n\n /**\n * Observable stream of user profile information\n *\n * Emits StandardUserInfo when authenticated, null otherwise.\n * This replaces the old getUserProfile() which returned 'any'.\n *\n * @example\n * ```typescript\n * this.authBase.getUserInfo().subscribe(user => {\n * if (user) {\n * console.log(`Welcome ${user.name}!`);\n * }\n * });\n * ```\n */\n getUserInfo(): Observable<StandardUserInfo | null>; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n\n /**\n * Observable stream of user's email address\n *\n * Emits email string when authenticated, empty string otherwise.\n *\n * @example\n * ```typescript\n * this.userEmail$ = this.authBase.getUserEmail();\n * ```\n */\n getUserEmail(): Observable<string>; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n\n // ============================================================================\n // TOKEN MANAGEMENT (v3.0.0 - Fixes Leaky Abstraction)\n // ============================================================================\n\n /**\n * Get the current ID token as a string\n *\n * This is the primary method applications should use to get the token\n * for backend API calls. It abstracts away provider-specific token storage\n * (Auth0's __raw vs MSAL's idToken).\n *\n * @returns Promise resolving to the ID token string, or null if not authenticated\n *\n * @example\n * ```typescript\n * const token = await this.authBase.getIdToken();\n * if (token) {\n * // Use token for GraphQL or REST API calls\n * setupGraphQLClient(token, apiUrl);\n * }\n * ```\n */\n getIdToken(): Promise<string | null>; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n\n /**\n * Get complete token information\n *\n * Returns a standardized token object with ID token, access token, and expiration.\n * Use this when you need more than just the token string.\n *\n * @returns Promise resolving to StandardAuthToken or null if not authenticated\n *\n * @example\n * ```typescript\n * const tokenInfo = await this.authBase.getTokenInfo();\n * if (tokenInfo) {\n * console.log(`Token expires at: ${new Date(tokenInfo.expiresAt)}`);\n * }\n * ```\n */\n getTokenInfo(): Promise<StandardAuthToken | null>; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n\n /**\n * Refresh the current authentication token\n *\n * Attempts to obtain a fresh authentication token using the provider's\n * refresh mechanism. If silent refresh fails due to session expiry, the\n * provider will handle re-authentication automatically (which may involve\n * redirecting to the auth provider's login page).\n *\n * Returns a fresh token on success, or throws on complete failure.\n *\n * IMPORTANT: If the provider requires interactive re-authentication (redirect\n * or popup), this method may never return. The app will reload after\n * authentication completes and re-initialize with a fresh token.\n *\n * @returns Promise resolving to StandardAuthToken or throws on failure\n *\n * @example\n * ```typescript\n * const token = await this.authBase.refreshToken();\n * return token.idToken; // Always succeeds or throws\n * ```\n */\n refreshToken(): Promise<StandardAuthToken>; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n\n // ============================================================================\n // ERROR HANDLING (v3.0.0 - Fixes Error Type Leakage)\n // ============================================================================\n\n /**\n * Classify an error into a standard error type\n *\n * This method converts provider-specific errors into semantic error types\n * that application code can handle consistently. Eliminates the need for\n * consumers to check provider-specific error names like 'BrowserAuthError'.\n *\n * @param error The error to classify (can be any type)\n * @returns StandardAuthError with categorized error type\n *\n * @example\n * ```typescript\n * try {\n * await this.authBase.login();\n * } catch (err) {\n * const authError = this.authBase.classifyError(err);\n *\n * switch (authError.type) {\n * case AuthErrorType.TOKEN_EXPIRED:\n * // Show \"session expired\" message\n * break;\n * case AuthErrorType.USER_CANCELLED:\n * // User cancelled - don't show error\n * break;\n * default:\n * // Show generic error\n * alert(authError.userMessage);\n * }\n * }\n * ```\n */\n classifyError(error: unknown): StandardAuthError; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n\n // ============================================================================\n // CONFIGURATION & VALIDATION\n // ============================================================================\n\n /**\n * Get list of required configuration fields for this provider\n *\n * @returns Array of required config field names\n *\n * @example\n * ```typescript\n * // Auth0 requires: ['clientId', 'domain']\n * // MSAL requires: ['clientId', 'tenantId']\n * ```\n */\n getRequiredConfig(): string[]; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n\n /**\n * Validate provider configuration\n *\n * @param config Configuration object to validate\n * @returns True if configuration is valid\n */\n validateConfig(config: Record<string, unknown>): boolean; // case-violation-ok-legacy-back-compat: the type is named in an exported signature, so consumers build object literals against it; an interface has no runtime carrier for a stub\n}"]}
|
|
@@ -39,6 +39,8 @@ export declare class AuthServicesModule {
|
|
|
39
39
|
* behaviour is byte-for-byte what it was before the catalog existed, which is what
|
|
40
40
|
* keeps every existing deployment working untouched.
|
|
41
41
|
*/
|
|
42
|
+
static ForRoot(environment: any, catalog?: PublicAuthProviderInfo[]): ModuleWithProviders<AuthServicesModule>;
|
|
43
|
+
/** @deprecated Use {@link ForRoot}. */
|
|
42
44
|
static forRoot(environment: any, catalog?: PublicAuthProviderInfo[]): ModuleWithProviders<AuthServicesModule>;
|
|
43
45
|
static ɵfac: i0.ɵɵFactoryDeclaration<AuthServicesModule, never>;
|
|
44
46
|
static ɵmod: i0.ɵɵNgModuleDeclaration<AuthServicesModule, [typeof i1.RedirectComponent], [typeof i2.CommonModule, typeof i3.MJLoginPickerComponent], [typeof i1.RedirectComponent, typeof i3.MJLoginPickerComponent]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-services.module.d.ts","sourceRoot":"","sources":["../../src/lib/auth-services.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,mBAAmB,EAAE,cAAc,EAAY,MAAM,eAAe,CAAC;AAMxF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAK3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;;;;;AAGzD,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,wCAA4E,CAAC;AAKrH;;;GAGG;AACH,qBAKa,kBAAkB;IAC7B;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,sBAAsB,EAAE,GAAG,mBAAmB,CAAC,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth-services.module.d.ts","sourceRoot":"","sources":["../../src/lib/auth-services.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,mBAAmB,EAAE,cAAc,EAAY,MAAM,eAAe,CAAC;AAMxF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAK3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;;;;;AAGzD,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,wCAA4E,CAAC;AAKrH;;;GAGG;AACH,qBAKa,kBAAkB;IAC7B;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,sBAAsB,EAAE,GAAG,mBAAmB,CAAC,kBAAkB,CAAC;IA0E7G,uCAAuC;IACvC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,sBAAsB,EAAE,GAAG,mBAAmB,CAAC,kBAAkB,CAAC;yCA/FlG,kBAAkB;0CAAlB,kBAAkB;0CAAlB,kBAAkB;CAkG9B"}
|
|
@@ -5,7 +5,7 @@ import { AngularAuthProviderFactory } from './AngularAuthProviderFactory';
|
|
|
5
5
|
import { MJMagicLinkProvider } from './providers/mjexplorer-magic-link-provider.service';
|
|
6
6
|
import { MJGlobal } from '@memberjunction/global';
|
|
7
7
|
import { AuthProviderCatalog } from './auth-provider-catalog';
|
|
8
|
-
import {
|
|
8
|
+
import { MergeCatalogEnvironment } from './catalog-environment';
|
|
9
9
|
import { MJLoginPickerComponent } from './login-picker.component';
|
|
10
10
|
// Import our generic redirect component
|
|
11
11
|
import { RedirectComponent } from './redirect.component';
|
|
@@ -46,7 +46,7 @@ export class AuthServicesModule {
|
|
|
46
46
|
* behaviour is byte-for-byte what it was before the catalog existed, which is what
|
|
47
47
|
* keeps every existing deployment working untouched.
|
|
48
48
|
*/
|
|
49
|
-
static
|
|
49
|
+
static ForRoot(environment, catalog) {
|
|
50
50
|
const env = environment;
|
|
51
51
|
const providers = [];
|
|
52
52
|
const configuredType = env['AUTH_TYPE']?.toLowerCase();
|
|
@@ -82,7 +82,7 @@ export class AuthServicesModule {
|
|
|
82
82
|
// environment, so the driver receives the row's values overlaid on the app's environment.
|
|
83
83
|
// Magic-link is excluded: its session is established by the redeem flow, not by catalog config.
|
|
84
84
|
const effectiveEnvironment = resolution.active && !magicLinkActive
|
|
85
|
-
?
|
|
85
|
+
? MergeCatalogEnvironment(environment, resolution.active, providerClass)
|
|
86
86
|
: environment;
|
|
87
87
|
// Use the factory to get provider-specific Angular services
|
|
88
88
|
// This uses the static method on each provider class for extensibility
|
|
@@ -105,6 +105,10 @@ export class AuthServicesModule {
|
|
|
105
105
|
providers: providers
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
|
+
/** @deprecated Use {@link ForRoot}. */
|
|
109
|
+
static forRoot(environment, catalog) {
|
|
110
|
+
return this.ForRoot(environment, catalog);
|
|
111
|
+
}
|
|
108
112
|
static ɵfac = function AuthServicesModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AuthServicesModule)(); };
|
|
109
113
|
static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AuthServicesModule });
|
|
110
114
|
static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-services.module.js","sourceRoot":"","sources":["../../src/lib/auth-services.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuB,cAA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AW,EAAE,UAAU,CAAC,MAAM,EAAE,aAAqD,CAAC;YAChH,CAAC,CAAC,WAAW,CAAC;QAElB,4DAA4D;QAC5D,uEAAuE;QACvE,MAAM,eAAe,GAAG,0BAA0B,CAAC,0BAA0B,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;QAC9G,SAAS,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,CAAC;QAEnC,IAAI,aAAa,EAAE,CAAC;YAClB,0BAA0B;YAC1B,SAAS,CAAC,IAAI,CAAC;gBACb,OAAO,EAAE,UAAU;gBACnB,QAAQ,EAAE,aAAa;aACxB,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,+CAA+C,QAAQ,EAAE,CAAC,CAAC;QAC3E,CAAC;QAED,yBAAyB;QACzB,SAAS,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QAE3C,OAAO;YACL,QAAQ,EAAE,kBAAkB;YAC5B,SAAS,EAAE,SAAoB;SAChC,CAAC;IACJ,CAAC;4GA5FU,kBAAkB;4DAAlB,kBAAkB;gEAJnB,YAAY;;iFAIX,kBAAkB;cAL9B,QAAQ;eAAC;gBACR,OAAO,EAAE,CAAC,YAAY,EAAE,sBAAsB,CAAC;gBAC/C,YAAY,EAAE,CAAC,iBAAiB,CAAC;gBACjC,OAAO,EAAE,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;aACrD;;wFACY,kBAAkB,mBAHd,iBAAiB,aADtB,YAAY,EAAE,sBAAsB,aAEpC,iBAAiB,EAAE,sBAAsB","sourcesContent":["import { NgModule, ModuleWithProviders, InjectionToken, Provider } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { MJAuthBase } from './mjexplorer-auth-base.service';\nimport { AngularAuthProviderFactory } from './AngularAuthProviderFactory';\nimport { MJMagicLinkProvider } from './providers/mjexplorer-magic-link-provider.service';\nimport { MJGlobal } from '@memberjunction/global';\nimport type { PublicAuthProviderInfo } from '@memberjunction/core';\nimport { AuthProviderCatalog, type AuthProviderResolution } from './auth-provider-catalog';\nimport { mergeCatalogEnvironment, type CatalogEnvironmentMapper } from './catalog-environment';\nimport { MJLoginPickerComponent } from './login-picker.component';\n\n// Import our generic redirect component\nimport { RedirectComponent } from './redirect.component';\n\n// Export the generic redirect component for backward compatibility\nexport { RedirectComponent };\n\n/**\n * Injection token carrying how authentication resolved for this page load.\n *\n * A login surface injects this to decide whether to render the multi-provider picker or the\n * single sign-in button, and whether to start the login flow immediately after a picker\n * choice caused a reload.\n */\nexport const MJ_AUTH_PROVIDER_RESOLUTION = new InjectionToken<AuthProviderResolution>('MJ_AUTH_PROVIDER_RESOLUTION');\n\n/** The resolution used when no catalog is supplied — i.e. the pre-existing single-provider path. */\nconst NO_CATALOG_RESOLUTION: AuthProviderResolution = { active: null, choices: [], showPicker: false, autoLogin: false };\n\n/**\n * Extensible authentication module that supports N providers\n * Uses MJGlobal ClassFactory pattern for dynamic provider creation\n */\n@NgModule({\n imports: [CommonModule, MJLoginPickerComponent],\n declarations: [RedirectComponent],\n exports: [RedirectComponent, MJLoginPickerComponent]\n})\nexport class AuthServicesModule {\n /**\n * Wires the authentication provider into DI.\n *\n * @param environment The app's compiled environment. Typed loosely on purpose: every app\n * declares its own environment shape (`MJEnvironmentConfig` and downstream equivalents\n * are interfaces, which TypeScript will not assign to an indexed record), so narrowing\n * this parameter would break every existing caller. It is narrowed once, below.\n * @param catalog Optional pre-auth provider catalog. Defaults to whatever the app preloaded\n * via {@link AuthProviderCatalog.Preload} in its bootstrap entry point — passing it\n * explicitly is for tests and for apps that source the catalog some other way. Callers\n * must NOT pass `AuthProviderCatalog.GetPreloaded()` themselves: Angular's compiler\n * requires every `imports` entry to be statically analyzable, and a function call in\n * the argument list fails AOT with \"Value could not be determined statically\".\n *\n * When the catalog is empty — an older server, a failed fetch, or a deployment that\n * never adopted the entity — resolution falls back to `environment.AUTH_TYPE` and\n * behaviour is byte-for-byte what it was before the catalog existed, which is what\n * keeps every existing deployment working untouched.\n */\n static forRoot(environment: any, catalog?: PublicAuthProviderInfo[]): ModuleWithProviders<AuthServicesModule> {\n const env = environment as Record<string, unknown>;\n const providers: Provider[] = [];\n const configuredType = (env['AUTH_TYPE'] as string | undefined)?.toLowerCase();\n const resolvedCatalog = catalog ?? AuthProviderCatalog.GetPreloaded();\n\n // Coexistence resolution: a single Explorer deployment can serve both SSO\n // users and magic-link guests. If a magic-link session token is present for\n // this page load (URL fragment from /redeem, or stored earlier this tab), use\n // the magic-link provider regardless of the configured primary IdP. Otherwise\n // use the catalog selection, then the configured AUTH_TYPE. This auto-falls-back\n // to the IdP once a guest's token is gone (expired/logged out), so the normal\n // login button works again.\n const magicLinkActive = MJMagicLinkProvider.hasSessionToken();\n\n // The catalog resolves which provider this load uses; it never overrides an active\n // magic-link session, which is a property of THIS page load rather than a configured choice.\n const resolution = resolvedCatalog.length ? AuthProviderCatalog.Resolve(resolvedCatalog) : NO_CATALOG_RESOLUTION;\n providers.push({ provide: MJ_AUTH_PROVIDER_RESOLUTION, useValue: resolution });\n\n const catalogType = resolution.active?.driverClass?.toLowerCase();\n const authType = magicLinkActive ? MJMagicLinkProvider.PROVIDER_TYPE : (catalogType ?? configuredType);\n\n if (!authType) {\n console.error('No authentication provider available: the server published no catalog and no AUTH_TYPE is set in the environment');\n return {\n ngModule: AuthServicesModule,\n providers: providers as never[]\n };\n }\n\n if (magicLinkActive && authType !== (catalogType ?? configuredType)) {\n console.log(`[Auth] Magic-link session token detected — using the magic-link provider for this load (configured primary: '${catalogType ?? configuredType ?? 'none'}').`);\n }\n\n // Get the provider class from ClassFactory for extensibility\n const registration = MJGlobal.Instance.ClassFactory.GetRegistration(\n MJAuthBase,\n authType\n );\n const providerClass = registration?.SubClass;\n\n // A catalog-selected provider takes its settings from metadata rather than from the compiled\n // environment, so the driver receives the row's values overlaid on the app's environment.\n // Magic-link is excluded: its session is established by the redeem flow, not by catalog config.\n const effectiveEnvironment =\n resolution.active && !magicLinkActive\n ? mergeCatalogEnvironment(environment, resolution.active, providerClass as CatalogEnvironmentMapper | undefined)\n : environment;\n\n // Use the factory to get provider-specific Angular services\n // This uses the static method on each provider class for extensibility\n const angularServices = AngularAuthProviderFactory.getProviderAngularServices(authType, effectiveEnvironment);\n providers.push(...angularServices);\n\n if (providerClass) {\n // Add the provider itself\n providers.push({\n provide: MJAuthBase,\n useClass: providerClass\n });\n } else {\n console.error(`No provider class registered for auth type: ${authType}`);\n }\n\n // Add the factory itself\n providers.push(AngularAuthProviderFactory);\n\n return {\n ngModule: AuthServicesModule,\n providers: providers as never[]\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"auth-services.module.js","sourceRoot":"","sources":["../../src/lib/auth-services.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuB,cAAc,EAAY,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAA+B,MAAM,yBAAyB,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAiC,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,wCAAwC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;;AAEzD,mEAAmE;AACnE,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,cAAc,CAAyB,6BAA6B,CAAC,CAAC;AAErH,oGAAoG;AACpG,MAAM,qBAAqB,GAA2B,EAAE,MAAM,EAAE,IA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,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;4GAjGU,kBAAkB;4DAAlB,kBAAkB;gEAJnB,YAAY;;iFAIX,kBAAkB;cAL9B,QAAQ;eAAC;gBACR,OAAO,EAAE,CAAC,YAAY,EAAE,sBAAsB,CAAC;gBAC/C,YAAY,EAAE,CAAC,iBAAiB,CAAC;gBACjC,OAAO,EAAE,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;aACrD;;wFACY,kBAAkB,mBAHd,iBAAiB,aADtB,YAAY,EAAE,sBAAsB,aAEpC,iBAAiB,EAAE,sBAAsB","sourcesContent":["import { NgModule, ModuleWithProviders, InjectionToken, Provider } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { MJAuthBase } from './mjexplorer-auth-base.service';\nimport { AngularAuthProviderFactory } from './AngularAuthProviderFactory';\nimport { MJMagicLinkProvider } from './providers/mjexplorer-magic-link-provider.service';\nimport { MJGlobal } from '@memberjunction/global';\nimport type { PublicAuthProviderInfo } from '@memberjunction/core';\nimport { AuthProviderCatalog, type AuthProviderResolution } from './auth-provider-catalog';\nimport { MergeCatalogEnvironment, type CatalogEnvironmentMapper } from './catalog-environment';\nimport { MJLoginPickerComponent } from './login-picker.component';\n\n// Import our generic redirect component\nimport { RedirectComponent } from './redirect.component';\n\n// Export the generic redirect component for backward compatibility\nexport { RedirectComponent };\n\n/**\n * Injection token carrying how authentication resolved for this page load.\n *\n * A login surface injects this to decide whether to render the multi-provider picker or the\n * single sign-in button, and whether to start the login flow immediately after a picker\n * choice caused a reload.\n */\nexport const MJ_AUTH_PROVIDER_RESOLUTION = new InjectionToken<AuthProviderResolution>('MJ_AUTH_PROVIDER_RESOLUTION');\n\n/** The resolution used when no catalog is supplied — i.e. the pre-existing single-provider path. */\nconst NO_CATALOG_RESOLUTION: AuthProviderResolution = { active: null, choices: [], showPicker: false, autoLogin: false };\n\n/**\n * Extensible authentication module that supports N providers\n * Uses MJGlobal ClassFactory pattern for dynamic provider creation\n */\n@NgModule({\n imports: [CommonModule, MJLoginPickerComponent],\n declarations: [RedirectComponent],\n exports: [RedirectComponent, MJLoginPickerComponent]\n})\nexport class AuthServicesModule {\n /**\n * Wires the authentication provider into DI.\n *\n * @param environment The app's compiled environment. Typed loosely on purpose: every app\n * declares its own environment shape (`MJEnvironmentConfig` and downstream equivalents\n * are interfaces, which TypeScript will not assign to an indexed record), so narrowing\n * this parameter would break every existing caller. It is narrowed once, below.\n * @param catalog Optional pre-auth provider catalog. Defaults to whatever the app preloaded\n * via {@link AuthProviderCatalog.Preload} in its bootstrap entry point — passing it\n * explicitly is for tests and for apps that source the catalog some other way. Callers\n * must NOT pass `AuthProviderCatalog.GetPreloaded()` themselves: Angular's compiler\n * requires every `imports` entry to be statically analyzable, and a function call in\n * the argument list fails AOT with \"Value could not be determined statically\".\n *\n * When the catalog is empty — an older server, a failed fetch, or a deployment that\n * never adopted the entity — resolution falls back to `environment.AUTH_TYPE` and\n * behaviour is byte-for-byte what it was before the catalog existed, which is what\n * keeps every existing deployment working untouched.\n */\n static ForRoot(environment: any, catalog?: PublicAuthProviderInfo[]): ModuleWithProviders<AuthServicesModule> {\n const env = environment as Record<string, unknown>;\n const providers: Provider[] = [];\n const configuredType = (env['AUTH_TYPE'] as string | undefined)?.toLowerCase();\n const resolvedCatalog = catalog ?? AuthProviderCatalog.GetPreloaded();\n\n // Coexistence resolution: a single Explorer deployment can serve both SSO\n // users and magic-link guests. If a magic-link session token is present for\n // this page load (URL fragment from /redeem, or stored earlier this tab), use\n // the magic-link provider regardless of the configured primary IdP. Otherwise\n // use the catalog selection, then the configured AUTH_TYPE. This auto-falls-back\n // to the IdP once a guest's token is gone (expired/logged out), so the normal\n // login button works again.\n const magicLinkActive = MJMagicLinkProvider.hasSessionToken();\n\n // The catalog resolves which provider this load uses; it never overrides an active\n // magic-link session, which is a property of THIS page load rather than a configured choice.\n const resolution = resolvedCatalog.length ? AuthProviderCatalog.Resolve(resolvedCatalog) : NO_CATALOG_RESOLUTION;\n providers.push({ provide: MJ_AUTH_PROVIDER_RESOLUTION, useValue: resolution });\n\n const catalogType = resolution.active?.driverClass?.toLowerCase();\n const authType = magicLinkActive ? MJMagicLinkProvider.PROVIDER_TYPE : (catalogType ?? configuredType);\n\n if (!authType) {\n console.error('No authentication provider available: the server published no catalog and no AUTH_TYPE is set in the environment');\n return {\n ngModule: AuthServicesModule,\n providers: providers as never[]\n };\n }\n\n if (magicLinkActive && authType !== (catalogType ?? configuredType)) {\n console.log(`[Auth] Magic-link session token detected — using the magic-link provider for this load (configured primary: '${catalogType ?? configuredType ?? 'none'}').`);\n }\n\n // Get the provider class from ClassFactory for extensibility\n const registration = MJGlobal.Instance.ClassFactory.GetRegistration(\n MJAuthBase,\n authType\n );\n const providerClass = registration?.SubClass;\n\n // A catalog-selected provider takes its settings from metadata rather than from the compiled\n // environment, so the driver receives the row's values overlaid on the app's environment.\n // Magic-link is excluded: its session is established by the redeem flow, not by catalog config.\n const effectiveEnvironment =\n resolution.active && !magicLinkActive\n ? MergeCatalogEnvironment(environment, resolution.active, providerClass as CatalogEnvironmentMapper | undefined)\n : environment;\n\n // Use the factory to get provider-specific Angular services\n // This uses the static method on each provider class for extensibility\n const angularServices = AngularAuthProviderFactory.getProviderAngularServices(authType, effectiveEnvironment);\n providers.push(...angularServices);\n\n if (providerClass) {\n // Add the provider itself\n providers.push({\n provide: MJAuthBase,\n useClass: providerClass\n });\n } else {\n console.error(`No provider class registered for auth type: ${authType}`);\n }\n\n // Add the factory itself\n providers.push(AngularAuthProviderFactory);\n\n return {\n ngModule: AuthServicesModule,\n providers: providers as never[]\n };\n }\n\n /** @deprecated Use {@link ForRoot}. */\n static forRoot(environment: any, catalog?: PublicAuthProviderInfo[]): ModuleWithProviders<AuthServicesModule> {\n return this.ForRoot(environment, catalog);\n }\n}\n"]}
|
|
@@ -33,6 +33,8 @@ export interface CatalogEnvironmentMapper {
|
|
|
33
33
|
* `buildProviderConfig`, where a blob must not silently redefine a described, reviewable column
|
|
34
34
|
* (`{"scopes": "..."}` in the blob would otherwise clobber the parsed `Scopes` column).
|
|
35
35
|
*/
|
|
36
|
+
export declare function BuildGenericEnvironmentOverlay(info: PublicAuthProviderInfo): Record<string, unknown>;
|
|
37
|
+
/** @deprecated Use {@link BuildGenericEnvironmentOverlay}. */
|
|
36
38
|
export declare function buildGenericEnvironmentOverlay(info: PublicAuthProviderInfo): Record<string, unknown>;
|
|
37
39
|
/**
|
|
38
40
|
* Produces the environment record to hand a driver for a catalog-selected provider.
|
|
@@ -46,5 +48,7 @@ export declare function buildGenericEnvironmentOverlay(info: PublicAuthProviderI
|
|
|
46
48
|
* @param info The provider selected from the catalog.
|
|
47
49
|
* @param providerClass The resolved `MJAuthBase` subclass, consulted for a custom mapper.
|
|
48
50
|
*/
|
|
51
|
+
export declare function MergeCatalogEnvironment(environment: Record<string, unknown>, info: PublicAuthProviderInfo, providerClass?: CatalogEnvironmentMapper): Record<string, unknown>;
|
|
52
|
+
/** @deprecated Use {@link MergeCatalogEnvironment}. */
|
|
49
53
|
export declare function mergeCatalogEnvironment(environment: Record<string, unknown>, info: PublicAuthProviderInfo, providerClass?: CatalogEnvironmentMapper): Record<string, unknown>;
|
|
50
54
|
//# sourceMappingURL=catalog-environment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-environment.d.ts","sourceRoot":"","sources":["../../src/lib/catalog-environment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEnE;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,sBAAsB,CAAC,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpF;AAmBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6BpG;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,IAAI,EAAE,sBAAsB,EAC5B,aAAa,CAAC,EAAE,wBAAwB,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOzB"}
|
|
1
|
+
{"version":3,"file":"catalog-environment.d.ts","sourceRoot":"","sources":["../../src/lib/catalog-environment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEnE;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,sBAAsB,CAAC,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpF;AAmBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6BpG;AAED,8DAA8D;AAC9D,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEpG;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,IAAI,EAAE,sBAAsB,EAC5B,aAAa,CAAC,EAAE,wBAAwB,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOzB;AAED,uDAAuD;AACvD,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,IAAI,EAAE,sBAAsB,EAC5B,aAAa,CAAC,EAAE,wBAAwB,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB"}
|
|
@@ -39,7 +39,7 @@ function environmentPrefix(driverClass) {
|
|
|
39
39
|
* `buildProviderConfig`, where a blob must not silently redefine a described, reviewable column
|
|
40
40
|
* (`{"scopes": "..."}` in the blob would otherwise clobber the parsed `Scopes` column).
|
|
41
41
|
*/
|
|
42
|
-
export function
|
|
42
|
+
export function BuildGenericEnvironmentOverlay(info) {
|
|
43
43
|
const prefix = environmentPrefix(info.driverClass);
|
|
44
44
|
const overlay = {};
|
|
45
45
|
for (const [key, value] of Object.entries(info.clientConfiguration ?? {})) {
|
|
@@ -66,6 +66,10 @@ export function buildGenericEnvironmentOverlay(info) {
|
|
|
66
66
|
}
|
|
67
67
|
return overlay;
|
|
68
68
|
}
|
|
69
|
+
/** @deprecated Use {@link BuildGenericEnvironmentOverlay}. */
|
|
70
|
+
export function buildGenericEnvironmentOverlay(info) {
|
|
71
|
+
return BuildGenericEnvironmentOverlay(info);
|
|
72
|
+
}
|
|
69
73
|
/**
|
|
70
74
|
* Produces the environment record to hand a driver for a catalog-selected provider.
|
|
71
75
|
*
|
|
@@ -78,10 +82,14 @@ export function buildGenericEnvironmentOverlay(info) {
|
|
|
78
82
|
* @param info The provider selected from the catalog.
|
|
79
83
|
* @param providerClass The resolved `MJAuthBase` subclass, consulted for a custom mapper.
|
|
80
84
|
*/
|
|
81
|
-
export function
|
|
85
|
+
export function MergeCatalogEnvironment(environment, info, providerClass) {
|
|
82
86
|
const overlay = typeof providerClass?.EnvironmentFromCatalog === 'function'
|
|
83
87
|
? providerClass.EnvironmentFromCatalog(info)
|
|
84
|
-
:
|
|
88
|
+
: BuildGenericEnvironmentOverlay(info);
|
|
85
89
|
return { ...environment, ...overlay, AUTH_TYPE: info.driverClass };
|
|
86
90
|
}
|
|
91
|
+
/** @deprecated Use {@link MergeCatalogEnvironment}. */
|
|
92
|
+
export function mergeCatalogEnvironment(environment, info, providerClass) {
|
|
93
|
+
return MergeCatalogEnvironment(environment, info, providerClass);
|
|
94
|
+
}
|
|
87
95
|
//# sourceMappingURL=catalog-environment.js.map
|
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AM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzD,yFAAyF;QACzF,2FAA2F;QAC3F,2FAA2F;QAC3F,2FAA2F;QAC3F,mDAAmD;QACnD,OAAO,CAAC,GAAG,MAAM,SAAS,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5C,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,MAAM,SAAS,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5C,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CACrC,WAAoC,EACpC,IAA4B,EAC5B,aAAwC;IAExC,MAAM,OAAO,GACX,OAAO,aAAa,EAAE,sBAAsB,KAAK,UAAU;QACzD,CAAC,CAAC,aAAa,CAAC,sBAAsB,CAAC,IAAI,CAAC;QAC5C,CAAC,CAAC,8BAA8B,CAAC,IAAI,CAAC,CAAC;IAE3C,OAAO,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;AACrE,CAAC","sourcesContent":["/**\n * @fileoverview Bridges a metadata provider row to the flat `environment` record that the\n * browser auth drivers already consume.\n *\n * Every `MJAuthBase` subclass exposes `static angularProviderFactory(environment)` and reads\n * its settings from prefixed keys on that record (`AUTH0_DOMAIN`, `WORKOS_CLIENTID`, ...).\n * Rather than rewrite each driver to accept a catalog row, the catalog is projected INTO that\n * record — so a provider configured from metadata and one configured from `environment.ts`\n * take an identical code path, and drivers keep working untouched.\n *\n * @module @memberjunction/ng-auth-services\n */\n\nimport type { PublicAuthProviderInfo } from '@memberjunction/core';\n\n/**\n * Optional hook a provider class may expose when the generic prefixed-key convention does not\n * describe its configuration. MSAL is the built-in example: it reads unprefixed `CLIENT_ID` /\n * `CLIENT_AUTHORITY`, so it maps the catalog row itself.\n */\nexport interface CatalogEnvironmentMapper {\n EnvironmentFromCatalog?: (info: PublicAuthProviderInfo) => Record<string, unknown>;\n}\n\n/**\n * `redirectUri` → `REDIRECT_URI`, `apiHostname` → `API_HOSTNAME`, `userPoolId` → `USER_POOL_ID`.\n */\nfunction camelToUpperSnake(key: string): string {\n return key\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .replace(/[-\\s]+/g, '_')\n .toUpperCase();\n}\n\n/**\n * The environment-key prefix for a driver: `workos` → `WORKOS`, `magic-link` → `MAGIC_LINK`.\n */\nfunction environmentPrefix(driverClass: string): string {\n return camelToUpperSnake(driverClass);\n}\n\n/**\n * Projects a catalog row onto the conventional prefixed environment keys.\n *\n * The convention — `<DRIVER>_CLIENTID`, `<DRIVER>_DOMAIN`, `<DRIVER>_SCOPES`, plus one key per\n * `clientConfiguration` entry — is exactly what the Auth0, Okta, Cognito and WorkOS drivers\n * already read, so those four need no per-driver mapping at all. A driver that deviates\n * supplies `EnvironmentFromCatalog`.\n *\n * Only defined values are emitted, so a catalog row never blanks out a key the app's compiled\n * environment legitimately supplies. `clientConfiguration` entries are projected FIRST so the\n * modelled columns win a key collision — the same precedence the server enforces in\n * `buildProviderConfig`, where a blob must not silently redefine a described, reviewable column\n * (`{\"scopes\": \"...\"}` in the blob would otherwise clobber the parsed `Scopes` column).\n */\nexport function
|
|
1
|
+
{"version":3,"file":"catalog-environment.js","sourceRoot":"","sources":["../../src/lib/catalog-environment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH;;GAEG;AACH,SAAS,iBAAiB,CAAC,GAAW;IACpC,OAAO,GAAG;SACP,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,WAAW,EAAE,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,WAAmB;IAC5C,OAAO,iBAAiB,CAAC,WAAW,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;;;GAaG;AAC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IAAI,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CACrC,WAAoC,EACpC,IAA4B,EAC5B,aAAwC;IAExC,MAAM,OAAO,GACX,OAAO,aAAa,EAAE,sBAAsB,KAAK,UAAU;QACzD,CAAC,CAAC,aAAa,CAAC,sBAAsB,CAAC,IAAI,CAAC;QAC5C,CAAC,CAAC,8BAA8B,CAAC,IAAI,CAAC,CAAC;IAE3C,OAAO,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;AACrE,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,uBAAuB,CACrC,WAAoC,EACpC,IAA4B,EAC5B,aAAwC;IAExC,OAAO,uBAAuB,CAAC,WAAW,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AACnE,CAAC","sourcesContent":["/**\n * @fileoverview Bridges a metadata provider row to the flat `environment` record that the\n * browser auth drivers already consume.\n *\n * Every `MJAuthBase` subclass exposes `static angularProviderFactory(environment)` and reads\n * its settings from prefixed keys on that record (`AUTH0_DOMAIN`, `WORKOS_CLIENTID`, ...).\n * Rather than rewrite each driver to accept a catalog row, the catalog is projected INTO that\n * record — so a provider configured from metadata and one configured from `environment.ts`\n * take an identical code path, and drivers keep working untouched.\n *\n * @module @memberjunction/ng-auth-services\n */\n\nimport type { PublicAuthProviderInfo } from '@memberjunction/core';\n\n/**\n * Optional hook a provider class may expose when the generic prefixed-key convention does not\n * describe its configuration. MSAL is the built-in example: it reads unprefixed `CLIENT_ID` /\n * `CLIENT_AUTHORITY`, so it maps the catalog row itself.\n */\nexport interface CatalogEnvironmentMapper {\n EnvironmentFromCatalog?: (info: PublicAuthProviderInfo) => Record<string, unknown>;\n}\n\n/**\n * `redirectUri` → `REDIRECT_URI`, `apiHostname` → `API_HOSTNAME`, `userPoolId` → `USER_POOL_ID`.\n */\nfunction camelToUpperSnake(key: string): string {\n return key\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .replace(/[-\\s]+/g, '_')\n .toUpperCase();\n}\n\n/**\n * The environment-key prefix for a driver: `workos` → `WORKOS`, `magic-link` → `MAGIC_LINK`.\n */\nfunction environmentPrefix(driverClass: string): string {\n return camelToUpperSnake(driverClass);\n}\n\n/**\n * Projects a catalog row onto the conventional prefixed environment keys.\n *\n * The convention — `<DRIVER>_CLIENTID`, `<DRIVER>_DOMAIN`, `<DRIVER>_SCOPES`, plus one key per\n * `clientConfiguration` entry — is exactly what the Auth0, Okta, Cognito and WorkOS drivers\n * already read, so those four need no per-driver mapping at all. A driver that deviates\n * supplies `EnvironmentFromCatalog`.\n *\n * Only defined values are emitted, so a catalog row never blanks out a key the app's compiled\n * environment legitimately supplies. `clientConfiguration` entries are projected FIRST so the\n * modelled columns win a key collision — the same precedence the server enforces in\n * `buildProviderConfig`, where a blob must not silently redefine a described, reviewable column\n * (`{\"scopes\": \"...\"}` in the blob would otherwise clobber the parsed `Scopes` column).\n */\nexport function BuildGenericEnvironmentOverlay(info: PublicAuthProviderInfo): Record<string, unknown> {\n const prefix = environmentPrefix(info.driverClass);\n const overlay: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(info.clientConfiguration ?? {})) {\n if (value !== null && value !== undefined) {\n overlay[`${prefix}_${camelToUpperSnake(key)}`] = value;\n }\n }\n\n if (info.clientId) {\n overlay[`${prefix}_CLIENTID`] = info.clientId;\n }\n if (info.domain) {\n overlay[`${prefix}_DOMAIN`] = info.domain;\n }\n if (Array.isArray(info.scopes) && info.scopes.length > 0) {\n // The catalog publishes scopes pre-parsed (the server splits the delimited column at the\n // trust boundary). The drivers that read this key — Okta and Cognito — hand it straight to\n // SDK config typed `string[]`. The Array.isArray guard keeps a malformed or older server's\n // string value from reaching those SDKs: this module runs at bootstrap, where the contract\n // is degrade-to-compiled-environment, never throw.\n overlay[`${prefix}_SCOPES`] = info.scopes;\n }\n if (info.issuer) {\n overlay[`${prefix}_ISSUER`] = info.issuer;\n }\n\n return overlay;\n}\n\n/** @deprecated Use {@link BuildGenericEnvironmentOverlay}. */\nexport function buildGenericEnvironmentOverlay(info: PublicAuthProviderInfo): Record<string, unknown> {\n return BuildGenericEnvironmentOverlay(info);\n}\n\n/**\n * Produces the environment record to hand a driver for a catalog-selected provider.\n *\n * The app's compiled environment stays the base layer — it carries app-wide settings such as\n * `GRAPHQL_URI` that have nothing to do with the identity provider — and the catalog overlays\n * only the provider's own keys on top. Metadata therefore wins over a stale compiled value for\n * the settings it owns, without the catalog having to restate the whole environment.\n *\n * @param environment The app's compiled environment object.\n * @param info The provider selected from the catalog.\n * @param providerClass The resolved `MJAuthBase` subclass, consulted for a custom mapper.\n */\nexport function MergeCatalogEnvironment(\n environment: Record<string, unknown>,\n info: PublicAuthProviderInfo,\n providerClass?: CatalogEnvironmentMapper\n): Record<string, unknown> {\n const overlay =\n typeof providerClass?.EnvironmentFromCatalog === 'function'\n ? providerClass.EnvironmentFromCatalog(info)\n : BuildGenericEnvironmentOverlay(info);\n\n return { ...environment, ...overlay, AUTH_TYPE: info.driverClass };\n}\n\n/** @deprecated Use {@link MergeCatalogEnvironment}. */\nexport function mergeCatalogEnvironment(\n environment: Record<string, unknown>,\n info: PublicAuthProviderInfo,\n providerClass?: CatalogEnvironmentMapper\n): Record<string, unknown> {\n return MergeCatalogEnvironment(environment, info, providerClass);\n}\n"]}
|
|
@@ -11,7 +11,7 @@ import * as i0 from "@angular/core";
|
|
|
11
11
|
* but consumers never need to know this detail.
|
|
12
12
|
*/
|
|
13
13
|
export declare class MJAuth0Provider extends MJAuthBase {
|
|
14
|
-
|
|
14
|
+
Auth: AuthService;
|
|
15
15
|
static readonly PROVIDER_TYPE = "auth0";
|
|
16
16
|
readonly type = "auth0";
|
|
17
17
|
private _initialized;
|
|
@@ -19,8 +19,16 @@ export declare class MJAuth0Provider extends MJAuthBase {
|
|
|
19
19
|
* Factory function to provide Angular dependencies required by Auth0
|
|
20
20
|
* Stored as a static property for the factory to access without instantiation
|
|
21
21
|
*/
|
|
22
|
-
static
|
|
23
|
-
|
|
22
|
+
static AngularProviderFactory: (environment: Record<string, unknown>) => Provider[];
|
|
23
|
+
/** @deprecated Use {@link AngularProviderFactory}. */
|
|
24
|
+
static get angularProviderFactory(): (environment: Record<string, unknown>) => Provider[];
|
|
25
|
+
/** @deprecated Use {@link AngularProviderFactory}. */
|
|
26
|
+
static set angularProviderFactory(value: (environment: Record<string, unknown>) => Provider[]);
|
|
27
|
+
constructor(Auth: AuthService);
|
|
28
|
+
/** @deprecated Use {@link Auth}. */
|
|
29
|
+
get auth(): AuthService;
|
|
30
|
+
/** @deprecated Use {@link Auth}. */
|
|
31
|
+
set auth(value: AuthService);
|
|
24
32
|
initialize(): Promise<void>;
|
|
25
33
|
protected loginInternal(options?: Record<string, unknown>): Promise<void>;
|
|
26
34
|
protected logoutInternal(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mjexplorer-auth0-provider.service.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/mjexplorer-auth0-provider.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,QAAQ,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAyG,MAAM,sBAAsB,CAAC;AAI1J,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EAEjB,kBAAkB,EACnB,MAAM,eAAe,CAAC;;AACvB;;;;;;GAMG;AACH,qBAIa,eAAgB,SAAQ,UAAU;
|
|
1
|
+
{"version":3,"file":"mjexplorer-auth0-provider.service.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/mjexplorer-auth0-provider.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,QAAQ,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,WAA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CAAC,gBAAgB,GAAG,IAAI,CAAC;IAc3E;;;;;OAKG;cACa,oBAAoB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IA6CnE;;;;OAIG;IACH,SAAS,CAAC,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB;YAgEpD,iBAAiB;IAM/B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAc9B;;;;;OAKG;cACa,4BAA4B,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAUtE;;;;;;OAMG;cACa,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC;IASnD,iBAAiB,IAAI,MAAM,EAAE;IAI7B,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO;yCAnYvD,eAAe;6CAAf,eAAe;CAuY3B"}
|
|
@@ -23,7 +23,7 @@ import * as i1 from "@auth0/auth0-angular";
|
|
|
23
23
|
*/
|
|
24
24
|
let MJAuth0Provider = class MJAuth0Provider extends MJAuthBase {
|
|
25
25
|
static { MJAuth0Provider_1 = this; }
|
|
26
|
-
|
|
26
|
+
Auth;
|
|
27
27
|
static PROVIDER_TYPE = 'auth0';
|
|
28
28
|
type = MJAuth0Provider_1.PROVIDER_TYPE;
|
|
29
29
|
_initialized = false;
|
|
@@ -31,7 +31,7 @@ let MJAuth0Provider = class MJAuth0Provider extends MJAuthBase {
|
|
|
31
31
|
* Factory function to provide Angular dependencies required by Auth0
|
|
32
32
|
* Stored as a static property for the factory to access without instantiation
|
|
33
33
|
*/
|
|
34
|
-
static
|
|
34
|
+
static AngularProviderFactory = (environment) => {
|
|
35
35
|
// Check if we're on the MCP OAuth callback path
|
|
36
36
|
const isMCPOAuthCallback = window.location.pathname.startsWith('/oauth/callback');
|
|
37
37
|
return [
|
|
@@ -67,13 +67,29 @@ let MJAuth0Provider = class MJAuth0Provider extends MJAuthBase {
|
|
|
67
67
|
}
|
|
68
68
|
];
|
|
69
69
|
};
|
|
70
|
-
|
|
70
|
+
/** @deprecated Use {@link AngularProviderFactory}. */
|
|
71
|
+
static get angularProviderFactory() {
|
|
72
|
+
return this.AngularProviderFactory;
|
|
73
|
+
}
|
|
74
|
+
/** @deprecated Use {@link AngularProviderFactory}. */
|
|
75
|
+
static set angularProviderFactory(value) {
|
|
76
|
+
this.AngularProviderFactory = value;
|
|
77
|
+
}
|
|
78
|
+
constructor(Auth) {
|
|
71
79
|
const config = {
|
|
72
80
|
name: MJAuth0Provider_1.PROVIDER_TYPE,
|
|
73
81
|
type: MJAuth0Provider_1.PROVIDER_TYPE
|
|
74
82
|
};
|
|
75
83
|
super(config);
|
|
76
|
-
this.
|
|
84
|
+
this.Auth = Auth;
|
|
85
|
+
}
|
|
86
|
+
/** @deprecated Use {@link Auth}. */
|
|
87
|
+
get auth() {
|
|
88
|
+
return this.Auth;
|
|
89
|
+
}
|
|
90
|
+
/** @deprecated Use {@link Auth}. */
|
|
91
|
+
set auth(value) {
|
|
92
|
+
this.Auth = value;
|
|
77
93
|
}
|
|
78
94
|
// ============================================================================
|
|
79
95
|
// LIFECYCLE METHODS
|
|
@@ -84,23 +100,23 @@ let MJAuth0Provider = class MJAuth0Provider extends MJAuthBase {
|
|
|
84
100
|
}
|
|
85
101
|
// CRITICAL: Wait for Auth0 SDK to process any redirect callback
|
|
86
102
|
// The SDK handles this internally and updates isLoading$ when done
|
|
87
|
-
await firstValueFrom(this.
|
|
103
|
+
await firstValueFrom(this.Auth.isLoading$.pipe(filter(loading => !loading), take(1)));
|
|
88
104
|
// Get current authentication state
|
|
89
|
-
const isAuthenticated = await firstValueFrom(this.
|
|
105
|
+
const isAuthenticated = await firstValueFrom(this.Auth.isAuthenticated$);
|
|
90
106
|
// CRITICAL: Get current user BEFORE setting up subscriptions
|
|
91
107
|
// This ensures userInfo$ has a value before app.component.ts subscribes
|
|
92
108
|
if (isAuthenticated) {
|
|
93
|
-
const user = await firstValueFrom(this.
|
|
109
|
+
const user = await firstValueFrom(this.Auth.user$);
|
|
94
110
|
if (user) {
|
|
95
111
|
const userInfo = this.mapAuth0UserToStandard(user);
|
|
96
112
|
this.updateUserInfo(userInfo);
|
|
97
113
|
}
|
|
98
114
|
}
|
|
99
115
|
// Subscribe to authentication state and user info for future changes
|
|
100
|
-
this.
|
|
116
|
+
this.Auth.isAuthenticated$.subscribe((loggedIn) => {
|
|
101
117
|
this.updateAuthState(loggedIn);
|
|
102
118
|
});
|
|
103
|
-
this.
|
|
119
|
+
this.Auth.user$.subscribe((user) => {
|
|
104
120
|
if (user) {
|
|
105
121
|
const userInfo = this.mapAuth0UserToStandard(user);
|
|
106
122
|
this.updateUserInfo(userInfo);
|
|
@@ -113,12 +129,12 @@ let MJAuth0Provider = class MJAuth0Provider extends MJAuthBase {
|
|
|
113
129
|
}
|
|
114
130
|
async loginInternal(options) {
|
|
115
131
|
await this.ensureInitialized();
|
|
116
|
-
this.
|
|
132
|
+
this.Auth.loginWithRedirect(options);
|
|
117
133
|
}
|
|
118
134
|
async logoutInternal() {
|
|
119
135
|
// Subscribe to the Observable so Auth0 Angular SDK v2's authState.refresh() fires.
|
|
120
136
|
try {
|
|
121
|
-
await firstValueFrom(this.
|
|
137
|
+
await firstValueFrom(this.Auth.logout({ logoutParams: { returnTo: document.location.origin } }));
|
|
122
138
|
}
|
|
123
139
|
catch {
|
|
124
140
|
// Expected when Auth0 redirects the browser before the Observable completes.
|
|
@@ -139,7 +155,7 @@ let MJAuth0Provider = class MJAuth0Provider extends MJAuthBase {
|
|
|
139
155
|
*/
|
|
140
156
|
async extractIdTokenInternal() {
|
|
141
157
|
try {
|
|
142
|
-
const claims = await firstValueFrom(this.
|
|
158
|
+
const claims = await firstValueFrom(this.Auth.idTokenClaims$);
|
|
143
159
|
// Auth0-specific detail: JWT is in __raw property
|
|
144
160
|
return claims?.__raw || null;
|
|
145
161
|
}
|
|
@@ -155,7 +171,7 @@ let MJAuth0Provider = class MJAuth0Provider extends MJAuthBase {
|
|
|
155
171
|
*/
|
|
156
172
|
async extractTokenInfoInternal() {
|
|
157
173
|
try {
|
|
158
|
-
const claims = await firstValueFrom(this.
|
|
174
|
+
const claims = await firstValueFrom(this.Auth.idTokenClaims$);
|
|
159
175
|
if (!claims) {
|
|
160
176
|
return null;
|
|
161
177
|
}
|
|
@@ -181,7 +197,7 @@ let MJAuth0Provider = class MJAuth0Provider extends MJAuthBase {
|
|
|
181
197
|
*/
|
|
182
198
|
async extractUserInfoInternal() {
|
|
183
199
|
try {
|
|
184
|
-
const user = await firstValueFrom(this.
|
|
200
|
+
const user = await firstValueFrom(this.Auth.user$);
|
|
185
201
|
if (!user) {
|
|
186
202
|
return null;
|
|
187
203
|
}
|
|
@@ -203,7 +219,7 @@ let MJAuth0Provider = class MJAuth0Provider extends MJAuthBase {
|
|
|
203
219
|
console.log('[Auth0] Attempting to refresh token...');
|
|
204
220
|
// Force token refresh by bypassing cache
|
|
205
221
|
// With useRefreshTokens: true and offline_access scope, this will use refresh tokens
|
|
206
|
-
await firstValueFrom(this.
|
|
222
|
+
await firstValueFrom(this.Auth.getAccessTokenSilently({
|
|
207
223
|
cacheMode: 'off'
|
|
208
224
|
}));
|
|
209
225
|
// Small delay to ensure Auth0 SDK has updated observables
|
|
@@ -326,7 +342,7 @@ let MJAuth0Provider = class MJAuth0Provider extends MJAuthBase {
|
|
|
326
342
|
*/
|
|
327
343
|
async getProfilePictureUrlInternal() {
|
|
328
344
|
try {
|
|
329
|
-
const user = await firstValueFrom(this.
|
|
345
|
+
const user = await firstValueFrom(this.Auth.user$);
|
|
330
346
|
return user?.picture || null;
|
|
331
347
|
}
|
|
332
348
|
catch (error) {
|