@memberjunction/ng-auth-services 2.129.0 → 2.130.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/lib/IAuthProvider.d.ts +177 -17
- package/dist/lib/IAuthProvider.d.ts.map +1 -1
- package/dist/lib/auth-types.d.ts +351 -0
- package/dist/lib/auth-types.d.ts.map +1 -0
- package/dist/lib/auth-types.js +98 -0
- package/dist/lib/auth-types.js.map +1 -0
- package/dist/lib/mjexplorer-auth-base.service.d.ts +204 -49
- package/dist/lib/mjexplorer-auth-base.service.d.ts.map +1 -1
- package/dist/lib/mjexplorer-auth-base.service.js +173 -67
- package/dist/lib/mjexplorer-auth-base.service.js.map +1 -1
- package/dist/lib/providers/mjexplorer-auth0-provider.service.d.ts +61 -17
- package/dist/lib/providers/mjexplorer-auth0-provider.service.d.ts.map +1 -1
- package/dist/lib/providers/mjexplorer-auth0-provider.service.js +245 -76
- package/dist/lib/providers/mjexplorer-auth0-provider.service.js.map +1 -1
- package/dist/lib/providers/mjexplorer-msal-provider.service.d.ts +57 -16
- package/dist/lib/providers/mjexplorer-msal-provider.service.d.ts.map +1 -1
- package/dist/lib/providers/mjexplorer-msal-provider.service.js +311 -114
- package/dist/lib/providers/mjexplorer-msal-provider.service.js.map +1 -1
- package/dist/lib/providers/mjexplorer-okta-provider.service.d.ts +55 -30
- package/dist/lib/providers/mjexplorer-okta-provider.service.d.ts.map +1 -1
- package/dist/lib/providers/mjexplorer-okta-provider.service.js +263 -235
- package/dist/lib/providers/mjexplorer-okta-provider.service.js.map +1 -1
- package/dist/public-api.d.ts +1 -0
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +2 -0
- package/dist/public-api.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import { MJAuthBase } from '../mjexplorer-auth-base.service';
|
|
2
|
-
import { AuthService,
|
|
3
|
-
import {
|
|
2
|
+
import { AuthService, AuthGuard, Auth0ClientFactory, AuthClientConfig } from '@auth0/auth0-angular';
|
|
3
|
+
import { StandardUserInfo, StandardAuthToken, StandardAuthError, TokenRefreshResult } from '../auth-types';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
export declare function LoadMJAuth0Provider(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Auth0 authentication provider implementation - v3.0.0
|
|
8
|
+
*
|
|
9
|
+
* Implements the abstract methods from MJAuthBase to hide Auth0-specific details.
|
|
10
|
+
* The key abstraction is that Auth0 stores the JWT in `idTokenClaims.__raw`,
|
|
11
|
+
* but consumers never need to know this detail.
|
|
12
|
+
*/
|
|
6
13
|
export declare class MJAuth0Provider extends MJAuthBase {
|
|
7
14
|
auth: AuthService;
|
|
8
15
|
static readonly PROVIDER_TYPE = "auth0";
|
|
9
|
-
type
|
|
16
|
+
readonly type = "auth0";
|
|
10
17
|
private _initialized;
|
|
11
18
|
/**
|
|
12
19
|
* Factory function to provide Angular dependencies required by Auth0
|
|
13
20
|
* Stored as a static property for the factory to access without instantiation
|
|
14
21
|
*/
|
|
15
|
-
static angularProviderFactory: (environment:
|
|
22
|
+
static angularProviderFactory: (environment: Record<string, unknown>) => (typeof AuthService | typeof AuthGuard | {
|
|
16
23
|
provide: import("@angular/core").InjectionToken<import("@auth0/auth0-angular").AuthConfig>;
|
|
17
24
|
useValue: {
|
|
18
|
-
domain:
|
|
19
|
-
clientId:
|
|
25
|
+
domain: unknown;
|
|
26
|
+
clientId: unknown;
|
|
20
27
|
authorizationParams: {
|
|
21
28
|
redirect_uri: string;
|
|
29
|
+
scope: string;
|
|
22
30
|
};
|
|
23
31
|
cacheLocation: string;
|
|
24
32
|
useRefreshTokens: boolean;
|
|
@@ -33,20 +41,56 @@ export declare class MJAuth0Provider extends MJAuthBase {
|
|
|
33
41
|
useValue?: undefined;
|
|
34
42
|
})[];
|
|
35
43
|
constructor(auth: AuthService);
|
|
36
|
-
login(options?: any): Observable<void>;
|
|
37
|
-
private ensureInitialized;
|
|
38
|
-
logout(): Promise<void>;
|
|
39
|
-
refresh(): Promise<Observable<any>>;
|
|
40
|
-
getUser(): Promise<Observable<User | null | undefined>>;
|
|
41
|
-
isAuthenticated(): Observable<boolean>;
|
|
42
|
-
getUserClaims(): Promise<Observable<any>>;
|
|
43
|
-
checkExpiredTokenError(error: string): boolean;
|
|
44
44
|
initialize(): Promise<void>;
|
|
45
|
-
protected loginInternal(options?:
|
|
46
|
-
|
|
45
|
+
protected loginInternal(options?: Record<string, unknown>): Promise<void>;
|
|
46
|
+
logout(): Promise<void>;
|
|
47
47
|
handleCallback(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Extract ID token from Auth0's storage
|
|
50
|
+
*
|
|
51
|
+
* Auth0 stores the JWT string in idTokenClaims.__raw
|
|
52
|
+
* This is the key abstraction - consumers never need to know about __raw!
|
|
53
|
+
*/
|
|
54
|
+
protected extractIdTokenInternal(): Promise<string | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Extract complete token info from Auth0
|
|
57
|
+
*
|
|
58
|
+
* Maps Auth0's token structure to StandardAuthToken
|
|
59
|
+
*/
|
|
60
|
+
protected extractTokenInfoInternal(): Promise<StandardAuthToken | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Extract user info from Auth0 claims
|
|
63
|
+
*
|
|
64
|
+
* Maps Auth0's user object structure to StandardUserInfo
|
|
65
|
+
*/
|
|
66
|
+
protected extractUserInfoInternal(): Promise<StandardUserInfo | null>;
|
|
67
|
+
/**
|
|
68
|
+
* Refresh token using Auth0's silent authentication
|
|
69
|
+
*
|
|
70
|
+
* Uses cacheMode: 'off' to bypass cache and force token refresh
|
|
71
|
+
* With useRefreshTokens: true and offline_access scope, this will use refresh tokens
|
|
72
|
+
*/
|
|
73
|
+
protected refreshTokenInternal(): Promise<TokenRefreshResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Classify Auth0-specific errors into semantic types
|
|
76
|
+
*
|
|
77
|
+
* Maps Auth0 error patterns to AuthErrorType enum
|
|
78
|
+
*/
|
|
79
|
+
protected classifyErrorInternal(error: unknown): StandardAuthError;
|
|
80
|
+
private ensureInitialized;
|
|
81
|
+
/**
|
|
82
|
+
* Map Auth0 User object to StandardUserInfo
|
|
83
|
+
*/
|
|
84
|
+
private mapAuth0UserToStandard;
|
|
85
|
+
/**
|
|
86
|
+
* Get profile picture URL from Auth0
|
|
87
|
+
*
|
|
88
|
+
* Auth0 includes the picture URL directly in user claims.
|
|
89
|
+
* No additional API call needed.
|
|
90
|
+
*/
|
|
91
|
+
protected getProfilePictureUrlInternal(): Promise<string | null>;
|
|
48
92
|
getRequiredConfig(): string[];
|
|
49
|
-
validateConfig(_config:
|
|
93
|
+
validateConfig(_config: Record<string, unknown>): boolean;
|
|
50
94
|
static ɵfac: i0.ɵɵFactoryDeclaration<MJAuth0Provider, never>;
|
|
51
95
|
static ɵprov: i0.ɵɵInjectableDeclaration<MJAuth0Provider>;
|
|
52
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mjexplorer-auth0-provider.service.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/mjexplorer-auth0-provider.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"mjexplorer-auth0-provider.service.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/mjexplorer-auth0-provider.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAiB,SAAS,EAAyC,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAI1J,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EAEjB,kBAAkB,EACnB,MAAM,eAAe,CAAC;;AAGvB,wBAAgB,mBAAmB,SAClC;AAED;;;;;;GAMG;AACH,qBAIa,eAAgB,SAAQ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from '@memberjunction/global';
|
|
10
10
|
import { MJAuthBase } from '../mjexplorer-auth-base.service';
|
|
11
11
|
import { AuthService, AuthGuard, AuthConfigService, Auth0ClientService, Auth0ClientFactory, AuthClientConfig } from '@auth0/auth0-angular';
|
|
12
|
-
import {
|
|
12
|
+
import { firstValueFrom } from 'rxjs';
|
|
13
|
+
import { take, filter } from 'rxjs/operators';
|
|
14
|
+
import { AuthErrorType } from '../auth-types';
|
|
13
15
|
import * as i0 from "@angular/core";
|
|
14
16
|
import * as i1 from "@auth0/auth0-angular";
|
|
15
17
|
// Prevent tree-shaking by explicitly referencing the class
|
|
16
18
|
export function LoadMJAuth0Provider() {
|
|
17
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Auth0 authentication provider implementation - v3.0.0
|
|
22
|
+
*
|
|
23
|
+
* Implements the abstract methods from MJAuthBase to hide Auth0-specific details.
|
|
24
|
+
* The key abstraction is that Auth0 stores the JWT in `idTokenClaims.__raw`,
|
|
25
|
+
* but consumers never need to know this detail.
|
|
26
|
+
*/
|
|
18
27
|
let MJAuth0Provider = class MJAuth0Provider extends MJAuthBase {
|
|
19
28
|
static { MJAuth0Provider_1 = this; }
|
|
20
29
|
auth;
|
|
@@ -31,10 +40,11 @@ let MJAuth0Provider = class MJAuth0Provider extends MJAuthBase {
|
|
|
31
40
|
{
|
|
32
41
|
provide: AuthConfigService,
|
|
33
42
|
useValue: {
|
|
34
|
-
domain: environment
|
|
35
|
-
clientId: environment
|
|
43
|
+
domain: environment['AUTH0_DOMAIN'],
|
|
44
|
+
clientId: environment['AUTH0_CLIENTID'],
|
|
36
45
|
authorizationParams: {
|
|
37
46
|
redirect_uri: window.location.origin,
|
|
47
|
+
scope: 'openid profile email offline_access',
|
|
38
48
|
// No audience parameter - uses ID tokens (matches pre-refactor behavior)
|
|
39
49
|
// ID tokens have aud=clientId by default and contain user claims
|
|
40
50
|
},
|
|
@@ -58,109 +68,268 @@ let MJAuth0Provider = class MJAuth0Provider extends MJAuthBase {
|
|
|
58
68
|
};
|
|
59
69
|
super(config);
|
|
60
70
|
this.auth = auth;
|
|
61
|
-
// Defer subscription to avoid blocking app startup
|
|
62
71
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this.
|
|
68
|
-
|
|
69
|
-
return of(void 0);
|
|
70
|
-
}
|
|
71
|
-
async ensureInitialized() {
|
|
72
|
-
if (!this._initialized) {
|
|
73
|
-
await this.initialize();
|
|
72
|
+
// ============================================================================
|
|
73
|
+
// LIFECYCLE METHODS
|
|
74
|
+
// ============================================================================
|
|
75
|
+
async initialize() {
|
|
76
|
+
if (this._initialized) {
|
|
77
|
+
return;
|
|
74
78
|
}
|
|
79
|
+
// CRITICAL: Wait for Auth0 SDK to process any redirect callback
|
|
80
|
+
// The SDK handles this internally and updates isLoading$ when done
|
|
81
|
+
await firstValueFrom(this.auth.isLoading$.pipe(filter(loading => !loading), take(1)));
|
|
82
|
+
// Get current authentication state
|
|
83
|
+
const isAuthenticated = await firstValueFrom(this.auth.isAuthenticated$);
|
|
84
|
+
// CRITICAL: Get current user BEFORE setting up subscriptions
|
|
85
|
+
// This ensures userInfo$ has a value before app.component.ts subscribes
|
|
86
|
+
if (isAuthenticated) {
|
|
87
|
+
const user = await firstValueFrom(this.auth.user$);
|
|
88
|
+
if (user) {
|
|
89
|
+
const userInfo = this.mapAuth0UserToStandard(user);
|
|
90
|
+
this.updateUserInfo(userInfo);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Subscribe to authentication state and user info for future changes
|
|
94
|
+
this.auth.isAuthenticated$.subscribe((loggedIn) => {
|
|
95
|
+
this.updateAuthState(loggedIn);
|
|
96
|
+
});
|
|
97
|
+
this.auth.user$.subscribe((user) => {
|
|
98
|
+
if (user) {
|
|
99
|
+
const userInfo = this.mapAuth0UserToStandard(user);
|
|
100
|
+
this.updateUserInfo(userInfo);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.updateUserInfo(null);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
this._initialized = true;
|
|
107
|
+
}
|
|
108
|
+
async loginInternal(options) {
|
|
109
|
+
await this.ensureInitialized();
|
|
110
|
+
this.auth.loginWithRedirect(options);
|
|
75
111
|
}
|
|
76
112
|
async logout() {
|
|
77
113
|
this.auth.logout({ logoutParams: { returnTo: document.location.origin } });
|
|
78
114
|
}
|
|
79
|
-
async
|
|
115
|
+
async handleCallback() {
|
|
116
|
+
// Auth0 Angular SDK handles callbacks internally via interceptors
|
|
117
|
+
// This method exists for interface compatibility
|
|
118
|
+
}
|
|
119
|
+
// ============================================================================
|
|
120
|
+
// ABSTRACT METHOD IMPLEMENTATIONS (v3.0.0)
|
|
121
|
+
// ============================================================================
|
|
122
|
+
/**
|
|
123
|
+
* Extract ID token from Auth0's storage
|
|
124
|
+
*
|
|
125
|
+
* Auth0 stores the JWT string in idTokenClaims.__raw
|
|
126
|
+
* This is the key abstraction - consumers never need to know about __raw!
|
|
127
|
+
*/
|
|
128
|
+
async extractIdTokenInternal() {
|
|
129
|
+
try {
|
|
130
|
+
const claims = await firstValueFrom(this.auth.idTokenClaims$);
|
|
131
|
+
// Auth0-specific detail: JWT is in __raw property
|
|
132
|
+
return claims?.__raw || null;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
console.error('[Auth0] Error extracting ID token:', error);
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Extract complete token info from Auth0
|
|
141
|
+
*
|
|
142
|
+
* Maps Auth0's token structure to StandardAuthToken
|
|
143
|
+
*/
|
|
144
|
+
async extractTokenInfoInternal() {
|
|
145
|
+
try {
|
|
146
|
+
const claims = await firstValueFrom(this.auth.idTokenClaims$);
|
|
147
|
+
if (!claims) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const idToken = claims.__raw;
|
|
151
|
+
if (!idToken) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
idToken,
|
|
156
|
+
expiresAt: claims.exp ? claims.exp * 1000 : 0, // Convert to milliseconds
|
|
157
|
+
scopes: claims.scope ? claims.scope.split(' ') : undefined
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
console.error('[Auth0] Error extracting token info:', error);
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Extract user info from Auth0 claims
|
|
167
|
+
*
|
|
168
|
+
* Maps Auth0's user object structure to StandardUserInfo
|
|
169
|
+
*/
|
|
170
|
+
async extractUserInfoInternal() {
|
|
171
|
+
try {
|
|
172
|
+
const user = await firstValueFrom(this.auth.user$);
|
|
173
|
+
if (!user) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
return this.mapAuth0UserToStandard(user);
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
console.error('[Auth0] Error extracting user info:', error);
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Refresh token using Auth0's silent authentication
|
|
185
|
+
*
|
|
186
|
+
* Uses cacheMode: 'off' to bypass cache and force token refresh
|
|
187
|
+
* With useRefreshTokens: true and offline_access scope, this will use refresh tokens
|
|
188
|
+
*/
|
|
189
|
+
async refreshTokenInternal() {
|
|
80
190
|
try {
|
|
81
|
-
console.log('[Auth0]
|
|
82
|
-
// Force token refresh
|
|
83
|
-
//
|
|
191
|
+
console.log('[Auth0] Attempting to refresh token...');
|
|
192
|
+
// Force token refresh by bypassing cache
|
|
193
|
+
// With useRefreshTokens: true and offline_access scope, this will use refresh tokens
|
|
84
194
|
await firstValueFrom(this.auth.getAccessTokenSilently({
|
|
85
|
-
cacheMode: 'off'
|
|
86
|
-
authorizationParams: {
|
|
87
|
-
ignoreCache: true
|
|
88
|
-
}
|
|
195
|
+
cacheMode: 'off'
|
|
89
196
|
}));
|
|
90
|
-
|
|
91
|
-
// Small delay to ensure Auth0 SDK has updated idTokenClaims$ observable
|
|
197
|
+
// Small delay to ensure Auth0 SDK has updated observables
|
|
92
198
|
await new Promise(resolve => setTimeout(resolve, 100));
|
|
93
|
-
//
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
199
|
+
// Extract fresh token info from updated observables
|
|
200
|
+
const token = await this.extractTokenInfoInternal();
|
|
201
|
+
if (!token) {
|
|
202
|
+
return {
|
|
203
|
+
success: false,
|
|
204
|
+
error: {
|
|
205
|
+
type: AuthErrorType.NO_ACTIVE_SESSION,
|
|
206
|
+
message: 'Token refresh succeeded but could not extract token info',
|
|
207
|
+
userMessage: 'Session refresh failed. Please log in again.'
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
console.log('[Auth0] Token refresh successful', {
|
|
212
|
+
expiresAt: new Date(token.expiresAt).toISOString()
|
|
98
213
|
});
|
|
99
|
-
|
|
100
|
-
|
|
214
|
+
return {
|
|
215
|
+
success: true,
|
|
216
|
+
token
|
|
217
|
+
};
|
|
101
218
|
}
|
|
102
219
|
catch (error) {
|
|
103
|
-
console.error('[Auth0]
|
|
104
|
-
|
|
105
|
-
|
|
220
|
+
console.error('[Auth0] Token refresh failed:', error);
|
|
221
|
+
return {
|
|
222
|
+
success: false,
|
|
223
|
+
error: this.classifyErrorInternal(error)
|
|
224
|
+
};
|
|
106
225
|
}
|
|
107
226
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Classify Auth0-specific errors into semantic types
|
|
229
|
+
*
|
|
230
|
+
* Maps Auth0 error patterns to AuthErrorType enum
|
|
231
|
+
*/
|
|
232
|
+
classifyErrorInternal(error) {
|
|
233
|
+
const errorObj = error;
|
|
234
|
+
const message = errorObj?.['message'] || 'Unknown error';
|
|
235
|
+
const errorType = errorObj?.['error'] || '';
|
|
236
|
+
// Check for specific Auth0 error patterns
|
|
237
|
+
if (message.includes('jwt expired') || message.includes('token expired')) {
|
|
238
|
+
return {
|
|
239
|
+
type: AuthErrorType.TOKEN_EXPIRED,
|
|
240
|
+
message,
|
|
241
|
+
originalError: error,
|
|
242
|
+
userMessage: 'Your session has expired. Please log in again.'
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
if (errorType === 'login_required' || message.includes('login_required')) {
|
|
246
|
+
return {
|
|
247
|
+
type: AuthErrorType.NO_ACTIVE_SESSION,
|
|
248
|
+
message,
|
|
249
|
+
originalError: error,
|
|
250
|
+
userMessage: 'You need to log in to continue.'
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
if (errorType === 'consent_required' || message.includes('consent_required')) {
|
|
254
|
+
return {
|
|
255
|
+
type: AuthErrorType.INTERACTION_REQUIRED,
|
|
256
|
+
message,
|
|
257
|
+
originalError: error,
|
|
258
|
+
userMessage: 'Additional permissions are required. Please log in again.'
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
if (message.includes('user closed') || message.includes('cancelled')) {
|
|
262
|
+
return {
|
|
263
|
+
type: AuthErrorType.USER_CANCELLED,
|
|
264
|
+
message,
|
|
265
|
+
originalError: error,
|
|
266
|
+
userMessage: 'Login was cancelled.'
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
if (message.includes('network') || message.includes('fetch')) {
|
|
270
|
+
return {
|
|
271
|
+
type: AuthErrorType.NETWORK_ERROR,
|
|
272
|
+
message,
|
|
273
|
+
originalError: error,
|
|
274
|
+
userMessage: 'Network error. Please check your connection and try again.'
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
// Default to unknown error
|
|
278
|
+
return {
|
|
279
|
+
type: AuthErrorType.UNKNOWN_ERROR,
|
|
280
|
+
message,
|
|
281
|
+
originalError: error,
|
|
282
|
+
userMessage: 'An unexpected error occurred. Please try again.'
|
|
283
|
+
};
|
|
128
284
|
}
|
|
129
|
-
//
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
285
|
+
// ============================================================================
|
|
286
|
+
// HELPER METHODS
|
|
287
|
+
// ============================================================================
|
|
288
|
+
async ensureInitialized() {
|
|
289
|
+
if (!this._initialized) {
|
|
290
|
+
await this.initialize();
|
|
133
291
|
}
|
|
134
|
-
// Auth0 Angular SDK handles initialization internally
|
|
135
|
-
// Just subscribe to authentication state once
|
|
136
|
-
this.auth.isAuthenticated$.subscribe((loggedIn) => {
|
|
137
|
-
this.updateAuthState(loggedIn);
|
|
138
|
-
});
|
|
139
|
-
this._initialized = true;
|
|
140
292
|
}
|
|
141
|
-
|
|
142
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Map Auth0 User object to StandardUserInfo
|
|
295
|
+
*/
|
|
296
|
+
mapAuth0UserToStandard(user) {
|
|
297
|
+
return {
|
|
298
|
+
id: user.sub || '',
|
|
299
|
+
email: user.email || '',
|
|
300
|
+
name: user.name || '',
|
|
301
|
+
givenName: user.given_name,
|
|
302
|
+
familyName: user.family_name,
|
|
303
|
+
preferredUsername: user.nickname,
|
|
304
|
+
pictureUrl: user.picture,
|
|
305
|
+
locale: user.locale,
|
|
306
|
+
emailVerified: user.email_verified
|
|
307
|
+
};
|
|
143
308
|
}
|
|
144
|
-
|
|
309
|
+
/**
|
|
310
|
+
* Get profile picture URL from Auth0
|
|
311
|
+
*
|
|
312
|
+
* Auth0 includes the picture URL directly in user claims.
|
|
313
|
+
* No additional API call needed.
|
|
314
|
+
*/
|
|
315
|
+
async getProfilePictureUrlInternal() {
|
|
145
316
|
try {
|
|
146
|
-
const
|
|
147
|
-
return
|
|
317
|
+
const user = await firstValueFrom(this.auth.user$);
|
|
318
|
+
return user?.picture || null;
|
|
148
319
|
}
|
|
149
320
|
catch (error) {
|
|
150
|
-
console.error('Error getting
|
|
321
|
+
console.error('[Auth0] Error getting profile picture:', error);
|
|
151
322
|
return null;
|
|
152
323
|
}
|
|
153
324
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
325
|
+
// ============================================================================
|
|
326
|
+
// CONFIGURATION
|
|
327
|
+
// ============================================================================
|
|
158
328
|
getRequiredConfig() {
|
|
159
329
|
return ['clientId', 'domain'];
|
|
160
330
|
}
|
|
161
331
|
validateConfig(_config) {
|
|
162
332
|
// Auth0 configuration is handled by Angular module providers
|
|
163
|
-
// Prefix with underscore to indicate intentionally unused
|
|
164
333
|
return true;
|
|
165
334
|
}
|
|
166
335
|
static ɵfac = function MJAuth0Provider_Factory(t) { return new (t || MJAuth0Provider)(i0.ɵɵinject(i1.AuthService)); };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mjexplorer-auth0-provider.service.js","sourceRoot":"","sources":["../../../src/lib/providers/mjexplorer-auth0-provider.service.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAiB,SAAS,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC1J,OAAO,
|
|
1
|
+
{"version":3,"file":"mjexplorer-auth0-provider.service.js","sourceRoot":"","sources":["../../../src/lib/providers/mjexplorer-auth0-provider.service.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,E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e;IAD3B,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC;GACtB,eAAe,CAwV3B;;iFAxVY,eAAe;cAJ3B,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB"}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { OnDestroy } from '@angular/core';
|
|
2
2
|
import { MJAuthBase } from '../mjexplorer-auth-base.service';
|
|
3
|
-
import { Observable } from 'rxjs';
|
|
4
3
|
import { MsalBroadcastService, MsalService, MsalGuard } from '@azure/msal-angular';
|
|
5
|
-
import { AccountInfo } from '@azure/msal-common';
|
|
6
4
|
import { PublicClientApplication, InteractionType } from '@azure/msal-browser';
|
|
5
|
+
import { StandardUserInfo, StandardAuthToken, StandardAuthError, TokenRefreshResult } from '../auth-types';
|
|
7
6
|
import * as i0 from "@angular/core";
|
|
8
7
|
export declare function LoadMJMSALProvider(): void;
|
|
8
|
+
/**
|
|
9
|
+
* MSAL (Microsoft Authentication Library) provider implementation - v3.0.0
|
|
10
|
+
*
|
|
11
|
+
* Implements the abstract methods from MJAuthBase to hide MSAL-specific details.
|
|
12
|
+
* The key abstraction is that MSAL stores the JWT in AuthenticationResult.idToken,
|
|
13
|
+
* but consumers never need to know this detail.
|
|
14
|
+
*/
|
|
9
15
|
export declare class MJMSALProvider extends MJAuthBase implements OnDestroy {
|
|
10
16
|
auth: MsalService;
|
|
11
17
|
private msalBroadcastService;
|
|
12
18
|
static readonly PROVIDER_TYPE = "msal";
|
|
13
|
-
type
|
|
19
|
+
readonly type = "msal";
|
|
14
20
|
private readonly _destroying$;
|
|
15
21
|
private readonly _initializationCompleted$;
|
|
16
22
|
private _initPromise;
|
|
@@ -18,7 +24,7 @@ export declare class MJMSALProvider extends MJAuthBase implements OnDestroy {
|
|
|
18
24
|
* Factory function to provide Angular dependencies required by MSAL
|
|
19
25
|
* Stored as a static property for the factory to access without instantiation
|
|
20
26
|
*/
|
|
21
|
-
static angularProviderFactory: (environment:
|
|
27
|
+
static angularProviderFactory: (environment: Record<string, unknown>) => (typeof MsalService | typeof MsalBroadcastService | typeof MsalGuard | {
|
|
22
28
|
provide: import("@angular/core").InjectionToken<string>;
|
|
23
29
|
useValue: PublicClientApplication;
|
|
24
30
|
} | {
|
|
@@ -39,22 +45,57 @@ export declare class MJMSALProvider extends MJAuthBase implements OnDestroy {
|
|
|
39
45
|
};
|
|
40
46
|
})[];
|
|
41
47
|
constructor(auth: MsalService, msalBroadcastService: MsalBroadcastService);
|
|
42
|
-
|
|
48
|
+
initialize(): Promise<void>;
|
|
43
49
|
private _performInitialization;
|
|
44
|
-
|
|
45
|
-
login(options?: any): Observable<void>;
|
|
50
|
+
protected loginInternal(options?: Record<string, unknown>): Promise<void>;
|
|
46
51
|
logout(): Promise<void>;
|
|
47
|
-
refresh(): Promise<Observable<any>>;
|
|
48
|
-
getUser(): Promise<AccountInfo | null>;
|
|
49
|
-
isAuthenticated(): Observable<boolean>;
|
|
50
|
-
getUserClaims(): Promise<Observable<any>>;
|
|
51
|
-
checkExpiredTokenError(error: string): boolean;
|
|
52
|
-
initialize(): Promise<void>;
|
|
53
|
-
protected loginInternal(options?: any): Promise<void>;
|
|
54
|
-
getToken(): Promise<string | null>;
|
|
55
52
|
handleCallback(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Extract ID token from MSAL's storage
|
|
55
|
+
*
|
|
56
|
+
* MSAL stores the JWT in AuthenticationResult.idToken
|
|
57
|
+
* This is the key abstraction - consumers never need to know about MSAL's structure!
|
|
58
|
+
*/
|
|
59
|
+
protected extractIdTokenInternal(): Promise<string | null>;
|
|
60
|
+
/**
|
|
61
|
+
* Extract complete token info from MSAL
|
|
62
|
+
*
|
|
63
|
+
* Maps MSAL's AuthenticationResult to StandardAuthToken
|
|
64
|
+
*/
|
|
65
|
+
protected extractTokenInfoInternal(): Promise<StandardAuthToken | null>;
|
|
66
|
+
/**
|
|
67
|
+
* Extract user info from MSAL account
|
|
68
|
+
*
|
|
69
|
+
* Maps MSAL's AccountInfo structure to StandardUserInfo
|
|
70
|
+
*/
|
|
71
|
+
protected extractUserInfoInternal(): Promise<StandardUserInfo | null>;
|
|
72
|
+
/**
|
|
73
|
+
* Refresh token using MSAL's silent token acquisition
|
|
74
|
+
*
|
|
75
|
+
* Uses acquireTokenSilent with forceRefresh to get new tokens
|
|
76
|
+
*/
|
|
77
|
+
protected refreshTokenInternal(): Promise<TokenRefreshResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Classify MSAL-specific errors into semantic types
|
|
80
|
+
*
|
|
81
|
+
* Maps MSAL error classes to AuthErrorType enum
|
|
82
|
+
*/
|
|
83
|
+
protected classifyErrorInternal(error: unknown): StandardAuthError;
|
|
84
|
+
private ensureInitialized;
|
|
85
|
+
/**
|
|
86
|
+
* Map MSAL AccountInfo to StandardUserInfo
|
|
87
|
+
*/
|
|
88
|
+
private mapMSALAccountToStandard;
|
|
89
|
+
/**
|
|
90
|
+
* Get profile picture URL from Microsoft Graph API
|
|
91
|
+
*
|
|
92
|
+
* MSAL requires fetching the photo from Microsoft Graph.
|
|
93
|
+
* This is the key advantage of encapsulation - consumers don't need
|
|
94
|
+
* to know about Graph API, they just call getProfilePictureUrl()!
|
|
95
|
+
*/
|
|
96
|
+
protected getProfilePictureUrlInternal(): Promise<string | null>;
|
|
56
97
|
getRequiredConfig(): string[];
|
|
57
|
-
validateConfig(_config:
|
|
98
|
+
validateConfig(_config: Record<string, unknown>): boolean;
|
|
58
99
|
ngOnDestroy(): void;
|
|
59
100
|
static ɵfac: i0.ɵɵFactoryDeclaration<MJMSALProvider, never>;
|
|
60
101
|
static ɵprov: i0.ɵɵInjectableDeclaration<MJMSALProvider>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mjexplorer-msal-provider.service.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/mjexplorer-msal-provider.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,UAAU,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