@azure/msal-browser
Version:
Microsoft Authentication Library for js
82 lines • 4.3 kB
TypeScript
import { PopupWindowAttributes } from "../request/PopupWindowAttributes.js";
/** Options for {@link runPopupRelay}. */
export type PopupRelayOptions = {
/**
* Wire protocol accepted by this endpoint. Defaults to 1 to preserve
* existing relay deployments. Version 1 is deprecated due to security
* concerns: URL-fragment descriptors do not authenticate their provenance.
* Deploy a separate endpoint with version 2 for authenticated handoff,
* then retire the v1 endpoint.
*/
protocolVersion?: 1 | 2;
/**
* Sizing/positioning for the IdP child popup the relay page opens. Same
* shape as `PopupRequest.popupWindowAttributes` (`popupSize` with width and
* height, `popupPosition` with top and left). Defaults to a 520x640 window.
*/
popupWindowAttributes?: PopupWindowAttributes;
/**
* How long (ms) to wait for the IdP child popup to deliver a response
* before giving up. Defaults to 300000 (5 minutes).
*/
timeoutMs?: number;
/**
* Origins the relay is allowed to navigate its IdP child popup to, e.g.
* `["https://login.microsoftonline.com"]`. Strongly recommended: set this
* to the origin(s) of the authority your app signs in against, so the relay
* page can only ever be used to reach your identity provider.
*
* Entries are compared by origin, so passing the full configured authority
* (`"https://login.microsoftonline.com/common"`), a trailing slash, mixed
* case, or an explicit `:443` all work.
*
* **Optional — omitting it does not disable the relay.** The relay page
* always rejects non-`https:` navigation targets; this option additionally
* pins *which* https origins are acceptable. When omitted, any https origin
* is allowed. V1 is deprecated due to security concerns: it accepts
* unauthenticated fragment descriptors and retains the legacy
* arbitrary-navigation risk until the endpoint is retired. V2 requires an
* authenticated opener request even when this option is omitted.
* Passing an explicitly empty array means "allow nothing" and will reject
* every navigation.
*/
allowedAuthorityOrigins?: string[];
};
/**
* Entry point for the top-level "popup-relay" page referenced by
* `auth.popupRelayUri`. Call this from the relay page (which MSAL opens as a
* top-level popup from inside an embedded, cross-origin iframe).
*
* V1 (the compatibility default) is deprecated due to security concerns. It
* executes validated but unauthenticated fragment descriptors and returns the
* legacy response envelope. It retains the legacy risk when origins are not
* pinned; retire that endpoint after migrating callers.
*
* V2 must be explicitly selected on both the app and its separate relay
* endpoint. It:
*
* 1. Reads the request id from the hash, then scrubs the hash. Navigation
* descriptors in the hash are never executed.
* 2. Reserves a blank child popup during the user gesture, then requests the
* navigation from the opener through an origin- and source-checked
* postMessage handoff bound to this relay document's nonce.
* 3. Validates and performs the authenticated navigation (the relay page
* stays put, so its `window.opener` link back to the embedded frame
* survives COOP).
* 4. Waits for the child's redirect URI page (which must run the redirect
* bridge, `broadcastResponseToMainFrame`) to broadcast the raw auth
* response over a same-origin `BroadcastChannel`.
* 5. Relays that raw response back to the embedded frame via
* `opener.postMessage`, posting only to its own (same) origin, then closes.
*
* The embedded frame keeps the PKCE verifier (and EAR private key) and exchanges
* the relayed response itself — no token, verifier, or private key ever crosses
* a window boundary.
*
* Note: the child popup is opened when this function runs, so call it from a
* user gesture (e.g. a "Continue" button click) to avoid popup blockers.
*
* @param options - {@link PopupRelayOptions}
*/
export declare function runPopupRelay(options?: PopupRelayOptions): void;
//# sourceMappingURL=index.d.ts.map