@microsoft/mgt-msal2-provider
Advanced tools
Comparing version 3.1.3-preview.df8af8c to 3.1.3-preview.e79fbdc
@@ -275,2 +275,3 @@ /** | ||
private initProvider; | ||
private readonly handleMsalEvent; | ||
/** | ||
@@ -277,0 +278,0 @@ * Attempts to sign in user silently |
@@ -107,2 +107,7 @@ /** | ||
this.isMultipleAccountEnabled = true; | ||
this.handleMsalEvent = (message) => { | ||
if (message.eventType === 'msal:acquireTokenSuccess' && 'scopes' in message.payload) { | ||
this.approvedScopes = message.payload.scopes; | ||
} | ||
}; | ||
void this.initProvider(config); | ||
@@ -155,2 +160,3 @@ } | ||
} | ||
this._publicClientApplication.addEventCallback(this.handleMsalEvent); | ||
yield this._publicClientApplication.initialize(); | ||
@@ -269,3 +275,12 @@ this.ms_config.system = msalConfig.system || {}; | ||
setActiveAccount(user) { | ||
this._publicClientApplication.setActiveAccount(this._publicClientApplication.getAccountByHomeId(user.id)); | ||
const accountToSet = this._publicClientApplication.getAccountByHomeId(user.id); | ||
const activeAccount = this._publicClientApplication.getActiveAccount(); | ||
const storedAccount = this.getStoredAccount(); | ||
// exit early if the account is already active and stored | ||
if (storedAccount && | ||
storedAccount.homeAccountId === accountToSet.homeAccountId && | ||
activeAccount.homeAccountId === accountToSet.homeAccountId) { | ||
return; | ||
} | ||
this._publicClientApplication.setActiveAccount(accountToSet); | ||
this.setStoredAccount(); | ||
@@ -272,0 +287,0 @@ super.setActiveAccount(user); |
{ | ||
"name": "@microsoft/mgt-msal2-provider", | ||
"version": "3.1.3-preview.df8af8c", | ||
"version": "3.1.3-preview.e79fbdc", | ||
"description": "The Microsoft Graph Toolkit Msal 2.0 Provider", | ||
@@ -47,3 +47,3 @@ "keywords": [ | ||
"@azure/msal-browser": "^2.22.0", | ||
"@microsoft/mgt-element": "3.1.3-preview.df8af8c", | ||
"@microsoft/mgt-element": "3.1.3-preview.e79fbdc", | ||
"@microsoft/microsoft-graph-client": "3.0.2" | ||
@@ -50,0 +50,0 @@ }, |
@@ -25,3 +25,5 @@ /** | ||
InteractionRequiredAuthError, | ||
SsoSilentRequest | ||
SsoSilentRequest, | ||
EventMessage, | ||
AuthenticationResult | ||
} from '@azure/msal-browser'; | ||
@@ -390,2 +392,3 @@ import { AuthenticationProviderOptions } from '@microsoft/microsoft-graph-client'; | ||
} | ||
this._publicClientApplication.addEventCallback(this.handleMsalEvent); | ||
await this._publicClientApplication.initialize(); | ||
@@ -424,2 +427,8 @@ | ||
private readonly handleMsalEvent = (message: EventMessage): void => { | ||
if (message.eventType === 'msal:acquireTokenSuccess' && 'scopes' in message.payload) { | ||
this.approvedScopes = message.payload.scopes; | ||
} | ||
}; | ||
/** | ||
@@ -502,3 +511,14 @@ * Attempts to sign in user silently | ||
public setActiveAccount(user: IProviderAccount) { | ||
this._publicClientApplication.setActiveAccount(this._publicClientApplication.getAccountByHomeId(user.id)); | ||
const accountToSet = this._publicClientApplication.getAccountByHomeId(user.id); | ||
const activeAccount = this._publicClientApplication.getActiveAccount(); | ||
const storedAccount = this.getStoredAccount(); | ||
// exit early if the account is already active and stored | ||
if ( | ||
storedAccount && | ||
storedAccount.homeAccountId === accountToSet.homeAccountId && | ||
activeAccount.homeAccountId === accountToSet.homeAccountId | ||
) { | ||
return; | ||
} | ||
this._publicClientApplication.setActiveAccount(accountToSet); | ||
this.setStoredAccount(); | ||
@@ -505,0 +525,0 @@ super.setActiveAccount(user); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
212446
2032
+ Added@lit/task@1.0.1(transitive)
+ Added@microsoft/mgt-element@3.1.3-preview.e79fbdc(transitive)
- Removed@microsoft/mgt-element@3.1.3-preview.df8af8c(transitive)