@microsoft/mgt-msal2-provider
Advanced tools
Comparing version 2.2.0-next.msal2provider.d842c5b to 2.2.0-next.teamsprovider.9d48fb0
@@ -29,13 +29,13 @@ /** | ||
/** | ||
* Comma separated list of scopes | ||
* The authority to use. | ||
* | ||
* @memberof MgtMsalProvider | ||
*/ | ||
scopes: any; | ||
authority: any; | ||
/** | ||
* The authority to use. | ||
* Comma separated list of scopes | ||
* | ||
* @memberof MgtMsalProvider | ||
*/ | ||
authority: any; | ||
scopes: any; | ||
/** | ||
@@ -42,0 +42,0 @@ * The redirect uri to use |
@@ -79,7 +79,2 @@ /** | ||
} | ||
if (this.prompt) { | ||
let prompt = this.prompt.toUpperCase(); | ||
const promptEnum = PromptType[prompt]; | ||
config.prompt = promptEnum; | ||
} | ||
this.provider = new Msal2Provider(config); | ||
@@ -105,2 +100,6 @@ Providers.globalProvider = this.provider; | ||
__decorate([ | ||
property(), | ||
__metadata("design:type", Object) | ||
], MgtMsal2Provider.prototype, "authority", void 0); | ||
__decorate([ | ||
property({ | ||
@@ -114,9 +113,2 @@ attribute: 'scopes', | ||
property({ | ||
attribute: 'authority', | ||
type: String | ||
}), | ||
__metadata("design:type", Object) | ||
], MgtMsal2Provider.prototype, "authority", void 0); | ||
__decorate([ | ||
property({ | ||
attribute: 'redirect-uri', | ||
@@ -123,0 +115,0 @@ type: String |
import { IProvider, LoginType, IProviderAccount } from '@microsoft/mgt-element'; | ||
import { Configuration, PublicClientApplication, AuthenticationResult } from '@azure/msal-browser'; | ||
import { Configuration, PublicClientApplication, AccountInfo } from '@azure/msal-browser'; | ||
import { AuthenticationProviderOptions } from '@microsoft/microsoft-graph-client/lib/es/IAuthenticationProviderOptions'; | ||
@@ -211,6 +211,6 @@ /** | ||
* | ||
* @param {(AuthenticationResult | null)} response | ||
* @param {(AuthenticationResult | null)} account | ||
* @memberof Msal2Provider | ||
*/ | ||
handleResponse(response: AuthenticationResult | null): void; | ||
handleResponse(account: AccountInfo): void; | ||
/** | ||
@@ -217,0 +217,0 @@ * Store the currently signed in account in storage |
@@ -99,3 +99,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (tokenResponse !== null) { | ||
this.handleResponse(tokenResponse); | ||
this.handleResponse(tokenResponse === null || tokenResponse === void 0 ? void 0 : tokenResponse.account); | ||
} | ||
@@ -129,11 +129,2 @@ else { | ||
silentRequest.loginHint = this._loginHint; | ||
} | ||
else { | ||
const account = this.getAccount(); | ||
if (account) { | ||
silentRequest.sid = account.idTokenClaims.sid || null; | ||
silentRequest.loginHint = account.idTokenClaims.preferred_username; | ||
} | ||
} | ||
if (silentRequest.sid || silentRequest.loginHint) { | ||
try { | ||
@@ -143,3 +134,3 @@ this.setState(ProviderState.Loading); | ||
if (response) { | ||
this.handleResponse(response); | ||
this.handleResponse(response === null || response === void 0 ? void 0 : response.account); | ||
} | ||
@@ -152,2 +143,9 @@ } | ||
else { | ||
const account = this.getAccount(); | ||
if (account) { | ||
if (yield this.getAccessToken(null)) { | ||
this.handleResponse(account); | ||
return; | ||
} | ||
} | ||
this.setState(ProviderState.SignedOut); | ||
@@ -173,3 +171,3 @@ } | ||
const response = yield this._publicClientApplication.loginPopup(loginRequest); | ||
this.handleResponse(response); | ||
this.handleResponse(response === null || response === void 0 ? void 0 : response.account); | ||
} | ||
@@ -209,10 +207,10 @@ else { | ||
* | ||
* @param {(AuthenticationResult | null)} response | ||
* @param {(AuthenticationResult | null)} account | ||
* @memberof Msal2Provider | ||
*/ | ||
handleResponse(response) { | ||
if (response !== null) { | ||
handleResponse(account) { | ||
if (account !== null) { | ||
this.setActiveAccount({ | ||
username: response.account.name, | ||
id: response.account.homeAccountId | ||
username: account.name, | ||
id: account.homeAccountId | ||
}); | ||
@@ -379,4 +377,3 @@ this.setState(ProviderState.SignedIn); | ||
scopes: scopes, | ||
loginHint: this._loginHint, | ||
domainHint: this._domainHint | ||
account: this.getAccount() | ||
}; | ||
@@ -383,0 +380,0 @@ try { |
{ | ||
"name": "@microsoft/mgt-msal2-provider", | ||
"version": "2.2.0-next.msal2provider.d842c5b", | ||
"version": "2.2.0-next.teamsprovider.9d48fb0", | ||
"description": "The Microsoft Graph Toolkit Msal 2.0 Provider", | ||
@@ -42,3 +42,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@microsoft/mgt-element": "2.2.0-next.msal2provider.d842c5b", | ||
"@microsoft/mgt-element": "2.2.0-next.teamsprovider.9d48fb0", | ||
"@microsoft/microsoft-graph-client": "^2.2.1", | ||
@@ -45,0 +45,0 @@ "@azure/msal-browser": "^2.13.0" |
@@ -43,14 +43,10 @@ /** | ||
/** | ||
* Comma separated list of scopes | ||
* The authority to use. | ||
* | ||
* @memberof MgtMsalProvider | ||
*/ | ||
@property({ | ||
attribute: 'scopes', | ||
type: String | ||
}) | ||
public scopes; | ||
@property() public authority; | ||
/** | ||
* The authority to use. | ||
* Comma separated list of scopes | ||
* | ||
@@ -60,6 +56,6 @@ * @memberof MgtMsalProvider | ||
@property({ | ||
attribute: 'authority', | ||
attribute: 'scopes', | ||
type: String | ||
}) | ||
public authority; | ||
public scopes; | ||
@@ -138,8 +134,2 @@ /** | ||
if (this.prompt) { | ||
let prompt: string = this.prompt.toUpperCase(); | ||
const promptEnum = PromptType[prompt]; | ||
config.prompt = promptEnum; | ||
} | ||
this.provider = new Msal2Provider(config); | ||
@@ -146,0 +136,0 @@ Providers.globalProvider = this.provider; |
@@ -265,3 +265,3 @@ import { | ||
if (tokenResponse !== null) { | ||
this.handleResponse(tokenResponse); | ||
this.handleResponse(tokenResponse?.account); | ||
} else { | ||
@@ -291,10 +291,2 @@ this.trySilentSignIn(); | ||
silentRequest.loginHint = this._loginHint; | ||
} else { | ||
const account: any = this.getAccount(); | ||
if (account) { | ||
silentRequest.sid = account.idTokenClaims.sid || null; | ||
silentRequest.loginHint = account.idTokenClaims.preferred_username; | ||
} | ||
} | ||
if (silentRequest.sid || silentRequest.loginHint) { | ||
try { | ||
@@ -304,3 +296,3 @@ this.setState(ProviderState.Loading); | ||
if (response) { | ||
this.handleResponse(response); | ||
this.handleResponse(response?.account); | ||
} | ||
@@ -311,2 +303,9 @@ } catch (e) { | ||
} else { | ||
const account: AccountInfo = this.getAccount(); | ||
if (account) { | ||
if (await this.getAccessToken(null)) { | ||
this.handleResponse(account); | ||
return; | ||
} | ||
} | ||
this.setState(ProviderState.SignedOut); | ||
@@ -331,3 +330,3 @@ } | ||
const response = await this._publicClientApplication.loginPopup(loginRequest); | ||
this.handleResponse(response); | ||
this.handleResponse(response?.account); | ||
} else { | ||
@@ -368,10 +367,10 @@ const loginRedirectRequest: RedirectRequest = { ...loginRequest }; | ||
* | ||
* @param {(AuthenticationResult | null)} response | ||
* @param {(AuthenticationResult | null)} account | ||
* @memberof Msal2Provider | ||
*/ | ||
handleResponse(response: AuthenticationResult | null) { | ||
if (response !== null) { | ||
handleResponse(account: AccountInfo) { | ||
if (account !== null) { | ||
this.setActiveAccount({ | ||
username: response.account.name, | ||
id: response.account.homeAccountId | ||
username: account.name, | ||
id: account.homeAccountId | ||
} as IProviderAccount); | ||
@@ -548,6 +547,5 @@ this.setState(ProviderState.SignedIn); | ||
const scopes = options ? options.scopes || this.scopes : this.scopes; | ||
const accessTokenRequest = { | ||
const accessTokenRequest: SilentRequest = { | ||
scopes: scopes, | ||
loginHint: this._loginHint, | ||
domainHint: this._domainHint | ||
account: this.getAccount() | ||
}; | ||
@@ -554,0 +552,0 @@ try { |
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
916317
1553
+ Added@microsoft/mgt-element@2.2.0-next.teamsprovider.9d48fb0(transitive)
- Removed@microsoft/mgt-element@2.2.0-next.msal2provider.d842c5b(transitive)
Updated@microsoft/mgt-element@2.2.0-next.teamsprovider.9d48fb0