@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 +25 -18
- package/dist/index.mjs +25 -18
- package/package.json +1 -1
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
|
|
218
|
-
|
|
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
|
-
}
|
|
222
|
-
if (
|
|
223
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
165
|
-
|
|
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
|
-
}
|
|
169
|
-
if (
|
|
170
|
-
|
|
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