Skip to content
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
0e9e1c4
- Update popup client with a minimal functionality to handle popup CO…
konstantin-msft Oct 29, 2025
8da953b
- Update popup client with a minimal functionality to handle popup CO…
konstantin-msft Oct 30, 2025
9759da1
- Update popup client with a minimal functionality to handle popup CO…
konstantin-msft Oct 30, 2025
b785cbb
- Code size optimizations
konstantin-msft Oct 31, 2025
125588f
- Code optimizations
konstantin-msft Nov 3, 2025
7eb65d7
- Refactor silent client to use redirect bridge for both popup and SS…
konstantin-msft Nov 4, 2025
1be20ef
- Refactor silent client to use redirect bridge for both popup and SS…
konstantin-msft Nov 4, 2025
d72ba13
Merge branch 'msal-v5' into popup_coop_support
konstantin-msft Nov 4, 2025
2b46d6a
Update package-lock.json
konstantin-msft Nov 4, 2025
da8168d
- Update unit tests.
konstantin-msft Nov 6, 2025
f186235
Merge branch 'msal-v5' into popup_coop_support
konstantin-msft Nov 6, 2025
afae280
Fix post-merge errors.
konstantin-msft Nov 6, 2025
e7e5c54
Change files
konstantin-msft Nov 6, 2025
40b8e3e
Add redirectBridgeEmptyResponse error code and update waitForBridgeRe…
konstantin-msft Nov 7, 2025
2a28584
- Update redirect page for samples
konstantin-msft Nov 11, 2025
afe6890
- Remove redundant "unloadWindow" listener
konstantin-msft Nov 12, 2025
240757c
Merge branch 'msal-v5' into popup_coop_support
konstantin-msft Nov 12, 2025
c3a5ed9
Merge branch 'msal-v5' of https://github.com/AzureAD/microsoft-authen…
lalimasharda Nov 15, 2025
a4c9ce5
Merge branch 'popup_coop_support' of https://github.com/AzureAD/micro…
lalimasharda Nov 19, 2025
8a167fc
Merge branch 'msal-v5' of https://github.com/AzureAD/microsoft-authen…
lalimasharda Nov 19, 2025
49b3506
- Add navigation to broadcastResponseToMainFrame
konstantin-msft Nov 19, 2025
2895e20
- Add error description.
konstantin-msft Nov 19, 2025
076df1d
- Resolve dep cycle
konstantin-msft Nov 19, 2025
5cb8ca8
- Add support for overriding ongoing interactions in popup flows
konstantin-msft Nov 19, 2025
bb9480a
Merge branch 'msal-v5' into popup_coop_support
konstantin-msft Nov 20, 2025
6636748
- Update core e2e tests
konstantin-msft Nov 20, 2025
48e01bf
- Address review comments
konstantin-msft Nov 21, 2025
b42be72
- Update COOP migration guide
konstantin-msft Nov 21, 2025
15086a0
- Update error doc
konstantin-msft Nov 21, 2025
2780349
- Handle hybrid URL response format
konstantin-msft Nov 21, 2025
4c1a103
Merge branch 'msal-v5' into popup_coop_support
konstantin-msft Nov 21, 2025
def925e
- Update migration doc
konstantin-msft Nov 21, 2025
704968f
Merge branch 'msal-v5' into popup_coop_support
konstantin-msft Nov 24, 2025
5ffe984
Update docs/errors.md
konstantin-msft Nov 24, 2025
ba93bd2
Update lib/msal-browser/docs/v4-migration.md
konstantin-msft Nov 24, 2025
f786341
Update lib/msal-browser/docs/v4-migration.md
konstantin-msft Nov 24, 2025
7d7bdd3
Update lib/msal-browser/docs/v4-migration.md
konstantin-msft Nov 24, 2025
0aadd91
Update lib/msal-browser/docs/v4-migration.md
konstantin-msft Nov 24, 2025
4c73bbd
Update lib/msal-browser/docs/v4-migration.md
konstantin-msft Nov 24, 2025
18b1e4f
- Pick up clientId from the session storage interaction key instead o…
konstantin-msft Nov 24, 2025
348c75e
- Formatting
konstantin-msft Nov 24, 2025
d45e1d4
- Use `AuthError` to throw in the redirect bridge
konstantin-msft Nov 24, 2025
2644d40
- Update API doc
konstantin-msft Nov 24, 2025
25996a0
- Update e2e tests
konstantin-msft Nov 24, 2025
48ba45d
Merge branch 'msal-v5' of https://github.com/AzureAD/microsoft-authen…
lalimasharda Nov 24, 2025
b58bd67
Merge branch 'popup_coop_support' of https://github.com/AzureAD/micro…
lalimasharda Nov 24, 2025
9a7bd3d
- Update e2e tests
konstantin-msft Nov 25, 2025
ece3225
Merge remote-tracking branch 'origin/popup_coop_support' into popup_c…
konstantin-msft Nov 25, 2025
9c32ec0
- Add visual examples on how to handle interaction override flag.
konstantin-msft Nov 25, 2025
a5572f0
- Update API doc
konstantin-msft Nov 25, 2025
cfef9f8
- Update redirect URI switch for express sample.
konstantin-msft Nov 25, 2025
be545c8
- Address review comments
konstantin-msft Nov 25, 2025
f5b340c
- Update API doc
konstantin-msft Nov 25, 2025
7c088ed
- Increase version switch timeout for express sample
konstantin-msft Nov 25, 2025
22be0a0
- Update redirect URI documentation
konstantin-msft Nov 26, 2025
ce57d1c
Update docs/errors.md
konstantin-msft Dec 1, 2025
53d9d6b
popup coop e2e tests (#8165)
lalimasharda Dec 1, 2025
8d09b33
Update lib/msal-browser/src/utils/BrowserUtils.ts
konstantin-msft Dec 2, 2025
38566ec
Update lib/msal-browser/src/utils/BrowserUtils.ts
konstantin-msft Dec 2, 2025
2c8fc69
Update lib/msal-browser/src/utils/BrowserUtils.ts
konstantin-msft Dec 2, 2025
35b7d56
Update lib/msal-browser/docs/login-user.md
konstantin-msft Dec 2, 2025
98116eb
Update lib/msal-browser/docs/login-user.md
konstantin-msft Dec 2, 2025
3be38b9
Update lib/msal-browser/docs/login-user.md
konstantin-msft Dec 2, 2025
3c69a41
Update lib/msal-browser/docs/login-user.md
konstantin-msft Dec 2, 2025
5237f78
Update lib/msal-browser/docs/login-user.md
konstantin-msft Dec 2, 2025
ace9170
Merge branch 'msal-v5' into popup_coop_support
konstantin-msft Dec 2, 2025
569e764
Refactor error handling in BrowserUtils and update error documentation
konstantin-msft Dec 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Implement redirect bridge to support COOP [#8118](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8118)",
"packageName": "@azure/msal-browser",
"email": "kshabelko@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Implement redirect bridge to support COOP [#8118](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8118)",
"packageName": "@azure/msal-common",
"email": "kshabelko@microsoft.com",
"dependentChangeType": "patch"
}
109 changes: 82 additions & 27 deletions docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ This error occurs when MSAL.js surpasses the allotted storage limit when attempt
- Authority mismatch error. Authority provided in login request or PublicClientApplication config does not match the environment of the provided account. Please use a matching account or make an interactive request to login to this authority.

### `invalid_request_method_for_EAR`
- The EAR protocol cannot be used with HTTP method `GET`. The `httpMethod` parameter in all requests using `protocolMode: ProtocolMode.EAR` must be either unset or `"POST"`/`HttpMethod.POST`.
- The EAR protocol cannot be used with HTTP method `GET`. The `httpMethod` parameter in all requests using `protocolMode: ProtocolMode.EAR` must be either unset or `"POST"`/`HttpMethod.POST`.

## Interaction required errors

Expand Down Expand Up @@ -558,6 +558,40 @@ If you are unable to figure out why this error is being thrown please [open an i
- Refresh the page. Does the error go away?
- Open your application in a new tab. Does the error go away?

### `interaction_in_progress_cancelled`

- The current interaction was cancelled by a new interaction request with `overrideInteractionInProgress` set to `true`.

This error is thrown when an existing popup interaction is cancelled because a new popup request was initiated with the `overrideInteractionInProgress` flag set to `true`. This is not necessarily an error condition - it indicates that the previous interaction was intentionally cancelled to allow a new one to proceed.

**When This Occurs:**

This error is thrown for the **previous/cancelled** interaction when:
1. A popup interaction is in progress (e.g., `acquireTokenPopup`)
2. A new popup request is made with `overrideInteractionInProgress: true`
3. The library cancels the pending interaction and starts the new one

**Example:**

```javascript
// First popup request starts
const request1 = { scopes: ["User.Read"] };
const promise1 = msalInstance.acquireTokenPopup(request1);

// User closes the popup or something goes wrong
// App decides to retry with override flag
const request2 = {
scopes: ["User.Read"],
overrideInteractionInProgress: true // Override the previous interaction
};
const promise2 = msalInstance.acquireTokenPopup(request2);

// promise1 will reject with interaction_in_progress_cancelled
// promise2 will proceed normally
```

**Note:** This error should only be seen when you explicitly use the `overrideInteractionInProgress` flag. Under normal circumstances, concurrent interaction attempts will throw `interaction_in_progress` instead.

### `popup_window_error`

- Error opening popup window. This can happen if you are using IE or if popups are blocked in the browser.
Expand All @@ -570,43 +604,61 @@ If you are unable to figure out why this error is being thrown please [open an i

- User cancelled the flow.

### `monitor_popup_timeout`
### `redirect_bridge_timeout`

- Token acquisition in popup failed due to timeout.
- Communication with the redirect page (popup or iframe) timed out while waiting for authentication response.

### `monitor_window_timeout`
**Error Messages**:

- Token acquisition in iframe failed due to timeout.
- Token acquisition in popup failed due to timeout.
- Token acquisition in iframe failed due to timeout.

**Error Messages**:
This error can be thrown when calling `ssoSilent`, `acquireTokenSilent`, `acquireTokenPopup` or `loginPopup` when the redirect bridge script fails to send the authentication response back to the main window within the configured timeout period.

- Token acquisition in iframe failed due to timeout.
**What is the redirect bridge?**

This error can be thrown when calling `ssoSilent`, `acquireTokenSilent`, `acquireTokenPopup` or `loginPopup` and there are several reasons this could happen. These are a few of the most common:
The redirect bridge is a mechanism that enables authentication flows in COOP (Cross-Origin-Opener-Policy) enabled applications. When COOP headers are present, popup and iframe windows cannot directly communicate with the main application window. The redirect bridge solves this by using the BroadcastChannel API to transmit authentication responses from the redirect page back to the main window. For more details on COOP support and the redirect bridge, see the [COOP Migration Guide](../lib/msal-browser/docs/v4-migration.md#cross-origin-opener-policy-coop-support).

1. The page you use as your `redirectUri` is removing or manipulating the hash
1. The page you use as your `redirectUri` is automatically navigating to a different page
1. You are being throttled by your identity provider. The identity provider may throttle clients that make too many similar requests in a short period of time. Never implement an endless retry mechanism or retry more than once. Attempts to retry non-network errors typically yield the same result. See [throttling guide](#Throttling) for more details.
1. Your identity provider did not redirect back to your `redirectUri`.
**Common Causes:**

**Important**: If your application uses a router library (e.g. React Router, Angular Router), please make sure it does not strip the hash or auto-redirect while MSAL token acquisition is in progress. If possible, it is best if your `redirectUri` page does not invoke the router at all.
This timeout typically occurs for the following reasons:

#### Issues caused by the redirectUri page
1. The page you use as your `redirectUri` is not loading the `msal-redirect-bridge.js` script
1. The redirect page is removing or manipulating the hash before the bridge script can process it
1. The redirect page is automatically navigating to a different page before the bridge can communicate the response
1. Your identity provider is being slow to redirect back to your `redirectUri` (network latency)
1. You are being throttled by your identity provider due to too many requests in a short period

When you make a silent call, in some cases, an iframe will be opened and will navigate to your identity provider's authorization page. After the identity provider has authorized the user it will redirect the iframe back to the `redirectUri` with the authorization code or error information in the hash fragment. The MSAL instance running in the frame or window that originally made the request will extract this response hash and process it. If your `redirectUri` is removing or manipulating this hash or navigating to a different page before MSAL has extracted it you will receive this timeout error.
**Resolution Steps:**

✔️ To solve this problem you should ensure that the page you use as your `redirectUri` is not doing any of these things, at the very least, when loaded in a popup or iframe. We recommend using a blank page as your `redirectUri` for silent and popup flows to ensure none of these things can occur.
✔️ **Ensure the redirect bridge script is loaded:**

You can do this on a per request basis, for example:
Your `redirectUri` page must include the redirect bridge script to enable communication back to the main window:

```javascript
msalInstance.acquireTokenSilent({
scopes: ["User.Read"],
redirectUri: "http://localhost:3000/blank.html",
});
```html
<!DOCTYPE html>
<html>
<head>
<title>Redirect</title>
</head>
<body>
<script src="path/to/msal-redirect-bridge.js"></script>
<script>
msalRedirectBridge.sendRedirectPayloadToMainFrame();
</script>
</body>
</html>
```

Remember that you will need to register this new `redirectUri` on your App Registration.
**Important**: If your application uses a router library (e.g. React Router, Angular Router), please make sure it does not strip the hash or auto-redirect while MSAL token acquisition is in progress. If possible, it is best if your `redirectUri` page does not invoke the router at all.

#### Issues caused by the redirectUri page

When you make a silent call, in some cases, an iframe will be opened and will navigate to your identity provider's authorization page. After the identity provider has authorized the user it will redirect the iframe back to the `redirectUri` with the authorization code or error information in the hash fragment. The MSAL redirect bridge running in the iframe will broadcast response to MSAL instance running in the frame or window that originally made the request. If your `redirectUri` is removing or manipulating this hash or navigating to a different page before MSAL redirect bridge has extracted it you will receive this timeout error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: A visual probably will make it easy. Not a blocking comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added visuals to express and react-router samples. Links are located in login-user.md


✔️ To solve this problem you should ensure that the page you use as your `redirectUri` is not doing any of these things, at the very least, when loaded in a popup or iframe.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add our recommendation is to use the html code that we recommend as the page content for the registered redirectUri here for continuity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added


Remember that you will need to register `redirectUri` on your App Registration.

**Notes regarding Angular and React:**

Expand Down Expand Up @@ -641,24 +693,27 @@ Some B2C flows are expected to throw this error due to their need for user inter

Another potential reason the identity provider may not redirect back to your application in time may be that there is some extra network latency.

✔️ The default timeout is about 10 seconds and should be sufficient in most cases, however, if your identity provider is taking longer than that to redirect you can increase this timeout in the MSAL config with either the `iframeHashTimeout`, `windowHashTimeout` or `loadFrameTimeout` configuration parameters.
✔️ The default timeout is about 10 seconds and should be sufficient in most cases, however, if your identity provider is taking longer than that to redirect you can increase this timeout in the MSAL config with either the `iframeBridgeTimeout` or `popupBridgeTimeout` configuration parameters.

```javascript
const msalConfig = {
auth: {
clientId: "your-client-id",
},
system: {
windowHashTimeout: 9000, // Applies just to popup calls - In milliseconds
iframeHashTimeout: 9000, // Applies just to silent calls - In milliseconds
loadFrameTimeout: 9000, // Applies to both silent and popup calls - In milliseconds
popupBridgeTimeout: 50000, // Applies just to popup calls - In milliseconds
iframeBridgeTimeout: 9000, // Applies just to silent calls - In milliseconds
},
};
```

> [!IMPORTANT]
> Please consult the [Troubleshooting Single-Sign On](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/FAQ.md#troubleshooting-single-sign-on) section of the MSAL Browser FAQ if you are having trouble with the `ssoSilent` API.

### `redirect_bridge_empty_response`

- The redirect bridge returned an empty response, indicating the redirect bridge script may have been modified or replaced.

### `redirect_in_iframe`

- Redirects are not supported for iframed or brokered applications. Please ensure you are using MSAL.js in a top frame of the window if using the redirect APIs, or use the popup APIs.
Expand Down
Loading