@microsoft/mgt-msal2-provider
Advanced tools
Comparing version 2.2.0-next.msal2provider.a9b1931b to 2.2.0-next.msal2provider.d842c5b
export * from './Msal2Provider'; | ||
export * from './mgt-msal2-provider'; | ||
//# sourceMappingURL=index.d.ts.map |
export * from './Msal2Provider'; | ||
export * from './mgt-msal2-provider'; | ||
//# sourceMappingURL=index.js.map |
@@ -29,13 +29,13 @@ /** | ||
/** | ||
* The authority to use. | ||
* Comma separated list of scopes | ||
* | ||
* @memberof MgtMsalProvider | ||
*/ | ||
authority: any; | ||
scopes: any; | ||
/** | ||
* Comma separated list of scopes | ||
* The authority to use. | ||
* | ||
* @memberof MgtMsalProvider | ||
*/ | ||
scopes: any; | ||
authority: any; | ||
/** | ||
@@ -48,7 +48,7 @@ * The redirect uri to use | ||
/** | ||
* Disables multiple account capability | ||
* Type of prompt for login | ||
* | ||
* @memberof MgtMsal2Provider | ||
*/ | ||
isMultiAccountDisabled: any; | ||
prompt: string; | ||
/** | ||
@@ -55,0 +55,0 @@ * Gets whether this provider can be used in this environment |
@@ -18,3 +18,3 @@ /** | ||
import { Providers, LoginType, MgtBaseProvider } from '@microsoft/mgt-element'; | ||
import { Msal2Provider } from './Msal2Provider'; | ||
import { Msal2Provider, PromptType } from './Msal2Provider'; | ||
/** | ||
@@ -75,5 +75,12 @@ * Authentication Library Provider for Microsoft personal accounts | ||
} | ||
if (this.isMultiAccountDisabled) { | ||
config.isMultiAccountDisabled = true; | ||
if (this.prompt) { | ||
let prompt = this.prompt.toUpperCase(); | ||
const promptEnum = PromptType[prompt]; | ||
config.prompt = promptEnum; | ||
} | ||
if (this.prompt) { | ||
let prompt = this.prompt.toUpperCase(); | ||
const promptEnum = PromptType[prompt]; | ||
config.prompt = promptEnum; | ||
} | ||
this.provider = new Msal2Provider(config); | ||
@@ -99,6 +106,2 @@ Providers.globalProvider = this.provider; | ||
__decorate([ | ||
property(), | ||
__metadata("design:type", Object) | ||
], MgtMsal2Provider.prototype, "authority", void 0); | ||
__decorate([ | ||
property({ | ||
@@ -112,2 +115,9 @@ attribute: 'scopes', | ||
property({ | ||
attribute: 'authority', | ||
type: String | ||
}), | ||
__metadata("design:type", Object) | ||
], MgtMsal2Provider.prototype, "authority", void 0); | ||
__decorate([ | ||
property({ | ||
attribute: 'redirect-uri', | ||
@@ -120,7 +130,7 @@ type: String | ||
property({ | ||
attribute: 'multi-account-disabled', | ||
type: Boolean | ||
attribute: 'prompt', | ||
type: String | ||
}), | ||
__metadata("design:type", Object) | ||
], MgtMsal2Provider.prototype, "isMultiAccountDisabled", void 0); | ||
__metadata("design:type", String) | ||
], MgtMsal2Provider.prototype, "prompt", void 0); | ||
MgtMsal2Provider = __decorate([ | ||
@@ -127,0 +137,0 @@ customElement('mgt-msal2-provider') |
@@ -52,4 +52,11 @@ import { IProvider, LoginType, IProviderAccount } from '@microsoft/mgt-element'; | ||
*/ | ||
domain_hint?: string; | ||
domainHint?: string; | ||
/** | ||
* Prompt type | ||
* | ||
* @type {Prompt} | ||
* @memberof Msal2Config | ||
*/ | ||
prompt?: PromptType; | ||
/** | ||
* Redirect URI | ||
@@ -69,9 +76,2 @@ * | ||
/** | ||
* Disable multi account functionality | ||
* | ||
* @type {boolean} | ||
* @memberof Msal2Config | ||
*/ | ||
isMultiAccountDisabled?: boolean; | ||
/** | ||
* Other options | ||
@@ -85,2 +85,13 @@ * | ||
/** | ||
* Prompt type enum | ||
* | ||
* @export | ||
* @enum {number} | ||
*/ | ||
export declare enum PromptType { | ||
SELECT_ACCOUNT = "select_account", | ||
LOGIN = "login", | ||
CONSENT = "consent" | ||
} | ||
/** | ||
* MSAL2Provider using msal-browser to acquire tokens for authentication | ||
@@ -117,2 +128,10 @@ * | ||
/** | ||
* Prompt type | ||
* | ||
* @private | ||
* @type {string} | ||
* @memberof Msal2Provider | ||
*/ | ||
private _prompt; | ||
/** | ||
* Session ID, if provided | ||
@@ -141,2 +160,9 @@ * | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
get name(): string; | ||
/** | ||
* List of scopes | ||
@@ -143,0 +169,0 @@ * |
@@ -13,2 +13,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
/** | ||
* Prompt type enum | ||
* | ||
* @export | ||
* @enum {number} | ||
*/ | ||
export var PromptType; | ||
(function (PromptType) { | ||
PromptType["SELECT_ACCOUNT"] = "select_account"; | ||
PromptType["LOGIN"] = "login"; | ||
PromptType["CONSENT"] = "consent"; | ||
})(PromptType || (PromptType = {})); | ||
/** | ||
* MSAL2Provider using msal-browser to acquire tokens for authentication | ||
@@ -39,2 +51,11 @@ * | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
get name() { | ||
return 'MgtMsal2Provider'; | ||
} | ||
/** | ||
* Initialize provider with configuration details | ||
@@ -72,7 +93,6 @@ * | ||
this._sid = typeof config.sid !== 'undefined' ? config.sid : null; | ||
this._domainHint = typeof config.domain_hint !== 'undefined' ? config.domain_hint : null; | ||
this._domainHint = typeof config.domainHint !== 'undefined' ? config.domainHint : null; | ||
this.scopes = typeof config.scopes !== 'undefined' ? config.scopes : ['user.read']; | ||
this._publicClientApplication = new PublicClientApplication(this.ms_config); | ||
this.isMultipleAccountDisabled = | ||
typeof config.isMultiAccountDisabled !== 'undefined' ? config.isMultiAccountDisabled : false; | ||
this._prompt = typeof config.prompt !== 'undefined' ? config.prompt : PromptType.SELECT_ACCOUNT; | ||
this.graph = createFromProvider(this); | ||
@@ -147,3 +167,3 @@ try { | ||
loginHint: this._loginHint, | ||
prompt: 'select_account', | ||
prompt: this._prompt, | ||
domainHint: this._domainHint | ||
@@ -341,8 +361,3 @@ }; | ||
yield this._publicClientApplication.logoutPopup(Object.assign({}, logOutRequest)); | ||
if (this._publicClientApplication.getAllAccounts.length == 1 || this.isMultiAccountDisabled) { | ||
this.setState(ProviderState.SignedOut); | ||
} | ||
else { | ||
this.trySilentSignIn(); | ||
} | ||
this.setState(ProviderState.SignedOut); | ||
} | ||
@@ -349,0 +364,0 @@ }); |
{ | ||
"name": "@microsoft/mgt-msal2-provider", | ||
"version": "2.2.0-next.msal2provider.a9b1931b", | ||
"version": "2.2.0-next.msal2provider.d842c5b", | ||
"description": "The Microsoft Graph Toolkit Msal 2.0 Provider", | ||
@@ -42,3 +42,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@microsoft/mgt-element": "2.2.0-next.msal2provider.a9b1931b", | ||
"@microsoft/mgt-element": "2.2.0-next.msal2provider.d842c5b", | ||
"@microsoft/microsoft-graph-client": "^2.2.1", | ||
@@ -45,0 +45,0 @@ "@azure/msal-browser": "^2.13.0" |
@@ -10,3 +10,3 @@ /** | ||
import { Providers, LoginType, MgtBaseProvider } from '@microsoft/mgt-element'; | ||
import { Msal2Config, Msal2Provider } from './Msal2Provider'; | ||
import { Msal2Config, Msal2Provider, PromptType } from './Msal2Provider'; | ||
/** | ||
@@ -44,10 +44,14 @@ * Authentication Library Provider for Microsoft personal accounts | ||
/** | ||
* The authority to use. | ||
* Comma separated list of scopes | ||
* | ||
* @memberof MgtMsalProvider | ||
*/ | ||
@property() public authority; | ||
@property({ | ||
attribute: 'scopes', | ||
type: String | ||
}) | ||
public scopes; | ||
/** | ||
* Comma separated list of scopes | ||
* The authority to use. | ||
* | ||
@@ -57,6 +61,6 @@ * @memberof MgtMsalProvider | ||
@property({ | ||
attribute: 'scopes', | ||
attribute: 'authority', | ||
type: String | ||
}) | ||
public scopes; | ||
public authority; | ||
@@ -75,3 +79,3 @@ /** | ||
/** | ||
* Disables multiple account capability | ||
* Type of prompt for login | ||
* | ||
@@ -81,6 +85,6 @@ * @memberof MgtMsal2Provider | ||
@property({ | ||
attribute: 'multi-account-disabled', | ||
type: Boolean | ||
attribute: 'prompt', | ||
type: String | ||
}) | ||
public isMultiAccountDisabled; | ||
public prompt: string; | ||
@@ -131,6 +135,14 @@ /** | ||
if (this.isMultiAccountDisabled) { | ||
config.isMultiAccountDisabled = true; | ||
if (this.prompt) { | ||
let prompt: string = this.prompt.toUpperCase(); | ||
const promptEnum = PromptType[prompt]; | ||
config.prompt = promptEnum; | ||
} | ||
if (this.prompt) { | ||
let prompt: string = this.prompt.toUpperCase(); | ||
const promptEnum = PromptType[prompt]; | ||
config.prompt = promptEnum; | ||
} | ||
this.provider = new Msal2Provider(config); | ||
@@ -137,0 +149,0 @@ Providers.globalProvider = this.provider; |
@@ -75,5 +75,13 @@ import { | ||
*/ | ||
domain_hint?: string; | ||
domainHint?: string; | ||
/** | ||
* Prompt type | ||
* | ||
* @type {Prompt} | ||
* @memberof Msal2Config | ||
*/ | ||
prompt?: PromptType; | ||
/** | ||
* Redirect URI | ||
@@ -95,10 +103,2 @@ * | ||
/** | ||
* Disable multi account functionality | ||
* | ||
* @type {boolean} | ||
* @memberof Msal2Config | ||
*/ | ||
isMultiAccountDisabled?: boolean; | ||
/** | ||
* Other options | ||
@@ -113,2 +113,14 @@ * | ||
/** | ||
* Prompt type enum | ||
* | ||
* @export | ||
* @enum {number} | ||
*/ | ||
export enum PromptType { | ||
SELECT_ACCOUNT = 'select_account', | ||
LOGIN = 'login', | ||
CONSENT = 'consent' | ||
} | ||
/** | ||
* MSAL2Provider using msal-browser to acquire tokens for authentication | ||
@@ -149,2 +161,11 @@ * | ||
/** | ||
* Prompt type | ||
* | ||
* @private | ||
* @type {string} | ||
* @memberof Msal2Provider | ||
*/ | ||
private _prompt: string; | ||
/** | ||
* Session ID, if provided | ||
@@ -178,2 +199,12 @@ * | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
public get name() { | ||
return 'MgtMsal2Provider'; | ||
} | ||
/** | ||
* List of scopes | ||
@@ -231,7 +262,6 @@ * | ||
this._sid = typeof config.sid !== 'undefined' ? config.sid : null; | ||
this._domainHint = typeof config.domain_hint !== 'undefined' ? config.domain_hint : null; | ||
this._domainHint = typeof config.domainHint !== 'undefined' ? config.domainHint : null; | ||
this.scopes = typeof config.scopes !== 'undefined' ? config.scopes : ['user.read']; | ||
this._publicClientApplication = new PublicClientApplication(this.ms_config); | ||
this.isMultipleAccountDisabled = | ||
typeof config.isMultiAccountDisabled !== 'undefined' ? config.isMultiAccountDisabled : false; | ||
this._prompt = typeof config.prompt !== 'undefined' ? config.prompt : PromptType.SELECT_ACCOUNT; | ||
this.graph = createFromProvider(this); | ||
@@ -298,3 +328,3 @@ try { | ||
loginHint: this._loginHint, | ||
prompt: 'select_account', | ||
prompt: this._prompt, | ||
domainHint: this._domainHint | ||
@@ -320,3 +350,3 @@ }; | ||
this._publicClientApplication.getAllAccounts().forEach((account: AccountInfo) => { | ||
usernames.push({ username: account.username, id: account.homeAccountId }); | ||
usernames.push({ username: account.username, id: account.homeAccountId } as IProviderAccount); | ||
}); | ||
@@ -507,7 +537,3 @@ return usernames; | ||
await this._publicClientApplication.logoutPopup({ ...logOutRequest }); | ||
if (this._publicClientApplication.getAllAccounts.length == 1 || this.isMultiAccountDisabled) { | ||
this.setState(ProviderState.SignedOut); | ||
} else { | ||
this.trySilentSignIn(); | ||
} | ||
this.setState(ProviderState.SignedOut); | ||
} | ||
@@ -514,0 +540,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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
918922
18
1575
0
58
105
+ Added@microsoft/mgt-element@2.2.0-next.msal2provider.d842c5b(transitive)
- Removed@microsoft/mgt-element@2.2.0-next.msal2provider.a9b1931b(transitive)
Updated@microsoft/mgt-element@2.2.0-next.msal2provider.d842c5b