diff --git a/JavaScriptSPA/index.html b/JavaScriptSPA/index.html
index d0e2f40..6209493 100644
--- a/JavaScriptSPA/index.html
+++ b/JavaScriptSPA/index.html
@@ -3,7 +3,7 @@
Quickstart for MSAL JS
-
+
@@ -41,7 +41,8 @@
var myMSALObj = new Msal.UserAgentApplication(msalConfig);
// Register Callbacks for redirect flow
- myMSALObj.handleRedirectCallbacks(acquireTokenRedirectCallBack, acquireTokenErrorRedirectCallBack);
+ // myMSALObj.handleRedirectCallbacks(acquireTokenRedirectCallBack, acquireTokenErrorRedirectCallBack);
+ myMSALObj.handleRedirectCallback(authRedirectCallBack);
function signIn() {
myMSALObj.loginPopup(requestObj).then(function (loginResponse) {
@@ -115,18 +116,18 @@
});
}
- function acquireTokenRedirectCallBack(response) {
- if (response.tokenType === "access_token") {
- callMSGraph(graphConfig.graphMeEndpoint, response.accessToken, graphAPICallback);
+ function authRedirectCallBack(error, response) {
+ if (error) {
+ console.log(error);
} else {
- console.log("token type is:" + response.tokenType);
+ if (response.tokenType === "access_token") {
+ callMSGraph(graphConfig.graphMeEndpoint, response.accessToken, graphAPICallback);
+ } else {
+ console.log("token type is:" + response.tokenType);
+ }
}
}
- function acquireTokenErrorRedirectCallBack(error) {
- console.log(error);
- }
-
function requiresInteraction(errorCode) {
if (!errorCode || !errorCode.length) {
return false;
diff --git a/JavaScriptSPA/msal-1.0.0-preview.4.min.js b/JavaScriptSPA/msal-1.0.0-preview.4.min.js
deleted file mode 100644
index 6a06ccb..0000000
--- a/JavaScriptSPA/msal-1.0.0-preview.4.min.js
+++ /dev/null
@@ -1,17 +0,0 @@
-/*! @azure/msal v1.0.0-preview.4 2019-04-25 */
-"use strict";!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Msal",[],t):"object"==typeof exports?exports.Msal=t():e.Msal=t()}(window,function(){return function(r){var n={};function o(e){if(n[e])return n[e].exports;var t=n[e]={i:e,l:!1,exports:{}};return r[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=r,o.c=n,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)o.d(r,n,function(e){return t[e]}.bind(null,n));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=15)}([function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),s=r(2),p=r(3),o=r(2),i=function(){function a(){}return a.compareAccounts=function(e,t){return!(!e||!t)&&!(!e.homeAccountIdentifier||!t.homeAccountIdentifier||e.homeAccountIdentifier!==t.homeAccountIdentifier)},a.decimalToHex=function(e){for(var t=e.toString(16);t.length<2;)t="0"+t;return t},a.getLibraryVersion=function(){return o.Library.version},a.createNewGuid=function(){var e=window.crypto;if(e&&e.getRandomValues){var t=new Uint8Array(16);return e.getRandomValues(t),t[6]|=64,t[6]&=79,t[8]|=128,t[8]&=191,a.decimalToHex(t[0])+a.decimalToHex(t[1])+a.decimalToHex(t[2])+a.decimalToHex(t[3])+"-"+a.decimalToHex(t[4])+a.decimalToHex(t[5])+"-"+a.decimalToHex(t[6])+a.decimalToHex(t[7])+"-"+a.decimalToHex(t[8])+a.decimalToHex(t[9])+"-"+a.decimalToHex(t[10])+a.decimalToHex(t[11])+a.decimalToHex(t[12])+a.decimalToHex(t[13])+a.decimalToHex(t[14])+a.decimalToHex(t[15])}for(var r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",n="0123456789abcdef",o=0,i="",s=0;s<36;s++)"-"!==r[s]&&"4"!==r[s]&&(o=16*Math.random()|0),"x"===r[s]?i+=n[o]:"y"===r[s]?(o&=3,i+=n[o|=8]):i+=r[s];return i},a.expiresIn=function(e){return e||(e="3599"),this.now()+parseInt(e,10)},a.now=function(){return Math.round((new Date).getTime()/1e3)},a.isEmpty=function(e){return void 0===e||!e||0===e.length},a.decodeJwt=function(e){if(this.isEmpty(e))return null;var t=/^([^\.\s]*)\.([^\.\s]+)\.([^\.\s]*)$/.exec(e);return!t||t.length<4?null:{header:t[1],JWSPayload:t[2],JWSSig:t[3]}},a.extractIdToken=function(e){var t=this.decodeJwt(e);if(!t)return null;try{var r=t.JWSPayload,n=this.base64DecodeStringUrlSafe(r);return n?JSON.parse(n):null}catch(e){}return null},a.base64EncodeStringUrlSafe=function(e){return window.btoa?window.btoa(e):this.encode(e)},a.base64DecodeStringUrlSafe=function(e){return e=e.replace(/-/g,"+").replace(/_/g,"/"),window.atob?decodeURIComponent(encodeURIComponent(window.atob(e))):decodeURIComponent(encodeURIComponent(this.decode(e)))},a.encode=function(e){var t,r,n,o,i,s,a,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u="",l=0;for(e=this.utf8Encode(e);l>2,i=(3&t)<<4|(r=e.charCodeAt(l++))>>4,s=(15&r)<<2|(n=e.charCodeAt(l++))>>6,a=63&n,isNaN(r)?s=a=64:isNaN(n)&&(a=64),u=u+c.charAt(o)+c.charAt(i)+c.charAt(s)+c.charAt(a);return u.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},a.utf8Encode=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",r=0;r>6|192):(t+=String.fromCharCode(n>>12|224),t+=String.fromCharCode(n>>6&63|128)),t+=String.fromCharCode(63&n|128))}return t},a.decode=function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r=(e=String(e).replace(/=+$/,"")).length;if(r%4==1)throw p.ClientAuthError.createTokenEncodingError(e);for(var n,o,i,s,a,c,u,l,d="",h=0;h>16&255,u=a>>8&255,d+=String.fromCharCode(c,u);break}if(h+1===r-1){c=(a=n<<18|o<<12)>>16&255,d+=String.fromCharCode(c);break}c=(a=n<<18|o<<12|i<<6|s)>>16&255,u=a>>8&255,l=255&a,d+=String.fromCharCode(c,u,l)}return d},a.deserialize=function(e){var t,r=/\+/g,n=/([^&=]+)=([^&]*)/g,o=function(e){return decodeURIComponent(e.replace(r," "))},i={};for(t=n.exec(e);t;)i[o(t[1])]=o(t[2]),t=n.exec(e);return i},a.isIntersectingScopes=function(e,t){e=this.convertToLowerCase(e);for(var r=0;r=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function i(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||0s[0]&&t[1]."},authorityUriInsecure:{code:"authority_uri_insecure",desc:"Authority URIs must use https."},authorityUriInvalidPath:{code:"authority_uri_invalid_path",desc:"Given authority URI is invalid."},unsupportedAuthorityValidation:{code:"unsupported_authority_validation",desc:"The authority validation is not supported for this authority type."},b2cAuthorityUriInvalidPath:{code:"b2c_authority_uri_invalid_path",desc:"The given URI for the B2C authority is invalid."}};var o=function(n){function o(e,t){var r=n.call(this,e,t)||this;return r.name="ClientConfigurationError",Object.setPrototypeOf(r,o.prototype),r}return i.__extends(o,n),o.createNoSetConfigurationError=function(){return new o(r.ClientConfigurationErrorMessage.configurationNotSet.code,""+r.ClientConfigurationErrorMessage.configurationNotSet.desc)},o.createInvalidCacheLocationConfigError=function(e){return new o(r.ClientConfigurationErrorMessage.invalidCacheLocation.code,r.ClientConfigurationErrorMessage.invalidCacheLocation.desc+" Provided value: "+e+". Possible values are: "+s.Constants.cacheLocationLocal+", "+s.Constants.cacheLocationSession+".")},o.createNoStorageSupportedError=function(){return new o(r.ClientConfigurationErrorMessage.noStorageSupported.code,r.ClientConfigurationErrorMessage.noStorageSupported.desc)},o.createRedirectCallbacksNotSetError=function(){return new o(r.ClientConfigurationErrorMessage.noRedirectCallbacksSet.code,r.ClientConfigurationErrorMessage.noRedirectCallbacksSet.desc)},o.createInvalidCallbackObjectError=function(e,t){return new o(r.ClientConfigurationErrorMessage.invalidCallbackObject.code,r.ClientConfigurationErrorMessage.invalidCallbackObject.desc+" Given value for "+e+" callback function: "+t)},o.createEmptyScopesArrayError=function(e){return new o(r.ClientConfigurationErrorMessage.emptyScopes.code,r.ClientConfigurationErrorMessage.emptyScopes.desc+" Given value: "+e+".")},o.createScopesNonArrayError=function(e){return new o(r.ClientConfigurationErrorMessage.nonArrayScopes.code,r.ClientConfigurationErrorMessage.nonArrayScopes.desc+" Given value: "+e+".")},o.createClientIdSingleScopeError=function(e){return new o(r.ClientConfigurationErrorMessage.clientScope.code,r.ClientConfigurationErrorMessage.clientScope.desc+" Given value: "+e+".")},o.createScopesRequiredError=function(e){return new o(r.ClientConfigurationErrorMessage.scopesRequired.code,r.ClientConfigurationErrorMessage.scopesRequired.desc+" Given value: "+e)},o.createInvalidPromptError=function(e){return new o(r.ClientConfigurationErrorMessage.invalidPrompt.code,r.ClientConfigurationErrorMessage.invalidPrompt.desc+" Given value: "+e)},o}(n.ClientAuthError);r.ClientConfigurationError=o},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var i=r(1);t.AuthErrorMessage={unexpectedError:{code:"unexpected_error",desc:"Unexpected error in authentication."}};var n=function(n){function o(e,t){var r=n.call(this,t)||this;return Object.setPrototypeOf(r,o.prototype),r.errorCode=e,r.errorMessage=t,r.name="AuthError",r}return i.__extends(o,n),o.createUnexpectedError=function(e){return new o(t.AuthErrorMessage.unexpectedError.code,t.AuthErrorMessage.unexpectedError.desc+": "+e)},o}(Error);t.AuthError=n},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(0),i=r(4),s=r(12);(n=t.AuthorityType||(t.AuthorityType={}))[n.Aad=0]="Aad",n[n.Adfs=1]="Adfs",n[n.B2C=2]="B2C";var a=function(){function e(e,t){this.IsValidationEnabled=t,this.CanonicalAuthority=e,this.validateAsUri()}return Object.defineProperty(e.prototype,"Tenant",{get:function(){return this.CanonicalAuthorityUrlComponents.PathSegments[0]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"AuthorizationEndpoint",{get:function(){return this.validateResolved(),this.tenantDiscoveryResponse.AuthorizationEndpoint.replace("{tenant}",this.Tenant)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"EndSessionEndpoint",{get:function(){return this.validateResolved(),this.tenantDiscoveryResponse.EndSessionEndpoint.replace("{tenant}",this.Tenant)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"SelfSignedJwtAudience",{get:function(){return this.validateResolved(),this.tenantDiscoveryResponse.Issuer.replace("{tenant}",this.Tenant)},enumerable:!0,configurable:!0}),e.prototype.validateResolved=function(){if(!this.tenantDiscoveryResponse)throw"Please call ResolveEndpointsAsync first"},Object.defineProperty(e.prototype,"CanonicalAuthority",{get:function(){return this.canonicalAuthority},set:function(e){this.canonicalAuthority=o.Utils.CanonicalizeUri(e),this.canonicalAuthorityUrlComponents=null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CanonicalAuthorityUrlComponents",{get:function(){return this.canonicalAuthorityUrlComponents||(this.canonicalAuthorityUrlComponents=o.Utils.GetUrlComponents(this.CanonicalAuthority)),this.canonicalAuthorityUrlComponents},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"DefaultOpenIdConfigurationEndpoint",{get:function(){return this.CanonicalAuthority+"v2.0/.well-known/openid-configuration"},enumerable:!0,configurable:!0}),e.prototype.validateAsUri=function(){var e;try{e=this.CanonicalAuthorityUrlComponents}catch(e){throw i.ClientConfigurationErrorMessage.invalidAuthorityType}if(!e.Protocol||"https:"!==e.Protocol.toLowerCase())throw i.ClientConfigurationErrorMessage.authorityUriInsecure;if(!e.PathSegments||e.PathSegments.length<1)throw i.ClientConfigurationErrorMessage.authorityUriInvalidPath},e.prototype.DiscoverEndpoints=function(e){return(new s.XhrClient).sendRequestAsync(e,"GET",!0).then(function(e){return{AuthorizationEndpoint:e.authorization_endpoint,EndSessionEndpoint:e.end_session_endpoint,Issuer:e.issuer}})},e.prototype.resolveEndpointsAsync=function(){var t=this,r="";return this.GetOpenIdConfigurationEndpointAsync().then(function(e){return r=e,t.DiscoverEndpoints(r)}).then(function(e){return t.tenantDiscoveryResponse=e,t})},e}();t.Authority=a},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var c,n,i=r(0);(n=c=t.LogLevel||(t.LogLevel={}))[n.Error=0]="Error",n[n.Warning=1]="Warning",n[n.Info=2]="Info",n[n.Verbose=3]="Verbose";var o=function(){function e(e,t){void 0===t&&(t={}),this.level=c.Info;var r=t.correlationId,n=void 0===r?"":r,o=t.level,i=void 0===o?c.Info:o,s=t.piiLoggingEnabled,a=void 0!==s&&s;this.localCallback=e,this.correlationId=n,this.level=i,this.piiLoggingEnabled=a}return e.prototype.logMessage=function(e,t,r){if(!(e>this.level||!this.piiLoggingEnabled&&r)){var n,o=(new Date).toUTCString();n=i.Utils.isEmpty(this.correlationId)?o+":"+i.Utils.getLibraryVersion()+"-"+c[e]+" "+t:o+":"+this.correlationId+"-"+i.Utils.getLibraryVersion()+"-"+c[e]+" "+t,this.executeCallback(e,n,r)}},e.prototype.executeCallback=function(e,t,r){this.localCallback&&this.localCallback(e,t,r)},e.prototype.error=function(e){this.logMessage(c.Error,e,!1)},e.prototype.errorPii=function(e){this.logMessage(c.Error,e,!0)},e.prototype.warning=function(e){this.logMessage(c.Warning,e,!1)},e.prototype.warningPii=function(e){this.logMessage(c.Warning,e,!0)},e.prototype.info=function(e){this.logMessage(c.Info,e,!1)},e.prototype.infoPii=function(e){this.logMessage(c.Info,e,!0)},e.prototype.verbose=function(e){this.logMessage(c.Verbose,e,!1)},e.prototype.verbosePii=function(e){this.logMessage(c.Verbose,e,!0)},e}();t.Logger=o},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var i=r(1),n=r(5);t.ServerErrorMessage={serverUnavailable:{code:"server_unavailable",desc:"Server is temporarily unavailable."},unknownServerError:{code:"unknown_server_error"}};var o=function(n){function o(e,t){var r=n.call(this,e,t)||this;return r.name="ServerError",Object.setPrototypeOf(r,o.prototype),r}return i.__extends(o,n),o.createServerUnavailableError=function(){return new o(t.ServerErrorMessage.serverUnavailable.code,t.ServerErrorMessage.serverUnavailable.desc)},o.createUnknownServerError=function(e){return new o(t.ServerErrorMessage.unknownServerError.code,e)},o}(n.AuthError);t.ServerError=o},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var y=r(1),m=r(17),C=r(18),h=r(19),v=r(20),w=r(2),I=r(21),S=r(22),b=r(10),E=r(0),g=r(24),n=r(13),a=r(4),k=r(5),A=r(3),T=r(8),O=r(14),l="id_token",o="token",i="id_token token",s=function(e,t,r){var n=r.value;return r.value=function(){for(var e=[],t=0;t");window.frames&&window.frames[e]&&(t=window.frames[e])}return t},e.prototype.addHintParameters=function(e,t,r){var n=e||this.getAccount();return n&&(n.sid&&r.promptValue===w.PromptState.NONE?t[w.SSOTypes.SID]||t[w.SSOTypes.LOGIN_HINT]||(t=E.Utils.addSSOParameter(w.SSOTypes.SID,n.sid,t)):t[w.SSOTypes.LOGIN_HINT]||!n.userName||E.Utils.isEmpty(n.userName)||(t=E.Utils.addSSOParameter(w.SSOTypes.LOGIN_HINT,n.userName,t)),t[w.SSOTypes.DOMAIN_REQ]||t[w.SSOTypes.LOGIN_REQ]||(t=E.Utils.addSSOParameter(w.SSOTypes.HOMEACCOUNT_ID,n.homeAccountIdentifier,t))),t},e.prototype.promptUser=function(e){if(!e||E.Utils.isEmpty(e))throw this.logger.info("Navigate url is empty"),k.AuthError.createUnexpectedError("Navigate url is empty");this.logger.infoPii("Navigate to:"+e),window.location.replace(e)},e.prototype.registerCallback=function(n,o,e,t){var i=this;window.activeRenewals[o]=n,window.promiseMappedToRenewStates[n]||(window.promiseMappedToRenewStates[n]=[]),window.promiseMappedToRenewStates[n].push({resolve:e,reject:t}),window.callbackMappedToRenewStates[n]||(window.callbackMappedToRenewStates[n]=function(e,t){window.activeRenewals[o]=null;for(var r=0;rE.Utils.now()+d){var h=new I.IdToken(r.value.idToken);if(!t&&!(t=this.getAccount()))throw k.AuthError.createUnexpectedError("Account should not be null here.");var p=this.getAccountState(this.cacheStorage.getItem(w.Constants.stateLogin,this.inCookie)),f={uniqueId:"",tenantId:"",tokenType:r.value.idToken===r.value.accessToken?w.Constants.idToken:w.Constants.accessToken,idToken:h,accessToken:r.value.accessToken,scopes:r.key.scopes.split(" "),expiresOn:new Date(1e3*l),account:t,accountState:p};return E.Utils.setResponseIdToken(f,h),f}return this.cacheStorage.removeItem(JSON.stringify(i[0].key)),null},e.prototype.getUniqueAuthority=function(e,t){var r=[],n=[];return e.forEach(function(e){e.key.hasOwnProperty(t)&&-1===n.indexOf(e.key[t])&&(n.push(e.key[t]),r.push(e.key[t]))}),r},e.prototype.extractADALIdToken=function(){var e=this.cacheStorage.getItem(w.Constants.adalIdToken);return E.Utils.isEmpty(e)?null:E.Utils.extractIdToken(e)},e.prototype.renewToken=function(e,t,r,n,o){var i=e.join(" ").toLowerCase();this.logger.verbose("renewToken is called for scope:"+i);var s=this.addHiddenIFrame("msalRenewFrame"+i);this.setAccountCache(n,o.state),this.setAuthorityCache(o.state,o.authority),this.cacheStorage.setItem(w.Constants.nonceIdToken,o.nonce,this.inCookie),this.logger.verbose("Renew token Expected state: "+o.state);var a=E.Utils.urlRemoveQueryStringParameter(o.createNavigateUrl(e),w.Constants.prompt)+w.Constants.prompt_none;window.renewStates.push(o.state),window.requestType=w.Constants.renewToken,this.registerCallback(o.state,i,t,r),this.logger.infoPii("Navigate to:"+a),s.src="about:blank",this.loadIframeTimeout(a,"msalRenewFrame"+i,i)},e.prototype.renewIdToken=function(e,t,r,n,o){this.logger.info("renewidToken is called");var i=this.addHiddenIFrame("msalIdTokenFrame");this.setAccountCache(n,o.state),this.setAuthorityCache(o.state,o.authority),this.cacheStorage.setItem(w.Constants.nonceIdToken,o.nonce,this.inCookie),this.logger.verbose("Renew Idtoken Expected state: "+o.state);var s=E.Utils.urlRemoveQueryStringParameter(o.createNavigateUrl(e),w.Constants.prompt)+w.Constants.prompt_none;this.silentLogin?(window.requestType=w.Constants.login,this.silentAuthenticationState=o.state):(window.requestType=w.Constants.renewToken,window.renewStates.push(o.state)),this.registerCallback(o.state,this.clientId,t,r),this.logger.infoPii("Navigate to:"+s),i.src="about:blank",this.loadIframeTimeout(s,"msalIdTokenFrame",this.clientId)},e.prototype.saveAccessToken=function(e,t,r,n){var o,i=y.__assign({},e),s=new v.ClientInfo(n);if(r.hasOwnProperty("scope")){for(var a=(o=r.scope).split(" "),c=this.cacheStorage.getAllAccessTokens(this.clientId,t),u=0;u