acsi-core 0.9.25 → 0.9.26

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 CHANGED
@@ -2977,33 +2977,79 @@ var BlockLogin = function BlockLogin(_ref) {
2977
2977
  }
2978
2978
  console.log('[MSAL] BlockLogin: Initializing MSAL instance...');
2979
2979
  return Promise.resolve(initializeMSAL(MICROSOFT_CLIENT_ID, MICROSOFT_URL_DIRECT)).then(function () {
2980
+ var _exit = false;
2981
+ function _temp4(_result3) {
2982
+ if (_exit) return _result3;
2983
+ console.log('[MSAL] BlockLogin: Calling loginRedirect with request:', loginRequest);
2984
+ console.log('[MSAL] BlockLogin: MSAL instance state:', {
2985
+ accounts: msalInstance.getAllAccounts().length
2986
+ });
2987
+ return Promise.resolve(msalInstance.loginRedirect(loginRequest)).then(function () {
2988
+ console.log('[MSAL] BlockLogin: loginRedirect called - redirect should happen');
2989
+ });
2990
+ }
2980
2991
  console.log('[MSAL] BlockLogin: MSAL instance initialized successfully');
2981
2992
  var loginRequest = {
2982
2993
  scopes: ["openid", "profile", "User.Read"],
2983
2994
  prompt: "select_account"
2984
2995
  };
2985
- console.log('[MSAL] BlockLogin: Calling loginRedirect with request:', loginRequest);
2986
- return Promise.resolve(msalInstance.loginRedirect(loginRequest)).then(function () {
2987
- console.log('[MSAL] BlockLogin: loginRedirect called successfully - user will be redirected');
2996
+ var _temp3 = _catch(function () {
2997
+ return Promise.resolve(msalInstance.handleRedirectPromise()).then(function (redirectResponse) {
2998
+ if (redirectResponse) {
2999
+ console.log('[MSAL] BlockLogin: Found pending redirect response, processing...');
3000
+ if (redirectResponse.account) {
3001
+ localStorage.setItem('MSAL_ACCOUNT', JSON.stringify(redirectResponse.account));
3002
+ localStorage.setItem('MSAL_ACCESS_TOKEN', redirectResponse.accessToken || '');
3003
+ localStorage.setItem('MSAL_LOGIN_PENDING', 'true');
3004
+ sessionStorage.setItem('MSAL_ACCOUNT', JSON.stringify(redirectResponse.account));
3005
+ sessionStorage.setItem('MSAL_ACCESS_TOKEN', redirectResponse.accessToken || '');
3006
+ sessionStorage.setItem('MSAL_LOGIN_PENDING', 'true');
3007
+ window.dispatchEvent(new CustomEvent('msal-login-success', {
3008
+ detail: {
3009
+ account: redirectResponse.account,
3010
+ accessToken: redirectResponse.accessToken,
3011
+ idToken: redirectResponse.idToken
3012
+ }
3013
+ }));
3014
+ _exit = true;
3015
+ }
3016
+ }
3017
+ });
3018
+ }, function (handleError) {
3019
+ console.log('[MSAL] BlockLogin: No pending redirect to handle:', handleError);
2988
3020
  });
3021
+ return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
2989
3022
  });
2990
3023
  }, function (error) {
2991
- var _error$stack, _error$message;
3024
+ var _errorObj$stack, _errorObj$toString, _errorObj$message, _errorObj$message2;
3025
+ var errorObj = error;
2992
3026
  console.error("[MSAL] BlockLogin: Microsoft login error:", error);
3027
+ console.error("[MSAL] BlockLogin: Error type:", typeof error);
3028
+ console.error("[MSAL] BlockLogin: Error stringified:", JSON.stringify(error, Object.getOwnPropertyNames(error)));
2993
3029
  console.error("[MSAL] BlockLogin: Error details:", {
2994
- name: error === null || error === void 0 ? void 0 : error.name,
2995
- message: error === null || error === void 0 ? void 0 : error.message,
2996
- errorCode: error === null || error === void 0 ? void 0 : error.errorCode,
2997
- stack: error === null || error === void 0 ? void 0 : (_error$stack = error.stack) === null || _error$stack === void 0 ? void 0 : _error$stack.substring(0, 300)
3030
+ name: errorObj === null || errorObj === void 0 ? void 0 : errorObj.name,
3031
+ message: errorObj === null || errorObj === void 0 ? void 0 : errorObj.message,
3032
+ errorCode: errorObj === null || errorObj === void 0 ? void 0 : errorObj.errorCode,
3033
+ errorMessage: errorObj === null || errorObj === void 0 ? void 0 : errorObj.errorMessage,
3034
+ stack: errorObj === null || errorObj === void 0 ? void 0 : (_errorObj$stack = errorObj.stack) === null || _errorObj$stack === void 0 ? void 0 : _errorObj$stack.substring(0, 500),
3035
+ toString: errorObj === null || errorObj === void 0 ? void 0 : (_errorObj$toString = errorObj.toString) === null || _errorObj$toString === void 0 ? void 0 : _errorObj$toString.call(errorObj)
2998
3036
  });
2999
- if ((error === null || error === void 0 ? void 0 : error.errorCode) === 'popup_window_error' || error !== null && error !== void 0 && (_error$message = error.message) !== null && _error$message !== void 0 && _error$message.includes('popup')) {
3037
+ 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')) {
3000
3038
  console.error("[MSAL] BlockLogin: Popup blocked or COOP error - this should not happen with redirect flow");
3039
+ alert("Popup was blocked. Please allow popups for this site and try again.");
3040
+ return;
3001
3041
  }
3002
- if ((error === null || error === void 0 ? void 0 : error.errorCode) === 'interaction_in_progress') {
3042
+ if ((errorObj === null || errorObj === void 0 ? void 0 : errorObj.errorCode) === 'interaction_in_progress') {
3003
3043
  console.warn("[MSAL] BlockLogin: Interaction already in progress, this is normal if redirect is happening");
3004
3044
  return;
3005
3045
  }
3006
- alert("An error occurred during Microsoft login. Please try again.");
3046
+ 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')) {
3047
+ console.error("[MSAL] BlockLogin: Redirect URI mismatch error");
3048
+ alert("Configuration error: Redirect URI mismatch. Please contact admin.");
3049
+ return;
3050
+ }
3051
+ console.error("[MSAL] BlockLogin: Full error object:", errorObj);
3052
+ 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.");
3007
3053
  }));
3008
3054
  } catch (e) {
3009
3055
  return Promise.reject(e);