@microsoft/mgt-msal2-provider
Advanced tools
Comparing version 2.2.0-next.multi-accounts.1078dff to 2.2.0-next.multi-accounts.5ab75ad
@@ -53,2 +53,8 @@ /** | ||
/** | ||
* Disables multiple account capability | ||
* | ||
* @memberof MgtMsal2Provider | ||
*/ | ||
isMultiAccountDisabled: any; | ||
/** | ||
* Gets whether this provider can be used in this environment | ||
@@ -55,0 +61,0 @@ * |
@@ -84,2 +84,5 @@ /** | ||
} | ||
if (this.isMultiAccountDisabled) { | ||
config.isMultiAccountDisabled = true; | ||
} | ||
this.provider = new Msal2Provider(config); | ||
@@ -132,2 +135,9 @@ Providers.globalProvider = this.provider; | ||
], MgtMsal2Provider.prototype, "prompt", void 0); | ||
__decorate([ | ||
property({ | ||
attribute: 'multi-account-disabled', | ||
type: Boolean | ||
}), | ||
__metadata("design:type", Object) | ||
], MgtMsal2Provider.prototype, "isMultiAccountDisabled", void 0); | ||
MgtMsal2Provider = __decorate([ | ||
@@ -134,0 +144,0 @@ customElement('mgt-msal2-provider') |
@@ -54,2 +54,9 @@ import { IProvider, LoginType, IProviderAccount } from '@microsoft/mgt-element'; | ||
/** | ||
* Redirect URI | ||
* | ||
* @type {string} | ||
* @memberof Msal2Config | ||
*/ | ||
redirectUri?: string; | ||
/** | ||
* Prompt type | ||
@@ -62,3 +69,3 @@ * | ||
/** | ||
* Redirect URI | ||
* Authority URL | ||
* | ||
@@ -68,10 +75,10 @@ * @type {string} | ||
*/ | ||
redirectUri?: string; | ||
authority?: string; | ||
/** | ||
* Authority URL | ||
* Disable multi account functionality | ||
* | ||
* @type {string} | ||
* @type {boolean} | ||
* @memberof Msal2Config | ||
*/ | ||
authority?: string; | ||
isMultiAccountDisabled?: boolean; | ||
/** | ||
@@ -172,2 +179,11 @@ * Other options | ||
scopes: string[]; | ||
/** | ||
* | ||
* Disables multi account functionality | ||
* @private | ||
* @type {boolean} | ||
* @memberof Msal2Provider | ||
*/ | ||
private _isMultipleAccountDisabled; | ||
get isMultiAccountSupported(): boolean; | ||
private sessionStorageRequestedScopesKey; | ||
@@ -213,2 +229,9 @@ private sessionStorageDeniedScopesKey; | ||
/** | ||
* Gets active account | ||
* | ||
* @return {*} | ||
* @memberof Msal2Provider | ||
*/ | ||
getActiveAccount(): IProviderAccount; | ||
/** | ||
* Once a succesful login occurs, set the active account and store it | ||
@@ -215,0 +238,0 @@ * |
@@ -34,2 +34,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
super(); | ||
/** | ||
* | ||
* Disables multi account functionality | ||
* @private | ||
* @type {boolean} | ||
* @memberof Msal2Provider | ||
*/ | ||
this._isMultipleAccountDisabled = false; | ||
this.sessionStorageRequestedScopesKey = 'mgt-requested-scopes'; | ||
@@ -59,2 +67,5 @@ this.sessionStorageDeniedScopesKey = 'mgt-denied-scopes'; | ||
} | ||
get isMultiAccountSupported() { | ||
return !this._isMultipleAccountDisabled; | ||
} | ||
/** | ||
@@ -97,2 +108,4 @@ * Initialize provider with configuration details | ||
this._prompt = typeof config.prompt !== 'undefined' ? config.prompt : PromptType.SELECT_ACCOUNT; | ||
this._isMultipleAccountDisabled = | ||
typeof config.isMultiAccountDisabled !== 'undefined' ? config.isMultiAccountDisabled : false; | ||
this.graph = createFromProvider(this); | ||
@@ -187,3 +200,3 @@ try { | ||
this._publicClientApplication.getAllAccounts().forEach((account) => { | ||
usernames.push({ username: account.username, id: account.homeAccountId }); | ||
usernames.push({ name: account.name, mail: account.username, id: account.homeAccountId }); | ||
}); | ||
@@ -204,2 +217,12 @@ return usernames; | ||
/** | ||
* Gets active account | ||
* | ||
* @return {*} | ||
* @memberof Msal2Provider | ||
*/ | ||
getActiveAccount() { | ||
const account = this._publicClientApplication.getActiveAccount(); | ||
return { name: account.name, mail: account.username, id: account.homeAccountId }; | ||
} | ||
/** | ||
* Once a succesful login occurs, set the active account and store it | ||
@@ -213,4 +236,5 @@ * | ||
this.setActiveAccount({ | ||
username: account.name, | ||
id: account.homeAccountId | ||
name: account.name, | ||
id: account.homeAccountId, | ||
mail: account.username | ||
}); | ||
@@ -361,3 +385,8 @@ this.setState(ProviderState.SignedIn); | ||
yield this._publicClientApplication.logoutPopup(Object.assign({}, logOutRequest)); | ||
this.setState(ProviderState.SignedOut); | ||
if (this._publicClientApplication.getAllAccounts.length == 1 || this._isMultipleAccountDisabled) { | ||
this.setState(ProviderState.SignedOut); | ||
} | ||
else { | ||
this.trySilentSignIn(); | ||
} | ||
} | ||
@@ -364,0 +393,0 @@ }); |
{ | ||
"name": "@microsoft/mgt-msal2-provider", | ||
"version": "2.2.0-next.multi-accounts.1078dff", | ||
"version": "2.2.0-next.multi-accounts.5ab75ad", | ||
"description": "The Microsoft Graph Toolkit Msal 2.0 Provider", | ||
@@ -42,3 +42,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@microsoft/mgt-element": "2.2.0-next.multi-accounts.1078dff", | ||
"@microsoft/mgt-element": "2.2.0-next.multi-accounts.5ab75ad", | ||
"@microsoft/microsoft-graph-client": "^2.2.1", | ||
@@ -45,0 +45,0 @@ "@azure/msal-browser": "^2.13.0" |
@@ -87,2 +87,13 @@ /** | ||
/** | ||
* Disables multiple account capability | ||
* | ||
* @memberof MgtMsal2Provider | ||
*/ | ||
@property({ | ||
attribute: 'multi-account-disabled', | ||
type: Boolean | ||
}) | ||
public isMultiAccountDisabled; | ||
/** | ||
* Gets whether this provider can be used in this environment | ||
@@ -143,2 +154,5 @@ * | ||
if (this.isMultiAccountDisabled) { | ||
config.isMultiAccountDisabled = true; | ||
} | ||
this.provider = new Msal2Provider(config); | ||
@@ -145,0 +159,0 @@ Providers.globalProvider = this.provider; |
@@ -78,2 +78,10 @@ import { | ||
/** | ||
* Redirect URI | ||
* | ||
* @type {string} | ||
* @memberof Msal2Config | ||
*/ | ||
redirectUri?: string; | ||
/** | ||
* Prompt type | ||
@@ -87,3 +95,3 @@ * | ||
/** | ||
* Redirect URI | ||
* Authority URL | ||
* | ||
@@ -93,11 +101,11 @@ * @type {string} | ||
*/ | ||
redirectUri?: string; | ||
authority?: string; | ||
/** | ||
* Authority URL | ||
* Disable multi account functionality | ||
* | ||
* @type {string} | ||
* @type {boolean} | ||
* @memberof Msal2Config | ||
*/ | ||
authority?: string; | ||
isMultiAccountDisabled?: boolean; | ||
@@ -215,2 +223,14 @@ /** | ||
/** | ||
* | ||
* Disables multi account functionality | ||
* @private | ||
* @type {boolean} | ||
* @memberof Msal2Provider | ||
*/ | ||
private _isMultipleAccountDisabled: boolean = false; | ||
public get isMultiAccountSupported(): boolean { | ||
return !this._isMultipleAccountDisabled; | ||
} | ||
private sessionStorageRequestedScopesKey = 'mgt-requested-scopes'; | ||
@@ -265,2 +285,4 @@ private sessionStorageDeniedScopesKey = 'mgt-denied-scopes'; | ||
this._prompt = typeof config.prompt !== 'undefined' ? config.prompt : PromptType.SELECT_ACCOUNT; | ||
this._isMultipleAccountDisabled = | ||
typeof config.isMultiAccountDisabled !== 'undefined' ? config.isMultiAccountDisabled : false; | ||
this.graph = createFromProvider(this); | ||
@@ -347,3 +369,3 @@ try { | ||
this._publicClientApplication.getAllAccounts().forEach((account: AccountInfo) => { | ||
usernames.push({ username: account.username, id: account.homeAccountId } as IProviderAccount); | ||
usernames.push({ name: account.name, mail: account.username, id: account.homeAccountId } as IProviderAccount); | ||
}); | ||
@@ -366,2 +388,13 @@ return usernames; | ||
/** | ||
* Gets active account | ||
* | ||
* @return {*} | ||
* @memberof Msal2Provider | ||
*/ | ||
public getActiveAccount() { | ||
const account = this._publicClientApplication.getActiveAccount(); | ||
return { name: account.name, mail: account.username, id: account.homeAccountId } as IProviderAccount; | ||
} | ||
/** | ||
* Once a succesful login occurs, set the active account and store it | ||
@@ -375,4 +408,5 @@ * | ||
this.setActiveAccount({ | ||
username: account.name, | ||
id: account.homeAccountId | ||
name: account.name, | ||
id: account.homeAccountId, | ||
mail: account.username | ||
} as IProviderAccount); | ||
@@ -536,3 +570,7 @@ this.setState(ProviderState.SignedIn); | ||
await this._publicClientApplication.logoutPopup({ ...logOutRequest }); | ||
this.setState(ProviderState.SignedOut); | ||
if (this._publicClientApplication.getAllAccounts.length == 1 || this._isMultipleAccountDisabled) { | ||
this.setState(ProviderState.SignedOut); | ||
} else { | ||
this.trySilentSignIn(); | ||
} | ||
} | ||
@@ -539,0 +577,0 @@ } |
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
923042
1686
+ Added@microsoft/mgt-element@2.2.0-next.multi-accounts.5ab75ad(transitive)
- Removed@microsoft/mgt-element@2.2.0-next.multi-accounts.1078dff(transitive)
Updated@microsoft/mgt-element@2.2.0-next.multi-accounts.5ab75ad