@chemmangat/msal-next 3.0.5 → 3.0.6

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
@@ -208,27 +208,34 @@ function MsalAuthProvider({ children, loadingComponent, onInitialized, ...config
208
208
  const msalConfig = createMsalConfig(config);
209
209
  const instance = new import_msal_browser2.PublicClientApplication(msalConfig);
210
210
  await instance.initialize();
211
- try {
212
- const response = await instance.handleRedirectPromise();
213
- if (response) {
214
- if (config.enableLogging) {
215
- console.log("[MSAL] Redirect authentication successful");
211
+ const isInPopup = window.opener && window.opener !== window;
212
+ if (!isInPopup) {
213
+ try {
214
+ const response = await instance.handleRedirectPromise();
215
+ if (response) {
216
+ if (config.enableLogging) {
217
+ console.log("[MSAL] Redirect authentication successful");
218
+ }
219
+ if (response.account) {
220
+ instance.setActiveAccount(response.account);
221
+ }
216
222
  }
217
- if (response.account) {
218
- instance.setActiveAccount(response.account);
223
+ } catch (redirectError) {
224
+ if (redirectError?.errorCode === "no_token_request_cache_error") {
225
+ if (config.enableLogging) {
226
+ console.log("[MSAL] No pending redirect found (this is normal)");
227
+ }
228
+ } else if (redirectError?.errorCode === "user_cancelled") {
229
+ if (config.enableLogging) {
230
+ console.log("[MSAL] User cancelled authentication");
231
+ }
232
+ } else {
233
+ console.error("[MSAL] Redirect handling error:", redirectError);
219
234
  }
220
235
  }
221
- } catch (redirectError) {
222
- if (redirectError?.errorCode === "no_token_request_cache_error") {
223
- if (config.enableLogging) {
224
- console.log("[MSAL] No pending redirect found (this is normal)");
225
- }
226
- } else if (redirectError?.errorCode === "user_cancelled") {
227
- if (config.enableLogging) {
228
- console.log("[MSAL] User cancelled authentication");
229
- }
230
- } else {
231
- console.error("[MSAL] Redirect handling error:", redirectError);
236
+ } else {
237
+ if (config.enableLogging) {
238
+ console.log("[MSAL] Running in popup window, skipping redirect handling");
232
239
  }
233
240
  }
234
241
  const accounts = instance.getAllAccounts();
package/dist/index.mjs CHANGED
@@ -155,27 +155,34 @@ function MsalAuthProvider({ children, loadingComponent, onInitialized, ...config
155
155
  const msalConfig = createMsalConfig(config);
156
156
  const instance = new PublicClientApplication(msalConfig);
157
157
  await instance.initialize();
158
- try {
159
- const response = await instance.handleRedirectPromise();
160
- if (response) {
161
- if (config.enableLogging) {
162
- console.log("[MSAL] Redirect authentication successful");
158
+ const isInPopup = window.opener && window.opener !== window;
159
+ if (!isInPopup) {
160
+ try {
161
+ const response = await instance.handleRedirectPromise();
162
+ if (response) {
163
+ if (config.enableLogging) {
164
+ console.log("[MSAL] Redirect authentication successful");
165
+ }
166
+ if (response.account) {
167
+ instance.setActiveAccount(response.account);
168
+ }
163
169
  }
164
- if (response.account) {
165
- instance.setActiveAccount(response.account);
170
+ } catch (redirectError) {
171
+ if (redirectError?.errorCode === "no_token_request_cache_error") {
172
+ if (config.enableLogging) {
173
+ console.log("[MSAL] No pending redirect found (this is normal)");
174
+ }
175
+ } else if (redirectError?.errorCode === "user_cancelled") {
176
+ if (config.enableLogging) {
177
+ console.log("[MSAL] User cancelled authentication");
178
+ }
179
+ } else {
180
+ console.error("[MSAL] Redirect handling error:", redirectError);
166
181
  }
167
182
  }
168
- } catch (redirectError) {
169
- if (redirectError?.errorCode === "no_token_request_cache_error") {
170
- if (config.enableLogging) {
171
- console.log("[MSAL] No pending redirect found (this is normal)");
172
- }
173
- } else if (redirectError?.errorCode === "user_cancelled") {
174
- if (config.enableLogging) {
175
- console.log("[MSAL] User cancelled authentication");
176
- }
177
- } else {
178
- console.error("[MSAL] Redirect handling error:", redirectError);
183
+ } else {
184
+ if (config.enableLogging) {
185
+ console.log("[MSAL] Running in popup window, skipping redirect handling");
179
186
  }
180
187
  }
181
188
  const accounts = instance.getAllAccounts();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chemmangat/msal-next",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "description": "Production-grade MSAL authentication package for Next.js App Router with minimal boilerplate",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",