@microsoft/mgt-msal2-provider
Advanced tools
Comparing version 3.1.3-preview.18925a9 to 3.1.3-preview.18d0aec
@@ -0,2 +1,9 @@ | ||
/** | ||
* ------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. | ||
* See License in the project root for license information. | ||
* ------------------------------------------------------------------------------------------- | ||
*/ | ||
export * from './mgt-msal2-provider'; | ||
export * from './exports'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,5 +7,4 @@ /** | ||
*/ | ||
import { registerMgtMsal2Provider } from './mgt-msal2-provider'; | ||
registerMgtMsal2Provider(); | ||
export * from './mgt-msal2-provider'; | ||
export * from './exports'; | ||
//# sourceMappingURL=index.js.map |
@@ -147,3 +147,3 @@ /** | ||
* @export | ||
* @enum {number} | ||
* @enum {string} | ||
*/ | ||
@@ -276,2 +276,3 @@ export declare enum PromptType { | ||
private initProvider; | ||
private readonly handleMsalEvent; | ||
/** | ||
@@ -278,0 +279,0 @@ * Attempts to sign in user silently |
@@ -22,3 +22,3 @@ /** | ||
* @export | ||
* @enum {number} | ||
* @enum {string} | ||
*/ | ||
@@ -108,2 +108,7 @@ export var PromptType; | ||
this.isMultipleAccountEnabled = true; | ||
this.handleMsalEvent = (message) => { | ||
if (message.eventType === 'msal:acquireTokenSuccess' && 'scopes' in message.payload) { | ||
this.approvedScopes = message.payload.scopes; | ||
} | ||
}; | ||
void this.initProvider(config); | ||
@@ -156,2 +161,3 @@ } | ||
} | ||
this._publicClientApplication.addEventCallback(this.handleMsalEvent); | ||
yield this._publicClientApplication.initialize(); | ||
@@ -270,3 +276,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(); | ||
@@ -273,0 +288,0 @@ super.setActiveAccount(user); |
{ | ||
"name": "@microsoft/mgt-msal2-provider", | ||
"version": "3.1.3-preview.18925a9", | ||
"version": "3.1.3-preview.18d0aec", | ||
"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.18925a9", | ||
"@microsoft/mgt-element": "3.1.3-preview.18d0aec", | ||
"@microsoft/microsoft-graph-client": "3.0.2" | ||
@@ -50,0 +50,0 @@ }, |
@@ -7,4 +7,3 @@ /** | ||
*/ | ||
import { registerMgtMsal2Provider } from './mgt-msal2-provider'; | ||
registerMgtMsal2Provider(); | ||
export * from './mgt-msal2-provider'; | ||
export * from './exports'; |
@@ -25,3 +25,5 @@ /** | ||
InteractionRequiredAuthError, | ||
SsoSilentRequest | ||
SsoSilentRequest, | ||
EventMessage, | ||
AuthenticationResult | ||
} from '@azure/msal-browser'; | ||
@@ -180,3 +182,3 @@ import { AuthenticationProviderOptions } from '@microsoft/microsoft-graph-client'; | ||
* @export | ||
* @enum {number} | ||
* @enum {string} | ||
*/ | ||
@@ -391,2 +393,3 @@ export enum PromptType { | ||
} | ||
this._publicClientApplication.addEventCallback(this.handleMsalEvent); | ||
await this._publicClientApplication.initialize(); | ||
@@ -425,2 +428,8 @@ | ||
private readonly handleMsalEvent = (message: EventMessage): void => { | ||
if (message.eventType === 'msal:acquireTokenSuccess' && 'scopes' in message.payload) { | ||
this.approvedScopes = message.payload.scopes; | ||
} | ||
}; | ||
/** | ||
@@ -503,3 +512,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(); | ||
@@ -506,0 +526,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
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/reactive-element@2.0.4(transitive)
+ Added@lit/task@1.0.1(transitive)
+ Added@microsoft/mgt-element@3.1.3-preview.18d0aec(transitive)
+ Addedlit@3.2.1(transitive)
+ Addedlit-element@4.1.1(transitive)
+ Addedlit-html@3.2.1(transitive)
- Removed@lit/reactive-element@1.6.3(transitive)
- Removed@microsoft/mgt-element@3.1.3-preview.18925a9(transitive)
- Removedlit@2.8.0(transitive)
- Removedlit-element@3.3.3(transitive)
- Removedlit-html@2.8.0(transitive)