acsi-core 0.9.27 → 0.9.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +66 -171
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +66 -171
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2228,20 +2228,14 @@ var getMSALInstance = function getMSALInstance(clientId, redirectUri) {
|
|
|
2228
2228
|
var finalClientId = clientId || MICROSOFT_CLIENT_ID;
|
|
2229
2229
|
var finalRedirectUri = redirectUri || MICROSOFT_URL_DIRECT || window.location.origin;
|
|
2230
2230
|
if (!finalClientId) {
|
|
2231
|
-
console.warn('[MSAL] Client ID not configured');
|
|
2232
2231
|
return null;
|
|
2233
2232
|
}
|
|
2234
2233
|
if (!msalInstance) {
|
|
2235
|
-
console.log('[MSAL] Creating new MSAL instance with:', {
|
|
2236
|
-
clientId: finalClientId ? 'configured' : 'missing',
|
|
2237
|
-
redirectUri: finalRedirectUri
|
|
2238
|
-
});
|
|
2239
2234
|
msalInstance = new msalBrowser.PublicClientApplication(msalConfig(finalClientId, finalRedirectUri));
|
|
2240
2235
|
} else {
|
|
2241
2236
|
var _existingConfig$auth, _existingConfig$auth2;
|
|
2242
2237
|
var existingConfig = msalInstance.config;
|
|
2243
2238
|
if ((existingConfig === null || existingConfig === void 0 ? void 0 : (_existingConfig$auth = existingConfig.auth) === null || _existingConfig$auth === void 0 ? void 0 : _existingConfig$auth.clientId) !== finalClientId || (existingConfig === null || existingConfig === void 0 ? void 0 : (_existingConfig$auth2 = existingConfig.auth) === null || _existingConfig$auth2 === void 0 ? void 0 : _existingConfig$auth2.redirectUri) !== finalRedirectUri) {
|
|
2244
|
-
console.warn('[MSAL] Config mismatch detected, creating new instance');
|
|
2245
2239
|
msalInstance = new msalBrowser.PublicClientApplication(msalConfig(finalClientId, finalRedirectUri));
|
|
2246
2240
|
}
|
|
2247
2241
|
}
|
|
@@ -2264,11 +2258,9 @@ var initializeMSAL = function initializeMSAL(clientId, redirectUri) {
|
|
|
2264
2258
|
isInitializing = true;
|
|
2265
2259
|
initPromise = instance.initialize().then(function () {
|
|
2266
2260
|
isInitializing = false;
|
|
2267
|
-
console.log('[MSAL] Instance initialized successfully');
|
|
2268
2261
|
return instance;
|
|
2269
2262
|
})["catch"](function (error) {
|
|
2270
2263
|
isInitializing = false;
|
|
2271
|
-
console.error('[MSAL] Initialization error:', error);
|
|
2272
2264
|
throw error;
|
|
2273
2265
|
});
|
|
2274
2266
|
return Promise.resolve(initPromise);
|
|
@@ -2279,105 +2271,54 @@ var initializeMSAL = function initializeMSAL(clientId, redirectUri) {
|
|
|
2279
2271
|
var handleMSALRedirect = function handleMSALRedirect(clientId, redirectUri) {
|
|
2280
2272
|
try {
|
|
2281
2273
|
if (!window.location.hash) {
|
|
2282
|
-
console.log('[MSAL] handleMSALRedirect: No hash found in URL');
|
|
2283
2274
|
return Promise.resolve(null);
|
|
2284
2275
|
}
|
|
2285
|
-
console.log('[MSAL] handleMSALRedirect: Hash found:', window.location.hash.substring(0, 100) + '...');
|
|
2286
2276
|
var hashParams = new URLSearchParams(window.location.hash.substring(1));
|
|
2287
2277
|
var hasAccessToken = hashParams.has('access_token');
|
|
2288
2278
|
var hasIdToken = hashParams.has('id_token');
|
|
2289
2279
|
var hasError = hashParams.has('error');
|
|
2290
2280
|
var hasCode = hashParams.has('code');
|
|
2291
2281
|
var hasMSALParams = hasAccessToken || hasIdToken || hasError || hasCode;
|
|
2292
|
-
console.log('[MSAL] handleMSALRedirect: Hash params check:', {
|
|
2293
|
-
hasAccessToken: hasAccessToken,
|
|
2294
|
-
hasIdToken: hasIdToken,
|
|
2295
|
-
hasError: hasError,
|
|
2296
|
-
hasCode: hasCode,
|
|
2297
|
-
hasMSALParams: hasMSALParams
|
|
2298
|
-
});
|
|
2299
2282
|
if (!hasMSALParams) {
|
|
2300
|
-
console.log('[MSAL] handleMSALRedirect: No MSAL parameters found in hash');
|
|
2301
2283
|
return Promise.resolve(null);
|
|
2302
2284
|
}
|
|
2303
2285
|
return Promise.resolve(_catch(function () {
|
|
2304
|
-
console.log('[MSAL] handleMSALRedirect: Initializing MSAL with:', {
|
|
2305
|
-
clientId: clientId ? 'configured' : 'missing',
|
|
2306
|
-
redirectUri: redirectUri
|
|
2307
|
-
});
|
|
2308
2286
|
return Promise.resolve(initializeMSAL(clientId, redirectUri)).then(function (instance) {
|
|
2309
|
-
|
|
2310
|
-
console.error('[MSAL] handleMSALRedirect: Failed to initialize instance');
|
|
2311
|
-
return null;
|
|
2312
|
-
}
|
|
2313
|
-
console.log('[MSAL] handleMSALRedirect: Calling handleRedirectPromise...');
|
|
2314
|
-
var accounts = instance.getAllAccounts();
|
|
2315
|
-
console.log('[MSAL] handleMSALRedirect: Current accounts:', accounts.length);
|
|
2316
|
-
return Promise.resolve(instance.handleRedirectPromise()).then(function (response) {
|
|
2287
|
+
return instance ? Promise.resolve(instance.handleRedirectPromise()).then(function (response) {
|
|
2317
2288
|
var _exit = false;
|
|
2318
2289
|
var _temp = function () {
|
|
2319
2290
|
if (response) {
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
account: (_response$account = response.account) === null || _response$account === void 0 ? void 0 : _response$account.username,
|
|
2323
|
-
hasAccessToken: !!response.accessToken,
|
|
2324
|
-
scopes: response.scopes
|
|
2325
|
-
});
|
|
2291
|
+
_exit = true;
|
|
2292
|
+
return response;
|
|
2326
2293
|
} else {
|
|
2327
|
-
console.log('[MSAL] handleMSALRedirect: handleRedirectPromise returned null/undefined');
|
|
2328
|
-
console.log('[MSAL] handleMSALRedirect: This might mean the redirect was already processed or state mismatch');
|
|
2329
|
-
console.log('[MSAL] handleMSALRedirect: Checking localStorage for interaction state...');
|
|
2330
|
-
try {
|
|
2331
|
-
var msalCacheKeys = Object.keys(localStorage).filter(function (key) {
|
|
2332
|
-
return key.startsWith('msal.');
|
|
2333
|
-
});
|
|
2334
|
-
console.log('[MSAL] handleMSALRedirect: Found MSAL cache keys:', msalCacheKeys.length);
|
|
2335
|
-
var interactionStateKey = msalCacheKeys.find(function (key) {
|
|
2336
|
-
return key.includes('interaction');
|
|
2337
|
-
});
|
|
2338
|
-
if (interactionStateKey) {
|
|
2339
|
-
console.log('[MSAL] handleMSALRedirect: Found interaction state key:', interactionStateKey);
|
|
2340
|
-
}
|
|
2341
|
-
} catch (cacheError) {
|
|
2342
|
-
console.error('[MSAL] handleMSALRedirect: Error checking cache:', cacheError);
|
|
2343
|
-
}
|
|
2344
2294
|
return function () {
|
|
2345
2295
|
if (hashParams.has('code')) {
|
|
2346
|
-
console.log('[MSAL] handleMSALRedirect: Attempting to extract account info from client_info...');
|
|
2347
2296
|
return _catch(function () {
|
|
2348
2297
|
var clientInfo = hashParams.get('client_info');
|
|
2349
2298
|
return function () {
|
|
2350
2299
|
if (clientInfo) {
|
|
2351
2300
|
var decodedClientInfo = JSON.parse(atob(clientInfo));
|
|
2352
|
-
console.log('[MSAL] handleMSALRedirect: Decoded client_info:', decodedClientInfo);
|
|
2353
2301
|
var allAccounts = instance.getAllAccounts();
|
|
2354
|
-
console.log('[MSAL] handleMSALRedirect: Accounts in cache:', allAccounts.length);
|
|
2355
2302
|
var matchingAccount = allAccounts.find(function (acc) {
|
|
2356
2303
|
return acc.homeAccountId === decodedClientInfo.uid || acc.username === decodedClientInfo.preferred_username || acc.username === decodedClientInfo.email;
|
|
2357
2304
|
});
|
|
2358
2305
|
if (!matchingAccount && allAccounts.length > 0) {
|
|
2359
2306
|
matchingAccount = allAccounts[0];
|
|
2360
|
-
console.log('[MSAL] handleMSALRedirect: Using first available account');
|
|
2361
2307
|
}
|
|
2362
2308
|
return function () {
|
|
2363
2309
|
if (matchingAccount) {
|
|
2364
|
-
console.log('[MSAL] handleMSALRedirect: Found matching account, trying silent token acquisition...');
|
|
2365
2310
|
return _catch(function () {
|
|
2366
2311
|
return Promise.resolve(instance.acquireTokenSilent({
|
|
2367
2312
|
scopes: ["openid", "profile", "User.Read"],
|
|
2368
2313
|
account: matchingAccount
|
|
2369
2314
|
})).then(function (silentResult) {
|
|
2370
2315
|
if (silentResult) {
|
|
2371
|
-
console.log('[MSAL] handleMSALRedirect: Got token via silent acquisition');
|
|
2372
2316
|
_exit = true;
|
|
2373
2317
|
return silentResult;
|
|
2374
2318
|
}
|
|
2375
2319
|
});
|
|
2376
|
-
}, function (
|
|
2377
|
-
console.error('[MSAL] handleMSALRedirect: Silent acquisition failed:', silentError);
|
|
2378
|
-
});
|
|
2320
|
+
}, function () {});
|
|
2379
2321
|
} else {
|
|
2380
|
-
console.log('[MSAL] handleMSALRedirect: No account in cache, creating account from client_info...');
|
|
2381
2322
|
var accountInfo = {
|
|
2382
2323
|
homeAccountId: decodedClientInfo.uid || decodedClientInfo.sub,
|
|
2383
2324
|
environment: 'login.microsoftonline.com',
|
|
@@ -2386,7 +2327,6 @@ var handleMSALRedirect = function handleMSALRedirect(clientId, redirectUri) {
|
|
|
2386
2327
|
name: decodedClientInfo.name,
|
|
2387
2328
|
localAccountId: decodedClientInfo.oid || decodedClientInfo.sub
|
|
2388
2329
|
};
|
|
2389
|
-
console.log('[MSAL] handleMSALRedirect: Created account info:', accountInfo);
|
|
2390
2330
|
var _account$accessToken$ = {
|
|
2391
2331
|
account: accountInfo,
|
|
2392
2332
|
accessToken: '',
|
|
@@ -2403,9 +2343,7 @@ var handleMSALRedirect = function handleMSALRedirect(clientId, redirectUri) {
|
|
|
2403
2343
|
}();
|
|
2404
2344
|
}
|
|
2405
2345
|
}();
|
|
2406
|
-
}, function (
|
|
2407
|
-
console.error('[MSAL] handleMSALRedirect: Manual code processing failed:', manualError);
|
|
2408
|
-
});
|
|
2346
|
+
}, function () {});
|
|
2409
2347
|
}
|
|
2410
2348
|
}();
|
|
2411
2349
|
}
|
|
@@ -2413,18 +2351,10 @@ var handleMSALRedirect = function handleMSALRedirect(clientId, redirectUri) {
|
|
|
2413
2351
|
return _temp && _temp.then ? _temp.then(function (_result6) {
|
|
2414
2352
|
return _exit ? _result6 : response;
|
|
2415
2353
|
}) : _exit ? _temp : response;
|
|
2416
|
-
});
|
|
2354
|
+
}) : null;
|
|
2417
2355
|
});
|
|
2418
2356
|
}, function (error) {
|
|
2419
|
-
console.error('[MSAL]
|
|
2420
|
-
if (error instanceof Error) {
|
|
2421
|
-
var _error$stack;
|
|
2422
|
-
console.error('[MSAL] handleMSALRedirect: Error details:', {
|
|
2423
|
-
name: error.name,
|
|
2424
|
-
message: error.message,
|
|
2425
|
-
stack: (_error$stack = error.stack) === null || _error$stack === void 0 ? void 0 : _error$stack.substring(0, 200)
|
|
2426
|
-
});
|
|
2427
|
-
}
|
|
2357
|
+
console.error('[MSAL] Error during redirect processing:', error);
|
|
2428
2358
|
return null;
|
|
2429
2359
|
}));
|
|
2430
2360
|
} catch (e) {
|
|
@@ -2459,23 +2389,14 @@ var MSALRedirectHandler = function MSALRedirectHandler() {
|
|
|
2459
2389
|
try {
|
|
2460
2390
|
var alreadyProcessed = localStorage.getItem('MSAL_LOGIN_PENDING');
|
|
2461
2391
|
if (alreadyProcessed === 'true') {
|
|
2462
|
-
console.log('[MSAL] RedirectHandler: Already processed by pre-init, skipping');
|
|
2463
2392
|
return Promise.resolve();
|
|
2464
2393
|
}
|
|
2465
2394
|
if (!isMSALRedirect()) {
|
|
2466
|
-
console.log('[MSAL] RedirectHandler: No MSAL redirect detected');
|
|
2467
2395
|
return Promise.resolve();
|
|
2468
2396
|
}
|
|
2469
|
-
console.log('[MSAL] RedirectHandler: Redirect detected, processing...');
|
|
2470
|
-
console.log('[MSAL] RedirectHandler: Hash:', window.location.hash);
|
|
2471
|
-
console.log('[MSAL] RedirectHandler: Full URL:', window.location.href);
|
|
2472
2397
|
var _temp = _catch(function () {
|
|
2473
2398
|
return Promise.resolve(handleMSALRedirect()).then(function (response) {
|
|
2474
2399
|
if (response && response.account) {
|
|
2475
|
-
console.log('[MSAL] Redirect handled successfully', {
|
|
2476
|
-
account: response.account.username,
|
|
2477
|
-
scopes: response.scopes
|
|
2478
|
-
});
|
|
2479
2400
|
if (window.history.replaceState) {
|
|
2480
2401
|
window.history.replaceState(null, '', window.location.pathname + window.location.search);
|
|
2481
2402
|
}
|
|
@@ -2500,9 +2421,6 @@ var MSALRedirectHandler = function MSALRedirectHandler() {
|
|
|
2500
2421
|
var errorDescription = hashParams.get('error_description');
|
|
2501
2422
|
if (error) {
|
|
2502
2423
|
console.error('[MSAL] Authentication error:', error, errorDescription);
|
|
2503
|
-
if (error === 'access_denied') {
|
|
2504
|
-
console.error('[MSAL] User denied access or scopes not configured in Azure AD');
|
|
2505
|
-
}
|
|
2506
2424
|
}
|
|
2507
2425
|
if (window.history.replaceState) {
|
|
2508
2426
|
window.history.replaceState(null, '', window.location.pathname + window.location.search);
|
|
@@ -2510,11 +2428,7 @@ var MSALRedirectHandler = function MSALRedirectHandler() {
|
|
|
2510
2428
|
}
|
|
2511
2429
|
});
|
|
2512
2430
|
}, function (error) {
|
|
2513
|
-
var _error$message;
|
|
2514
2431
|
console.error('[MSAL] Redirect handling error:', error);
|
|
2515
|
-
if ((error === null || error === void 0 ? void 0 : error.errorCode) === 'hash_empty_error' || error !== null && error !== void 0 && (_error$message = error.message) !== null && _error$message !== void 0 && _error$message.includes('hash_empty')) {
|
|
2516
|
-
console.error('[MSAL] Hash was cleared before MSAL could process it. ' + 'This usually means code is running that clears the URL hash before MSAL handler executes.');
|
|
2517
|
-
}
|
|
2518
2432
|
if (window.history.replaceState) {
|
|
2519
2433
|
window.history.replaceState(null, '', window.location.pathname + window.location.search);
|
|
2520
2434
|
}
|
|
@@ -2727,31 +2641,37 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
2727
2641
|
return Promise.reject(e);
|
|
2728
2642
|
}
|
|
2729
2643
|
};
|
|
2644
|
+
var isProcessingLogin = React__default.useRef(false);
|
|
2730
2645
|
var processMSALLogin = function processMSALLogin(account, accessToken) {
|
|
2731
2646
|
try {
|
|
2647
|
+
var _exit = false;
|
|
2648
|
+
if (isProcessingLogin.current) {
|
|
2649
|
+
return Promise.resolve();
|
|
2650
|
+
}
|
|
2651
|
+
isProcessingLogin.current = true;
|
|
2732
2652
|
return Promise.resolve(_catch(function () {
|
|
2733
|
-
|
|
2734
|
-
var fullName = (account === null || account === void 0 ? void 0 : account.name) || "";
|
|
2735
|
-
var infoLogin = {
|
|
2736
|
-
firstName: fullName.split(' ').slice(0, -1).join(' '),
|
|
2737
|
-
lastName: fullName.split(' ').slice(-1).join(' '),
|
|
2738
|
-
fullName: fullName,
|
|
2739
|
-
imageUrl: "",
|
|
2740
|
-
email: (account === null || account === void 0 ? void 0 : account.username) || "",
|
|
2741
|
-
token: accessToken || "",
|
|
2742
|
-
googleId: (account === null || account === void 0 ? void 0 : account.homeAccountId) || "",
|
|
2743
|
-
role: role,
|
|
2744
|
-
type: TypeLogin.Microsoft
|
|
2745
|
-
};
|
|
2746
|
-
return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (authResult) {
|
|
2653
|
+
function _temp3(_result) {
|
|
2747
2654
|
var _authResult$data;
|
|
2748
|
-
if (
|
|
2655
|
+
if (_exit) return _result;
|
|
2656
|
+
if (!authResult || !authResult.data || ((_authResult$data = authResult.data) === null || _authResult$data === void 0 ? void 0 : _authResult$data.id) == null) {
|
|
2749
2657
|
dispatch(setLoading(false));
|
|
2658
|
+
isProcessingLogin.current = false;
|
|
2750
2659
|
alert("Please contact admin.");
|
|
2751
2660
|
return;
|
|
2752
2661
|
}
|
|
2662
|
+
var msalCacheKeys = Object.keys(localStorage).filter(function (key) {
|
|
2663
|
+
return key.startsWith('msal.');
|
|
2664
|
+
});
|
|
2665
|
+
var msalCache = {};
|
|
2666
|
+
msalCacheKeys.forEach(function (key) {
|
|
2667
|
+
msalCache[key] = localStorage.getItem(key) || '';
|
|
2668
|
+
});
|
|
2753
2669
|
localStorage.clear();
|
|
2670
|
+
Object.keys(msalCache).forEach(function (key) {
|
|
2671
|
+
localStorage.setItem(key, msalCache[key]);
|
|
2672
|
+
});
|
|
2754
2673
|
var tokenJWT = authResult.data.token;
|
|
2674
|
+
isProcessingLogin.current = false;
|
|
2755
2675
|
trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
|
|
2756
2676
|
eventName: exports.AmplitudeEvent.LOGIN,
|
|
2757
2677
|
eventProperties: {
|
|
@@ -2785,9 +2705,34 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
2785
2705
|
onNavigate("/dashboard");
|
|
2786
2706
|
dispatch(setLoading(false));
|
|
2787
2707
|
}
|
|
2708
|
+
}
|
|
2709
|
+
dispatch(setLoading(true));
|
|
2710
|
+
var fullName = (account === null || account === void 0 ? void 0 : account.name) || "";
|
|
2711
|
+
var infoLogin = {
|
|
2712
|
+
firstName: fullName.split(' ').slice(0, -1).join(' '),
|
|
2713
|
+
lastName: fullName.split(' ').slice(-1).join(' '),
|
|
2714
|
+
fullName: fullName,
|
|
2715
|
+
imageUrl: "",
|
|
2716
|
+
email: (account === null || account === void 0 ? void 0 : account.username) || "",
|
|
2717
|
+
token: accessToken || "",
|
|
2718
|
+
googleId: (account === null || account === void 0 ? void 0 : account.homeAccountId) || "",
|
|
2719
|
+
role: role,
|
|
2720
|
+
type: TypeLogin.Microsoft
|
|
2721
|
+
};
|
|
2722
|
+
var authResult;
|
|
2723
|
+
var _temp2 = _catch(function () {
|
|
2724
|
+
return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (_apiLoginGoogle) {
|
|
2725
|
+
authResult = _apiLoginGoogle;
|
|
2726
|
+
});
|
|
2727
|
+
}, function () {
|
|
2728
|
+
dispatch(setLoading(false));
|
|
2729
|
+
isProcessingLogin.current = false;
|
|
2730
|
+
alert("Failed to authenticate with server. Please try again.");
|
|
2731
|
+
_exit = true;
|
|
2788
2732
|
});
|
|
2789
|
-
|
|
2790
|
-
|
|
2733
|
+
return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
|
|
2734
|
+
}, function () {
|
|
2735
|
+
isProcessingLogin.current = false;
|
|
2791
2736
|
dispatch(setLoading(false));
|
|
2792
2737
|
alert("An error occurred while processing your login. Please try again.");
|
|
2793
2738
|
}));
|
|
@@ -2801,16 +2746,13 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
2801
2746
|
}
|
|
2802
2747
|
}, []);
|
|
2803
2748
|
React.useEffect(function () {
|
|
2804
|
-
console.log('[MSAL] BlockLogin: useEffect mounted, checking for pending MSAL login...');
|
|
2805
2749
|
var handleMSALLoginSuccess = function handleMSALLoginSuccess(event) {
|
|
2806
2750
|
try {
|
|
2807
|
-
console.log('[MSAL] BlockLogin: Received msal-login-success event', event.detail);
|
|
2808
2751
|
var _event$detail = event.detail,
|
|
2809
2752
|
account = _event$detail.account,
|
|
2810
2753
|
_accessToken = _event$detail.accessToken;
|
|
2811
|
-
var
|
|
2754
|
+
var _temp4 = function () {
|
|
2812
2755
|
if (account && _accessToken) {
|
|
2813
|
-
console.log('[MSAL] BlockLogin: Processing login from event...');
|
|
2814
2756
|
localStorage.removeItem('MSAL_LOGIN_PENDING');
|
|
2815
2757
|
localStorage.removeItem('MSAL_ACCOUNT');
|
|
2816
2758
|
localStorage.removeItem('MSAL_ACCESS_TOKEN');
|
|
@@ -2818,52 +2760,40 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
2818
2760
|
sessionStorage.removeItem('MSAL_ACCOUNT');
|
|
2819
2761
|
sessionStorage.removeItem('MSAL_ACCESS_TOKEN');
|
|
2820
2762
|
return Promise.resolve(processMSALLogin(account, _accessToken)).then(function () {});
|
|
2821
|
-
} else {
|
|
2822
|
-
console.warn('[MSAL] BlockLogin: Event received but missing account or accessToken');
|
|
2823
2763
|
}
|
|
2824
2764
|
}();
|
|
2825
|
-
return Promise.resolve(
|
|
2765
|
+
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
|
|
2826
2766
|
} catch (e) {
|
|
2827
2767
|
return Promise.reject(e);
|
|
2828
2768
|
}
|
|
2829
2769
|
};
|
|
2830
2770
|
window.addEventListener('msal-login-success', handleMSALLoginSuccess);
|
|
2831
|
-
console.log('[MSAL] BlockLogin: Event listener registered');
|
|
2832
2771
|
var pendingLogin = localStorage.getItem('MSAL_LOGIN_PENDING');
|
|
2833
2772
|
var accountStr = localStorage.getItem('MSAL_ACCOUNT');
|
|
2834
2773
|
var accessToken = localStorage.getItem('MSAL_ACCESS_TOKEN');
|
|
2835
2774
|
if (!pendingLogin || pendingLogin !== 'true') {
|
|
2836
|
-
console.log('[MSAL] BlockLogin: Not found in localStorage, checking sessionStorage...');
|
|
2837
2775
|
pendingLogin = sessionStorage.getItem('MSAL_LOGIN_PENDING');
|
|
2838
2776
|
accountStr = sessionStorage.getItem('MSAL_ACCOUNT');
|
|
2839
2777
|
accessToken = sessionStorage.getItem('MSAL_ACCESS_TOKEN');
|
|
2840
2778
|
if (pendingLogin === 'true' && accountStr && accessToken) {
|
|
2841
|
-
console.log('[MSAL] BlockLogin: Found in sessionStorage, copying to localStorage...');
|
|
2842
2779
|
localStorage.setItem('MSAL_ACCOUNT', accountStr);
|
|
2843
2780
|
localStorage.setItem('MSAL_ACCESS_TOKEN', accessToken);
|
|
2844
2781
|
localStorage.setItem('MSAL_LOGIN_PENDING', pendingLogin);
|
|
2845
2782
|
}
|
|
2846
2783
|
}
|
|
2847
|
-
console.log('[MSAL] BlockLogin: Pending login check:', pendingLogin);
|
|
2848
2784
|
if (pendingLogin === 'true') {
|
|
2849
|
-
console.log('[MSAL] BlockLogin: Found pending login', {
|
|
2850
|
-
hasAccount: !!accountStr,
|
|
2851
|
-
hasAccessToken: !!accessToken
|
|
2852
|
-
});
|
|
2853
2785
|
if (accountStr && accessToken) {
|
|
2854
2786
|
try {
|
|
2855
2787
|
var account = JSON.parse(accountStr);
|
|
2856
|
-
console.log('[MSAL] BlockLogin: Parsed account:', account.username);
|
|
2857
2788
|
localStorage.removeItem('MSAL_LOGIN_PENDING');
|
|
2858
2789
|
localStorage.removeItem('MSAL_ACCOUNT');
|
|
2859
2790
|
localStorage.removeItem('MSAL_ACCESS_TOKEN');
|
|
2860
2791
|
sessionStorage.removeItem('MSAL_LOGIN_PENDING');
|
|
2861
2792
|
sessionStorage.removeItem('MSAL_ACCOUNT');
|
|
2862
2793
|
sessionStorage.removeItem('MSAL_ACCESS_TOKEN');
|
|
2863
|
-
console.log('[MSAL] BlockLogin: Calling processMSALLogin...');
|
|
2864
2794
|
processMSALLogin(account, accessToken);
|
|
2865
2795
|
} catch (error) {
|
|
2866
|
-
console.error('[MSAL]
|
|
2796
|
+
console.error('[MSAL] Error parsing stored account:', error);
|
|
2867
2797
|
localStorage.removeItem('MSAL_LOGIN_PENDING');
|
|
2868
2798
|
localStorage.removeItem('MSAL_ACCOUNT');
|
|
2869
2799
|
localStorage.removeItem('MSAL_ACCESS_TOKEN');
|
|
@@ -2871,13 +2801,10 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
2871
2801
|
sessionStorage.removeItem('MSAL_ACCOUNT');
|
|
2872
2802
|
sessionStorage.removeItem('MSAL_ACCESS_TOKEN');
|
|
2873
2803
|
}
|
|
2874
|
-
} else {
|
|
2875
|
-
console.warn('[MSAL] BlockLogin: Pending login flag set but missing account or token');
|
|
2876
2804
|
}
|
|
2877
2805
|
}
|
|
2878
2806
|
return function () {
|
|
2879
2807
|
window.removeEventListener('msal-login-success', handleMSALLoginSuccess);
|
|
2880
|
-
console.log('[MSAL] BlockLogin: Event listener removed');
|
|
2881
2808
|
};
|
|
2882
2809
|
}, []);
|
|
2883
2810
|
var googleLogin = google.useGoogleLogin({
|
|
@@ -2966,42 +2893,27 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
2966
2893
|
var fnLoginMicrosoft = function fnLoginMicrosoft() {
|
|
2967
2894
|
try {
|
|
2968
2895
|
return Promise.resolve(_catch(function () {
|
|
2969
|
-
console.log('[MSAL] BlockLogin: Starting Microsoft login...');
|
|
2970
|
-
console.log('[MSAL] BlockLogin: Client ID:', MICROSOFT_CLIENT_ID ? 'configured' : 'missing');
|
|
2971
|
-
console.log('[MSAL] BlockLogin: Redirect URI:', MICROSOFT_URL_DIRECT || window.location.origin);
|
|
2972
2896
|
var msalInstance = getMSALInstance(MICROSOFT_CLIENT_ID, MICROSOFT_URL_DIRECT);
|
|
2973
2897
|
if (!msalInstance) {
|
|
2974
|
-
console.error("[MSAL] BlockLogin: Instance not initialized - check client ID configuration");
|
|
2975
2898
|
alert("Microsoft login is not configured. Please contact admin.");
|
|
2976
2899
|
return;
|
|
2977
2900
|
}
|
|
2978
|
-
console.log('[MSAL] BlockLogin: Initializing MSAL instance...');
|
|
2979
2901
|
return Promise.resolve(initializeMSAL(MICROSOFT_CLIENT_ID, MICROSOFT_URL_DIRECT)).then(function (initializedInstance) {
|
|
2980
|
-
var
|
|
2981
|
-
function
|
|
2982
|
-
|
|
2983
|
-
console.log('[MSAL] BlockLogin: Calling loginRedirect with request:', loginRequest);
|
|
2984
|
-
console.log('[MSAL] BlockLogin: MSAL instance state:', {
|
|
2985
|
-
accounts: initializedInstance.getAllAccounts().length
|
|
2986
|
-
});
|
|
2987
|
-
return Promise.resolve(initializedInstance.loginRedirect(loginRequest)).then(function () {
|
|
2988
|
-
console.log('[MSAL] BlockLogin: loginRedirect called - redirect should happen');
|
|
2989
|
-
});
|
|
2902
|
+
var _exit2 = false;
|
|
2903
|
+
function _temp6(_result5) {
|
|
2904
|
+
return _exit2 ? _result5 : Promise.resolve(initializedInstance.loginRedirect(loginRequest)).then(function () {});
|
|
2990
2905
|
}
|
|
2991
2906
|
if (!initializedInstance) {
|
|
2992
|
-
console.error("[MSAL] BlockLogin: Failed to initialize MSAL instance");
|
|
2993
2907
|
alert("Failed to initialize Microsoft login. Please try again.");
|
|
2994
2908
|
return;
|
|
2995
2909
|
}
|
|
2996
|
-
console.log('[MSAL] BlockLogin: MSAL instance initialized successfully');
|
|
2997
2910
|
var loginRequest = {
|
|
2998
2911
|
scopes: ["openid", "profile", "User.Read"],
|
|
2999
2912
|
prompt: "select_account"
|
|
3000
2913
|
};
|
|
3001
|
-
var
|
|
2914
|
+
var _temp5 = _catch(function () {
|
|
3002
2915
|
return Promise.resolve(initializedInstance.handleRedirectPromise()).then(function (redirectResponse) {
|
|
3003
2916
|
if (redirectResponse) {
|
|
3004
|
-
console.log('[MSAL] BlockLogin: Found pending redirect response, processing...');
|
|
3005
2917
|
if (redirectResponse.account) {
|
|
3006
2918
|
localStorage.setItem('MSAL_ACCOUNT', JSON.stringify(redirectResponse.account));
|
|
3007
2919
|
localStorage.setItem('MSAL_ACCESS_TOKEN', redirectResponse.accessToken || '');
|
|
@@ -3016,44 +2928,27 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
3016
2928
|
idToken: redirectResponse.idToken
|
|
3017
2929
|
}
|
|
3018
2930
|
}));
|
|
3019
|
-
|
|
2931
|
+
_exit2 = true;
|
|
3020
2932
|
}
|
|
3021
2933
|
}
|
|
3022
2934
|
});
|
|
3023
|
-
}, function () {
|
|
3024
|
-
|
|
3025
|
-
});
|
|
3026
|
-
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
|
2935
|
+
}, function () {});
|
|
2936
|
+
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
|
|
3027
2937
|
});
|
|
3028
2938
|
}, function (error) {
|
|
3029
|
-
var _errorObj$
|
|
2939
|
+
var _errorObj$message, _errorObj$message2;
|
|
3030
2940
|
var errorObj = error;
|
|
3031
|
-
console.error("[MSAL] BlockLogin: Microsoft login error:", error);
|
|
3032
|
-
console.error("[MSAL] BlockLogin: Error type:", typeof error);
|
|
3033
|
-
console.error("[MSAL] BlockLogin: Error stringified:", JSON.stringify(error, Object.getOwnPropertyNames(error)));
|
|
3034
|
-
console.error("[MSAL] BlockLogin: Error details:", {
|
|
3035
|
-
name: errorObj === null || errorObj === void 0 ? void 0 : errorObj.name,
|
|
3036
|
-
message: errorObj === null || errorObj === void 0 ? void 0 : errorObj.message,
|
|
3037
|
-
errorCode: errorObj === null || errorObj === void 0 ? void 0 : errorObj.errorCode,
|
|
3038
|
-
errorMessage: errorObj === null || errorObj === void 0 ? void 0 : errorObj.errorMessage,
|
|
3039
|
-
stack: errorObj === null || errorObj === void 0 ? void 0 : (_errorObj$stack = errorObj.stack) === null || _errorObj$stack === void 0 ? void 0 : _errorObj$stack.substring(0, 500),
|
|
3040
|
-
toString: errorObj === null || errorObj === void 0 ? void 0 : (_errorObj$toString = errorObj.toString) === null || _errorObj$toString === void 0 ? void 0 : _errorObj$toString.call(errorObj)
|
|
3041
|
-
});
|
|
3042
2941
|
if ((errorObj === null || errorObj === void 0 ? void 0 : errorObj.errorCode) === 'popup_window_error' || errorObj !== null && errorObj !== void 0 && (_errorObj$message = errorObj.message) !== null && _errorObj$message !== void 0 && _errorObj$message.includes('popup')) {
|
|
3043
|
-
console.error("[MSAL] BlockLogin: Popup blocked or COOP error - this should not happen with redirect flow");
|
|
3044
2942
|
alert("Popup was blocked. Please allow popups for this site and try again.");
|
|
3045
2943
|
return;
|
|
3046
2944
|
}
|
|
3047
2945
|
if ((errorObj === null || errorObj === void 0 ? void 0 : errorObj.errorCode) === 'interaction_in_progress') {
|
|
3048
|
-
console.warn("[MSAL] BlockLogin: Interaction already in progress, this is normal if redirect is happening");
|
|
3049
2946
|
return;
|
|
3050
2947
|
}
|
|
3051
2948
|
if ((errorObj === null || errorObj === void 0 ? void 0 : errorObj.errorCode) === 'invalid_request' || errorObj !== null && errorObj !== void 0 && (_errorObj$message2 = errorObj.message) !== null && _errorObj$message2 !== void 0 && _errorObj$message2.includes('redirect_uri')) {
|
|
3052
|
-
console.error("[MSAL] BlockLogin: Redirect URI mismatch error");
|
|
3053
2949
|
alert("Configuration error: Redirect URI mismatch. Please contact admin.");
|
|
3054
2950
|
return;
|
|
3055
2951
|
}
|
|
3056
|
-
console.error("[MSAL] BlockLogin: Full error object:", errorObj);
|
|
3057
2952
|
alert("An error occurred during Microsoft login: " + ((errorObj === null || errorObj === void 0 ? void 0 : errorObj.message) || (errorObj === null || errorObj === void 0 ? void 0 : errorObj.errorCode) || 'Unknown error') + ". Please try again.");
|
|
3058
2953
|
}));
|
|
3059
2954
|
} catch (e) {
|