acsi-core 0.9.23 → 0.9.24
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 +160 -19
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +160 -19
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2189,7 +2189,7 @@ var msalConfig = function msalConfig(clientId, redirectUri) {
|
|
|
2189
2189
|
navigateToLoginRequestUrl: false
|
|
2190
2190
|
},
|
|
2191
2191
|
cache: {
|
|
2192
|
-
cacheLocation: "
|
|
2192
|
+
cacheLocation: "localStorage",
|
|
2193
2193
|
storeAuthStateInCookie: false
|
|
2194
2194
|
},
|
|
2195
2195
|
system: {
|
|
@@ -2232,7 +2232,18 @@ var getMSALInstance = function getMSALInstance(clientId, redirectUri) {
|
|
|
2232
2232
|
return null;
|
|
2233
2233
|
}
|
|
2234
2234
|
if (!msalInstance) {
|
|
2235
|
+
console.log('[MSAL] Creating new MSAL instance with:', {
|
|
2236
|
+
clientId: finalClientId ? 'configured' : 'missing',
|
|
2237
|
+
redirectUri: finalRedirectUri
|
|
2238
|
+
});
|
|
2235
2239
|
msalInstance = new msalBrowser.PublicClientApplication(msalConfig(finalClientId, finalRedirectUri));
|
|
2240
|
+
} else {
|
|
2241
|
+
var _existingConfig$auth, _existingConfig$auth2;
|
|
2242
|
+
var existingConfig = msalInstance.config;
|
|
2243
|
+
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
|
+
msalInstance = new msalBrowser.PublicClientApplication(msalConfig(finalClientId, finalRedirectUri));
|
|
2246
|
+
}
|
|
2236
2247
|
}
|
|
2237
2248
|
return msalInstance;
|
|
2238
2249
|
};
|
|
@@ -2253,6 +2264,7 @@ var initializeMSAL = function initializeMSAL(clientId, redirectUri) {
|
|
|
2253
2264
|
isInitializing = true;
|
|
2254
2265
|
initPromise = instance.initialize().then(function () {
|
|
2255
2266
|
isInitializing = false;
|
|
2267
|
+
console.log('[MSAL] Instance initialized successfully');
|
|
2256
2268
|
return instance;
|
|
2257
2269
|
})["catch"](function (error) {
|
|
2258
2270
|
isInitializing = false;
|
|
@@ -2299,18 +2311,108 @@ var handleMSALRedirect = function handleMSALRedirect(clientId, redirectUri) {
|
|
|
2299
2311
|
return null;
|
|
2300
2312
|
}
|
|
2301
2313
|
console.log('[MSAL] handleMSALRedirect: Calling handleRedirectPromise...');
|
|
2314
|
+
var accounts = instance.getAllAccounts();
|
|
2315
|
+
console.log('[MSAL] handleMSALRedirect: Current accounts:', accounts.length);
|
|
2302
2316
|
return Promise.resolve(instance.handleRedirectPromise()).then(function (response) {
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2317
|
+
var _exit = false;
|
|
2318
|
+
var _temp = function () {
|
|
2319
|
+
if (response) {
|
|
2320
|
+
var _response$account;
|
|
2321
|
+
console.log('[MSAL] handleMSALRedirect: Got response from handleRedirectPromise', {
|
|
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
|
+
});
|
|
2326
|
+
} 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
|
+
return function () {
|
|
2345
|
+
if (hashParams.has('code')) {
|
|
2346
|
+
console.log('[MSAL] handleMSALRedirect: Attempting to extract account info from client_info...');
|
|
2347
|
+
return _catch(function () {
|
|
2348
|
+
var clientInfo = hashParams.get('client_info');
|
|
2349
|
+
return function () {
|
|
2350
|
+
if (clientInfo) {
|
|
2351
|
+
var decodedClientInfo = JSON.parse(atob(clientInfo));
|
|
2352
|
+
console.log('[MSAL] handleMSALRedirect: Decoded client_info:', decodedClientInfo);
|
|
2353
|
+
var allAccounts = instance.getAllAccounts();
|
|
2354
|
+
console.log('[MSAL] handleMSALRedirect: Accounts in cache:', allAccounts.length);
|
|
2355
|
+
var matchingAccount = allAccounts.find(function (acc) {
|
|
2356
|
+
return acc.homeAccountId === decodedClientInfo.uid || acc.username === decodedClientInfo.preferred_username || acc.username === decodedClientInfo.email;
|
|
2357
|
+
});
|
|
2358
|
+
if (!matchingAccount && allAccounts.length > 0) {
|
|
2359
|
+
matchingAccount = allAccounts[0];
|
|
2360
|
+
console.log('[MSAL] handleMSALRedirect: Using first available account');
|
|
2361
|
+
}
|
|
2362
|
+
return function () {
|
|
2363
|
+
if (matchingAccount) {
|
|
2364
|
+
console.log('[MSAL] handleMSALRedirect: Found matching account, trying silent token acquisition...');
|
|
2365
|
+
return _catch(function () {
|
|
2366
|
+
return Promise.resolve(instance.acquireTokenSilent({
|
|
2367
|
+
scopes: ["openid", "profile", "User.Read"],
|
|
2368
|
+
account: matchingAccount
|
|
2369
|
+
})).then(function (silentResult) {
|
|
2370
|
+
if (silentResult) {
|
|
2371
|
+
console.log('[MSAL] handleMSALRedirect: Got token via silent acquisition');
|
|
2372
|
+
_exit = true;
|
|
2373
|
+
return silentResult;
|
|
2374
|
+
}
|
|
2375
|
+
});
|
|
2376
|
+
}, function (silentError) {
|
|
2377
|
+
console.error('[MSAL] handleMSALRedirect: Silent acquisition failed:', silentError);
|
|
2378
|
+
});
|
|
2379
|
+
} else {
|
|
2380
|
+
console.log('[MSAL] handleMSALRedirect: No account in cache, creating account from client_info...');
|
|
2381
|
+
var accountInfo = {
|
|
2382
|
+
homeAccountId: decodedClientInfo.uid || decodedClientInfo.sub,
|
|
2383
|
+
environment: 'login.microsoftonline.com',
|
|
2384
|
+
tenantId: decodedClientInfo.tid,
|
|
2385
|
+
username: decodedClientInfo.preferred_username || decodedClientInfo.email,
|
|
2386
|
+
name: decodedClientInfo.name,
|
|
2387
|
+
localAccountId: decodedClientInfo.oid || decodedClientInfo.sub
|
|
2388
|
+
};
|
|
2389
|
+
console.log('[MSAL] handleMSALRedirect: Created account info:', accountInfo);
|
|
2390
|
+
var _account$accessToken$ = {
|
|
2391
|
+
account: accountInfo,
|
|
2392
|
+
accessToken: '',
|
|
2393
|
+
idToken: '',
|
|
2394
|
+
scopes: ["openid", "profile", "User.Read"],
|
|
2395
|
+
expiresOn: null,
|
|
2396
|
+
tenantId: decodedClientInfo.tid,
|
|
2397
|
+
uniqueId: decodedClientInfo.oid || decodedClientInfo.sub,
|
|
2398
|
+
tokenType: 'Bearer'
|
|
2399
|
+
};
|
|
2400
|
+
_exit = true;
|
|
2401
|
+
return _account$accessToken$;
|
|
2402
|
+
}
|
|
2403
|
+
}();
|
|
2404
|
+
}
|
|
2405
|
+
}();
|
|
2406
|
+
}, function (manualError) {
|
|
2407
|
+
console.error('[MSAL] handleMSALRedirect: Manual code processing failed:', manualError);
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
}();
|
|
2411
|
+
}
|
|
2412
|
+
}();
|
|
2413
|
+
return _temp && _temp.then ? _temp.then(function (_result6) {
|
|
2414
|
+
return _exit ? _result6 : response;
|
|
2415
|
+
}) : _exit ? _temp : response;
|
|
2314
2416
|
});
|
|
2315
2417
|
});
|
|
2316
2418
|
}, function (error) {
|
|
@@ -2699,15 +2801,25 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
2699
2801
|
}
|
|
2700
2802
|
}, []);
|
|
2701
2803
|
React.useEffect(function () {
|
|
2804
|
+
console.log('[MSAL] BlockLogin: useEffect mounted, checking for pending MSAL login...');
|
|
2702
2805
|
var handleMSALLoginSuccess = function handleMSALLoginSuccess(event) {
|
|
2703
2806
|
try {
|
|
2807
|
+
console.log('[MSAL] BlockLogin: Received msal-login-success event', event.detail);
|
|
2704
2808
|
var _event$detail = event.detail,
|
|
2705
2809
|
account = _event$detail.account,
|
|
2706
|
-
|
|
2810
|
+
_accessToken = _event$detail.accessToken;
|
|
2707
2811
|
var _temp2 = function () {
|
|
2708
|
-
if (account &&
|
|
2812
|
+
if (account && _accessToken) {
|
|
2813
|
+
console.log('[MSAL] BlockLogin: Processing login from event...');
|
|
2709
2814
|
localStorage.removeItem('MSAL_LOGIN_PENDING');
|
|
2710
|
-
|
|
2815
|
+
localStorage.removeItem('MSAL_ACCOUNT');
|
|
2816
|
+
localStorage.removeItem('MSAL_ACCESS_TOKEN');
|
|
2817
|
+
sessionStorage.removeItem('MSAL_LOGIN_PENDING');
|
|
2818
|
+
sessionStorage.removeItem('MSAL_ACCOUNT');
|
|
2819
|
+
sessionStorage.removeItem('MSAL_ACCESS_TOKEN');
|
|
2820
|
+
return Promise.resolve(processMSALLogin(account, _accessToken)).then(function () {});
|
|
2821
|
+
} else {
|
|
2822
|
+
console.warn('[MSAL] BlockLogin: Event received but missing account or accessToken');
|
|
2711
2823
|
}
|
|
2712
2824
|
}();
|
|
2713
2825
|
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
|
|
@@ -2715,28 +2827,57 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
2715
2827
|
return Promise.reject(e);
|
|
2716
2828
|
}
|
|
2717
2829
|
};
|
|
2830
|
+
window.addEventListener('msal-login-success', handleMSALLoginSuccess);
|
|
2831
|
+
console.log('[MSAL] BlockLogin: Event listener registered');
|
|
2718
2832
|
var pendingLogin = localStorage.getItem('MSAL_LOGIN_PENDING');
|
|
2833
|
+
var accountStr = localStorage.getItem('MSAL_ACCOUNT');
|
|
2834
|
+
var accessToken = localStorage.getItem('MSAL_ACCESS_TOKEN');
|
|
2835
|
+
if (!pendingLogin || pendingLogin !== 'true') {
|
|
2836
|
+
console.log('[MSAL] BlockLogin: Not found in localStorage, checking sessionStorage...');
|
|
2837
|
+
pendingLogin = sessionStorage.getItem('MSAL_LOGIN_PENDING');
|
|
2838
|
+
accountStr = sessionStorage.getItem('MSAL_ACCOUNT');
|
|
2839
|
+
accessToken = sessionStorage.getItem('MSAL_ACCESS_TOKEN');
|
|
2840
|
+
if (pendingLogin === 'true' && accountStr && accessToken) {
|
|
2841
|
+
console.log('[MSAL] BlockLogin: Found in sessionStorage, copying to localStorage...');
|
|
2842
|
+
localStorage.setItem('MSAL_ACCOUNT', accountStr);
|
|
2843
|
+
localStorage.setItem('MSAL_ACCESS_TOKEN', accessToken);
|
|
2844
|
+
localStorage.setItem('MSAL_LOGIN_PENDING', pendingLogin);
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
console.log('[MSAL] BlockLogin: Pending login check:', pendingLogin);
|
|
2719
2848
|
if (pendingLogin === 'true') {
|
|
2720
|
-
|
|
2721
|
-
|
|
2849
|
+
console.log('[MSAL] BlockLogin: Found pending login', {
|
|
2850
|
+
hasAccount: !!accountStr,
|
|
2851
|
+
hasAccessToken: !!accessToken
|
|
2852
|
+
});
|
|
2722
2853
|
if (accountStr && accessToken) {
|
|
2723
2854
|
try {
|
|
2724
2855
|
var account = JSON.parse(accountStr);
|
|
2856
|
+
console.log('[MSAL] BlockLogin: Parsed account:', account.username);
|
|
2725
2857
|
localStorage.removeItem('MSAL_LOGIN_PENDING');
|
|
2726
2858
|
localStorage.removeItem('MSAL_ACCOUNT');
|
|
2727
2859
|
localStorage.removeItem('MSAL_ACCESS_TOKEN');
|
|
2860
|
+
sessionStorage.removeItem('MSAL_LOGIN_PENDING');
|
|
2861
|
+
sessionStorage.removeItem('MSAL_ACCOUNT');
|
|
2862
|
+
sessionStorage.removeItem('MSAL_ACCESS_TOKEN');
|
|
2863
|
+
console.log('[MSAL] BlockLogin: Calling processMSALLogin...');
|
|
2728
2864
|
processMSALLogin(account, accessToken);
|
|
2729
2865
|
} catch (error) {
|
|
2730
|
-
console.error('[MSAL] Error parsing stored account:', error);
|
|
2866
|
+
console.error('[MSAL] BlockLogin: Error parsing stored account:', error);
|
|
2731
2867
|
localStorage.removeItem('MSAL_LOGIN_PENDING');
|
|
2732
2868
|
localStorage.removeItem('MSAL_ACCOUNT');
|
|
2733
2869
|
localStorage.removeItem('MSAL_ACCESS_TOKEN');
|
|
2870
|
+
sessionStorage.removeItem('MSAL_LOGIN_PENDING');
|
|
2871
|
+
sessionStorage.removeItem('MSAL_ACCOUNT');
|
|
2872
|
+
sessionStorage.removeItem('MSAL_ACCESS_TOKEN');
|
|
2734
2873
|
}
|
|
2874
|
+
} else {
|
|
2875
|
+
console.warn('[MSAL] BlockLogin: Pending login flag set but missing account or token');
|
|
2735
2876
|
}
|
|
2736
2877
|
}
|
|
2737
|
-
window.addEventListener('msal-login-success', handleMSALLoginSuccess);
|
|
2738
2878
|
return function () {
|
|
2739
2879
|
window.removeEventListener('msal-login-success', handleMSALLoginSuccess);
|
|
2880
|
+
console.log('[MSAL] BlockLogin: Event listener removed');
|
|
2740
2881
|
};
|
|
2741
2882
|
}, []);
|
|
2742
2883
|
var googleLogin = google.useGoogleLogin({
|