Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// since this is a token renewal request in iFrame, we don't need to proceed with the location change.
if (window.parent !== window) {//in iframe
if (event && event.preventDefault) {
event.preventDefault();
}
return;
}
// redirect to login start page
if (window.parent === window && !isPopup) {
if (this._navigateToLoginRequestUrl) {
var loginStartPage = this._cacheStorage.getItem(Constants.loginRequest);
this._cacheStorage.setItem(Constants.urlHash, hash);
if (typeof loginStartPage !== "undefined" && loginStartPage && loginStartPage.length !== 0) {
// prevent the current location change and redirect the user back to the login start page
this._logger.verbose("Redirecting to start page: " + loginStartPage);
window.location.href = loginStartPage;
}
}
//redirect to redirect uri. No page reload here since we are only removing the url after the hash
else {
window.location.hash = '';
}
}
}
else {
// state did not match, broadcast an error
this.broadcastService.broadcast("msal:stateMismatch", msalError);
}
window.location.href = loginStartPage;
}
}
//redirect to redirect uri. No page reload here since we are only removing the url after the hash
else {
window.location.hash = '';
}
}
}
else {
// state did not match, broadcast an error
this.broadcastService.broadcast("msal:stateMismatch", msalError);
}
}
else {
var pendingCallback = this._cacheStorage.getItem(Constants.urlHash);
if (pendingCallback) {
this.processRedirectCallBack(pendingCallback);
}
}
}
;
processRedirectCallBack(hash) {
this._logger.info('Processing the callback from redirect response');
const requestInfo = this.getRequestInfo(hash);
const token = requestInfo.parameters[Constants.accessToken] || requestInfo.parameters[Constants.idToken];
const errorDesc = requestInfo.parameters[Constants.errorDescription];
const error = requestInfo.parameters[Constants.error];
var tokenType;
this._cacheStorage.removeItem(Constants.urlHash);
var msalError = new MSALError(error, errorDesc);
var authenticationResult = new AuthenticationResult(token);
if (requestInfo.parameters[Constants.accessToken]) {
tokenType = Constants.accessToken;
if (token) {
authenticationResult.tokenType = tokenType;
this.broadcastService.broadcast("msal:acquireTokenSuccess", authenticationResult);
}
else if (error && errorDesc) {
//TODO this should also send back the scopes
this.broadcastService.broadcast("msal:acquireTokenFailure", msalError);
}
}
else {
tokenType = Constants.idToken;
if (token) {
private processRedirectCallBack(hash: string): void {
this._logger.info('Processing the callback from redirect response');
const requestInfo = this.getRequestInfo(hash);
const token = requestInfo.parameters[Constants.accessToken] || requestInfo.parameters[Constants.idToken];
const errorDesc = requestInfo.parameters[Constants.errorDescription];
const error = requestInfo.parameters[Constants.error];
var tokenType: string;
this._cacheStorage.removeItem(Constants.urlHash);
var msalError = new MSALError(error, errorDesc);
var authenticationResult = new AuthenticationResult(token);
if (requestInfo.parameters[Constants.accessToken]) {
tokenType = Constants.accessToken;
if (token) {
authenticationResult.tokenType= tokenType;
this.broadcastService.broadcast("msal:acquireTokenSuccess", authenticationResult);
}
else if (error && errorDesc) {
//TODO this should also send back the scopes
this.broadcastService.broadcast("msal:acquireTokenFailure", msalError);
}
}
else {
tokenType = Constants.idToken;
if (token) {