Skip to content

Commit

Permalink
Add __initializeNestedAppAuth function for Nested App Auth (#7289)
Browse files Browse the repository at this point in the history
Add a function call to `__initializeNestedAppAuth` that can be used to
setup Nested App Auth dependencies such as the bridge. It is an optional
function, and may only be needed in some implementations.
  • Loading branch information
codexeon authored Sep 5, 2024
1 parent 7c12d6d commit 5cd28fe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Add __initializeNestedAppAuth function for Nested App Auth (#7289)",
"packageName": "@azure/msal-browser",
"email": "[email protected]",
"dependentChangeType": "patch"
}
15 changes: 10 additions & 5 deletions lib/msal-browser/src/operatingcontext/NestedAppOperatingContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import { IBridgeProxy } from "../naa/IBridgeProxy";
import { BridgeProxy } from "../naa/BridgeProxy";
import { AccountContext } from "../naa/BridgeAccountContext";

declare global {
interface Window {
__initializeNestedAppAuth?(): Promise<void>;
}
}

export class NestedAppOperatingContext extends BaseOperatingContext {
protected bridgeProxy: IBridgeProxy | undefined = undefined;
protected accountContext: AccountContext | null = null;
Expand Down Expand Up @@ -54,13 +60,12 @@ export class NestedAppOperatingContext extends BaseOperatingContext {
* @returns Promise<boolean> indicating whether this operating context is currently available.
*/
async initialize(): Promise<boolean> {
/*
* TODO: Add implementation to check for presence of inject Nested App Auth Bridge JavaScript interface
*
*/

try {
if (typeof window !== "undefined") {
if (typeof window.__initializeNestedAppAuth === "function") {
await window.__initializeNestedAppAuth();
}

const bridgeProxy: IBridgeProxy = await BridgeProxy.create();
/*
* Because we want single sign on we expect the host app to provide the account context
Expand Down

0 comments on commit 5cd28fe

Please sign in to comment.