Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional logging for NAA initialization #7064

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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": "patch",
"comment": "Add additional logging for Nested App Auth initialization errors (#7064)",
"packageName": "@azure/msal-browser",
"email": "[email protected]",
"dependentChangeType": "patch"
}
5 changes: 1 addition & 4 deletions lib/msal-browser/src/controllers/ControllerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ export async function createController(

await Promise.all(operatingContexts);

if (
teamsApp.isAvailable() &&
teamsApp.getConfig().auth.supportsNestedAppAuth
) {
if (teamsApp.isAvailable()) {
const controller = await import("./NestedAppAuthController");
return controller.NestedAppAuthController.createController(teamsApp);
} else if (standard.isAvailable()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export class TeamsAppOperatingContext extends BaseOperatingContext {
* TODO: Add implementation to check for presence of inject Nested App Auth Bridge JavaScript interface
*
*/

if (!this.getConfig().auth.supportsNestedAppAuth) {
return false;
}

try {
if (typeof window !== "undefined") {
const bridgeProxy: IBridgeProxy = await BridgeProxy.create();
Expand All @@ -74,18 +79,19 @@ export class TeamsAppOperatingContext extends BaseOperatingContext {
this.activeAccount =
await bridgeProxy.getActiveAccount();
}
} catch (e) {
this.activeAccount = undefined;
} catch {
// Ignore errors
}
this.bridgeProxy = bridgeProxy;
this.available = bridgeProxy !== undefined;
} else {
this.available = false;
}
} catch (e) {
this.available = false;
} finally {
return this.available;
} catch (ex) {
this.logger.infoPii(
`Could not initialize Nested App Auth bridge (${ex})`
);
}

this.logger.info(`Nested App Auth Bridge available: ${this.available}`);
return this.available;
}
}
Loading