1 | {"version":3,"sources":["webpack://Msal/webpack/universalModuleDefinition","webpack://Msal/./node_modules/tslib/tslib.es6.js","webpack://Msal/./src/Account.ts","webpack://Msal/./src/AuthResponse.ts","webpack://Msal/./src/AuthenticationParameters.ts","webpack://Msal/./src/ClientInfo.ts","webpack://Msal/./src/Configuration.ts","webpack://Msal/./src/IdToken.ts","webpack://Msal/./src/Logger.ts","webpack://Msal/./src/ScopeSet.ts","webpack://Msal/./src/ServerRequestParameters.ts","webpack://Msal/./src/UserAgentApplication.ts","webpack://Msal/./src/XHRClient.ts","webpack://Msal/./src/authority/Authority.ts","webpack://Msal/./src/authority/AuthorityFactory.ts","webpack://Msal/./src/authority/TrustedAuthority.ts","webpack://Msal/./src/cache/AccessTokenCacheItem.ts","webpack://Msal/./src/cache/AccessTokenKey.ts","webpack://Msal/./src/cache/AccessTokenValue.ts","webpack://Msal/./src/cache/AuthCache.ts","webpack://Msal/./src/cache/BrowserStorage.ts","webpack://Msal/./src/error/AuthError.ts","webpack://Msal/./src/error/ClientAuthError.ts","webpack://Msal/./src/error/ClientConfigurationError.ts","webpack://Msal/./src/error/InteractionRequiredAuthError.ts","webpack://Msal/./src/error/ServerError.ts","webpack://Msal/./src/index.ts","webpack://Msal/./src/packageMetadata.ts","webpack://Msal/./src/telemetry/ApiEvent.ts","webpack://Msal/./src/telemetry/DefaultEvent.ts","webpack://Msal/./src/telemetry/HttpEvent.ts","webpack://Msal/./src/telemetry/TelemetryConstants.ts","webpack://Msal/./src/telemetry/TelemetryEvent.ts","webpack://Msal/./src/telemetry/TelemetryManager.ts","webpack://Msal/./src/telemetry/TelemetryUtils.ts","webpack://Msal/./src/utils/AuthCacheUtils.ts","webpack://Msal/./src/utils/Constants.ts","webpack://Msal/./src/utils/CryptoUtils.ts","webpack://Msal/./src/utils/RequestUtils.ts","webpack://Msal/./src/utils/ResponseUtils.ts","webpack://Msal/./src/utils/StringUtils.ts","webpack://Msal/./src/utils/TimeUtils.ts","webpack://Msal/./src/utils/TokenUtils.ts","webpack://Msal/./src/utils/UrlUtils.ts","webpack://Msal/./src/utils/WindowUtils.ts","webpack://Msal/webpack/bootstrap","webpack://Msal/webpack/startup"],"names":["root","factory","exports","module","define","amd","self","extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","hasOwnProperty","__values","o","m","Symbol","iterator","i","call","next","length","value","done","__read","n","r","e","ar","push","error","__await","v","this","__","constructor","prototype","create","__assign","assign","t","s","arguments","apply","indexOf","getOwnPropertySymbols","propertyIsEnumerable","decorators","target","key","desc","c","getOwnPropertyDescriptor","Reflect","decorate","defineProperty","paramIndex","decorator","metadataKey","metadataValue","metadata","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","step","rejected","result","then","body","f","y","g","_","label","sent","trys","ops","verb","op","TypeError","pop","concat","il","k","a","j","jl","asyncIterator","q","resume","fulfill","settle","shift","cooked","raw","mod","__esModule","default","accountIdentifier","homeAccountIdentifier","userName","name","idTokenClaims","sid","environment","idToken","createAccount","clientInfo","objectId","subject","uid","utid","StringUtils","isEmpty","CryptoUtils","base64Encode","Account","preferredName","claims","issuer","compareAccounts","a1","a2","state","uniqueId","tenantId","tokenType","accessToken","scopes","expiresOn","account","accountState","fromCache","request","claimsRequest","JSON","parse","ClientConfigurationError","createClaimsRequestParsingError","rawClientInfo","authority","decodedClientInfo","base64Decode","ClientInfo","stripPolicyFromUid","ClientAuthError","createClientInfoDecodingError","_uid","_utid","createClientInfoFromIdToken","stringify","uidSegments","split","urlSegments","reverse","policy","slice","join","encodeClientInfo","DEFAULT_AUTH_OPTIONS","clientId","validateAuthority","authorityMetadata","knownAuthorities","redirectUri","UrlUtils","getCurrentUrl","postLogoutRedirectUri","navigateToLoginRequestUrl","DEFAULT_CACHE_OPTIONS","cacheLocation","storeAuthStateInCookie","DEFAULT_SYSTEM_OPTIONS","logger","Logger","loadFrameTimeout","tokenRenewalOffsetSeconds","navigateFrameWait","DEFAULT_FRAMEWORK_OPTIONS","isAngular","unprotectedResources","protectedResourceMap","Map","auth","cache","system","framework","rawIdToken","createIdTokenNullOrEmptyError","TokenUtils","extractIdToken","version","nonce","expiration","homeObjectId","cloudInstance","createIdTokenParsingError","IdToken","LogLevel","localCallback","options","level","Info","correlationId","piiLoggingEnabled","logMessage","logLevel","containsPii","log","timestamp","Date","toUTCString","executeCallback","message","Error","errorPii","warning","Warning","warningPii","info","infoPii","verbose","Verbose","verbosePii","isPiiLoggingEnabled","isIntersectingScopes","cachedScopes","convertedCachedScopes","trimAndConvertArrayToLowerCase","requestScopes","toLowerCase","containsScope","every","toString","trimAndConvertToLowerCase","scope","trim","map","trimScopes","removeElement","scopeVal","filter","parseScope","scopeList","validateInputScope","scopesRequired","isArray","createScopesNonArrayError","createEmptyScopesArrayError","createScopesRequiredError","getScopeFromState","splitIndex","Constants","resourceDelimiter","substring","appendScopes","reqScopes","reqExtraScopesToConsent","convertedExtraScopes","convertedReqScopes","onlyContainsOidcScopes","scopesCount","oidcScopesFound","openidScope","profileScope","containsAnyOidcScopes","containsOpenIdScope","containsProfileScope","onlyContainsClientId","appendDefaultScopes","extendedScopes","removeDefaultScopes","translateClientIdIfSingleScope","oidcScopes","ScopeSet","responseType","authorityInstance","createNewGuid","xClientSku","xClientVer","CanonicalAuthority","populateQueryParams","adalIdTokenObject","silentCall","queryParameters","prompt","promptValue","claimsValue","ServerRequestParameters","isSSOParam","constructUnifiedCacheQueryParameter","addHintParameters","eQParams","extraQueryParameters","generateQueryParametersString","idTokenObject","ssoType","ssoData","SSOTypes","SID","LOGIN_HINT","loginHint","upn","ID_TOKEN","addSSOParameter","params","qParams","PromptState","NONE","ssoParam","paramsString","keys","forEach","domain_hint","encodeURIComponent","determineResponseType","accountsMatch","ResponseTypes","id_token","responseTypeForMatchingAccounts","id_token_token","token","configuration","authResponseCallback","tokenReceivedCallback","errorReceivedCallback","config","buildConfiguration","inCookie","telemetryManager","getTelemetryManagerFromConfig","telemetry","TrustedAuthority","setTrustedAuthoritiesFromConfig","AuthorityFactory","saveMetadataFromConfig","cacheStorage","AuthCache","window","activeRenewals","renewStates","callbackMappedToRenewStates","promiseMappedToRenewStates","msal","urlHash","location","hash","urlContainsHash","WindowUtils","checkIfBackButtonIsPressed","isInteractionInProgress","getResponseState","method","interactionTypeRedirect","handleRedirectAuthenticationResponse","val","CreateInstance","getAuthorityInstance","handleRedirectCallback","authOrTokenCallback","createInvalidCallbackObjectError","redirectError","authErrorHandler","redirectResponse","authResponseHandler","interactionType","response","interactionTypePopup","createInvalidInteractionTypeError","authErr","setInteractionInProgress","loginRedirect","userRequest","RequestUtils","validateRequest","acquireTokenInteractive","acquireTokenRedirect","loginPopup","apiEvent","createAndStartApiEvent","API_EVENT_IDENTIFIER","LoginPopup","resp","stopAndFlushApiEvent","catch","resetTempCacheItems","errorCode","acquireTokenPopup","AcquireTokenPopup","isLoginCall","blockReloadInHiddenIframes","interactionProgress","setItem","TemporaryCacheKeys","REDIRECT_REQUEST","inProgress","thrownError","createLoginInProgressError","createAcquireTokenInProgressError","stateOnlyResponse","buildResponseStateOnly","getAccountState","getAccount","acquireTokenHelper","createUserLoginRequiredError","extractADALIdToken","tokenRequest","buildIDTokenRequest","silentLogin","acquireTokenSilent","requestSignature","acquireTokenAuthority","hasCachedMetadata","saveMetadataFromNetwork","getTokenType","loginStartPage","redirectStartPage","href","serverAuthenticationRequest","getRedirectUri","updateCacheEntries","urlNavigate","createNavigateUrl","response_mode_fragment","generateTemporaryCacheKey","STATE_ACQ_TOKEN","requestType","login","renewToken","registerCallback","popUpWindow","openPopup","popUpWidth","popUpHeight","trackPopup","ClientAuthErrorMessage","popUpWindowError","code","ErrorCacheKeys","ERROR","ERROR_DESC","createPopupWindowError","monitorPopupForHash","handleAuthenticationResponse","broadcast","closePopups","errorMessage","close","onRedirectNavigate","navigateWindow","createEndpointResolutionError","ssoSilent","createEmptyRequestError","createSsoSilentError","interactionTypeSilent","AcquireTokenSilent","createRequestSignature","adalIdToken","getItem","userContainedClaims","forceRefresh","cacheResultResponse","getCachedToken","renewIdToken","res","title","winLeft","screenLeft","screenX","winTop","screenTop","screenY","width","innerWidth","document","documentElement","clientWidth","height","innerHeight","clientHeight","left","top","popupWindow","open","focus","loadIframeTimeout","frameName","expectedState","RENEW_STATUS","loadFrame","loadFrameSync","iframe","monitorIframeForHash","contentWindow","removeItem","removeHiddenIframe","AuthError","createUnexpectedError","logout","logoutAsync","requestCorrelationId","Logout","clearCache","correlationIdParam","postLogoutQueryParam","getPostLogoutRedirectUri","EndSessionEndpoint","tokenCacheItems","getAllTokens","resetCacheItems","clearMsalCookie","clearCacheForScope","accessTokenItems","getAllAccessTokens","isCallback","processCallBack","respStateInfo","parentCallback","stateInfo","saveTokenFromHash","err","parent","ServerHashParamKeys","ACCESS_TOKEN","createErrorInCallbackFunction","locationHash","tokenResponseCallback","clearUrlFragment","loginRequestUrl","LOGIN_REQUEST","currentUrl","removeHashFromUrl","finalRedirectUrl","loginRequestUrlComponents","GetUrlComponents","Hash","stateResponse","parameters","deserializeHash","STATE","parsedState","parseLibraryState","unknown","ts","stateMatch","STATE_LOGIN","silentAuthenticationState","statesInParentContext","getCachedIdToken","authResponse","getCachedAccessToken","ResponseUtils","buildAuthResponse","getTokenCacheItemByAuthority","filteredAuthorityItems","isCommonAuthority","isOrganizationsAuthority","isConsumersAuthority","AuthCacheUtils","filterTokenCacheItemsByDomain","HostNameAndPort","filterTokenCacheItemsByAuthority","accessTokenCacheItem","idTokenCacheItems","getAllIdTokens","matchAuthority","idTokenCacheItem","evaluateTokenExpiration","idTokenValue","scopeFilteredTokenCacheItems","filterTokenCacheItemsByScope","responseAccount","aState","Number","expiresIn","tokenCacheItem","validateExpirationIsWithinOffset","generateFrameName","FramePrefix","TOKEN_FRAME","addHiddenIFrame","urlRemoveQueryStringParameter","prompt_none","ID_TOKEN_FRAME","saveToken","accessTokenKey","AccessTokenKey","accessTokenValue","AccessTokenValue","saveIdToken","idTokenObj","idTokenResponse","saveAccessToken","accessTokenResponse","SCOPE","consentedScopes","accessTokenCacheItems","TimeUtils","parseExpiresIn","EXPIRES_IN","hashParams","authorityKey","acquireTokenAccountKey","ERROR_DESCRIPTION","LOGIN_ERROR","generateAuthorityKey","accountId","no_account","generateAcquireTokenAccountKey","hashErr","hashErrDesc","InteractionRequiredAuthError","isInteractionRequiredError","ServerError","SESSION_STATE","PersistentCacheKeys","IDTOKEN","setResponseIdToken","populateAuthority","CLIENT_INFO","AuthorityType","Adfs","accountKey","acquireTokenAccountKey_noaccount","cachedAccount","acquireTokenAccount","cachedNonce","NONCE_IDTOKEN","createNonceMismatchError","createInvalidIdTokenError","createInvalidStateError","setItemCookie","cachedAuthority","replaceTenantPath","getAllAccounts","accounts","getUniqueAccounts","flags","uniqueAccounts","index","eventName","data","evt","CustomEvent","detail","dispatchEvent","getCachedTokenInternal","accountObject","newAuthority","getScopesForEndpoint","endpoint","size","from","get","getHostFromUri","getLoginInProgress","setloginInProgress","loginInProgress","getAcquireTokenInProgress","setAcquireTokenInProgress","acquireTokenInProgress","getLogger","setLogger","reqRedirectUri","getCurrentConfiguration","createNoSetConfigurationError","setAccountCache","getAccountId","setAuthorityCache","CanonicalizeUri","getTelemetrymanagerStub","applicationName","applicationVersion","telemetryEmitter","createTelemetryConfigError","telemetryManagerConfig","platform","UserAgentApplication","sendRequestAsync","url","enableCaching","xhr","XMLHttpRequest","onload","jsonResponse","status","handleError","responseText","statusCode","onerror","NetworkRequestType","GET","send","XhrClient","IsValidationEnabled","validateAsUri","tenantDiscoveryResponse","isAdfs","authorityUrl","pathSegments","PathSegments","ADFS","Authority","canonicalAuthority","Default","CanonicalAuthorityUrlComponents","validateResolved","AuthorizationEndpoint","replace","Tenant","Issuer","canonicalAuthorityUrlComponents","WELL_KNOWN_SUFFIX","components","ClientConfigurationErrorMessage","invalidAuthorityType","Protocol","authorityUriInsecure","authorityUriInvalidPath","DiscoverEndpoints","openIdConfigurationEndpoint","client","httpMethod","httpEvent","createAndStartHttpEvent","httpResponseStatus","stopEvent","serverErrorCode","resolveEndpointsAsync","host","getTrustedHostList","setTrustedAuthoritiesFromNetwork","IsInTrustedHostList","createUntrustedAuthorityError","openIdConfigurationEndpointResponse","GetOpenIdConfigurationEndpoint","DefaultOpenIdConfigurationEndpoint","metadataMap","set","getMetadata","authorityMetadataJson","parsedMetadata","authorization_endpoint","end_session_endpoint","createInvalidAuthorityMetadataError","TrustedHostList","getAliases","authorityToVerify","instanceDiscoveryEndpoint","AAD_INSTANCE_DISCOVERY_ENDPOINT","entry","AccessTokenCacheItem","temporaryCache","BrowserStorage","SESSION_STORAGE","rollbackEnabled","migrateCacheEntries","idTokenKey","cachePrefix","clientInfoKey","errorKey","errorDescKey","aud","cacheKey","duplicateCacheEntry","newKey","generateCacheKey","addInstanceId","matchKeyForType","parsedKey","validateAndParseJsonCacheKey","accountMatches","match","tokenTypeMatches","enableCookieStorage","setTemporaryItem","getTemporaryItem","storage","stateId","id","isTokenRenewalInProgress","tokenRenewalInProgress","clearItemCookie","cName","cValue","expires","getItemCookie","getAllTokensByType","reduce","tokens","matchedTokenKey","newAccessTokenCacheItem","accessTokens","idTokens","matchClientId","getInteractionInProgress","INTERACTION_STATUS","newInProgressValue","stateValue","renewStatus","cookie","cookieString","cookieName","ACQUIRE_TOKEN_ACCOUNT","AUTHORITY","tempCacheKey","createNoWindowObjectError","createStorageNotSupportedError","clear","cookieStr","getCookieExpirationTime","ca","charAt","decodeURIComponent","cookieLifeDays","today","getTime","AuthErrorMessage","unexpectedError","noWindowObjectError","errDesc","endpointResolutionError","tokenRenewalError","invalidIdToken","invalidStateError","nonceMismatchError","loginProgressError","acquireTokenProgressError","userCancelledError","callbackError","userLoginRequiredError","userDoesNotExistError","clientInfoDecodingError","clientInfoNotPopulatedError","nullOrEmptyIdToken","idTokenNotParsed","tokenEncodingError","invalidInteractionType","cacheParseError","blockTokenRequestsInHiddenIframe","errDetail","createTokenRenewalTimeoutError","invalidState","actualState","invalidNonce","actualNonce","createUserCancelledError","errorDesc","createUserDoesNotExistError","caughtError","createClientInfoNotPopulatedError","invalidRawTokenString","caughtParsingError","createTokenEncodingError","incorrectlyEncodedToken","createCacheParseError","createBlockTokenRequestsInHiddenIframeError","configurationNotSet","storageNotSupported","noRedirectCallbacksSet","invalidCallbackObject","emptyScopes","nonArrayScopes","invalidPrompt","unsupportedAuthorityValidation","untrustedAuthority","b2cAuthorityUriInvalidPath","b2cKnownAuthoritiesNotSet","claimsRequestParsingError","emptyRequestError","invalidCorrelationIdError","telemetryConfigError","ssoSilentError","invalidAuthorityMetadataError","givenCacheLocation","createRedirectCallbacksNotSetError","callbackObject","scopesValue","createInvalidPromptError","claimsRequestParseError","createInvalidCorrelationIdError","createKnownAuthoritiesNotSetError","createInvalidAuthorityTypeError","requiredKeys","InteractionRequiredAuthErrorMessage","interactionRequired","consentRequired","loginRequired","errorString","interactionRequiredCodes","createLoginRequiredAuthError","createInteractionRequiredAuthError","createConsentRequiredAuthError","ServerErrorMessage","serverUnavailable","unknownServerError","createServerUnavailableError","createUnknownServerError","CacheResult","CacheLocation","Configuration","AuthenticationParameters","AuthResponse","API_CODE","EVENT_KEYS","prependEventNamePrefix","AUTHORITY_TYPE","PROMPT","TENANT_ID","USER_ID","WAS_SUCESSFUL","API_ERROR_CODE","mapEventIdentiferToCode","AcquireTokenRedirect","LoginRedirect","piiEnabled","apiEventIdentifier","apiCode","event","TELEMETRY_BLOB_EVENT_NAMES","ApiTelemIdConstStrKey","ApiIdConstStrKey","uri","scrubTenantFromUri","hashPersonalIdentifier","wasSuccessful","authorityType","promptType","eventCount","sdk","sdkVersion","networkInformation","connectionSpeed","UiEventCountTelemetryBatchKey","getEventCount","HttpEventCountTelemetryBatchKey","CacheEventCountConstStrKey","HTTP_PATH","USER_AGENT","QUERY_PARAMETERS","API_VERSION","RESPONSE_CODE","O_AUTH_ERROR_CODE","HTTP_METHOD","REQUEST_ID_HEADER","SPE_INFO","SERVER_ERROR_CODE","SERVER_SUB_ERROR_CODE","URL","eventLabel","scrubbedUri","httpPath","userAgent","queryParams","apiVersion","requestIdHeader","speInfo","subErrorCode","EVENT_NAME_PREFIX","EVENT_NAME_KEY","START_TIME_KEY","ELAPSED_TIME_KEY","MsalCorrelationIdConstStrKey","BrokerAppConstStrKey","IdpConstStrKey","IsSilentTelemetryBatchKey","IsSuccessfulConstStrKey","ResponseTimeConstStrKey","TenantIdConstStrKey","TENANT_PLACEHOLDER","eventId","setElapsedTime","time","stop","now","startTimestamp","endBrowserPerformanceMeasurement","displayName","perfStartMark","perfEndMark","start","startBrowserPerformanceMeasurement","telemetryCorrelationId","completedEvents","inProgressEvents","eventCountByCorrelationId","onlySendFailureTelemetry","telemetryPlatform","libraryName","navigator","connection","effectiveType","startEvent","incrementEventCount","flush","orphanedEvents","getOrphanedEvents","eventsToFlush","eventCountsToFlush","defaultEvent","eventsWithDefaultEvent","apiErrorCode","correlation","memo","eventKey","pathParams","tenantPosition","valueToHash","suffix","supportsBrowserPerformance","performance","mark","measure","measureName","startMark","endMark","clearMeasures","clearMarks","cacheItem","searchScopes","requestDomain","_popUpWidth","_popUpHeight","DEFAULT_AUTHORITY","BlacklistedEQParams","POST","LOGIN","SELECT_ACCOUNT","CONSENT","cryptoObj","crypto","getRandomValues","buffer","Uint8Array","decimalToHex","guidHolder","hex","guidResponse","Math","random","isGuid","guid","test","num","input","btoa","p1","String","fromCharCode","encodedString","atob","charCodeAt","deserialize","query","pl","search","decode","obj","exec","extraScopesToConsent","validatePromptParameter","validateEQParameters","validateClaimsRequest","validateAndGenerateState","validateAndGenerateCorrelationId","param","userState","generateLibraryState","stateObject","stateString","libraryState","originalResponse","exp","idTokeTokenResponse","str","parseInt","round","relativeNowMs","decodeJwt","jwtToken","matches","header","JWSPayload","JWSSig","offset","encodedIdToken","decodedToken","base64IdToken","base64Decoded","serverRequestParams","createNavigationUrlString","authEndpoint","lowerCaseUrl","urlObject","pathArray","common","ORGANIZATIONS","CONSUMERS","constructAuthorityUriFromObject","regEx","RegExp","urlComponents","AbsolutePath","Search","endsWith","regex","getHashFromUrl","urlStringOrFragment","hashIndex1","hashIndex2","urlString","urlFragment","extractedUri","isInIframe","isInPopup","opener","prefix","timeout","timeoutMark","intervalId","setInterval","clearInterval","POLLING_INTERVAL_MS","maxTicks","ticks","closed","timeoutMs","setTimeout","frameHandle","src","iframeId","adalFrame","getElementById","createElement","ifr","setAttribute","style","visibility","position","border","getElementsByTagName","appendChild","insertAdjacentHTML","frames","parentNode","removeChild","getIframeWithHash","iframes","item","getPopups","openedWindows","getPopUpWithHash","popup","redirectCache","splitCache","history","replaceState","pathname","__webpack_module_cache__","__webpack_require__","moduleId","__webpack_modules__"],"mappings":";cAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,OAAQ,GAAIH,GACO,iBAAZC,QACdA,QAAc,KAAID,IAElBD,EAAW,KAAIC,IARjB,CASGK,MAAM,WACT,O;;;;;;;;;;;;;;;iDCMA,IAAIC,EAAgB,SAASC,EAAGC,GAI5B,OAHAF,EAAgBG,OAAOC,gBAClB,CAAEC,UAAW,cAAgBC,OAAS,SAAUL,EAAGC,GAAKD,EAAEI,UAAYH,IACvE,SAAUD,EAAGC,GAAK,IAAK,IAAIK,KAAKL,EAAOA,EAAEM,eAAeD,KAAIN,EAAEM,GAAKL,EAAEK,MACpDN,EAAGC,IAwF5B,SAAgBO,EAASC,GACrB,IAAIC,EAAsB,mBAAXC,QAAyBF,EAAEE,OAAOC,UAAWC,EAAI,EAChE,OAAIH,EAAUA,EAAEI,KAAKL,GACd,CACHM,KAAM,WAEF,OADIN,GAAKI,GAAKJ,EAAEO,SAAQP,OAAI,GACrB,CAAEQ,MAAOR,GAAKA,EAAEI,KAAMK,MAAOT,KAKhD,SAAgBU,EAAOV,EAAGW,GACtB,IAAIV,EAAsB,mBAAXC,QAAyBF,EAAEE,OAAOC,UACjD,IAAKF,EAAG,OAAOD,EACf,IAAmBY,EAAYC,EAA3BT,EAA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GAAU9oC,QAG3C,IAAIC,EAAS2oC,EAAyBE,GAAY,CAGjD9oC,QAAS,IAOV,OAHA+oC,EAAoBD,GAAU7oC,EAAQA,EAAOD,QAAS6oC,GAG/C5oC,EAAOD,QCjBR6oC,CAAoB,K,MDFvBD","file":"msal.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"Msal\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Msal\"] = factory();\n\telse\n\t\troot[\"Msal\"] = factory();\n})(self, function() {\nreturn ","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\r\n if (m) return m.call(o);\r\n return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ClientInfo } from \"./ClientInfo\";\r\nimport { IdToken } from \"./IdToken\";\r\nimport { CryptoUtils } from \"./utils/CryptoUtils\";\r\nimport { StringUtils } from \"./utils/StringUtils\";\r\nimport { StringDict } from \"./MsalTypes\";\r\n\r\n/**\r\n * accountIdentifier combination of idToken.uid and idToken.utid\r\n * homeAccountIdentifier combination of clientInfo.uid and clientInfo.utid\r\n * userName idToken.preferred_username\r\n * name idToken.name\r\n * idToken idToken\r\n * sid idToken.sid - session identifier\r\n * environment idtoken.issuer (the authority that issues the token)\r\n */\r\nexport class Account {\r\n\r\n accountIdentifier: string;\r\n homeAccountIdentifier: string;\r\n userName: string;\r\n name: string;\r\n idToken: StringDict; // will be deprecated soon\r\n idTokenClaims: StringDict;\r\n sid: string;\r\n environment: string;\r\n\r\n /**\r\n * Creates an Account Object\r\n * @praram accountIdentifier\r\n * @param homeAccountIdentifier\r\n * @param userName\r\n * @param name\r\n * @param idToken\r\n * @param sid\r\n * @param environment\r\n */\r\n constructor(accountIdentifier: string, homeAccountIdentifier: string, userName: string, name: string, idTokenClaims: StringDict, sid: string, environment: string) {\r\n this.accountIdentifier = accountIdentifier;\r\n this.homeAccountIdentifier = homeAccountIdentifier;\r\n this.userName = userName;\r\n this.name = name;\r\n // will be deprecated soon\r\n this.idToken = idTokenClaims;\r\n this.idTokenClaims = idTokenClaims;\r\n this.sid = sid;\r\n this.environment = environment;\r\n }\r\n\r\n /**\r\n * @hidden\r\n * @param idToken\r\n * @param clientInfo\r\n */\r\n static createAccount(idToken: IdToken, clientInfo: ClientInfo): Account {\r\n\r\n // create accountIdentifier\r\n const accountIdentifier: string = idToken.objectId || idToken.subject;\r\n\r\n // create homeAccountIdentifier\r\n const uid: string = clientInfo ? clientInfo.uid : \"\";\r\n const utid: string = clientInfo ? clientInfo.utid : \"\";\r\n\r\n let homeAccountIdentifier: string;\r\n if (!StringUtils.isEmpty(uid)) {\r\n homeAccountIdentifier = StringUtils.isEmpty(utid)? CryptoUtils.base64Encode(uid): CryptoUtils.base64Encode(uid) + \".\" + CryptoUtils.base64Encode(utid);\r\n }\r\n return new Account(accountIdentifier, homeAccountIdentifier, idToken.preferredName, idToken.name, idToken.claims, idToken.sid, idToken.issuer);\r\n }\r\n\r\n /**\r\n * Utils function to compare two Account objects - used to check if the same user account is logged in\r\n *\r\n * @param a1: Account object\r\n * @param a2: Account object\r\n */\r\n static compareAccounts(a1: Account, a2: Account): boolean {\r\n if (!a1 || !a2) {\r\n return false;\r\n }\r\n if (a1.homeAccountIdentifier && a2.homeAccountIdentifier) {\r\n if (a1.homeAccountIdentifier === a2.homeAccountIdentifier) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { Account } from \"./Account\";\r\nimport { IdToken } from \"./IdToken\";\r\nimport { StringDict } from \"./MsalTypes\";\r\n\r\nexport type AuthResponse = {\r\n uniqueId: string;\r\n tenantId: string;\r\n tokenType: string;\r\n idToken: IdToken;\r\n idTokenClaims: StringDict;\r\n accessToken: string;\r\n scopes: Array<string>;\r\n expiresOn: Date;\r\n account: Account;\r\n accountState: string;\r\n fromCache: boolean\r\n};\r\n\r\nexport function buildResponseStateOnly(state: string) : AuthResponse {\r\n return {\r\n uniqueId: \"\",\r\n tenantId: \"\",\r\n tokenType: \"\",\r\n idToken: null,\r\n idTokenClaims: null,\r\n accessToken: \"\",\r\n scopes: null,\r\n expiresOn: null,\r\n account: null,\r\n accountState: state,\r\n fromCache: false\r\n };\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { Account } from \"./Account\";\r\nimport { ClientConfigurationError } from \"./error/ClientConfigurationError\";\r\nimport { StringDict } from \"./MsalTypes\";\r\n\r\n/**\r\n * @link AuthenticationParameters}AuthenticationParameters\r\n */\r\nexport type AuthenticationParameters = {\r\n scopes?: Array<string>;\r\n extraScopesToConsent?: Array<string>;\r\n prompt?: string;\r\n extraQueryParameters?: StringDict;\r\n claimsRequest?: string;\r\n authority?: string;\r\n state?: string;\r\n correlationId?: string;\r\n account?: Account;\r\n sid?: string;\r\n loginHint?: string;\r\n forceRefresh?: boolean;\r\n redirectUri?: string;\r\n redirectStartPage?: string;\r\n authorityMetadata?: string;\r\n onRedirectNavigate?: ((url: string) => void | boolean)\r\n};\r\n\r\nexport function validateClaimsRequest(request: AuthenticationParameters): void {\r\n if (!request.claimsRequest) {\r\n return;\r\n }\r\n try {\r\n JSON.parse(request.claimsRequest);\r\n } catch (e) {\r\n throw ClientConfigurationError.createClaimsRequestParsingError(e);\r\n }\r\n\r\n // TODO: More validation will be added when the server team tells us how they have actually implemented claims\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { CryptoUtils } from \"./utils/CryptoUtils\";\r\nimport { ClientAuthError } from \"./error/ClientAuthError\";\r\nimport { StringUtils } from \"./utils/StringUtils\";\r\nimport { IdToken } from \"./IdToken\";\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class ClientInfo {\r\n\r\n private _uid: string;\r\n get uid(): string {\r\n return this._uid ? this._uid : \"\";\r\n }\r\n\r\n set uid(uid: string) {\r\n this._uid = uid;\r\n }\r\n\r\n private _utid: string;\r\n get utid(): string {\r\n return this._utid ? this._utid : \"\";\r\n }\r\n\r\n set utid(utid: string) {\r\n this._utid = utid;\r\n }\r\n\r\n static createClientInfoFromIdToken(idToken:IdToken, authority: string): ClientInfo {\r\n const clientInfo = {\r\n uid: idToken.subject, \r\n utid: \"\"\r\n };\r\n\r\n return new ClientInfo(CryptoUtils.base64Encode(JSON.stringify(clientInfo)), authority);\r\n }\r\n\r\n constructor(rawClientInfo: string, authority: string) {\r\n if (!rawClientInfo || StringUtils.isEmpty(rawClientInfo)) {\r\n this.uid = \"\";\r\n this.utid = \"\";\r\n return;\r\n }\r\n\r\n try {\r\n const decodedClientInfo: string = CryptoUtils.base64Decode(rawClientInfo);\r\n const clientInfo: ClientInfo = <ClientInfo>JSON.parse(decodedClientInfo);\r\n if (clientInfo) {\r\n if (clientInfo.hasOwnProperty(\"uid\")) {\r\n this.uid = authority ? ClientInfo.stripPolicyFromUid(clientInfo.uid, authority): clientInfo.uid;\r\n }\r\n\r\n if (clientInfo.hasOwnProperty(\"utid\")) {\r\n this.utid = clientInfo.utid;\r\n }\r\n }\r\n } catch (e) {\r\n throw ClientAuthError.createClientInfoDecodingError(e);\r\n }\r\n }\r\n\r\n static stripPolicyFromUid(uid: string, authority: string): string {\r\n const uidSegments = uid.split(\"-\");\r\n // Reverse the url segments so the last one is more easily accessible\r\n const urlSegments = authority.split(\"/\").reverse();\r\n let policy = \"\";\r\n\r\n if (!StringUtils.isEmpty(urlSegments[0])) {\r\n policy = urlSegments[0];\r\n } else if (urlSegments.length > 1) {\r\n // If the original url had a trailing slash, urlSegments[0] would be \"\" so take the next element\r\n policy = urlSegments[1];\r\n }\r\n\r\n if (uidSegments[uidSegments.length - 1] === policy) {\r\n // If the last segment of uid matches the last segment of authority url, remove the last segment of uid\r\n return uidSegments.slice(0, uidSegments.length - 1).join(\"-\");\r\n }\r\n\r\n return uid;\r\n }\r\n\r\n public encodeClientInfo(): string {\r\n const clientInfo = JSON.stringify({uid: this.uid, utid: this.utid});\r\n\r\n return CryptoUtils.base64Encode(clientInfo);\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { Logger } from \"./Logger\";\r\nimport { UrlUtils } from \"./utils/UrlUtils\";\r\nimport { TelemetryEmitter } from \"./telemetry/TelemetryTypes\";\r\n\r\n/**\r\n * Cache location options supported by MSAL are:\r\n * - local storage: MSAL uses browsers local storage to store its cache\r\n * - session storage: MSAL uses the browsers session storage to store its cache\r\n */\r\nexport type CacheLocation = \"localStorage\" | \"sessionStorage\";\r\n\r\n/**\r\n * Defaults for the Configuration Options\r\n */\r\nconst FRAME_TIMEOUT = 6000;\r\nconst OFFSET = 300;\r\nconst NAVIGATE_FRAME_WAIT = 500;\r\n\r\n/**\r\n * @type AuthOptions: Use this to configure the auth options in the Configuration object\r\n *\r\n * - clientId - Client ID of your app registered with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview in Microsoft Identity Platform\r\n * - authority - You can configure a specific authority, defaults to \" \" or \"https://login.microsoftonline.com/common\"\r\n * - validateAuthority - Used to turn authority validation on/off. When set to true (default), MSAL will compare the application's authority against well-known URLs templates representing well-formed authorities. It is useful when the authority is obtained at run time to prevent MSAL from displaying authentication prompts from malicious pages.\r\n * - authorityMetadata - OpenID configuration metadata for the configured authority. Must be passed as a JSON string.\r\n * - knownAuthorities - If validateAuthority is set to True, this will be used to set the Trusted Host list. Defaults to empty array\r\n * - redirectUri - The redirect URI of the application, this should be same as the value in the application registration portal.Defaults to `window.location.href`.\r\n * - postLogoutRedirectUri - Used to redirect the user to this location after logout. Defaults to `window.location.href`.\r\n * - navigateToLoginRequestUrl - Used to turn off default navigation to start page after login. Default is true. This is used only for redirect flows.\r\n *\r\n */\r\nexport type AuthOptions = {\r\n clientId: string;\r\n authority?: string;\r\n validateAuthority?: boolean;\r\n authorityMetadata?: string;\r\n knownAuthorities?: Array<string>;\r\n redirectUri?: string | (() => string);\r\n postLogoutRedirectUri?: string | (() => string);\r\n navigateToLoginRequestUrl?: boolean;\r\n};\r\n\r\n/**\r\n * Use this to configure the below cache configuration options:\r\n *\r\n * - cacheLocation - Used to specify the cacheLocation user wants to set. Valid values are \"localStorage\" and \"sessionStorage\"\r\n * - storeAuthStateInCookie - If set, MSAL store's the auth request state required for validation of the auth flows in the browser cookies. By default this flag is set to false.\r\n */\r\nexport type CacheOptions = {\r\n cacheLocation?: CacheLocation;\r\n storeAuthStateInCookie?: boolean;\r\n};\r\n\r\n/**\r\n * Telemetry Config Options\r\n * - applicationName - Name of the consuming apps application\r\n * - applicationVersion - Verison of the consuming application\r\n * - telemetryEmitter - Function where telemetry events are flushed to\r\n */\r\nexport type TelemetryOptions = {\r\n applicationName: string;\r\n applicationVersion: string;\r\n telemetryEmitter: TelemetryEmitter\r\n // TODO, add onlyAddFailureTelemetry option\r\n};\r\n\r\n/**\r\n * Library Specific Options\r\n *\r\n * - logger - Used to initialize the Logger object; TODO: Expand on logger details or link to the documentation on logger\r\n * - loadFrameTimeout - maximum time the library should wait for a frame to load\r\n * - tokenRenewalOffsetSeconds - sets the window of offset needed to renew the token before expiry\r\n * - navigateFrameWait - sets the wait time for hidden iFrame navigation\r\n */\r\nexport type SystemOptions = {\r\n logger?: Logger;\r\n loadFrameTimeout?: number;\r\n tokenRenewalOffsetSeconds?: number;\r\n navigateFrameWait?: number;\r\n telemetry?: TelemetryOptions\r\n};\r\n\r\n/**\r\n * App/Framework specific environment support\r\n *\r\n * - isAngular - flag set to determine if it is Angular Framework. MSAL uses this to broadcast tokens. More to come here: detangle this dependency from core.\r\n * - unprotectedResources - Array of URI's which are unprotected resources. MSAL will not attach a token to outgoing requests that have these URI. Defaults to 'null'.\r\n * - protectedResourceMap - This is mapping of resources to scopes used by MSAL for automatically attaching access tokens in web API calls.A single access token is obtained for the resource. So you can map a specific resource path as follows: {\"https://graph.microsoft.com/v1.0/me\", [\"user.read\"]}, or the app URL of the resource as: {\"https://graph.microsoft.com/\", [\"user.read\", \"mail.send\"]}. This is required for CORS calls.\r\n *\r\n */\r\nexport type FrameworkOptions = {\r\n isAngular?: boolean;\r\n unprotectedResources?: Array<string>;\r\n protectedResourceMap?: Map<string, Array<string>>;\r\n};\r\n\r\n/**\r\n * Use the configuration object to configure MSAL and initialize the UserAgentApplication.\r\n *\r\n * This object allows you to configure important elements of MSAL functionality:\r\n * - auth: this is where you configure auth elements like clientID, authority used for authenticating against the Microsoft Identity Platform\r\n * - cache: this is where you configure cache location and whether to store cache in cookies\r\n * - system: this is where you can configure the logger, frame timeout etc.\r\n * - framework: this is where you can configure the running mode of angular. More to come here soon.\r\n */\r\nexport type Configuration = {\r\n auth: AuthOptions,\r\n cache?: CacheOptions,\r\n system?: SystemOptions,\r\n framework?: FrameworkOptions\r\n};\r\n\r\nconst DEFAULT_AUTH_OPTIONS: AuthOptions = {\r\n clientId: \"\",\r\n authority: null,\r\n validateAuthority: true,\r\n authorityMetadata: \"\",\r\n knownAuthorities: [],\r\n redirectUri: () => UrlUtils.getCurrentUrl(),\r\n postLogoutRedirectUri: () => UrlUtils.getCurrentUrl(),\r\n navigateToLoginRequestUrl: true\r\n};\r\n\r\nconst DEFAULT_CACHE_OPTIONS: CacheOptions = {\r\n cacheLocation: \"sessionStorage\",\r\n storeAuthStateInCookie: false\r\n};\r\n\r\nconst DEFAULT_SYSTEM_OPTIONS: SystemOptions = {\r\n logger: new Logger(null),\r\n loadFrameTimeout: FRAME_TIMEOUT,\r\n tokenRenewalOffsetSeconds: OFFSET,\r\n navigateFrameWait: NAVIGATE_FRAME_WAIT\r\n};\r\n\r\nconst DEFAULT_FRAMEWORK_OPTIONS: FrameworkOptions = {\r\n isAngular: false,\r\n unprotectedResources: new Array<string>(),\r\n protectedResourceMap: new Map<string, Array<string>>()\r\n};\r\n\r\n/**\r\n * MSAL function that sets the default options when not explicitly configured from app developer\r\n *\r\n * @param TAuthOptions\r\n * @param TCacheOptions\r\n * @param TSystemOptions\r\n * @param TFrameworkOptions\r\n * @param TAuthorityDataOptions\r\n *\r\n * @returns TConfiguration object\r\n */\r\n\r\nexport function buildConfiguration({ auth, cache = {}, system = {}, framework = {}}: Configuration): Configuration {\r\n const overlayedConfig: Configuration = {\r\n auth: { ...DEFAULT_AUTH_OPTIONS, ...auth },\r\n cache: { ...DEFAULT_CACHE_OPTIONS, ...cache },\r\n system: { ...DEFAULT_SYSTEM_OPTIONS, ...system },\r\n framework: { ...DEFAULT_FRAMEWORK_OPTIONS, ...framework }\r\n };\r\n return overlayedConfig;\r\n}\r\n\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ClientAuthError } from \"./error/ClientAuthError\";\r\nimport { TokenUtils } from \"./utils/TokenUtils\";\r\nimport { StringDict } from \"./MsalTypes\";\r\nimport { StringUtils } from \"./utils/StringUtils\";\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class IdToken {\r\n\r\n issuer: string;\r\n objectId: string;\r\n subject: string;\r\n tenantId: string;\r\n version: string;\r\n preferredName: string;\r\n name: string;\r\n homeObjectId: string;\r\n nonce: string;\r\n expiration: string;\r\n rawIdToken: string;\r\n claims: StringDict;\r\n sid: string;\r\n cloudInstance: string;\r\n /* tslint:disable:no-string-literal */\r\n constructor(rawIdToken: string) {\r\n if (StringUtils.isEmpty(rawIdToken)) {\r\n throw ClientAuthError.createIdTokenNullOrEmptyError(rawIdToken);\r\n }\r\n try {\r\n this.rawIdToken = rawIdToken;\r\n this.claims = TokenUtils.extractIdToken(rawIdToken) as StringDict;\r\n if (this.claims) {\r\n if (this.claims.hasOwnProperty(\"iss\")) {\r\n this.issuer = this.claims[\"iss\"];\r\n }\r\n\r\n if (this.claims.hasOwnProperty(\"oid\")) {\r\n this.objectId = this.claims[\"oid\"];\r\n }\r\n\r\n if (this.claims.hasOwnProperty(\"sub\")) {\r\n this.subject = this.claims[\"sub\"];\r\n }\r\n\r\n if (this.claims.hasOwnProperty(\"tid\")) {\r\n this.tenantId = this.claims[\"tid\"];\r\n }\r\n\r\n if (this.claims.hasOwnProperty(\"ver\")) {\r\n this.version = this.claims[\"ver\"];\r\n }\r\n\r\n if (this.claims.hasOwnProperty(\"preferred_username\")) {\r\n this.preferredName = this.claims[\"preferred_username\"];\r\n } else if (this.claims.hasOwnProperty(\"upn\")) {\r\n this.preferredName = this.claims[\"upn\"];\r\n }\r\n\r\n if (this.claims.hasOwnProperty(\"name\")) {\r\n this.name = this.claims[\"name\"];\r\n }\r\n\r\n if (this.claims.hasOwnProperty(\"nonce\")) {\r\n this.nonce = this.claims[\"nonce\"];\r\n }\r\n\r\n if (this.claims.hasOwnProperty(\"exp\")) {\r\n this.expiration = this.claims[\"exp\"];\r\n }\r\n\r\n if (this.claims.hasOwnProperty(\"home_oid\")) {\r\n this.homeObjectId = this.claims[\"home_oid\"];\r\n }\r\n\r\n if (this.claims.hasOwnProperty(\"sid\")) {\r\n this.sid = this.claims[\"sid\"];\r\n }\r\n\r\n if (this.claims.hasOwnProperty(\"cloud_instance_host_name\")) {\r\n this.cloudInstance = this.claims[\"cloud_instance_host_name\"];\r\n }\r\n /* tslint:enable:no-string-literal */\r\n }\r\n } catch (e) {\r\n /*\r\n * TODO: This error here won't really every be thrown, since extractIdToken() returns null if the decodeJwt() fails.\r\n * Need to add better error handling here to account for being unable to decode jwts.\r\n */\r\n throw ClientAuthError.createIdTokenParsingError(e);\r\n }\r\n }\r\n\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { StringUtils } from \"./utils/StringUtils\";\r\nimport { version as libraryVersion } from \"./packageMetadata\";\r\n\r\nexport interface ILoggerCallback {\r\n (level: LogLevel, message: string, containsPii: boolean): void;\r\n}\r\n\r\nexport enum LogLevel {\r\n Error,\r\n Warning,\r\n Info,\r\n Verbose\r\n}\r\n\r\nexport class Logger {// Singleton Class\r\n\r\n /**\r\n * @hidden\r\n */\r\n // TODO: This does not seem to be a singleton!! Change or Delete.\r\n private static instance: Logger;\r\n\r\n /**\r\n * @hidden\r\n */\r\n private correlationId: string;\r\n\r\n /**\r\n * @hidden\r\n */\r\n private level: LogLevel = LogLevel.Info;\r\n\r\n /**\r\n * @hidden\r\n */\r\n private piiLoggingEnabled: boolean;\r\n\r\n /**\r\n * @hidden\r\n */\r\n private localCallback: ILoggerCallback;\r\n\r\n constructor(localCallback: ILoggerCallback,\r\n options:\r\n {\r\n correlationId?: string,\r\n level?: LogLevel,\r\n piiLoggingEnabled?: boolean,\r\n } = {}) {\r\n const {\r\n correlationId = \"\",\r\n level = LogLevel.Info,\r\n piiLoggingEnabled = false\r\n } = options;\r\n\r\n this.localCallback = localCallback;\r\n this.correlationId = correlationId;\r\n this.level = level;\r\n this.piiLoggingEnabled = piiLoggingEnabled;\r\n }\r\n\r\n /**\r\n * @hidden\r\n */\r\n private logMessage(logLevel: LogLevel, logMessage: string, containsPii: boolean): void {\r\n if ((logLevel > this.level) || (!this.piiLoggingEnabled && containsPii)) {\r\n return;\r\n }\r\n const timestamp = new Date().toUTCString();\r\n let log: string;\r\n if (!StringUtils.isEmpty(this.correlationId)) {\r\n log = timestamp + \":\" + this.correlationId + \"-\" + libraryVersion + \"-\" + LogLevel[logLevel] + (containsPii ? \"-pii\" : \"\") + \" \" + logMessage;\r\n }\r\n else {\r\n log = timestamp + \":\" + libraryVersion + \"-\" + LogLevel[logLevel] + (containsPii ? \"-pii\" : \"\") + \" \" + logMessage;\r\n }\r\n this.executeCallback(logLevel, log, containsPii);\r\n }\r\n\r\n /**\r\n * @hidden\r\n */\r\n executeCallback(level: LogLevel, message: string, containsPii: boolean): void {\r\n if (this.localCallback) {\r\n this.localCallback(level, message, containsPii);\r\n }\r\n }\r\n\r\n /**\r\n * @hidden\r\n */\r\n error(message: string): void {\r\n this.logMessage(LogLevel.Error, message, false);\r\n }\r\n\r\n /**\r\n * @hidden\r\n */\r\n errorPii(message: string): void {\r\n this.logMessage(LogLevel.Error, message, true);\r\n }\r\n\r\n /**\r\n * @hidden\r\n */\r\n warning(message: string): void {\r\n this.logMessage(LogLevel.Warning, message, false);\r\n }\r\n\r\n /**\r\n * @hidden\r\n */\r\n warningPii(message: string): void {\r\n this.logMessage(LogLevel.Warning, message, true);\r\n }\r\n\r\n /**\r\n * @hidden\r\n */\r\n info(message: string): void {\r\n this.logMessage(LogLevel.Info, message, false);\r\n }\r\n\r\n /**\r\n * @hidden\r\n */\r\n infoPii(message: string): void {\r\n this.logMessage(LogLevel.Info, message, true);\r\n }\r\n\r\n /**\r\n * @hidden\r\n */\r\n verbose(message: string): void {\r\n this.logMessage(LogLevel.Verbose, message, false);\r\n }\r\n\r\n /**\r\n * @hidden\r\n */\r\n verbosePii(message: string): void {\r\n this.logMessage(LogLevel.Verbose, message, true);\r\n }\r\n\r\n isPiiLoggingEnabled(): boolean {\r\n return this.piiLoggingEnabled;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ClientConfigurationError } from \"./error/ClientConfigurationError\";\r\nimport { Constants } from \"./utils/Constants\";\r\n\r\nexport class ScopeSet {\r\n\r\n /**\r\n * Check if there are dup scopes in a given request\r\n *\r\n * @param cachedScopes\r\n * @param scopes\r\n */\r\n // TODO: Rename this, intersecting scopes isn't a great name for duplicate checker\r\n static isIntersectingScopes(cachedScopes: Array<string>, scopes: Array<string>): boolean {\r\n const convertedCachedScopes = this.trimAndConvertArrayToLowerCase([...cachedScopes]);\r\n const requestScopes = this.trimAndConvertArrayToLowerCase([...scopes]);\r\n for (let i = 0; i < requestScopes.length; i++) {\r\n if (convertedCachedScopes.indexOf(requestScopes[i].toLowerCase()) > -1) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Check if a given scope is present in the request\r\n *\r\n * @param cachedScopes\r\n * @param scopes\r\n */\r\n static containsScope(cachedScopes: Array<string>, scopes: Array<string>): boolean {\r\n const convertedCachedScopes = this.trimAndConvertArrayToLowerCase([...cachedScopes]);\r\n const requestScopes = this.trimAndConvertArrayToLowerCase([...scopes]);\r\n return requestScopes.every((value: string): boolean => convertedCachedScopes.indexOf(value.toString().toLowerCase()) >= 0);\r\n }\r\n\r\n /**\r\n * Trims and converts string to lower case\r\n *\r\n * @param scopes\r\n */\r\n // TODO: Rename this, too generic name for a function that only deals with scopes\r\n static trimAndConvertToLowerCase(scope: string): string {\r\n return scope.trim().toLowerCase();\r\n }\r\n\r\n /**\r\n * Performs trimAndConvertToLowerCase on string array\r\n * @param scopes \r\n */\r\n static trimAndConvertArrayToLowerCase(scopes: Array<string>): Array<string> {\r\n return scopes.map(scope => this.trimAndConvertToLowerCase(scope));\r\n }\r\n\r\n /**\r\n * Trims each scope in scopes array\r\n * @param scopes \r\n */\r\n static trimScopes(scopes: Array<string>): Array<string> {\r\n return scopes.map(scope => scope.trim());\r\n }\r\n\r\n /**\r\n * Remove one element from a scope array\r\n *\r\n * @param scopes\r\n * @param scope\r\n */\r\n // TODO: Rename this, too generic name for a function that only deals with scopes\r\n static removeElement(scopes: Array<string>, scope: string): Array<string> {\r\n const scopeVal = this.trimAndConvertToLowerCase(scope);\r\n return scopes.filter(value => value !== scopeVal);\r\n }\r\n\r\n /**\r\n * Parse the scopes into a formatted scopeList\r\n * @param scopes\r\n */\r\n static parseScope(scopes: Array<string>): string {\r\n let scopeList: string = \"\";\r\n if (scopes) {\r\n for (let i: number = 0; i < scopes.length; ++i) {\r\n scopeList += (i !== scopes.length - 1) ? scopes[i] + \" \" : scopes[i];\r\n }\r\n }\r\n\r\n return scopeList;\r\n }\r\n\r\n /**\r\n * @hidden\r\n *\r\n * Used to validate the scopes input parameter requested by the developer.\r\n * @param {Array<string>} scopes - Developer requested permissions. Not all scopes are guaranteed to be included in the access token returned.\r\n * @param {boolean} scopesRequired - Boolean indicating whether the scopes array is required or not\r\n * @ignore\r\n */\r\n static validateInputScope(scopes: Array<string>, scopesRequired: boolean): void {\r\n if (!scopes) {\r\n if (scopesRequired) {\r\n throw ClientConfigurationError.createScopesRequiredError(scopes);\r\n } else {\r\n return;\r\n }\r\n }\r\n\r\n // Check that scopes is an array object (also throws error if scopes == null)\r\n if (!Array.isArray(scopes)) {\r\n throw ClientConfigurationError.createScopesNonArrayError(scopes);\r\n }\r\n\r\n // Check that scopes is not an empty array\r\n if (scopes.length < 1 && scopesRequired) {\r\n throw ClientConfigurationError.createEmptyScopesArrayError(scopes.toString());\r\n }\r\n }\r\n\r\n /**\r\n * @hidden\r\n *\r\n * Extracts scope value from the state sent with the authentication request.\r\n * @param {string} state\r\n * @returns {string} scope.\r\n * @ignore\r\n */\r\n static getScopeFromState(state: string): string {\r\n if (state) {\r\n const splitIndex = state.indexOf(Constants.resourceDelimiter);\r\n if (splitIndex > -1 && splitIndex + 1 < state.length) {\r\n return state.substring(splitIndex + 1);\r\n }\r\n }\r\n return \"\";\r\n }\r\n\r\n /**\r\n * @ignore\r\n * Appends extraScopesToConsent if passed\r\n * @param {@link AuthenticationParameters}\r\n */\r\n static appendScopes(reqScopes: Array<string>, reqExtraScopesToConsent: Array<string>): Array<string> {\r\n if (reqScopes) {\r\n const convertedExtraScopes = reqExtraScopesToConsent ? this.trimAndConvertArrayToLowerCase([...reqExtraScopesToConsent]) : null;\r\n const convertedReqScopes = this.trimAndConvertArrayToLowerCase([...reqScopes]);\r\n return convertedExtraScopes ? [...convertedReqScopes, ...convertedExtraScopes] : convertedReqScopes;\r\n }\r\n return null;\r\n }\r\n\r\n // #endregion\r\n\r\n /**\r\n * @ignore\r\n * Returns true if the scopes array only contains openid and/or profile\r\n */\r\n static onlyContainsOidcScopes(scopes: Array<string>): boolean {\r\n const scopesCount = scopes.length;\r\n let oidcScopesFound = 0;\r\n\r\n if (scopes.indexOf(Constants.openidScope) > -1) {\r\n oidcScopesFound += 1;\r\n }\r\n\r\n if (scopes.indexOf(Constants.profileScope) > -1) {\r\n oidcScopesFound += 1;\r\n }\r\n\r\n return (scopesCount > 0 && scopesCount === oidcScopesFound);\r\n }\r\n\r\n /**\r\n * @ignore\r\n * Returns true if the scopes array only contains openid and/or profile\r\n */\r\n static containsAnyOidcScopes(scopes: Array<string>): boolean {\r\n const containsOpenIdScope = scopes.indexOf(Constants.openidScope) > -1;\r\n const containsProfileScope = scopes.indexOf(Constants.profileScope) > -1;\r\n\r\n return (containsOpenIdScope || containsProfileScope);\r\n }\r\n\r\n /**\r\n * @ignore\r\n * Returns true if the clientId is the only scope in the array\r\n */\r\n static onlyContainsClientId(scopes: Array<String>, clientId: string): boolean {\r\n // Double negation to force false value returned in case scopes is null\r\n return !!scopes && (scopes.indexOf(clientId) > -1 && scopes.length === 1);\r\n }\r\n\r\n /**\r\n * @ignore\r\n * Adds missing OIDC scopes to scopes array without duplication. Since STS requires OIDC scopes for\r\n * all implicit flow requests, 'openid' and 'profile' should always be included in the final request\r\n */\r\n static appendDefaultScopes(scopes: Array<string>): Array<string> {\r\n const extendedScopes = scopes;\r\n if (extendedScopes.indexOf(Constants.openidScope) === -1) {\r\n extendedScopes.push(Constants.openidScope);\r\n }\r\n\r\n if(extendedScopes.indexOf(Constants.profileScope) === -1) {\r\n extendedScopes.push(Constants.profileScope);\r\n }\r\n\r\n return extendedScopes;\r\n }\r\n\r\n /**\r\n * @ignore\r\n * Removes present OIDC scopes from scopes array.\r\n */\r\n static removeDefaultScopes(scopes: Array<string>): Array<string> {\r\n return scopes.filter(scope => {\r\n return (scope !== Constants.openidScope && scope !== Constants.profileScope);\r\n });\r\n }\r\n\r\n /**\r\n * @ignore\r\n * Removes clientId from scopes array if included as only scope. If it's not the only scope, it is treated as a resource scope.\r\n * @param scopes Array<string>: Pre-normalized scopes array\r\n * @param clientId string: The application's clientId that is searched for in the scopes array\r\n */\r\n static translateClientIdIfSingleScope(scopes: Array<string>, clientId: string): Array<string> {\r\n return this.onlyContainsClientId(scopes, clientId) ? Constants.oidcScopes : scopes;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { Authority } from \"./authority/Authority\";\r\nimport { CryptoUtils } from \"./utils/CryptoUtils\";\r\nimport { AuthenticationParameters } from \"./AuthenticationParameters\";\r\nimport { StringDict } from \"./MsalTypes\";\r\nimport { Account } from \"./Account\";\r\nimport { SSOTypes, Constants, PromptState, ResponseTypes } from \"./utils/Constants\";\r\nimport { StringUtils } from \"./utils/StringUtils\";\r\nimport { ScopeSet } from \"./ScopeSet\";\r\nimport { version as libraryVersion } from \"./packageMetadata\";\r\n\r\n/**\r\n * Nonce: OIDC Nonce definition: https://openid.net/specs/openid-connect-core-1_0.html#IDToken\r\n * State: OAuth Spec: https://tools.ietf.org/html/rfc6749#section-10.12\r\n * @hidden\r\n */\r\nexport class ServerRequestParameters {\r\n\r\n authorityInstance: Authority;\r\n clientId: string;\r\n scopes: Array<string>;\r\n\r\n nonce: string;\r\n state: string;\r\n\r\n // telemetry information\r\n xClientVer: string;\r\n xClientSku: string;\r\n correlationId: string;\r\n\r\n responseType: string;\r\n redirectUri: string;\r\n\r\n promptValue: string;\r\n claimsValue: string;\r\n\r\n queryParameters: string;\r\n extraQueryParameters: string;\r\n\r\n public get authority(): string {\r\n return this.authorityInstance ? this.authorityInstance.CanonicalAuthority : null;\r\n }\r\n\r\n /**\r\n * Constructor\r\n * @param authority\r\n * @param clientId\r\n * @param scope\r\n * @param responseType\r\n * @param redirectUri\r\n * @param state\r\n */\r\n constructor (authority: Authority, clientId: string, responseType: string, redirectUri: string, scopes: Array<string>, state: string, correlationId: string) {\r\n this.authorityInstance = authority;\r\n this.clientId = clientId;\r\n this.nonce = CryptoUtils.createNewGuid();\r\n\r\n // set scope to clientId if null\r\n this.scopes = scopes ? [ ...scopes] : Constants.oidcScopes;\r\n this.scopes = ScopeSet.trimScopes(this.scopes);\r\n\r\n // set state (already set at top level)\r\n this.state = state;\r\n\r\n // set correlationId\r\n this.correlationId = correlationId;\r\n\r\n // telemetry information\r\n this.xClientSku = \"MSAL.JS\";\r\n this.xClientVer = libraryVersion;\r\n\r\n this.responseType = responseType;\r\n this.redirectUri = redirectUri;\r\n }\r\n\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * Utility to populate QueryParameters and ExtraQueryParameters to ServerRequestParamerers\r\n * @param request\r\n * @param serverAuthenticationRequest\r\n */\r\n populateQueryParams(account: Account, request: AuthenticationParameters|null, adalIdTokenObject?: object, silentCall?: boolean): void {\r\n let queryParameters: StringDict = {};\r\n\r\n if (request) {\r\n // add the prompt parameter to serverRequestParameters if passed\r\n if (request.prompt) {\r\n this.promptValue = request.prompt;\r\n }\r\n\r\n // Add claims challenge to serverRequestParameters if passed\r\n if (request.claimsRequest) {\r\n this.claimsValue = request.claimsRequest;\r\n }\r\n\r\n // if the developer provides one of these, give preference to developer choice\r\n if (ServerRequestParameters.isSSOParam(request)) {\r\n queryParameters = this.constructUnifiedCacheQueryParameter(request, null);\r\n }\r\n }\r\n\r\n if (adalIdTokenObject) {\r\n queryParameters = this.constructUnifiedCacheQueryParameter(null, adalIdTokenObject);\r\n }\r\n\r\n /*\r\n * adds sid/login_hint if not populated\r\n * this.logger.verbose(\"Calling addHint parameters\");\r\n */\r\n queryParameters = this.addHintParameters(account, queryParameters);\r\n\r\n // sanity check for developer passed extraQueryParameters\r\n const eQParams: StringDict|null = request ? request.extraQueryParameters : null;\r\n\r\n // Populate the extraQueryParameters to be sent to the server\r\n this.queryParameters = ServerRequestParameters.generateQueryParametersString(queryParameters);\r\n this.extraQueryParameters = ServerRequestParameters.generateQueryParametersString(eQParams, silentCall);\r\n }\r\n\r\n // #region QueryParam helpers\r\n\r\n /**\r\n * Constructs extraQueryParameters to be sent to the server for the AuthenticationParameters set by the developer\r\n * in any login() or acquireToken() calls\r\n * @param idTokenObject\r\n * @param extraQueryParameters\r\n * @param sid\r\n * @param loginHint\r\n */\r\n // TODO: check how this behaves when domain_hint only is sent in extraparameters and idToken has no upn.\r\n private constructUnifiedCacheQueryParameter(request: AuthenticationParameters, idTokenObject: object): StringDict {\r\n\r\n // preference order: account > sid > login_hint\r\n let ssoType;\r\n let ssoData;\r\n let serverReqParam: StringDict = {};\r\n // if account info is passed, account.sid > account.login_hint\r\n if (request) {\r\n if (request.account) {\r\n const account: Account = request.account;\r\n if (account.sid) {\r\n ssoType = SSOTypes.SID;\r\n ssoData = account.sid;\r\n }\r\n else if (account.userName) {\r\n ssoType = SSOTypes.LOGIN_HINT;\r\n ssoData = account.userName;\r\n }\r\n }\r\n // sid from request\r\n else if (request.sid) {\r\n ssoType = SSOTypes.SID;\r\n ssoData = request.sid;\r\n }\r\n // loginHint from request\r\n else if (request.loginHint) {\r\n ssoType = SSOTypes.LOGIN_HINT;\r\n ssoData = request.loginHint;\r\n }\r\n }\r\n // adalIdToken retrieved from cache\r\n else if (idTokenObject) {\r\n if (idTokenObject.hasOwnProperty(Constants.upn)) {\r\n ssoType = SSOTypes.ID_TOKEN;\r\n ssoData = idTokenObject[\"upn\"];\r\n }\r\n }\r\n\r\n serverReqParam = this.addSSOParameter(ssoType, ssoData);\r\n return serverReqParam;\r\n }\r\n\r\n /**\r\n * @hidden\r\n *\r\n * Adds login_hint to authorization URL which is used to pre-fill the username field of sign in page for the user if known ahead of time\r\n * domain_hint if added skips the email based discovery process of the user - only supported for interactive calls in implicit_flow\r\n * domain_req utid received as part of the clientInfo\r\n * login_req uid received as part of clientInfo\r\n * Also does a sanity check for extraQueryParameters passed by the user to ensure no repeat queryParameters\r\n *\r\n * @param {@link Account} account - Account for which the token is requested\r\n * @param queryparams\r\n * @param {@link ServerRequestParameters}\r\n * @ignore\r\n */\r\n private addHintParameters(account: Account, params: StringDict): StringDict {\r\n /*\r\n * This is a final check for all queryParams added so far; preference order: sid > login_hint\r\n * sid cannot be passed along with login_hint or domain_hint, hence we check both are not populated yet in queryParameters\r\n */\r\n let qParams = params;\r\n if (account && !qParams[SSOTypes.SID]) {\r\n // sid - populate only if login_hint is not already populated and the account has sid\r\n const populateSID = !qParams[SSOTypes.LOGIN_HINT] && account.sid && this.promptValue === PromptState.NONE;\r\n if (populateSID) {\r\n qParams = this.addSSOParameter(SSOTypes.SID, account.sid, qParams);\r\n }\r\n // login_hint - account.userName\r\n else {\r\n const populateLoginHint = !qParams[SSOTypes.LOGIN_HINT] && account.userName && !StringUtils.isEmpty(account.userName);\r\n if (populateLoginHint) {\r\n qParams = this.addSSOParameter(SSOTypes.LOGIN_HINT, account.userName, qParams);\r\n }\r\n }\r\n }\r\n\r\n return qParams;\r\n }\r\n\r\n /**\r\n * Add SID to extraQueryParameters\r\n * @param sid\r\n */\r\n private addSSOParameter(ssoType: string, ssoData: string, params?: StringDict): StringDict {\r\n const ssoParam = params || {};\r\n\r\n if (!ssoData) {\r\n return ssoParam;\r\n }\r\n\r\n switch (ssoType) {\r\n case SSOTypes.SID: {\r\n ssoParam[SSOTypes.SID] = ssoData;\r\n break;\r\n }\r\n case SSOTypes.ID_TOKEN: {\r\n ssoParam[SSOTypes.LOGIN_HINT] = ssoData;\r\n break;\r\n }\r\n case SSOTypes.LOGIN_HINT: {\r\n ssoParam[SSOTypes.LOGIN_HINT] = ssoData;\r\n break;\r\n }\r\n }\r\n\r\n return ssoParam;\r\n }\r\n\r\n /**\r\n * Utility to generate a QueryParameterString from a Key-Value mapping of extraQueryParameters passed\r\n * @param extraQueryParameters\r\n */\r\n static generateQueryParametersString(queryParameters?: StringDict, silentCall?: boolean): string|null {\r\n let paramsString: string|null = null;\r\n\r\n if (queryParameters) {\r\n Object.keys(queryParameters).forEach((key: string) => {\r\n // sid cannot be passed along with login_hint or domain_hint\r\n if(key === Constants.domain_hint && (silentCall || queryParameters[SSOTypes.SID])) {\r\n return;\r\n }\r\n\r\n if (!paramsString) {\r\n paramsString = `${key}=${encodeURIComponent(queryParameters[key])}`;\r\n }\r\n else {\r\n paramsString += `&${key}=${encodeURIComponent(queryParameters[key])}`;\r\n }\r\n });\r\n }\r\n\r\n return paramsString;\r\n }\r\n // #endregion\r\n\r\n /**\r\n * Check to see if there are SSO params set in the Request\r\n * @param request\r\n */\r\n static isSSOParam(request: AuthenticationParameters): boolean {\r\n return !!(request && (request.account || request.sid || request.loginHint));\r\n }\r\n\r\n /**\r\n * Returns the correct response_type string attribute for an acquireToken request configuration\r\n * @param accountsMatch boolean: Determines whether the account in the request matches the cached account\r\n * @param scopes Array<string>: AuthenticationRequest scopes configuration\r\n * @param loginScopesOnly boolean: True if the scopes array ONLY contains the clientId or any combination of OIDC scopes, without resource scopes\r\n */\r\n static determineResponseType(accountsMatch: boolean, scopes: Array<string>): string {\r\n // Supports getting an id_token by sending in clientId as only scope or OIDC scopes as only scopes\r\n if (ScopeSet.onlyContainsOidcScopes(scopes)) {\r\n return ResponseTypes.id_token;\r\n }\r\n // If accounts match, check if OIDC scopes are included, otherwise return id_token_token\r\n return (accountsMatch) ? this.responseTypeForMatchingAccounts(scopes) : ResponseTypes.id_token_token;\r\n }\r\n\r\n /**\r\n * Returns the correct response_type string attribute for an acquireToken request configuration that contains an\r\n * account that matches the account in the MSAL cache.\r\n * @param scopes Array<string>: AuthenticationRequest scopes configuration\r\n */\r\n private static responseTypeForMatchingAccounts(scopes: Array<string>): string {\r\n // Opt-into also requesting an ID token by sending in 'openid', 'profile' or both along with resource scopes when login is not necessary.\r\n return (ScopeSet.containsAnyOidcScopes(scopes)) ? ResponseTypes.id_token_token : ResponseTypes.token;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AccessTokenCacheItem } from \"./cache/AccessTokenCacheItem\";\r\nimport { AccessTokenKey } from \"./cache/AccessTokenKey\";\r\nimport { AccessTokenValue } from \"./cache/AccessTokenValue\";\r\nimport { ServerRequestParameters } from \"./ServerRequestParameters\";\r\nimport { Authority, AuthorityType } from \"./authority/Authority\";\r\nimport { ClientInfo } from \"./ClientInfo\";\r\nimport { IdToken } from \"./IdToken\";\r\nimport { Logger } from \"./Logger\";\r\nimport { AuthCache } from \"./cache/AuthCache\";\r\nimport { Account } from \"./Account\";\r\nimport { ScopeSet } from \"./ScopeSet\";\r\nimport { StringUtils } from \"./utils/StringUtils\";\r\nimport { WindowUtils } from \"./utils/WindowUtils\";\r\nimport { TokenUtils } from \"./utils/TokenUtils\";\r\nimport { TimeUtils } from \"./utils/TimeUtils\";\r\nimport { UrlUtils } from \"./utils/UrlUtils\";\r\nimport { RequestUtils } from \"./utils/RequestUtils\";\r\nimport { ResponseUtils } from \"./utils/ResponseUtils\";\r\nimport { AuthorityFactory } from \"./authority/AuthorityFactory\";\r\nimport { Configuration, buildConfiguration, TelemetryOptions } from \"./Configuration\";\r\nimport { AuthenticationParameters } from \"./AuthenticationParameters\";\r\nimport { ClientConfigurationError } from \"./error/ClientConfigurationError\";\r\nimport { AuthError } from \"./error/AuthError\";\r\nimport { ClientAuthError, ClientAuthErrorMessage } from \"./error/ClientAuthError\";\r\nimport { ServerError } from \"./error/ServerError\";\r\nimport { InteractionRequiredAuthError } from \"./error/InteractionRequiredAuthError\";\r\nimport { AuthResponse, buildResponseStateOnly } from \"./AuthResponse\";\r\nimport TelemetryManager from \"./telemetry/TelemetryManager\";\r\nimport { TelemetryPlatform, TelemetryConfig } from \"./telemetry/TelemetryTypes\";\r\nimport ApiEvent, { API_EVENT_IDENTIFIER } from \"./telemetry/ApiEvent\";\r\n\r\nimport { Constants,\r\n ServerHashParamKeys,\r\n InteractionType,\r\n ResponseTypes,\r\n TemporaryCacheKeys,\r\n PersistentCacheKeys,\r\n ErrorCacheKeys,\r\n FramePrefix\r\n} from \"./utils/Constants\";\r\nimport { CryptoUtils } from \"./utils/CryptoUtils\";\r\nimport { TrustedAuthority } from \"./authority/TrustedAuthority\";\r\nimport { AuthCacheUtils } from \"./utils/AuthCacheUtils\";\r\n\r\n// default authority\r\nconst DEFAULT_AUTHORITY = \"https://login.microsoftonline.com/common\";\r\n\r\n/**\r\n * Interface to handle iFrame generation, Popup Window creation and redirect handling\r\n */\r\ndeclare global {\r\n // eslint-disable-next-line\r\n interface Window {\r\n msal: Object;\r\n CustomEvent: CustomEvent;\r\n Event: Event;\r\n activeRenewals: {};\r\n renewStates: Array<string>;\r\n callbackMappedToRenewStates : {};\r\n promiseMappedToRenewStates: {};\r\n openedWindows: Array<Window>;\r\n requestType: string;\r\n }\r\n}\r\n\r\n/**\r\n * @hidden\r\n * @ignore\r\n */\r\nexport interface CacheResult {\r\n errorDesc: string;\r\n token: string;\r\n error: string;\r\n}\r\n\r\n/**\r\n * @hidden\r\n * @ignore\r\n * Data type to hold information about state returned from the server\r\n */\r\nexport type ResponseStateInfo = {\r\n state: string;\r\n timestamp: number,\r\n method: string;\r\n stateMatch: boolean;\r\n requestType: string;\r\n};\r\n\r\n/**\r\n * A type alias for an authResponseCallback function.\r\n * {@link (authResponseCallback:type)}\r\n * @param authErr error created for failure cases\r\n * @param response response containing token strings in success cases, or just state value in error cases\r\n */\r\nexport type authResponseCallback = (authErr: AuthError, response?: AuthResponse) => void;\r\n\r\n/**\r\n * A type alias for a tokenReceivedCallback function.\r\n * {@link (tokenReceivedCallback:type)}\r\n * @returns response of type {@link (AuthResponse:type)}\r\n * The function that will get the call back once this API is completed (either successfully or with a failure).\r\n */\r\nexport type tokenReceivedCallback = (response: AuthResponse) => void;\r\n\r\n/**\r\n * A type alias for a errorReceivedCallback function.\r\n * {@link (errorReceivedCallback:type)}\r\n * @returns response of type {@link (AuthError:class)}\r\n * @returns {string} account state\r\n */\r\nexport type errorReceivedCallback = (authErr: AuthError, accountState: string) => void;\r\n\r\n/**\r\n * UserAgentApplication class\r\n *\r\n * Object Instance that the developer can use to make loginXX OR acquireTokenXX functions\r\n */\r\nexport class UserAgentApplication {\r\n\r\n // input Configuration by the developer/user\r\n private config: Configuration;\r\n\r\n // callbacks for token/error\r\n private authResponseCallback: authResponseCallback = null;\r\n private tokenReceivedCallback: tokenReceivedCallback = null;\r\n private errorReceivedCallback: errorReceivedCallback = null;\r\n\r\n // Added for readability as these params are very frequently used\r\n private logger: Logger;\r\n private clientId: string;\r\n private inCookie: boolean;\r\n private telemetryManager: TelemetryManager;\r\n\r\n // Cache and Account info referred across token grant flow\r\n protected cacheStorage: AuthCache;\r\n private account: Account;\r\n\r\n // state variables\r\n private silentAuthenticationState: string;\r\n private silentLogin: boolean;\r\n private redirectResponse: AuthResponse;\r\n private redirectError: AuthError;\r\n\r\n // Authority Functionality\r\n protected authorityInstance: Authority;\r\n\r\n /**\r\n * setter for the authority URL\r\n * @param {string} authority\r\n */\r\n // If the developer passes an authority, create an instance\r\n public set authority(val: string) {\r\n this.authorityInstance = AuthorityFactory.CreateInstance(val, this.config.auth.validateAuthority);\r\n }\r\n\r\n /**\r\n * Method to manage the authority URL.\r\n *\r\n * @returns {string} authority\r\n */\r\n public get authority(): string {\r\n return this.authorityInstance.CanonicalAuthority;\r\n }\r\n\r\n /**\r\n * Get the current authority instance from the MSAL configuration object\r\n *\r\n * @returns {@link Authority} authority instance\r\n */\r\n public getAuthorityInstance(): Authority {\r\n return this.authorityInstance;\r\n }\r\n\r\n /**\r\n * @constructor\r\n * Constructor for the UserAgentApplication used to instantiate the UserAgentApplication object\r\n *\r\n * Important attributes in the Configuration object for auth are:\r\n * - clientID: the application ID of your application.\r\n * You can obtain one by registering your application with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview\r\n * - authority: the authority URL for your application.\r\n *\r\n * In Azure AD, authority is a URL indicating the Azure active directory that MSAL uses to obtain tokens.\r\n * It is of the form https://login.microsoftonline.com/<Enter_the_Tenant_Info_Here>.\r\n * If your application supports Accounts in one organizational directory, replace \"Enter_the_Tenant_Info_Here\" value with the Tenant Id or Tenant name (for example, contoso.microsoft.com).\r\n * If your application supports Accounts in any organizational directory, replace \"Enter_the_Tenant_Info_Here\" value with organizations.\r\n * If your application supports Accounts in any organizational directory and personal Microsoft accounts, replace \"Enter_the_Tenant_Info_Here\" value with common.\r\n * To restrict support to Personal Microsoft accounts only, replace \"Enter_the_Tenant_Info_Here\" value with consumers.\r\n *\r\n *\r\n * In Azure B2C, authority is of the form https://<instance>/tfp/<tenant>/<policyName>/\r\n *\r\n * @param {@link (Configuration:type)} configuration object for the MSAL UserAgentApplication instance\r\n */\r\n constructor(configuration: Configuration) {\r\n \r\n // Set the Configuration\r\n this.config = buildConfiguration(configuration);\r\n\r\n this.logger = this.config.system.logger;\r\n this.clientId = this.config.auth.clientId;\r\n this.inCookie = this.config.cache.storeAuthStateInCookie;\r\n\r\n this.telemetryManager = this.getTelemetryManagerFromConfig(this.config.system.telemetry, this.clientId);\r\n\r\n TrustedAuthority.setTrustedAuthoritiesFromConfig(this.config.auth.validateAuthority, this.config.auth.knownAuthorities);\r\n AuthorityFactory.saveMetadataFromConfig(this.config.auth.authority, this.config.auth.authorityMetadata);\r\n\r\n // if no authority is passed, set the default: \"https://login.microsoftonline.com/common\"\r\n this.authority = this.config.auth.authority || DEFAULT_AUTHORITY;\r\n // cache keys msal - typescript throws an error if any value other than \"localStorage\" or \"sessionStorage\" is passed\r\n this.cacheStorage = new AuthCache(this.clientId, this.config.cache.cacheLocation, this.inCookie);\r\n\r\n // Initialize window handling code\r\n if (!window.activeRenewals) {\r\n window.activeRenewals = {};\r\n }\r\n if (!window.renewStates) {\r\n window.renewStates = [];\r\n }\r\n if (!window.callbackMappedToRenewStates) {\r\n window.callbackMappedToRenewStates = {};\r\n }\r\n if (!window.promiseMappedToRenewStates) {\r\n window.promiseMappedToRenewStates = {};\r\n }\r\n window.msal = this;\r\n\r\n const urlHash = window.location.hash;\r\n const urlContainsHash = UrlUtils.urlContainsHash(urlHash);\r\n\r\n // check if back button is pressed\r\n WindowUtils.checkIfBackButtonIsPressed(this.cacheStorage);\r\n\r\n // On the server 302 - Redirect, handle this\r\n if (urlContainsHash && this.cacheStorage.isInteractionInProgress(true)) {\r\n const stateInfo = this.getResponseState(urlHash);\r\n if (stateInfo.method === Constants.interactionTypeRedirect) {\r\n this.handleRedirectAuthenticationResponse(urlHash);\r\n }\r\n }\r\n }\r\n\r\n // #region Redirect Callbacks\r\n /**\r\n * @hidden\r\n * @ignore\r\n * Set the callback functions for the redirect flow to send back the success or error object.\r\n * @param {@link (tokenReceivedCallback:type)} successCallback - Callback which contains the AuthResponse object, containing data from the server.\r\n * @param {@link (errorReceivedCallback:type)} errorCallback - Callback which contains a AuthError object, containing error data from either the server\r\n * or the library, depending on the origin of the error.\r\n */\r\n handleRedirectCallback(tokenReceivedCallback: tokenReceivedCallback, errorReceivedCallback: errorReceivedCallback): void;\r\n handleRedirectCallback(authCallback: authResponseCallback): void;\r\n handleRedirectCallback(authOrTokenCallback: authResponseCallback | tokenReceivedCallback, errorReceivedCallback?: errorReceivedCallback): void {\r\n if (!authOrTokenCallback) {\r\n throw ClientConfigurationError.createInvalidCallbackObjectError(authOrTokenCallback);\r\n }\r\n\r\n // Set callbacks\r\n if (errorReceivedCallback) {\r\n this.tokenReceivedCallback = authOrTokenCallback as tokenReceivedCallback;\r\n this.errorReceivedCallback = errorReceivedCallback;\r\n this.logger.warning(\"This overload for callback is deprecated - please change the format of the callbacks to a single callback as shown: (err: AuthError, response: AuthResponse).\");\r\n } else {\r\n this.authResponseCallback = authOrTokenCallback as authResponseCallback;\r\n }\r\n\r\n if (this.redirectError) {\r\n this.authErrorHandler(Constants.interactionTypeRedirect, this.redirectError, this.redirectResponse);\r\n } else if (this.redirectResponse) {\r\n this.authResponseHandler(Constants.interactionTypeRedirect, this.redirectResponse);\r\n }\r\n }\r\n\r\n /**\r\n * Public API to verify if the URL contains the hash with known properties\r\n * @param hash\r\n */\r\n public urlContainsHash(hash: string): boolean {\r\n this.logger.verbose(\"UrlContainsHash has been called\");\r\n return UrlUtils.urlContainsHash(hash);\r\n }\r\n\r\n private authResponseHandler(interactionType: InteractionType, response: AuthResponse, resolve?: Function) : void {\r\n this.logger.verbose(\"AuthResponseHandler has been called\");\r\n\r\n if (interactionType === Constants.interactionTypeRedirect) {\r\n this.logger.verbose(\"Interaction type is redirect\");\r\n if (this.errorReceivedCallback) {\r\n this.logger.verbose(\"Two callbacks were provided to handleRedirectCallback, calling success callback with response\");\r\n this.tokenReceivedCallback(response);\r\n } else if (this.authResponseCallback) {\r\n this.logger.verbose(\"One callback was provided to handleRedirectCallback, calling authResponseCallback with response\");\r\n this.authResponseCallback(null, response);\r\n }\r\n } else if (interactionType === Constants.interactionTypePopup) {\r\n this.logger.verbose(\"Interaction type is popup, resolving\");\r\n resolve(response);\r\n } else {\r\n throw ClientAuthError.createInvalidInteractionTypeError();\r\n }\r\n }\r\n\r\n private authErrorHandler(interactionType: InteractionType, authErr: AuthError, response: AuthResponse, reject?: Function) : void {\r\n this.logger.verbose(\"AuthErrorHandler has been called\");\r\n\r\n // set interaction_status to complete\r\n this.cacheStorage.setInteractionInProgress(false);\r\n if (interactionType === Constants.interactionTypeRedirect) {\r\n this.logger.verbose(\"Interaction type is redirect\");\r\n if (this.errorReceivedCallback) {\r\n this.logger.verbose(\"Two callbacks were provided to handleRedirectCallback, calling error callback\");\r\n this.errorReceivedCallback(authErr, response.accountState);\r\n } else if (this.authResponseCallback) {\r\n this.logger.verbose(\"One callback was provided to handleRedirectCallback, calling authResponseCallback with error\");\r\n this.authResponseCallback(authErr, response);\r\n } else {\r\n this.logger.verbose(\"handleRedirectCallback has not been called and no callbacks are registered, throwing error\");\r\n throw authErr;\r\n }\r\n } else if (interactionType === Constants.interactionTypePopup) {\r\n this.logger.verbose(\"Interaction type is popup, rejecting\");\r\n reject(authErr);\r\n } else {\r\n throw ClientAuthError.createInvalidInteractionTypeError();\r\n }\r\n }\r\n\r\n // #endregion\r\n /**\r\n * Use when initiating the login process by redirecting the user's browser to the authorization endpoint.\r\n * @param {@link (AuthenticationParameters:type)}\r\n */\r\n loginRedirect(userRequest?: AuthenticationParameters): void {\r\n this.logger.verbose(\"LoginRedirect has been called\");\r\n\r\n // validate request\r\n const request: AuthenticationParameters = RequestUtils.validateRequest(userRequest, true, this.clientId, Constants.interactionTypeRedirect);\r\n this.acquireTokenInteractive(Constants.interactionTypeRedirect, true, request, null, null);\r\n }\r\n\r\n /**\r\n * Use when you want to obtain an access_token for your API by redirecting the user's browser window to the authorization endpoint.\r\n * @param {@link (AuthenticationParameters:type)}\r\n *\r\n * To renew idToken, please pass clientId as the only scope in the Authentication Parameters\r\n */\r\n acquireTokenRedirect(userRequest: AuthenticationParameters): void {\r\n this.logger.verbose(\"AcquireTokenRedirect has been called\");\r\n\r\n // validate request\r\n const request: AuthenticationParameters = RequestUtils.validateRequest(userRequest, false, this.clientId, Constants.interactionTypeRedirect);\r\n this.acquireTokenInteractive(Constants.interactionTypeRedirect, false, request, null, null);\r\n }\r\n\r\n /**\r\n * Use when initiating the login process via opening a popup window in the user's browser\r\n *\r\n * @param {@link (AuthenticationParameters:type)}\r\n *\r\n * @returns {Promise.<AuthResponse>} - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthResponse} object\r\n */\r\n loginPopup(userRequest?: AuthenticationParameters): Promise<AuthResponse> {\r\n this.logger.verbose(\"LoginPopup has been called\");\r\n\r\n // validate request\r\n const request: AuthenticationParameters = RequestUtils.validateRequest(userRequest, true, this.clientId, Constants.interactionTypePopup);\r\n const apiEvent: ApiEvent = this.telemetryManager.createAndStartApiEvent(request.correlationId, API_EVENT_IDENTIFIER.LoginPopup);\r\n\r\n return new Promise<AuthResponse>((resolve, reject) => {\r\n this.acquireTokenInteractive(Constants.interactionTypePopup, true, request, resolve, reject);\r\n })\r\n .then((resp) => {\r\n this.logger.verbose(\"Successfully logged in\");\r\n this.telemetryManager.stopAndFlushApiEvent(request.correlationId, apiEvent, true);\r\n return resp;\r\n })\r\n .catch((error: AuthError) => {\r\n this.cacheStorage.resetTempCacheItems(request.state);\r\n this.telemetryManager.stopAndFlushApiEvent(request.correlationId, apiEvent, false, error.errorCode);\r\n throw error;\r\n });\r\n }\r\n\r\n /**\r\n * Use when you want to obtain an access_token for your API via opening a popup window in the user's browser\r\n * @param {@link AuthenticationParameters}\r\n *\r\n * To renew idToken, please pass clientId as the only scope in the Authentication Parameters\r\n * @returns {Promise.<AuthResponse>} - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthResponse} object\r\n */\r\n acquireTokenPopup(userRequest: AuthenticationParameters): Promise<AuthResponse> {\r\n this.logger.verbose(\"AcquireTokenPopup has been called\");\r\n\r\n // validate request\r\n const request: AuthenticationParameters = RequestUtils.validateRequest(userRequest, false, this.clientId, Constants.interactionTypePopup);\r\n const apiEvent: ApiEvent = this.telemetryManager.createAndStartApiEvent(request.correlationId, API_EVENT_IDENTIFIER.AcquireTokenPopup);\r\n\r\n return new Promise<AuthResponse>((resolve, reject) => {\r\n this.acquireTokenInteractive(Constants.interactionTypePopup, false, request, resolve, reject);\r\n })\r\n .then((resp) => {\r\n this.logger.verbose(\"Successfully acquired token\");\r\n this.telemetryManager.stopAndFlushApiEvent(request.correlationId, apiEvent, true);\r\n return resp;\r\n })\r\n .catch((error: AuthError) => {\r\n this.cacheStorage.resetTempCacheItems(request.state);\r\n this.telemetryManager.stopAndFlushApiEvent(request.correlationId, apiEvent, false, error.errorCode);\r\n throw error;\r\n });\r\n }\r\n\r\n // #region Acquire Token\r\n\r\n /**\r\n * Use when initiating the login process or when you want to obtain an access_token for your API,\r\n * either by redirecting the user's browser window to the authorization endpoint or via opening a popup window in the user's browser.\r\n * @param {@link (AuthenticationParameters:type)}\r\n *\r\n * To renew idToken, please pass clientId as the only scope in the Authentication Parameters\r\n */\r\n private acquireTokenInteractive(interactionType: InteractionType, isLoginCall: boolean, request: AuthenticationParameters, resolve?: Function, reject?: Function): void {\r\n this.logger.verbose(\"AcquireTokenInteractive has been called\");\r\n\r\n // block the request if made from the hidden iframe\r\n WindowUtils.blockReloadInHiddenIframes();\r\n\r\n const interactionProgress = this.cacheStorage.isInteractionInProgress(false);\r\n if(interactionType === Constants.interactionTypeRedirect) {\r\n this.cacheStorage.setItem(TemporaryCacheKeys.REDIRECT_REQUEST, `${Constants.inProgress}${Constants.resourceDelimiter}${request.state}`);\r\n }\r\n\r\n // If already in progress, do not proceed\r\n if (interactionProgress) {\r\n const thrownError = isLoginCall ? ClientAuthError.createLoginInProgressError() : ClientAuthError.createAcquireTokenInProgressError();\r\n const stateOnlyResponse = buildResponseStateOnly(this.getAccountState(request.state));\r\n this.cacheStorage.resetTempCacheItems(request.state);\r\n this.authErrorHandler(interactionType,\r\n thrownError,\r\n stateOnlyResponse,\r\n reject);\r\n return;\r\n }\r\n\r\n // Get the account object if a session exists\r\n let account: Account;\r\n if (request && request.account && !isLoginCall) {\r\n account = request.account;\r\n this.logger.verbose(\"Account set from request\");\r\n } else {\r\n account = this.getAccount();\r\n this.logger.verbose(\"Account set from MSAL Cache\");\r\n }\r\n\r\n // If no session exists, prompt the user to login.\r\n if (!account && !ServerRequestParameters.isSSOParam(request)) {\r\n if (isLoginCall) {\r\n // extract ADAL id_token if exists\r\n const adalIdToken = this.extractADALIdToken();\r\n\r\n // silent login if ADAL id_token is retrieved successfully - SSO\r\n if (adalIdToken && !request.scopes) {\r\n this.logger.info(\"ADAL's idToken exists. Extracting login information from ADAL's idToken\");\r\n const tokenRequest: AuthenticationParameters = this.buildIDTokenRequest(request);\r\n\r\n this.silentLogin = true;\r\n this.acquireTokenSilent(tokenRequest).then(response => {\r\n this.silentLogin = false;\r\n this.logger.info(\"Unified cache call is successful\");\r\n\r\n this.authResponseHandler(interactionType, response, resolve);\r\n return;\r\n }, (error) => {\r\n this.silentLogin = false;\r\n this.logger.error(\"Error occurred during unified cache ATS: \" + error);\r\n\r\n // proceed to login since ATS failed\r\n this.acquireTokenHelper(null, interactionType, isLoginCall, request, resolve, reject);\r\n });\r\n }\r\n // No ADAL token found, proceed to login\r\n else {\r\n this.logger.verbose(\"Login call but no token found, proceed to login\");\r\n this.acquireTokenHelper(null, interactionType, isLoginCall, request, resolve, reject);\r\n }\r\n }\r\n // AcquireToken call, but no account or context given, so throw error\r\n else {\r\n this.logger.verbose(\"AcquireToken call, no context or account given\");\r\n this.logger.info(\"User login is required\");\r\n const stateOnlyResponse = buildResponseStateOnly(this.getAccountState(request.state));\r\n this.cacheStorage.resetTempCacheItems(request.state);\r\n this.authErrorHandler(interactionType,\r\n ClientAuthError.createUserLoginRequiredError(),\r\n stateOnlyResponse,\r\n reject);\r\n return;\r\n }\r\n }\r\n // User session exists\r\n else {\r\n this.logger.verbose(\"User session exists, login not required\");\r\n this.acquireTokenHelper(account, interactionType, isLoginCall, request, resolve, reject);\r\n }\r\n }\r\n\r\n /**\r\n * @hidden\r\n * @ignore\r\n * Helper function to acquireToken\r\n *\r\n */\r\n private async acquireTokenHelper(account: Account, interactionType: InteractionType, isLoginCall: boolean, request: AuthenticationParameters, resolve?: Function, reject?: Function): Promise<void> {\r\n this.logger.verbose(\"AcquireTokenHelper has been called\");\r\n this.logger.verbose(`Interaction type: ${interactionType}. isLoginCall: ${isLoginCall}`);\r\n\r\n // Track the acquireToken progress\r\n this.cacheStorage.setInteractionInProgress(true);\r\n const requestSignature = request.scopes ? request.scopes.join(\" \").toLowerCase() : Constants.oidcScopes.join(\" \");\r\n this.logger.verbosePii(`Request signature: ${requestSignature}`);\r\n\r\n let serverAuthenticationRequest: ServerRequestParameters;\r\n const acquireTokenAuthority = (request && request.authority) ? AuthorityFactory.CreateInstance(request.authority, this.config.auth.validateAuthority, request.authorityMetadata) : this.authorityInstance;\r\n let popUpWindow: Window;\r\n\r\n try {\r\n if (!acquireTokenAuthority.hasCachedMetadata()) {\r\n this.logger.verbose(\"No cached metadata for authority\");\r\n await AuthorityFactory.saveMetadataFromNetwork(acquireTokenAuthority, this.telemetryManager, request.correlationId);\r\n } else {\r\n this.logger.verbose(\"Cached metadata found for authority\");\r\n }\r\n\r\n // On Fulfillment\r\n const responseType: string = isLoginCall ? ResponseTypes.id_token : this.getTokenType(account, request.scopes);\r\n\r\n const loginStartPage = request.redirectStartPage || window.location.href;\r\n\r\n serverAuthenticationRequest = new ServerRequestParameters(\r\n acquireTokenAuthority,\r\n this.clientId,\r\n responseType,\r\n this.getRedirectUri(request && request.redirectUri),\r\n request.scopes,\r\n request.state,\r\n request.correlationId\r\n );\r\n this.logger.verbose(\"Finished building server authentication request\");\r\n\r\n this.updateCacheEntries(serverAuthenticationRequest, account, isLoginCall, loginStartPage);\r\n this.logger.verbose(\"Updating cache entries\");\r\n\r\n // populate QueryParameters (sid/login_hint) and any other extraQueryParameters set by the developer\r\n serverAuthenticationRequest.populateQueryParams(account, request);\r\n this.logger.verbose(\"Query parameters populated from account\");\r\n\r\n // Construct urlNavigate\r\n const urlNavigate = UrlUtils.createNavigateUrl(serverAuthenticationRequest) + Constants.response_mode_fragment;\r\n // set state in cache\r\n if (interactionType === Constants.interactionTypeRedirect) {\r\n if (!isLoginCall) {\r\n this.cacheStorage.setItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.STATE_ACQ_TOKEN, request.state), serverAuthenticationRequest.state, this.inCookie);\r\n this.logger.verbose(\"State cached for redirect\");\r\n this.logger.verbosePii(`State cached: ${serverAuthenticationRequest.state}`);\r\n } else {\r\n this.logger.verbose(\"Interaction type redirect but login call is true. State not cached\");\r\n }\r\n } else if (interactionType === Constants.interactionTypePopup) {\r\n window.renewStates.push(serverAuthenticationRequest.state);\r\n window.requestType = isLoginCall ? Constants.login : Constants.renewToken;\r\n this.logger.verbose(\"State saved to window\");\r\n this.logger.verbosePii(`State saved: ${serverAuthenticationRequest.state}`);\r\n\r\n // Register callback to capture results from server\r\n this.registerCallback(serverAuthenticationRequest.state, requestSignature, resolve, reject);\r\n } else {\r\n this.logger.verbose(\"Invalid interaction error. State not cached\");\r\n throw ClientAuthError.createInvalidInteractionTypeError();\r\n }\r\n\r\n if (interactionType === Constants.interactionTypePopup) {\r\n this.logger.verbose(\"Interaction type is popup. Generating popup window\");\r\n // Generate a popup window\r\n try {\r\n popUpWindow = this.openPopup(urlNavigate, \"msal\", Constants.popUpWidth, Constants.popUpHeight);\r\n \r\n // Push popup window handle onto stack for tracking\r\n WindowUtils.trackPopup(popUpWindow);\r\n } catch (e) {\r\n this.logger.info(ClientAuthErrorMessage.popUpWindowError.code + \":\" + ClientAuthErrorMessage.popUpWindowError.desc);\r\n this.cacheStorage.setItem(ErrorCacheKeys.ERROR, ClientAuthErrorMessage.popUpWindowError.code);\r\n this.cacheStorage.setItem(ErrorCacheKeys.ERROR_DESC, ClientAuthErrorMessage.popUpWindowError.desc);\r\n if (reject) {\r\n reject(ClientAuthError.createPopupWindowError());\r\n return;\r\n }\r\n }\r\n \r\n // popUpWindow will be null for redirects, so we dont need to attempt to monitor the window\r\n if (popUpWindow) {\r\n try {\r\n const hash = await WindowUtils.monitorPopupForHash(popUpWindow, this.config.system.loadFrameTimeout, urlNavigate, this.logger);\r\n\r\n this.handleAuthenticationResponse(hash);\r\n\r\n // Request completed successfully, set to completed\r\n this.cacheStorage.setInteractionInProgress(false);\r\n this.logger.info(\"Closing popup window\");\r\n\r\n // TODO: Check how this can be extracted for any framework specific code?\r\n if (this.config.framework.isAngular) {\r\n this.broadcast(\"msal:popUpHashChanged\", hash);\r\n }\r\n \r\n WindowUtils.closePopups();\r\n } catch (error) {\r\n if (reject) {\r\n reject(error);\r\n }\r\n\r\n if (this.config.framework.isAngular) {\r\n this.broadcast(\"msal:popUpClosed\", error.errorCode + Constants.resourceDelimiter + error.errorMessage);\r\n } else {\r\n // Request failed, set to canceled\r\n this.cacheStorage.setInteractionInProgress(false);\r\n popUpWindow.close();\r\n }\r\n }\r\n }\r\n } else {\r\n // If onRedirectNavigate is implemented, invoke it and provide urlNavigate\r\n if (request.onRedirectNavigate) {\r\n this.logger.verbose(\"Invoking onRedirectNavigate callback\");\r\n\r\n const navigate = request.onRedirectNavigate(urlNavigate);\r\n\r\n // Returning false from onRedirectNavigate will stop navigation\r\n if (navigate !== false) {\r\n this.logger.verbose(\"onRedirectNavigate did not return false, navigating\");\r\n this.navigateWindow(urlNavigate);\r\n } else {\r\n this.logger.verbose(\"onRedirectNavigate returned false, stopping navigation\");\r\n }\r\n } else {\r\n // Otherwise, perform navigation\r\n this.logger.verbose(\"Navigating window to urlNavigate\");\r\n this.navigateWindow(urlNavigate);\r\n }\r\n }\r\n } catch (err) {\r\n this.logger.error(err);\r\n this.cacheStorage.resetTempCacheItems(request.state);\r\n this.authErrorHandler(interactionType, ClientAuthError.createEndpointResolutionError(err.toString), buildResponseStateOnly(request.state), reject);\r\n if (popUpWindow) {\r\n popUpWindow.close();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * API interfacing idToken request when applications already have a session/hint acquired by authorization client applications\r\n * @param request\r\n */\r\n ssoSilent(request: AuthenticationParameters): Promise<AuthResponse> {\r\n this.logger.verbose(\"ssoSilent has been called\");\r\n \r\n // throw an error on an empty request\r\n if (!request) {\r\n throw ClientConfigurationError.createEmptyRequestError();\r\n }\r\n\r\n // throw an error on no hints passed\r\n if (!request.sid && !request.loginHint) {\r\n throw ClientConfigurationError.createSsoSilentError();\r\n }\r\n\r\n return this.acquireTokenSilent({\r\n ...request,\r\n scopes: Constants.oidcScopes\r\n });\r\n }\r\n\r\n /**\r\n * Use this function to obtain a token before every call to the API / resource provider\r\n *\r\n * MSAL return's a cached token when available\r\n * Or it send's a request to the STS to obtain a new token using a hidden iframe.\r\n *\r\n * @param {@link AuthenticationParameters}\r\n *\r\n * To renew idToken, please pass clientId as the only scope in the Authentication Parameters\r\n * @returns {Promise.<AuthResponse>} - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthResponse} object\r\n *\r\n */\r\n acquireTokenSilent(userRequest: AuthenticationParameters): Promise<AuthResponse> {\r\n this.logger.verbose(\"AcquireTokenSilent has been called\");\r\n\r\n // validate the request\r\n const request = RequestUtils.validateRequest(userRequest, false, this.clientId, Constants.interactionTypeSilent);\r\n const apiEvent: ApiEvent = this.telemetryManager.createAndStartApiEvent(request.correlationId, API_EVENT_IDENTIFIER.AcquireTokenSilent);\r\n const requestSignature = RequestUtils.createRequestSignature(request);\r\n\r\n return new Promise<AuthResponse>(async (resolve, reject) => {\r\n\r\n // block the request if made from the hidden iframe\r\n WindowUtils.blockReloadInHiddenIframes();\r\n\r\n const scope = request.scopes.join(\" \").toLowerCase();\r\n this.logger.verbosePii(`Serialized scopes: ${scope}`);\r\n\r\n // if the developer passes an account, give that account the priority\r\n let account: Account;\r\n if (request.account) {\r\n account = request.account;\r\n this.logger.verbose(\"Account set from request\");\r\n } else {\r\n account = this.getAccount();\r\n this.logger.verbose(\"Account set from MSAL Cache\");\r\n }\r\n\r\n // Extract adalIdToken if stashed in the cache to allow for seamless ADAL to MSAL migration\r\n const adalIdToken = this.cacheStorage.getItem(Constants.adalIdToken);\r\n\r\n // In the event of no account being passed in the config, no session id, and no pre-existing adalIdToken, user will need to log in\r\n if (!account && !(request.sid || request.loginHint) && StringUtils.isEmpty(adalIdToken) ) {\r\n this.logger.info(\"User login is required\");\r\n // The promise rejects with a UserLoginRequiredError, which should be caught and user should be prompted to log in interactively\r\n return reject(ClientAuthError.createUserLoginRequiredError());\r\n }\r\n\r\n // set the response type based on the current cache status / scopes set\r\n const responseType = this.getTokenType(account, request.scopes);\r\n this.logger.verbose(`Response type: ${responseType}`);\r\n\r\n // create a serverAuthenticationRequest populating the `queryParameters` to be sent to the Server\r\n const serverAuthenticationRequest = new ServerRequestParameters(\r\n AuthorityFactory.CreateInstance(request.authority, this.config.auth.validateAuthority, request.authorityMetadata),\r\n this.clientId,\r\n responseType,\r\n this.getRedirectUri(request.redirectUri),\r\n request.scopes,\r\n request.state,\r\n request.correlationId,\r\n );\r\n\r\n this.logger.verbose(\"Finished building server authentication request\");\r\n\r\n // populate QueryParameters (sid/login_hint) and any other extraQueryParameters set by the developer\r\n if (ServerRequestParameters.isSSOParam(request) || account) {\r\n serverAuthenticationRequest.populateQueryParams(account, request, null, true);\r\n this.logger.verbose(\"Query parameters populated from existing SSO or account\");\r\n }\r\n // if user didn't pass login_hint/sid and adal's idtoken is present, extract the login_hint from the adalIdToken\r\n else if (!account && !StringUtils.isEmpty(adalIdToken)) {\r\n // if adalIdToken exists, extract the SSO info from the same\r\n const adalIdTokenObject = TokenUtils.extractIdToken(adalIdToken);\r\n this.logger.verbose(\"ADAL's idToken exists. Extracting login information from ADAL's idToken to populate query parameters\");\r\n serverAuthenticationRequest.populateQueryParams(account, null, adalIdTokenObject, true);\r\n }\r\n else {\r\n this.logger.verbose(\"No additional query parameters added\");\r\n }\r\n\r\n const userContainedClaims = request.claimsRequest || serverAuthenticationRequest.claimsValue;\r\n\r\n let authErr: AuthError;\r\n let cacheResultResponse;\r\n\r\n // If request.forceRefresh is set to true, force a request for a new token instead of getting it from the cache\r\n if (!userContainedClaims && !request.forceRefresh) {\r\n try {\r\n cacheResultResponse = this.getCachedToken(serverAuthenticationRequest, account);\r\n } catch (e) {\r\n authErr = e;\r\n }\r\n }\r\n \r\n // resolve/reject based on cacheResult\r\n if (cacheResultResponse) {\r\n this.logger.verbose(\"Token found in cache lookup\");\r\n this.logger.verbosePii(`Scopes found: ${JSON.stringify(cacheResultResponse.scopes)}`);\r\n resolve(cacheResultResponse);\r\n return null;\r\n }\r\n else if (authErr) {\r\n this.logger.infoPii(authErr.errorCode + \":\" + authErr.errorMessage);\r\n reject(authErr);\r\n return null;\r\n }\r\n // else proceed with login\r\n else {\r\n \r\n let logMessage;\r\n if (userContainedClaims) {\r\n logMessage = \"Skipped cache lookup since claims were given\";\r\n } else if (request.forceRefresh) {\r\n logMessage = \"Skipped cache lookup since request.forceRefresh option was set to true\";\r\n } else {\r\n logMessage = \"No valid token found in cache lookup\";\r\n }\r\n this.logger.verbose(logMessage);\r\n \r\n // Cache result can return null if cache is empty. In that case, set authority to default value if no authority is passed to the API.\r\n if (!serverAuthenticationRequest.authorityInstance) {\r\n serverAuthenticationRequest.authorityInstance = request.authority ? \r\n AuthorityFactory.CreateInstance(request.authority, this.config.auth.validateAuthority, request.authorityMetadata)\r\n : this.authorityInstance;\r\n } \r\n this.logger.verbosePii(`Authority instance: ${serverAuthenticationRequest.authority}`);\r\n \r\n try {\r\n if (!serverAuthenticationRequest.authorityInstance.hasCachedMetadata()) {\r\n this.logger.verbose(\"No cached metadata for authority\");\r\n await AuthorityFactory.saveMetadataFromNetwork(serverAuthenticationRequest.authorityInstance, this.telemetryManager, request.correlationId);\r\n this.logger.verbose(\"Authority has been updated with endpoint discovery response\");\r\n } else {\r\n this.logger.verbose(\"Cached metadata found for authority\");\r\n }\r\n\r\n /*\r\n * refresh attempt with iframe\r\n * Already renewing for this scope, callback when we get the token.\r\n */\r\n if (window.activeRenewals[requestSignature]) {\r\n this.logger.verbose(\"Renewing token in progress. Registering callback\");\r\n // Active renewals contains the state for each renewal.\r\n this.registerCallback(window.activeRenewals[requestSignature], requestSignature, resolve, reject);\r\n }\r\n else {\r\n if (request.scopes && ScopeSet.onlyContainsOidcScopes(request.scopes)) {\r\n /*\r\n * App uses idToken to send to api endpoints\r\n * Default scope is tracked as OIDC scopes to store this token\r\n */\r\n this.logger.verbose(\"OpenID Connect scopes only, renewing idToken\");\r\n this.silentLogin = true;\r\n this.renewIdToken(requestSignature, resolve, reject, account, serverAuthenticationRequest);\r\n } else {\r\n // renew access token\r\n this.logger.verbose(\"Renewing access token\");\r\n this.renewToken(requestSignature, resolve, reject, account, serverAuthenticationRequest);\r\n }\r\n }\r\n } catch (err) {\r\n this.logger.error(err);\r\n reject(ClientAuthError.createEndpointResolutionError(err.toString()));\r\n return null;\r\n }\r\n }\r\n })\r\n .then(res => {\r\n this.logger.verbose(\"Successfully acquired token\");\r\n this.telemetryManager.stopAndFlushApiEvent(request.correlationId, apiEvent, true);\r\n return res;\r\n })\r\n .catch((error: AuthError) => {\r\n this.cacheStorage.resetTempCacheItems(request.state);\r\n this.telemetryManager.stopAndFlushApiEvent(request.correlationId, apiEvent, false, error.errorCode);\r\n throw error;\r\n });\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Popup Window Creation\r\n\r\n /**\r\n * @hidden\r\n *\r\n * Configures popup window for login.\r\n *\r\n * @param urlNavigate\r\n * @param title\r\n * @param popUpWidth\r\n * @param popUpHeight\r\n * @ignore\r\n * @hidden\r\n */\r\n private openPopup(urlNavigate: string, title: string, popUpWidth: number, popUpHeight: number) {\r\n this.logger.verbose(\"OpenPopup has been called\");\r\n try {\r\n /**\r\n * adding winLeft and winTop to account for dual monitor\r\n * using screenLeft and screenTop for IE8 and earlier\r\n */\r\n const winLeft = window.screenLeft ? window.screenLeft : window.screenX;\r\n const winTop = window.screenTop ? window.screenTop : window.screenY;\r\n /**\r\n * window.innerWidth displays browser window\"s height and width excluding toolbars\r\n * using document.documentElement.clientWidth for IE8 and earlier\r\n */\r\n const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;\r\n const height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;\r\n const left = ((width / 2) - (popUpWidth / 2)) + winLeft;\r\n const top = ((height / 2) - (popUpHeight / 2)) + winTop;\r\n\r\n // open the window\r\n const popupWindow = window.open(urlNavigate, title, \"width=\" + popUpWidth + \", height=\" + popUpHeight + \", top=\" + top + \", left=\" + left + \", scrollbars=yes\");\r\n if (!popupWindow) {\r\n throw ClientAuthError.createPopupWindowError();\r\n }\r\n if (popupWindow.focus) {\r\n popupWindow.focus();\r\n }\r\n\r\n return popupWindow;\r\n } catch (e) {\r\n this.cacheStorage.setInteractionInProgress(false);\r\n throw ClientAuthError.createPopupWindowError(e.toString());\r\n }\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Iframe Management\r\n\r\n /**\r\n * @hidden\r\n * Calling _loadFrame but with a timeout to signal failure in loadframeStatus. Callbacks are left.\r\n * registered when network errors occur and subsequent token requests for same resource are registered to the pending request.\r\n * @ignore\r\n */\r\n private async loadIframeTimeout(urlNavigate: string, frameName: string, requestSignature: string): Promise<void> {\r\n // set iframe session to pending\r\n const expectedState = window.activeRenewals[requestSignature];\r\n this.logger.verbosePii(\"Set loading state to pending for: \" + requestSignature + \":\" + expectedState);\r\n this.cacheStorage.setItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.RENEW_STATUS, expectedState), Constants.inProgress);\r\n\r\n // render the iframe synchronously if app chooses no timeout, else wait for the set timer to expire\r\n const iframe: HTMLIFrameElement = this.config.system.navigateFrameWait ?\r\n await WindowUtils.loadFrame(urlNavigate, frameName, this.config.system.navigateFrameWait, this.logger):\r\n WindowUtils.loadFrameSync(urlNavigate, frameName, this.logger);\r\n\r\n try {\r\n const hash = await WindowUtils.monitorIframeForHash(iframe.contentWindow, this.config.system.loadFrameTimeout, urlNavigate, this.logger);\r\n\r\n if (hash) {\r\n this.handleAuthenticationResponse(hash);\r\n }\r\n } catch (error) {\r\n if (this.cacheStorage.getItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.RENEW_STATUS, expectedState)) === Constants.inProgress) {\r\n // fail the iframe session if it's in pending state\r\n this.logger.verbose(\"Loading frame has timed out after: \" + (this.config.system.loadFrameTimeout / 1000) + \" seconds for scope/authority \" + requestSignature + \":\" + expectedState);\r\n // Error after timeout\r\n if (expectedState && window.callbackMappedToRenewStates[expectedState]) {\r\n window.callbackMappedToRenewStates[expectedState](null, error);\r\n }\r\n\r\n this.cacheStorage.removeItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.RENEW_STATUS, expectedState));\r\n }\r\n WindowUtils.removeHiddenIframe(iframe);\r\n throw error;\r\n }\r\n WindowUtils.removeHiddenIframe(iframe);\r\n }\r\n\r\n // #endregion\r\n\r\n // #region General Helpers\r\n\r\n /**\r\n * @hidden\r\n * Used to redirect the browser to the STS authorization endpoint\r\n * @param {string} urlNavigate - URL of the authorization endpoint\r\n */\r\n private navigateWindow(urlNavigate: string, popupWindow?: Window) {\r\n // Navigate if valid URL\r\n if (urlNavigate && !StringUtils.isEmpty(urlNavigate)) {\r\n const navigateWindow: Window = popupWindow ? popupWindow : window;\r\n const logMessage: string = popupWindow ? \"Navigated Popup window to:\" + urlNavigate : \"Navigate to:\" + urlNavigate;\r\n this.logger.infoPii(logMessage);\r\n navigateWindow.location.assign(urlNavigate);\r\n }\r\n else {\r\n this.logger.info(\"Navigate url is empty\");\r\n throw AuthError.createUnexpectedError(\"Navigate url is empty\");\r\n }\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Used to add the developer requested callback to the array of callbacks for the specified scopes. The updated array is stored on the window object\r\n * @param {string} expectedState - Unique state identifier (guid).\r\n * @param {string} scope - Developer requested permissions. Not all scopes are guaranteed to be included in the access token returned.\r\n * @param {Function} resolve - The resolve function of the promise object.\r\n * @param {Function} reject - The reject function of the promise object.\r\n * @ignore\r\n */\r\n private registerCallback(expectedState: string, requestSignature: string, resolve: Function, reject: Function): void {\r\n // track active renewals\r\n window.activeRenewals[requestSignature] = expectedState;\r\n\r\n // initialize callbacks mapped array\r\n if (!window.promiseMappedToRenewStates[expectedState]) {\r\n window.promiseMappedToRenewStates[expectedState] = [];\r\n }\r\n // indexing on the current state, push the callback params to callbacks mapped\r\n window.promiseMappedToRenewStates[expectedState].push({ resolve: resolve, reject: reject });\r\n\r\n // Store the server response in the current window??\r\n if (!window.callbackMappedToRenewStates[expectedState]) {\r\n window.callbackMappedToRenewStates[expectedState] = (response: AuthResponse, error: AuthError) => {\r\n // reset active renewals\r\n delete window.activeRenewals[requestSignature];\r\n\r\n // for all promiseMappedtoRenewStates for a given 'state' - call the reject/resolve with error/token respectively\r\n for (let i = 0; i < window.promiseMappedToRenewStates[expectedState].length; ++i) {\r\n try {\r\n if (error) {\r\n window.promiseMappedToRenewStates[expectedState][i].reject(error);\r\n } else if (response) {\r\n window.promiseMappedToRenewStates[expectedState][i].resolve(response);\r\n } else {\r\n this.cacheStorage.resetTempCacheItems(expectedState);\r\n throw AuthError.createUnexpectedError(\"Error and response are both null\");\r\n }\r\n } catch (e) {\r\n this.logger.warning(e);\r\n }\r\n }\r\n\r\n // reset\r\n delete window.promiseMappedToRenewStates[expectedState];\r\n delete window.callbackMappedToRenewStates[expectedState];\r\n };\r\n }\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Logout\r\n\r\n /**\r\n * Use to log out the current user, and redirect the user to the postLogoutRedirectUri.\r\n * Default behaviour is to redirect the user to `window.location.href`.\r\n */\r\n logout(correlationId?: string): void {\r\n this.logger.verbose(\"Logout has been called\");\r\n this.logoutAsync(correlationId);\r\n }\r\n\r\n /**\r\n * Async version of logout(). Use to log out the current user.\r\n * @param correlationId Request correlationId\r\n */\r\n private async logoutAsync(correlationId?: string): Promise<void> {\r\n const requestCorrelationId = correlationId || CryptoUtils.createNewGuid();\r\n const apiEvent = this.telemetryManager.createAndStartApiEvent(requestCorrelationId, API_EVENT_IDENTIFIER.Logout);\r\n\r\n this.clearCache();\r\n this.account = null;\r\n\r\n try {\r\n if (!this.authorityInstance.hasCachedMetadata()) {\r\n this.logger.verbose(\"No cached metadata for authority\");\r\n await AuthorityFactory.saveMetadataFromNetwork(this.authorityInstance, this.telemetryManager, correlationId);\r\n } else {\r\n this.logger.verbose(\"Cached metadata found for authority\");\r\n }\r\n\r\n const correlationIdParam = `client-request-id=${requestCorrelationId}`;\r\n\r\n let postLogoutQueryParam: string;\r\n if (this.getPostLogoutRedirectUri()) {\r\n postLogoutQueryParam = `&post_logout_redirect_uri=${encodeURIComponent(this.getPostLogoutRedirectUri())}`;\r\n this.logger.verbose(\"redirectUri found and set\");\r\n } else {\r\n postLogoutQueryParam = \"\";\r\n this.logger.verbose(\"No redirectUri set for app. postLogoutQueryParam is empty\");\r\n }\r\n\r\n let urlNavigate: string;\r\n if (this.authorityInstance.EndSessionEndpoint) {\r\n urlNavigate = `${this.authorityInstance.EndSessionEndpoint}?${correlationIdParam}${postLogoutQueryParam}`;\r\n this.logger.verbose(\"EndSessionEndpoint found and urlNavigate set\");\r\n this.logger.verbosePii(`urlNavigate set to: ${this.authorityInstance.EndSessionEndpoint}`);\r\n } else {\r\n urlNavigate = `${this.authority}oauth2/v2.0/logout?${correlationIdParam}${postLogoutQueryParam}`;\r\n this.logger.verbose(\"No endpoint, urlNavigate set to default\");\r\n }\r\n\r\n this.telemetryManager.stopAndFlushApiEvent(requestCorrelationId, apiEvent, true);\r\n\r\n this.logger.verbose(\"Navigating window to urlNavigate\");\r\n this.navigateWindow(urlNavigate);\r\n } catch (error) {\r\n this.telemetryManager.stopAndFlushApiEvent(requestCorrelationId, apiEvent, false, error.errorCode);\r\n }\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Clear all access tokens and ID tokens in the cache.\r\n * @ignore\r\n */\r\n protected clearCache(): void {\r\n this.logger.verbose(\"Clearing cache\");\r\n window.renewStates = [];\r\n const tokenCacheItems = this.cacheStorage.getAllTokens(Constants.clientId, Constants.homeAccountIdentifier);\r\n for (let i = 0; i < tokenCacheItems.length; i++) {\r\n this.cacheStorage.removeItem(JSON.stringify(tokenCacheItems[i].key));\r\n }\r\n this.cacheStorage.resetCacheItems();\r\n this.cacheStorage.clearMsalCookie();\r\n this.logger.verbose(\"Cache cleared\");\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Clear a given access token from the cache.\r\n *\r\n * @param accessToken\r\n */\r\n protected clearCacheForScope(accessToken: string): void {\r\n this.logger.verbose(\"Clearing access token from cache\");\r\n const accessTokenItems = this.cacheStorage.getAllAccessTokens(Constants.clientId, Constants.homeAccountIdentifier);\r\n for (let i = 0; i < accessTokenItems.length; i++) {\r\n const token = accessTokenItems[i];\r\n if (token.value.accessToken === accessToken) {\r\n this.cacheStorage.removeItem(JSON.stringify(token.key));\r\n this.logger.verbosePii(`Access token removed: ${token.key}`);\r\n }\r\n }\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Response\r\n\r\n /**\r\n * @hidden\r\n * @ignore\r\n * Checks if the redirect response is received from the STS. In case of redirect, the url fragment has either id_token, access_token or error.\r\n * @param {string} hash - Hash passed from redirect page.\r\n * @returns {Boolean} - true if response contains id_token, access_token or error, false otherwise.\r\n */\r\n isCallback(hash: string): boolean {\r\n this.logger.info(\"isCallback will be deprecated in favor of urlContainsHash in MSAL.js v2.0.\");\r\n this.logger.verbose(\"isCallback has been called\");\r\n return UrlUtils.urlContainsHash(hash);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Used to call the constructor callback with the token/error\r\n * @param {string} [hash=window.location.hash] - Hash fragment of Url.\r\n */\r\n private processCallBack(hash: string, respStateInfo: ResponseStateInfo, parentCallback?: Function): void {\r\n this.logger.info(\"ProcessCallBack has been called. Processing callback from redirect response\");\r\n\r\n // get the state info from the hash\r\n let stateInfo = respStateInfo;\r\n if (!stateInfo) {\r\n this.logger.verbose(\"StateInfo is null, getting stateInfo from hash\");\r\n stateInfo = this.getResponseState(hash);\r\n }\r\n\r\n let response : AuthResponse;\r\n let authErr : AuthError;\r\n // Save the token info from the hash\r\n try {\r\n response = this.saveTokenFromHash(hash, stateInfo);\r\n } catch (err) {\r\n authErr = err;\r\n }\r\n\r\n try {\r\n // Clear the cookie in the hash\r\n this.cacheStorage.clearMsalCookie(stateInfo.state);\r\n const accountState: string = this.getAccountState(stateInfo.state);\r\n if (response) {\r\n if ((stateInfo.requestType === Constants.renewToken) || response.accessToken) {\r\n if (window.parent !== window) {\r\n this.logger.verbose(\"Window is in iframe, acquiring token silently\");\r\n } else {\r\n this.logger.verbose(\"Acquiring token interactive in progress\");\r\n }\r\n this.logger.verbose(`Response tokenType set to ${ServerHashParamKeys.ACCESS_TOKEN}`);\r\n response.tokenType = ServerHashParamKeys.ACCESS_TOKEN;\r\n }\r\n else if (stateInfo.requestType === Constants.login) {\r\n this.logger.verbose(`Response tokenType set to ${ServerHashParamKeys.ID_TOKEN}`);\r\n response.tokenType = ServerHashParamKeys.ID_TOKEN;\r\n }\r\n if (!parentCallback) {\r\n this.logger.verbose(\"Setting redirectResponse\");\r\n this.redirectResponse = response;\r\n return;\r\n }\r\n } else if (!parentCallback) {\r\n this.logger.verbose(\"Response is null, setting redirectResponse with state\");\r\n this.redirectResponse = buildResponseStateOnly(accountState);\r\n this.redirectError = authErr;\r\n this.cacheStorage.resetTempCacheItems(stateInfo.state);\r\n return;\r\n }\r\n\r\n this.logger.verbose(\"Calling callback provided to processCallback\");\r\n parentCallback(response, authErr);\r\n } catch (err) {\r\n this.logger.error(\"Error occurred in token received callback function: \" + err);\r\n throw ClientAuthError.createErrorInCallbackFunction(err.toString());\r\n }\r\n }\r\n\r\n /**\r\n * @hidden\r\n * This method must be called for processing the response received from the STS if using popups or iframes. It extracts the hash, processes the token or error\r\n * information and saves it in the cache. It then resolves the promises with the result.\r\n * @param {string} [hash=window.location.hash] - Hash fragment of Url.\r\n */\r\n private handleAuthenticationResponse(hash: string): void {\r\n this.logger.verbose(\"HandleAuthenticationResponse has been called\");\r\n\r\n // retrieve the hash\r\n const locationHash = hash || window.location.hash;\r\n\r\n // if (window.parent !== window), by using self, window.parent becomes equal to window in getResponseState method specifically\r\n const stateInfo = this.getResponseState(locationHash);\r\n this.logger.verbose(\"Obtained state from response\");\r\n\r\n const tokenResponseCallback = window.callbackMappedToRenewStates[stateInfo.state];\r\n this.processCallBack(locationHash, stateInfo, tokenResponseCallback);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * This method must be called for processing the response received from the STS when using redirect flows. It extracts the hash, processes the token or error\r\n * information and saves it in the cache. The result can then be accessed by user registered callbacks.\r\n * @param {string} [hash=window.location.hash] - Hash fragment of Url.\r\n */\r\n private handleRedirectAuthenticationResponse(hash: string): void {\r\n this.logger.info(\"Returned from redirect url\");\r\n this.logger.verbose(\"HandleRedirectAuthenticationResponse has been called\");\r\n\r\n // clear hash from window\r\n WindowUtils.clearUrlFragment(window);\r\n this.logger.verbose(\"Window.location.hash cleared\");\r\n\r\n // if (window.parent !== window), by using self, window.parent becomes equal to window in getResponseState method specifically\r\n const stateInfo = this.getResponseState(hash);\r\n \r\n // if set to navigate to loginRequest page post login\r\n if (this.config.auth.navigateToLoginRequestUrl && window.parent === window) {\r\n this.logger.verbose(\"Window.parent is equal to window, not in popup or iframe. Navigation to login request url after login turned on\");\r\n const loginRequestUrl = this.cacheStorage.getItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.LOGIN_REQUEST, stateInfo.state), this.inCookie);\r\n\r\n // Redirect to home page if login request url is null (real null or the string null)\r\n if (!loginRequestUrl || loginRequestUrl === \"null\") {\r\n this.logger.error(\"Unable to get valid login request url from cache, redirecting to home page\");\r\n window.location.assign(\"/\");\r\n return;\r\n } else {\r\n this.logger.verbose(\"Valid login request url obtained from cache\");\r\n const currentUrl = UrlUtils.removeHashFromUrl(window.location.href);\r\n const finalRedirectUrl = UrlUtils.removeHashFromUrl(loginRequestUrl);\r\n if (currentUrl !== finalRedirectUrl) {\r\n this.logger.verbose(\"Current url is not login request url, navigating\");\r\n this.logger.verbosePii(`CurrentUrl: ${currentUrl}, finalRedirectUrl: ${finalRedirectUrl}`);\r\n window.location.assign(`${finalRedirectUrl}${hash}`);\r\n return;\r\n } else {\r\n this.logger.verbose(\"Current url matches login request url\");\r\n const loginRequestUrlComponents = UrlUtils.GetUrlComponents(loginRequestUrl);\r\n if (loginRequestUrlComponents.Hash){\r\n this.logger.verbose(\"Login request url contains hash, resetting non-msal hash\");\r\n window.location.hash = loginRequestUrlComponents.Hash;\r\n }\r\n }\r\n }\r\n } else if (!this.config.auth.navigateToLoginRequestUrl) {\r\n this.logger.verbose(\"Default navigation to start page after login turned off\");\r\n }\r\n\r\n this.processCallBack(hash, stateInfo, null);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Creates a stateInfo object from the URL fragment and returns it.\r\n * @param {string} hash - Hash passed from redirect page\r\n * @returns {TokenResponse} an object created from the redirect response from AAD comprising of the keys - parameters, requestType, stateMatch, stateResponse and valid.\r\n * @ignore\r\n */\r\n protected getResponseState(hash: string): ResponseStateInfo {\r\n this.logger.verbose(\"GetResponseState has been called\");\r\n\r\n const parameters = UrlUtils.deserializeHash(hash);\r\n let stateResponse: ResponseStateInfo;\r\n if (!parameters) {\r\n throw AuthError.createUnexpectedError(\"Hash was not parsed correctly.\");\r\n }\r\n if (parameters.hasOwnProperty(ServerHashParamKeys.STATE)) {\r\n this.logger.verbose(\"Hash contains state. Creating stateInfo object\");\r\n const parsedState = RequestUtils.parseLibraryState(parameters[\"state\"]);\r\n\r\n stateResponse = {\r\n requestType: Constants.unknown,\r\n state: parameters[\"state\"],\r\n timestamp: parsedState.ts,\r\n method: parsedState.method,\r\n stateMatch: false\r\n };\r\n } else {\r\n throw AuthError.createUnexpectedError(\"Hash does not contain state.\");\r\n }\r\n /*\r\n * async calls can fire iframe and login request at the same time if developer does not use the API as expected\r\n * incoming callback needs to be looked up to find the request type\r\n */\r\n\r\n // loginRedirect\r\n if (stateResponse.state === this.cacheStorage.getItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.STATE_LOGIN, stateResponse.state), this.inCookie) || stateResponse.state === this.silentAuthenticationState) {\r\n this.logger.verbose(\"State matches cached state, setting requestType to login\");\r\n stateResponse.requestType = Constants.login;\r\n stateResponse.stateMatch = true;\r\n return stateResponse;\r\n }\r\n // acquireTokenRedirect\r\n else if (stateResponse.state === this.cacheStorage.getItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.STATE_ACQ_TOKEN, stateResponse.state), this.inCookie)) {\r\n this.logger.verbose(\"State matches cached state, setting requestType to renewToken\");\r\n stateResponse.requestType = Constants.renewToken;\r\n stateResponse.stateMatch = true;\r\n return stateResponse;\r\n }\r\n\r\n // external api requests may have many renewtoken requests for different resource\r\n if (!stateResponse.stateMatch) {\r\n this.logger.verbose(\"State does not match cached state, setting requestType to type from window\");\r\n stateResponse.requestType = window.requestType;\r\n const statesInParentContext = window.renewStates;\r\n for (let i = 0; i < statesInParentContext.length; i++) {\r\n if (statesInParentContext[i] === stateResponse.state) {\r\n this.logger.verbose(\"Matching state found for request\");\r\n stateResponse.stateMatch = true;\r\n break;\r\n }\r\n }\r\n if (!stateResponse.stateMatch) {\r\n this.logger.verbose(\"Matching state not found for request\");\r\n }\r\n }\r\n\r\n return stateResponse;\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Token Processing (Extract to TokenProcessing.ts)\r\n\r\n /**\r\n * @hidden\r\n * Used to get token for the specified set of scopes from the cache\r\n * @param {@link ServerRequestParameters} - Request sent to the STS to obtain an id_token/access_token\r\n * @param {Account} account - Account for which the scopes were requested\r\n */\r\n private getCachedToken(serverAuthenticationRequest: ServerRequestParameters, account: Account): AuthResponse {\r\n this.logger.verbose(\"GetCachedToken has been called\");\r\n const scopes = serverAuthenticationRequest.scopes;\r\n\r\n /**\r\n * Id Token should be returned in every acquireTokenSilent call. The only exception is a response_type = token\r\n * request when a valid ID Token is not present in the cache.\r\n */\r\n const idToken = this.getCachedIdToken(serverAuthenticationRequest, account);\r\n const authResponse = this.getCachedAccessToken(serverAuthenticationRequest, account, scopes);\r\n const accountState = this.getAccountState(serverAuthenticationRequest.state);\r\n return ResponseUtils.buildAuthResponse(idToken, authResponse, serverAuthenticationRequest, account, scopes, accountState);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * \r\n * Uses passed in authority to further filter an array of tokenCacheItems until only the token being searched for remains, then returns that tokenCacheItem.\r\n * This method will throw if authority filtering still yields multiple matching tokens and will return null if not tokens match the authority passed in.\r\n * \r\n * @param authority \r\n * @param tokenCacheItems \r\n * @param request \r\n * @param requestScopes \r\n * @param tokenType \r\n */\r\n private getTokenCacheItemByAuthority(authority: string, tokenCacheItems: Array<AccessTokenCacheItem>, requestScopes: Array<string>, tokenType: string): AccessTokenCacheItem {\r\n let filteredAuthorityItems: Array<AccessTokenCacheItem>;\r\n \r\n if (UrlUtils.isCommonAuthority(authority) || UrlUtils.isOrganizationsAuthority(authority) || UrlUtils.isConsumersAuthority(authority)) {\r\n filteredAuthorityItems = AuthCacheUtils.filterTokenCacheItemsByDomain(tokenCacheItems, UrlUtils.GetUrlComponents(authority).HostNameAndPort);\r\n } else {\r\n filteredAuthorityItems = AuthCacheUtils.filterTokenCacheItemsByAuthority(tokenCacheItems, authority);\r\n }\r\n if (filteredAuthorityItems.length === 1) {\r\n return filteredAuthorityItems[0];\r\n }\r\n else if (filteredAuthorityItems.length > 1) {\r\n this.logger.warning(\"Multiple matching tokens found. Cleaning cache and requesting a new token.\");\r\n filteredAuthorityItems.forEach((accessTokenCacheItem) => {\r\n this.cacheStorage.removeItem(JSON.stringify(accessTokenCacheItem.key));\r\n });\r\n return null;\r\n }\r\n else {\r\n this.logger.verbose(`No matching tokens of type ${tokenType} found`);\r\n return null;\r\n } \r\n }\r\n\r\n /**\r\n * \r\n * @hidden\r\n * \r\n * Searches the token cache for an ID Token that matches the request parameter and returns it as an IdToken object.\r\n * \r\n * @param serverAuthenticationRequest \r\n * @param account \r\n */\r\n private getCachedIdToken(serverAuthenticationRequest: ServerRequestParameters, account: Account): IdToken {\r\n this.logger.verbose(\"Getting all cached tokens of type ID Token\");\r\n const idTokenCacheItems = this.cacheStorage.getAllIdTokens(this.clientId, account ? account.homeAccountIdentifier : null);\r\n const matchAuthority = serverAuthenticationRequest.authority || this.authority;\r\n const idTokenCacheItem = this.getTokenCacheItemByAuthority(matchAuthority, idTokenCacheItems, null, ServerHashParamKeys.ID_TOKEN);\r\n \r\n if (idTokenCacheItem) {\r\n this.logger.verbose(\"Evaluating ID token found\");\r\n const idTokenIsStillValid = this.evaluateTokenExpiration(idTokenCacheItem);\r\n\r\n if (idTokenIsStillValid) {\r\n this.logger.verbose(\"ID token expiration is within offset, using ID token found in cache\");\r\n const idTokenValue = idTokenCacheItem.value;\r\n if (idTokenValue) {\r\n this.logger.verbose(\"ID Token found in cache is valid and unexpired\");\r\n } else {\r\n this.logger.verbose(\"ID Token found in cache is invalid\");\r\n }\r\n \r\n return (idTokenValue) ? new IdToken(idTokenValue.idToken) : null;\r\n } else {\r\n this.logger.verbose(\"Cached ID token is expired, removing from cache\");\r\n this.cacheStorage.removeItem(JSON.stringify(idTokenCacheItem.key));\r\n return null;\r\n }\r\n } else {\r\n this.logger.verbose(\"No tokens found\");\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * \r\n * @hidden\r\n * \r\n * Searches the token cache for an access token that matches the request parameters and returns it as an AuthResponse.\r\n * \r\n * @param serverAuthenticationRequest \r\n * @param account \r\n * @param scopes \r\n */\r\n private getCachedAccessToken(serverAuthenticationRequest: ServerRequestParameters, account: Account, scopes: string[]): AuthResponse {\r\n this.logger.verbose(\"Getting all cached tokens of type Access Token\");\r\n const tokenCacheItems = this.cacheStorage.getAllAccessTokens(this.clientId, account ? account.homeAccountIdentifier : null);\r\n \r\n const scopeFilteredTokenCacheItems = AuthCacheUtils.filterTokenCacheItemsByScope(tokenCacheItems, scopes);\r\n const matchAuthority = serverAuthenticationRequest.authority || this.authority;\r\n // serverAuthenticationRequest.authority can only be common or organizations if not null\r\n const accessTokenCacheItem = this.getTokenCacheItemByAuthority(matchAuthority, scopeFilteredTokenCacheItems, scopes, ServerHashParamKeys.ACCESS_TOKEN);\r\n \r\n if (!accessTokenCacheItem) {\r\n this.logger.verbose(\"No matching token found when filtering by scope and authority\");\r\n return null;\r\n } else {\r\n serverAuthenticationRequest.authorityInstance = AuthorityFactory.CreateInstance(accessTokenCacheItem.key.authority, this.config.auth.validateAuthority);\r\n this.logger.verbose(\"Evaluating access token found\");\r\n const tokenIsStillValid = this.evaluateTokenExpiration(accessTokenCacheItem);\r\n // The response value will stay null if token retrieved from the cache is expired, otherwise it will be populated with said token's data\r\n \r\n if (tokenIsStillValid) {\r\n this.logger.verbose(\"Access token expiration is within offset, using access token found in cache\");\r\n const responseAccount: Account = account || this.getAccount();\r\n if (!responseAccount) {\r\n throw AuthError.createUnexpectedError(\"Account should not be null here.\");\r\n }\r\n\r\n const aState = this.getAccountState(serverAuthenticationRequest.state);\r\n const response: AuthResponse = {\r\n uniqueId: \"\",\r\n tenantId: \"\",\r\n tokenType: ServerHashParamKeys.ACCESS_TOKEN,\r\n idToken: null,\r\n idTokenClaims: null,\r\n accessToken: accessTokenCacheItem.value.accessToken,\r\n scopes: accessTokenCacheItem.key.scopes.split(\" \"),\r\n expiresOn: new Date(Number(accessTokenCacheItem.value.expiresIn) * 1000),\r\n account: responseAccount,\r\n accountState: aState,\r\n fromCache: true\r\n }; \r\n \r\n return response;\r\n } else {\r\n this.logger.verbose(\"Access token expired, removing from cache\");\r\n this.cacheStorage.removeItem(JSON.stringify(accessTokenCacheItem.key));\r\n return null;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if the token passed in is within the acceptable expiration time offset, false if it is expired.\r\n * @param tokenCacheItem \r\n * @param serverAuthenticationRequest \r\n */\r\n private evaluateTokenExpiration(tokenCacheItem: AccessTokenCacheItem): Boolean {\r\n const expiration = Number(tokenCacheItem.value.expiresIn);\r\n return TokenUtils.validateExpirationIsWithinOffset(expiration, this.config.system.tokenRenewalOffsetSeconds);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Check if ADAL id_token exists and return if exists.\r\n *\r\n */\r\n private extractADALIdToken(): object {\r\n this.logger.verbose(\"ExtractADALIdToken has been called\");\r\n const adalIdToken = this.cacheStorage.getItem(Constants.adalIdToken);\r\n return (!StringUtils.isEmpty(adalIdToken)) ? TokenUtils.extractIdToken(adalIdToken) : null;\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Acquires access token using a hidden iframe.\r\n * @ignore\r\n */\r\n private renewToken(requestSignature: string, resolve: Function, reject: Function, account: Account, serverAuthenticationRequest: ServerRequestParameters): void {\r\n this.logger.verbose(\"RenewToken has been called\");\r\n this.logger.verbosePii(`RenewToken scope and authority: ${requestSignature}`);\r\n\r\n const frameName = WindowUtils.generateFrameName(FramePrefix.TOKEN_FRAME, requestSignature);\r\n WindowUtils.addHiddenIFrame(frameName, this.logger);\r\n\r\n this.updateCacheEntries(serverAuthenticationRequest, account, false);\r\n this.logger.verbosePii(`RenewToken expected state: ${serverAuthenticationRequest.state}`);\r\n\r\n // Build urlNavigate with \"prompt=none\" and navigate to URL in hidden iFrame\r\n const urlNavigate = UrlUtils.urlRemoveQueryStringParameter(UrlUtils.createNavigateUrl(serverAuthenticationRequest), Constants.prompt) + Constants.prompt_none + Constants.response_mode_fragment;\r\n\r\n window.renewStates.push(serverAuthenticationRequest.state);\r\n window.requestType = Constants.renewToken;\r\n this.logger.verbose(\"Set window.renewState and requestType\");\r\n this.registerCallback(serverAuthenticationRequest.state, requestSignature, resolve, reject);\r\n this.logger.infoPii(`Navigate to: ${urlNavigate}`);\r\n this.loadIframeTimeout(urlNavigate, frameName, requestSignature).catch(error => reject(error));\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Renews idtoken for app's own backend when clientId is passed as a single scope in the scopes array.\r\n * @ignore\r\n */\r\n private renewIdToken(requestSignature: string, resolve: Function, reject: Function, account: Account, serverAuthenticationRequest: ServerRequestParameters): void {\r\n this.logger.info(\"RenewIdToken has been called\");\r\n\r\n const frameName = WindowUtils.generateFrameName(FramePrefix.ID_TOKEN_FRAME, requestSignature);\r\n WindowUtils.addHiddenIFrame(frameName, this.logger);\r\n\r\n this.updateCacheEntries(serverAuthenticationRequest, account, false);\r\n\r\n this.logger.verbose(`RenewIdToken expected state: ${serverAuthenticationRequest.state}`);\r\n\r\n // Build urlNavigate with \"prompt=none\" and navigate to URL in hidden iFrame\r\n const urlNavigate = UrlUtils.urlRemoveQueryStringParameter(UrlUtils.createNavigateUrl(serverAuthenticationRequest), Constants.prompt) + Constants.prompt_none + Constants.response_mode_fragment;\r\n\r\n if (this.silentLogin) {\r\n this.logger.verbose(\"Silent login is true, set silentAuthenticationState\");\r\n window.requestType = Constants.login;\r\n this.silentAuthenticationState = serverAuthenticationRequest.state;\r\n } else {\r\n this.logger.verbose(\"Not silent login, set window.renewState and requestType\");\r\n window.requestType = Constants.renewToken;\r\n window.renewStates.push(serverAuthenticationRequest.state);\r\n }\r\n\r\n // note: scope here is clientId\r\n this.registerCallback(serverAuthenticationRequest.state, requestSignature, resolve, reject);\r\n this.logger.infoPii(`Navigate to:\" ${urlNavigate}`);\r\n this.loadIframeTimeout(urlNavigate, frameName, requestSignature).catch(error => reject(error));\r\n }\r\n\r\n /**\r\n * @hidden\r\n * \r\n * This method builds an Access Token Cache item and saves it to the cache, returning the original\r\n * AuthResponse augmented with a parsed expiresOn attribute.\r\n * \r\n * @param response The AuthResponse object that contains the token to be saved\r\n * @param authority The authority under which the ID token will be cached\r\n * @param scopes The scopes to be added to the cache item key (undefined for ID token cache items)\r\n * @param clientInfo Client Info object that is used to generate the homeAccountIdentifier\r\n * @param expiration Token expiration timestamp\r\n */\r\n private saveToken(response: AuthResponse, authority: string, scopes: string, clientInfo: ClientInfo, expiration: number): AuthResponse {\r\n const accessTokenKey = new AccessTokenKey(authority, this.clientId, scopes, clientInfo.uid, clientInfo.utid);\r\n const accessTokenValue = new AccessTokenValue(response.accessToken, response.idToken.rawIdToken, expiration.toString(), clientInfo.encodeClientInfo());\r\n this.cacheStorage.setItem(JSON.stringify(accessTokenKey), JSON.stringify(accessTokenValue));\r\n\r\n if (expiration) {\r\n this.logger.verbose(\"New expiration set for token\");\r\n response.expiresOn = new Date(expiration * 1000);\r\n } else {\r\n this.logger.error(\"Could not parse expiresIn parameter for access token\");\r\n }\r\n\r\n return response;\r\n }\r\n\r\n /**\r\n * @hidden\r\n * \r\n * This method sets up the elements of an ID Token cache item and calls saveToken to save it in\r\n * Access Token Cache item format for the client application to use.\r\n * \r\n * @param response The AuthResponse object that will be used to build the cache item\r\n * @param authority The authority under which the ID token will be cached\r\n * @param parameters The response's Hash Params, which contain the ID token returned from the server\r\n * @param clientInfo Client Info object that is used to generate the homeAccountIdentifier\r\n * @param idTokenObj ID Token object from which the ID token's expiration is extracted\r\n */\r\n /* tslint:disable:no-string-literal */\r\n private saveIdToken(response: AuthResponse, authority: string, parameters: object, clientInfo: ClientInfo, idTokenObj: IdToken): AuthResponse {\r\n this.logger.verbose(\"SaveIdToken has been called\");\r\n const idTokenResponse = { ...response };\r\n\r\n // Scopes are undefined so they don't show up in ID token cache key\r\n let scopes: string;\r\n\r\n idTokenResponse.scopes = Constants.oidcScopes;\r\n idTokenResponse.accessToken = parameters[ServerHashParamKeys.ID_TOKEN];\r\n\r\n const expiration = Number(idTokenObj.expiration);\r\n\r\n // Set ID Token item in cache\r\n this.logger.verbose(\"Saving ID token to cache\");\r\n return this.saveToken(idTokenResponse, authority, scopes, clientInfo, expiration);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * \r\n * This method sets up the elements of an Access Token cache item and calls saveToken to save it to the cache\r\n * \r\n * @param response The AuthResponse object that will be used to build the cache item\r\n * @param authority The authority under which the access token will be cached\r\n * @param parameters The response's Hash Params, which contain the access token returned from the server\r\n * @param clientInfo Client Info object that is used to generate the homeAccountIdentifier\r\n */\r\n /* tslint:disable:no-string-literal */\r\n private saveAccessToken(response: AuthResponse, authority: string, parameters: object, clientInfo: ClientInfo): AuthResponse {\r\n this.logger.verbose(\"SaveAccessToken has been called\");\r\n const accessTokenResponse = { ...response };\r\n\r\n // read the scopes\r\n const scope = parameters[ServerHashParamKeys.SCOPE];\r\n const consentedScopes = scope.split(\" \");\r\n\r\n // retrieve all access tokens from the cache, remove the dup scopes\r\n const accessTokenCacheItems = this.cacheStorage.getAllAccessTokens(this.clientId, authority);\r\n this.logger.verbose(\"Retrieving all access tokens from cache and removing duplicates\");\r\n\r\n for (let i = 0; i < accessTokenCacheItems.length; i++) {\r\n const accessTokenCacheItem = accessTokenCacheItems[i];\r\n\r\n if (accessTokenCacheItem.key.homeAccountIdentifier === response.account.homeAccountIdentifier) {\r\n const cachedScopes = accessTokenCacheItem.key.scopes.split(\" \");\r\n if (ScopeSet.isIntersectingScopes(cachedScopes, consentedScopes)) {\r\n this.cacheStorage.removeItem(JSON.stringify(accessTokenCacheItem.key));\r\n }\r\n }\r\n }\r\n\r\n accessTokenResponse.accessToken = parameters[ServerHashParamKeys.ACCESS_TOKEN];\r\n accessTokenResponse.scopes = consentedScopes;\r\n\r\n const expiresIn = TimeUtils.parseExpiresIn(parameters[ServerHashParamKeys.EXPIRES_IN]);\r\n const parsedState = RequestUtils.parseLibraryState(parameters[ServerHashParamKeys.STATE]);\r\n const expiration = parsedState.ts + expiresIn;\r\n\r\n this.logger.verbose(\"Saving access token to cache\");\r\n return this.saveToken(accessTokenResponse, authority, scope, clientInfo, expiration);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Saves token or error received in the response from AAD in the cache. In case of id_token, it also creates the account object.\r\n * @ignore\r\n */\r\n protected saveTokenFromHash(hash: string, stateInfo: ResponseStateInfo): AuthResponse {\r\n this.logger.verbose(\"SaveTokenFromHash has been called\");\r\n this.logger.info(`State status: ${stateInfo.stateMatch}; Request type: ${stateInfo.requestType}`);\r\n\r\n let response : AuthResponse = {\r\n uniqueId: \"\",\r\n tenantId: \"\",\r\n tokenType: \"\",\r\n idToken: null,\r\n idTokenClaims: null,\r\n accessToken: null,\r\n scopes: [],\r\n expiresOn: null,\r\n account: null,\r\n accountState: \"\",\r\n fromCache: false\r\n };\r\n\r\n let error: AuthError;\r\n const hashParams = UrlUtils.deserializeHash(hash);\r\n let authorityKey: string = \"\";\r\n let acquireTokenAccountKey: string = \"\";\r\n let idTokenObj: IdToken = null;\r\n\r\n // If server returns an error\r\n if (hashParams.hasOwnProperty(ServerHashParamKeys.ERROR_DESCRIPTION) || hashParams.hasOwnProperty(ServerHashParamKeys.ERROR)) {\r\n this.logger.verbose(\"Server returned an error\");\r\n this.logger.infoPii(`Error : ${hashParams[ServerHashParamKeys.ERROR]}; Error description: ${hashParams[ServerHashParamKeys.ERROR_DESCRIPTION]}`);\r\n this.cacheStorage.setItem(ErrorCacheKeys.ERROR, hashParams[ServerHashParamKeys.ERROR]);\r\n this.cacheStorage.setItem(ErrorCacheKeys.ERROR_DESC, hashParams[ServerHashParamKeys.ERROR_DESCRIPTION]);\r\n\r\n // login\r\n if (stateInfo.requestType === Constants.login) {\r\n this.logger.verbose(\"RequestType is login, caching login error, generating authorityKey\");\r\n this.cacheStorage.setItem(ErrorCacheKeys.LOGIN_ERROR, hashParams[ServerHashParamKeys.ERROR_DESCRIPTION] + \":\" + hashParams[ServerHashParamKeys.ERROR]);\r\n authorityKey = AuthCache.generateAuthorityKey(stateInfo.state);\r\n }\r\n\r\n // acquireToken\r\n if (stateInfo.requestType === Constants.renewToken) {\r\n this.logger.verbose(\"RequestType is renewToken, generating acquireTokenAccountKey\");\r\n authorityKey = AuthCache.generateAuthorityKey(stateInfo.state);\r\n\r\n const account: Account = this.getAccount();\r\n let accountId;\r\n\r\n if (account && !StringUtils.isEmpty(account.homeAccountIdentifier)) {\r\n accountId = account.homeAccountIdentifier;\r\n this.logger.verbose(\"AccountId is set\");\r\n }\r\n else {\r\n accountId = Constants.no_account;\r\n this.logger.verbose(\"AccountId is set as no_account\");\r\n }\r\n\r\n acquireTokenAccountKey = AuthCache.generateAcquireTokenAccountKey(accountId, stateInfo.state);\r\n }\r\n\r\n const hashErr = hashParams[ServerHashParamKeys.ERROR];\r\n const hashErrDesc = hashParams[ServerHashParamKeys.ERROR_DESCRIPTION];\r\n if (InteractionRequiredAuthError.isInteractionRequiredError(hashErr) ||\r\n InteractionRequiredAuthError.isInteractionRequiredError(hashErrDesc)) {\r\n error = new InteractionRequiredAuthError(hashParams[ServerHashParamKeys.ERROR], hashParams[ServerHashParamKeys.ERROR_DESCRIPTION]);\r\n } else {\r\n error = new ServerError(hashParams[ServerHashParamKeys.ERROR], hashParams[ServerHashParamKeys.ERROR_DESCRIPTION]);\r\n }\r\n }\r\n // If the server returns \"Success\"\r\n else {\r\n this.logger.verbose(\"Server returns success\");\r\n // Verify the state from redirect and record tokens to storage if exists\r\n if (stateInfo.stateMatch) {\r\n this.logger.info(\"State is right\");\r\n if (hashParams.hasOwnProperty(ServerHashParamKeys.SESSION_STATE)) {\r\n this.logger.verbose(\"Fragment has session state, caching\");\r\n this.cacheStorage.setItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.SESSION_STATE, stateInfo.state), hashParams[ServerHashParamKeys.SESSION_STATE]);\r\n }\r\n response.accountState = this.getAccountState(stateInfo.state);\r\n\r\n let clientInfo: ClientInfo;\r\n\r\n // Process access_token\r\n if (hashParams.hasOwnProperty(ServerHashParamKeys.ACCESS_TOKEN)) {\r\n this.logger.info(\"Fragment has access token\");\r\n response.accessToken = hashParams[ServerHashParamKeys.ACCESS_TOKEN];\r\n\r\n if (hashParams.hasOwnProperty(ServerHashParamKeys.SCOPE)) {\r\n response.scopes = hashParams[ServerHashParamKeys.SCOPE].split(\" \");\r\n }\r\n\r\n // retrieve the id_token from response if present\r\n if (hashParams.hasOwnProperty(ServerHashParamKeys.ID_TOKEN)) {\r\n this.logger.verbose(\"Fragment has id_token\");\r\n idTokenObj = new IdToken(hashParams[ServerHashParamKeys.ID_TOKEN]);\r\n } else {\r\n this.logger.verbose(\"No idToken on fragment, getting idToken from cache\");\r\n idTokenObj = new IdToken(this.cacheStorage.getItem(PersistentCacheKeys.IDTOKEN));\r\n }\r\n\r\n response = ResponseUtils.setResponseIdToken(response, idTokenObj);\r\n\r\n // set authority\r\n const authority: string = this.populateAuthority(stateInfo.state, this.inCookie, this.cacheStorage, idTokenObj);\r\n this.logger.verbose(\"Got authority from cache\");\r\n\r\n // retrieve client_info - if it is not found, generate the uid and utid from idToken\r\n if (hashParams.hasOwnProperty(ServerHashParamKeys.CLIENT_INFO)) {\r\n this.logger.verbose(\"Fragment has clientInfo\");\r\n clientInfo = new ClientInfo(hashParams[ServerHashParamKeys.CLIENT_INFO], authority);\r\n } else if (this.authorityInstance.AuthorityType === AuthorityType.Adfs) {\r\n clientInfo = ClientInfo.createClientInfoFromIdToken(idTokenObj, authority);\r\n } else {\r\n this.logger.warning(\"ClientInfo not received in the response from AAD\");\r\n }\r\n\r\n response.account = Account.createAccount(idTokenObj, clientInfo);\r\n this.logger.verbose(\"Account object created from response\");\r\n\r\n let accountKey: string;\r\n if (response.account && !StringUtils.isEmpty(response.account.homeAccountIdentifier)) {\r\n this.logger.verbose(\"AccountKey set\");\r\n accountKey = response.account.homeAccountIdentifier;\r\n }\r\n else {\r\n this.logger.verbose(\"AccountKey set as no_account\");\r\n accountKey = Constants.no_account;\r\n }\r\n\r\n acquireTokenAccountKey = AuthCache.generateAcquireTokenAccountKey(accountKey, stateInfo.state);\r\n const acquireTokenAccountKey_noaccount = AuthCache.generateAcquireTokenAccountKey(Constants.no_account, stateInfo.state);\r\n this.logger.verbose(\"AcquireTokenAccountKey generated\");\r\n\r\n const cachedAccount: string = this.cacheStorage.getItem(acquireTokenAccountKey);\r\n let acquireTokenAccount: Account;\r\n\r\n // Check with the account in the Cache\r\n if (!StringUtils.isEmpty(cachedAccount)) {\r\n acquireTokenAccount = JSON.parse(cachedAccount);\r\n this.logger.verbose(\"AcquireToken request account retrieved from cache\");\r\n if (response.account && acquireTokenAccount && Account.compareAccounts(response.account, acquireTokenAccount)) {\r\n response = this.saveAccessToken(response, authority, hashParams, clientInfo);\r\n this.logger.info(\"The user object received in the response is the same as the one passed in the acquireToken request\");\r\n }\r\n else {\r\n this.logger.warning(\r\n \"The account object created from the response is not the same as the one passed in the acquireToken request\");\r\n }\r\n }\r\n else if (!StringUtils.isEmpty(this.cacheStorage.getItem(acquireTokenAccountKey_noaccount))) {\r\n this.logger.verbose(\"No acquireToken account retrieved from cache\");\r\n response = this.saveAccessToken(response, authority, hashParams, clientInfo);\r\n }\r\n }\r\n\r\n // Process id_token\r\n if (hashParams.hasOwnProperty(ServerHashParamKeys.ID_TOKEN)) {\r\n this.logger.info(\"Fragment has idToken\");\r\n\r\n // set the idToken\r\n idTokenObj = new IdToken(hashParams[ServerHashParamKeys.ID_TOKEN]);\r\n\r\n // set authority\r\n const authority: string = this.populateAuthority(stateInfo.state, this.inCookie, this.cacheStorage, idTokenObj);\r\n\r\n response = ResponseUtils.setResponseIdToken(response, idTokenObj);\r\n if (hashParams.hasOwnProperty(ServerHashParamKeys.CLIENT_INFO)) {\r\n this.logger.verbose(\"Fragment has clientInfo\");\r\n clientInfo = new ClientInfo(hashParams[ServerHashParamKeys.CLIENT_INFO], authority);\r\n } else if (this.authorityInstance.AuthorityType === AuthorityType.Adfs) {\r\n clientInfo = ClientInfo.createClientInfoFromIdToken(idTokenObj, authority);\r\n } else {\r\n this.logger.warning(\"ClientInfo not received in the response from AAD\");\r\n }\r\n\r\n this.account = Account.createAccount(idTokenObj, clientInfo);\r\n response.account = this.account;\r\n this.logger.verbose(\"Account object created from response\");\r\n\r\n if (idTokenObj && idTokenObj.nonce) {\r\n this.logger.verbose(\"IdToken has nonce\");\r\n // check nonce integrity if idToken has nonce - throw an error if not matched\r\n const cachedNonce = this.cacheStorage.getItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.NONCE_IDTOKEN, stateInfo.state), this.inCookie);\r\n if (idTokenObj.nonce !== cachedNonce) {\r\n this.account = null;\r\n this.cacheStorage.setItem(ErrorCacheKeys.LOGIN_ERROR, \"Nonce Mismatch. Expected Nonce: \" + cachedNonce + \",\" + \"Actual Nonce: \" + idTokenObj.nonce);\r\n this.logger.error(`Nonce Mismatch. Expected Nonce: ${cachedNonce}, Actual Nonce: ${idTokenObj.nonce}`);\r\n error = ClientAuthError.createNonceMismatchError(cachedNonce, idTokenObj.nonce);\r\n }\r\n // Save the token\r\n else {\r\n this.logger.verbose(\"Nonce matches, saving idToken to cache\");\r\n this.cacheStorage.setItem(PersistentCacheKeys.IDTOKEN, hashParams[ServerHashParamKeys.ID_TOKEN], this.inCookie);\r\n this.cacheStorage.setItem(PersistentCacheKeys.CLIENT_INFO, clientInfo.encodeClientInfo(), this.inCookie);\r\n\r\n // Save idToken as access token item for app itself\r\n this.saveIdToken(response, authority, hashParams, clientInfo, idTokenObj);\r\n }\r\n } else {\r\n this.logger.verbose(\"No idToken or no nonce. Cache key for Authority set as state\");\r\n authorityKey = stateInfo.state;\r\n acquireTokenAccountKey = stateInfo.state;\r\n\r\n this.logger.error(\"Invalid id_token received in the response\");\r\n error = ClientAuthError.createInvalidIdTokenError(idTokenObj);\r\n this.cacheStorage.setItem(ErrorCacheKeys.ERROR, error.errorCode);\r\n this.cacheStorage.setItem(ErrorCacheKeys.ERROR_DESC, error.errorMessage);\r\n }\r\n }\r\n }\r\n // State mismatch - unexpected/invalid state\r\n else {\r\n this.logger.verbose(\"State mismatch\");\r\n authorityKey = stateInfo.state;\r\n acquireTokenAccountKey = stateInfo.state;\r\n\r\n const expectedState = this.cacheStorage.getItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.STATE_LOGIN, stateInfo.state), this.inCookie);\r\n this.logger.error(`State Mismatch. Expected State: ${expectedState}, Actual State: ${stateInfo.state}`);\r\n error = ClientAuthError.createInvalidStateError(stateInfo.state, expectedState);\r\n this.cacheStorage.setItem(ErrorCacheKeys.ERROR, error.errorCode);\r\n this.cacheStorage.setItem(ErrorCacheKeys.ERROR_DESC, error.errorMessage);\r\n }\r\n }\r\n\r\n // Set status to completed\r\n this.cacheStorage.removeItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.RENEW_STATUS, stateInfo.state));\r\n this.cacheStorage.resetTempCacheItems(stateInfo.state);\r\n this.logger.verbose(\"Status set to complete, temporary cache cleared\");\r\n\r\n // this is required if navigateToLoginRequestUrl=false\r\n if (this.inCookie) {\r\n this.logger.verbose(\"InCookie is true, setting authorityKey in cookie\");\r\n this.cacheStorage.setItemCookie(authorityKey, \"\", -1);\r\n this.cacheStorage.clearMsalCookie(stateInfo.state);\r\n }\r\n if (error) {\r\n // Error case, set status to cancelled\r\n throw error;\r\n }\r\n\r\n if (!response) {\r\n throw AuthError.createUnexpectedError(\"Response is null\");\r\n }\r\n\r\n return response;\r\n }\r\n\r\n /**\r\n * Set Authority when saving Token from the hash\r\n * @param state\r\n * @param inCookie\r\n * @param cacheStorage\r\n * @param idTokenObj\r\n * @param response\r\n */\r\n private populateAuthority(state: string, inCookie: boolean, cacheStorage: AuthCache, idTokenObj: IdToken): string {\r\n this.logger.verbose(\"PopulateAuthority has been called\");\r\n const authorityKey: string = AuthCache.generateAuthorityKey(state);\r\n const cachedAuthority: string = cacheStorage.getItem(authorityKey, inCookie);\r\n\r\n // retrieve the authority from cache and replace with tenantID\r\n return StringUtils.isEmpty(cachedAuthority) ? cachedAuthority : UrlUtils.replaceTenantPath(cachedAuthority, idTokenObj.tenantId);\r\n }\r\n\r\n /* tslint:enable:no-string-literal */\r\n\r\n // #endregion\r\n\r\n // #region Account\r\n\r\n /**\r\n * Returns the signed in account\r\n * (the account object is created at the time of successful login)\r\n * or null when no state is found\r\n * @returns {@link Account} - the account object stored in MSAL\r\n */\r\n getAccount(): Account {\r\n // if a session already exists, get the account from the session\r\n if (this.account) {\r\n return this.account;\r\n }\r\n\r\n // frame is used to get idToken and populate the account for the given session\r\n const rawIdToken = this.cacheStorage.getItem(PersistentCacheKeys.IDTOKEN, this.inCookie);\r\n const rawClientInfo = this.cacheStorage.getItem(PersistentCacheKeys.CLIENT_INFO, this.inCookie);\r\n\r\n if (!StringUtils.isEmpty(rawIdToken) && !StringUtils.isEmpty(rawClientInfo)) {\r\n const idToken = new IdToken(rawIdToken);\r\n const clientInfo = new ClientInfo(rawClientInfo, \"\");\r\n this.account = Account.createAccount(idToken, clientInfo);\r\n return this.account;\r\n }\r\n // if login not yet done, return null\r\n return null;\r\n }\r\n\r\n /**\r\n * @hidden\r\n *\r\n * Extracts state value from the accountState sent with the authentication request.\r\n * @returns {string} scope.\r\n * @ignore\r\n */\r\n getAccountState (state: string): string {\r\n if (state) {\r\n const splitIndex = state.indexOf(Constants.resourceDelimiter);\r\n if (splitIndex > -1 && splitIndex + 1 < state.length) {\r\n return state.substring(splitIndex + 1);\r\n }\r\n }\r\n return state;\r\n }\r\n\r\n /**\r\n * Use to get a list of unique accounts in MSAL cache based on homeAccountIdentifier.\r\n *\r\n * @param {@link Array<Account>} Account - all unique accounts in MSAL cache.\r\n */\r\n getAllAccounts(): Array<Account> {\r\n const accounts: Array<Account> = [];\r\n const accessTokenCacheItems = this.cacheStorage.getAllAccessTokens(Constants.clientId, Constants.homeAccountIdentifier);\r\n\r\n for (let i = 0; i < accessTokenCacheItems.length; i++) {\r\n const idToken = new IdToken(accessTokenCacheItems[i].value.idToken);\r\n const clientInfo = new ClientInfo(accessTokenCacheItems[i].value.homeAccountIdentifier, \"\");\r\n const account: Account = Account.createAccount(idToken, clientInfo);\r\n accounts.push(account);\r\n }\r\n\r\n return this.getUniqueAccounts(accounts);\r\n }\r\n\r\n /**\r\n * @hidden\r\n *\r\n * Used to filter accounts based on homeAccountIdentifier\r\n * @param {Array<Account>} Accounts - accounts saved in the cache\r\n * @ignore\r\n */\r\n private getUniqueAccounts(accounts: Array<Account>): Array<Account> {\r\n if (!accounts || accounts.length <= 1) {\r\n return accounts;\r\n }\r\n\r\n const flags: Array<string> = [];\r\n const uniqueAccounts: Array<Account> = [];\r\n for (let index = 0; index < accounts.length; ++index) {\r\n if (accounts[index].homeAccountIdentifier && flags.indexOf(accounts[index].homeAccountIdentifier) === -1) {\r\n flags.push(accounts[index].homeAccountIdentifier);\r\n uniqueAccounts.push(accounts[index]);\r\n }\r\n }\r\n\r\n return uniqueAccounts;\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Angular\r\n\r\n /**\r\n * @hidden\r\n *\r\n * Broadcast messages - Used only for Angular? *\r\n * @param eventName\r\n * @param data\r\n */\r\n private broadcast(eventName: string, data: string) {\r\n const evt = new CustomEvent(eventName, { detail: data });\r\n window.dispatchEvent(evt);\r\n }\r\n\r\n /**\r\n * @hidden\r\n *\r\n * Helper function to retrieve the cached token\r\n *\r\n * @param scopes\r\n * @param {@link Account} account\r\n * @param state\r\n * @return {@link AuthResponse} AuthResponse\r\n */\r\n protected getCachedTokenInternal(scopes : Array<string> , account: Account, state: string, correlationId?: string): AuthResponse {\r\n // Get the current session's account object\r\n const accountObject: Account = account || this.getAccount();\r\n if (!accountObject) {\r\n return null;\r\n }\r\n\r\n // Construct AuthenticationRequest based on response type; set \"redirectUri\" from the \"request\" which makes this call from Angular - for this.getRedirectUri()\r\n const newAuthority = this.authorityInstance ? this.authorityInstance : AuthorityFactory.CreateInstance(this.authority, this.config.auth.validateAuthority);\r\n const responseType = this.getTokenType(accountObject, scopes);\r\n\r\n const serverAuthenticationRequest = new ServerRequestParameters(\r\n newAuthority,\r\n this.clientId,\r\n responseType,\r\n this.getRedirectUri(),\r\n scopes,\r\n state,\r\n correlationId\r\n );\r\n\r\n // get cached token\r\n return this.getCachedToken(serverAuthenticationRequest, account);\r\n }\r\n\r\n /**\r\n * @hidden\r\n *\r\n * Get scopes for the Endpoint - Used in Angular to track protected and unprotected resources without interaction from the developer app\r\n * Note: Please check if we need to set the \"redirectUri\" from the \"request\" which makes this call from Angular - for this.getRedirectUri()\r\n *\r\n * @param endpoint\r\n */\r\n protected getScopesForEndpoint(endpoint: string) : Array<string> {\r\n // if user specified list of unprotectedResources, no need to send token to these endpoints, return null.\r\n if (this.config.framework.unprotectedResources.length > 0) {\r\n for (let i = 0; i < this.config.framework.unprotectedResources.length; i++) {\r\n if (endpoint.indexOf(this.config.framework.unprotectedResources[i]) > -1) {\r\n return null;\r\n }\r\n }\r\n }\r\n\r\n // process all protected resources and send the matched one\r\n if (this.config.framework.protectedResourceMap.size > 0) {\r\n for (const key of Array.from(this.config.framework.protectedResourceMap.keys())) {\r\n // configEndpoint is like /api/Todo requested endpoint can be /api/Todo/1\r\n if (endpoint.indexOf(key) > -1) {\r\n return this.config.framework.protectedResourceMap.get(key);\r\n }\r\n }\r\n }\r\n\r\n /*\r\n * default resource will be clientid if nothing specified\r\n * App will use idtoken for calls to itself\r\n * check if it's staring from http or https, needs to match with app host\r\n */\r\n if (endpoint.indexOf(\"http://\") > -1 || endpoint.indexOf(\"https://\") > -1) {\r\n if (UrlUtils.getHostFromUri(endpoint) === UrlUtils.getHostFromUri(this.getRedirectUri())) {\r\n return new Array<string>(this.clientId);\r\n }\r\n } else {\r\n /*\r\n * in angular level, the url for $http interceptor call could be relative url,\r\n * if it's relative call, we'll treat it as app backend call.\r\n */\r\n return new Array<string>(this.clientId);\r\n }\r\n\r\n // if not the app's own backend or not a domain listed in the endpoints structure\r\n return null;\r\n }\r\n\r\n /**\r\n * Return boolean flag to developer to help inform if login is in progress\r\n * @returns {boolean} true/false\r\n */\r\n public getLoginInProgress(): boolean {\r\n return this.cacheStorage.isInteractionInProgress(true);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * @param loginInProgress\r\n */\r\n protected setInteractionInProgress(inProgress: boolean): void {\r\n this.cacheStorage.setInteractionInProgress(inProgress);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * @param loginInProgress\r\n */\r\n protected setloginInProgress(loginInProgress : boolean): void {\r\n this.setInteractionInProgress(loginInProgress);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * returns the status of acquireTokenInProgress\r\n */\r\n protected getAcquireTokenInProgress(): boolean {\r\n return this.cacheStorage.isInteractionInProgress(true);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * @param acquireTokenInProgress\r\n */\r\n protected setAcquireTokenInProgress(acquireTokenInProgress : boolean): void {\r\n this.setInteractionInProgress(acquireTokenInProgress);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * returns the logger handle\r\n */\r\n getLogger(): Logger {\r\n return this.logger;\r\n }\r\n\r\n /**\r\n * Sets the logger callback.\r\n * @param logger Logger callback\r\n */\r\n setLogger(logger: Logger): void {\r\n this.logger = logger;\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Getters and Setters\r\n\r\n /**\r\n * Use to get the redirect uri configured in MSAL or null.\r\n * Evaluates redirectUri if its a function, otherwise simply returns its value.\r\n *\r\n * @returns {string} redirect URL\r\n */\r\n public getRedirectUri(reqRedirectUri?: string): string {\r\n if(reqRedirectUri) {\r\n return reqRedirectUri;\r\n }\r\n else if (typeof this.config.auth.redirectUri === \"function\") {\r\n return this.config.auth.redirectUri();\r\n }\r\n return this.config.auth.redirectUri;\r\n }\r\n\r\n /**\r\n * Use to get the post logout redirect uri configured in MSAL or null.\r\n * Evaluates postLogoutredirectUri if its a function, otherwise simply returns its value.\r\n *\r\n * @returns {string} post logout redirect URL\r\n */\r\n public getPostLogoutRedirectUri(): string {\r\n if (typeof this.config.auth.postLogoutRedirectUri === \"function\") {\r\n return this.config.auth.postLogoutRedirectUri();\r\n }\r\n return this.config.auth.postLogoutRedirectUri;\r\n }\r\n\r\n /**\r\n * Use to get the current {@link Configuration} object in MSAL\r\n *\r\n * @returns {@link Configuration}\r\n */\r\n public getCurrentConfiguration(): Configuration {\r\n if (!this.config) {\r\n throw ClientConfigurationError.createNoSetConfigurationError();\r\n }\r\n return this.config;\r\n }\r\n\r\n /**\r\n * @ignore\r\n *\r\n * Utils function to create the Authentication\r\n * @param {@link account} account object\r\n * @param scopes\r\n *\r\n * @returns {string} token type: token, id_token or id_token token\r\n *\r\n */\r\n private getTokenType(accountObject: Account, scopes: string[]): string {\r\n const accountsMatch = Account.compareAccounts(accountObject, this.getAccount());\r\n return ServerRequestParameters.determineResponseType(accountsMatch, scopes);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * Sets the cachekeys for and stores the account information in cache\r\n * @param account\r\n * @param state\r\n * @hidden\r\n */\r\n private setAccountCache(account: Account, state: string) {\r\n\r\n // Cache acquireTokenAccountKey\r\n const accountId = account ? this.getAccountId(account) : Constants.no_account;\r\n\r\n const acquireTokenAccountKey = AuthCache.generateAcquireTokenAccountKey(accountId, state);\r\n this.cacheStorage.setItem(acquireTokenAccountKey, JSON.stringify(account));\r\n }\r\n\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * Sets the cacheKey for and stores the authority information in cache\r\n * @param state\r\n * @param authority\r\n * @hidden\r\n */\r\n private setAuthorityCache(state: string, authority: string) {\r\n // Cache authorityKey\r\n const authorityKey = AuthCache.generateAuthorityKey(state);\r\n this.cacheStorage.setItem(authorityKey, UrlUtils.CanonicalizeUri(authority), this.inCookie);\r\n }\r\n\r\n /**\r\n * Updates account, authority, and nonce in cache\r\n * @param serverAuthenticationRequest\r\n * @param account\r\n * @hidden\r\n * @ignore\r\n */\r\n private updateCacheEntries(serverAuthenticationRequest: ServerRequestParameters, account: Account, isLoginCall: boolean, loginStartPage?: string) {\r\n // Cache Request Originator Page\r\n if (loginStartPage) {\r\n this.cacheStorage.setItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.LOGIN_REQUEST, serverAuthenticationRequest.state), loginStartPage, this.inCookie);\r\n }\r\n\r\n // Cache account and authority\r\n if (isLoginCall) {\r\n // Cache the state\r\n this.cacheStorage.setItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.STATE_LOGIN, serverAuthenticationRequest.state), serverAuthenticationRequest.state, this.inCookie);\r\n } else {\r\n this.setAccountCache(account, serverAuthenticationRequest.state);\r\n }\r\n // Cache authorityKey\r\n this.setAuthorityCache(serverAuthenticationRequest.state, serverAuthenticationRequest.authority);\r\n\r\n // Cache nonce\r\n this.cacheStorage.setItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.NONCE_IDTOKEN, serverAuthenticationRequest.state), serverAuthenticationRequest.nonce, this.inCookie);\r\n }\r\n\r\n /**\r\n * Returns the unique identifier for the logged in account\r\n * @param account\r\n * @hidden\r\n * @ignore\r\n */\r\n private getAccountId(account: Account): string {\r\n // return `${account.accountIdentifier}` + Constants.resourceDelimiter + `${account.homeAccountIdentifier}`;\r\n let accountId: string;\r\n if (!StringUtils.isEmpty(account.homeAccountIdentifier)) {\r\n accountId = account.homeAccountIdentifier;\r\n }\r\n else {\r\n accountId = Constants.no_account;\r\n }\r\n\r\n return accountId;\r\n }\r\n\r\n /**\r\n * @ignore\r\n * @param extraQueryParameters\r\n *\r\n * Construct 'tokenRequest' from the available data in adalIdToken\r\n */\r\n private buildIDTokenRequest(request: AuthenticationParameters): AuthenticationParameters {\r\n\r\n const tokenRequest: AuthenticationParameters = {\r\n scopes: Constants.oidcScopes,\r\n authority: this.authority,\r\n account: this.getAccount(),\r\n extraQueryParameters: request.extraQueryParameters,\r\n correlationId: request.correlationId\r\n };\r\n\r\n return tokenRequest;\r\n }\r\n\r\n /**\r\n * @ignore\r\n * @param config\r\n * @param clientId\r\n *\r\n * Construct TelemetryManager from Configuration\r\n */\r\n private getTelemetryManagerFromConfig(config: TelemetryOptions, clientId: string): TelemetryManager {\r\n if (!config) { // if unset\r\n return TelemetryManager.getTelemetrymanagerStub(clientId, this.logger);\r\n }\r\n // if set then validate\r\n const { applicationName, applicationVersion, telemetryEmitter } = config;\r\n if (!applicationName || !applicationVersion || !telemetryEmitter) {\r\n throw ClientConfigurationError.createTelemetryConfigError(config);\r\n }\r\n // if valid then construct\r\n const telemetryPlatform: TelemetryPlatform = {\r\n applicationName,\r\n applicationVersion\r\n };\r\n const telemetryManagerConfig: TelemetryConfig = {\r\n platform: telemetryPlatform,\r\n clientId: clientId\r\n };\r\n return new TelemetryManager(telemetryManagerConfig, telemetryEmitter, this.logger);\r\n }\r\n\r\n // #endregion\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { NetworkRequestType } from \"./utils/Constants\";\r\n\r\n/**\r\n * XHR client for JSON endpoints\r\n * https://www.npmjs.com/package/async-promise\r\n * @hidden\r\n */\r\n\r\nexport class XhrClient {\r\n\r\n public sendRequestAsync(url: string, method: string, enableCaching?: boolean): Promise<XhrResponse> {\r\n return new Promise<XhrResponse>((resolve, reject) => {\r\n const xhr = new XMLHttpRequest();\r\n xhr.open(method, url, /* async: */ true);\r\n if (enableCaching) {\r\n /*\r\n * TODO: (shivb) ensure that this can be cached\r\n * xhr.setRequestHeader(\"Cache-Control\", \"Public\");\r\n */\r\n }\r\n\r\n xhr.onload = () => {\r\n if (xhr.status < 200 || xhr.status >= 300) {\r\n reject(this.handleError(xhr.responseText));\r\n }\r\n let jsonResponse;\r\n try {\r\n jsonResponse = JSON.parse(xhr.responseText);\r\n } catch (e) {\r\n reject(this.handleError(xhr.responseText));\r\n }\r\n const response: XhrResponse = {\r\n statusCode: xhr.status,\r\n body: jsonResponse\r\n };\r\n resolve(response);\r\n };\r\n\r\n xhr.onerror = () => {\r\n reject(xhr.status);\r\n };\r\n\r\n if (method === NetworkRequestType.GET) {\r\n xhr.send();\r\n }\r\n else {\r\n throw \"not implemented\";\r\n }\r\n });\r\n }\r\n\r\n protected handleError(responseText: string): string {\r\n let jsonResponse: object;\r\n try {\r\n jsonResponse = JSON.parse(responseText);\r\n if (jsonResponse[\"error\"]) {\r\n return jsonResponse[\"error\"];\r\n } else {\r\n throw responseText;\r\n }\r\n } catch (e) {\r\n return responseText;\r\n }\r\n }\r\n}\r\n\r\nexport type XhrResponse = {\r\n body: object,\r\n statusCode: number\r\n};\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { IUri } from \"../IUri\";\r\nimport { ITenantDiscoveryResponse } from \"./ITenantDiscoveryResponse\";\r\nimport { ClientConfigurationErrorMessage, ClientConfigurationError } from \"../error/ClientConfigurationError\";\r\nimport { XhrClient, XhrResponse } from \"../XHRClient\";\r\nimport { UrlUtils } from \"../utils/UrlUtils\";\r\nimport TelemetryManager from \"../telemetry/TelemetryManager\";\r\nimport HttpEvent from \"../telemetry/HttpEvent\";\r\nimport { TrustedAuthority } from \"./TrustedAuthority\";\r\nimport { NetworkRequestType, Constants, WELL_KNOWN_SUFFIX } from \"../utils/Constants\";\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport enum AuthorityType {\r\n Default,\r\n Adfs\r\n}\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class Authority {\r\n constructor(authority: string, validateAuthority: boolean, authorityMetadata?: ITenantDiscoveryResponse) {\r\n this.IsValidationEnabled = validateAuthority;\r\n this.CanonicalAuthority = authority;\r\n\r\n this.validateAsUri();\r\n this.tenantDiscoveryResponse = authorityMetadata;\r\n }\r\n\r\n public static isAdfs(authorityUrl: string): boolean {\r\n const components = UrlUtils.GetUrlComponents(authorityUrl);\r\n const pathSegments = components.PathSegments;\r\n\r\n return (pathSegments.length && pathSegments[0].toLowerCase() === Constants.ADFS);\r\n }\r\n\r\n public get AuthorityType(): AuthorityType {\r\n return Authority.isAdfs(this.canonicalAuthority)? AuthorityType.Adfs : AuthorityType.Default;\r\n }\r\n\r\n public IsValidationEnabled: boolean;\r\n\r\n public get Tenant(): string {\r\n return this.CanonicalAuthorityUrlComponents.PathSegments[0];\r\n }\r\n\r\n private tenantDiscoveryResponse: ITenantDiscoveryResponse;\r\n\r\n public get AuthorizationEndpoint(): string {\r\n this.validateResolved();\r\n return this.tenantDiscoveryResponse.AuthorizationEndpoint.replace(/{tenant}|{tenantid}/g, this.Tenant);\r\n }\r\n\r\n public get EndSessionEndpoint(): string {\r\n this.validateResolved();\r\n return this.tenantDiscoveryResponse.EndSessionEndpoint.replace(/{tenant}|{tenantid}/g, this.Tenant);\r\n }\r\n\r\n public get SelfSignedJwtAudience(): string {\r\n this.validateResolved();\r\n return this.tenantDiscoveryResponse.Issuer.replace(/{tenant}|{tenantid}/g, this.Tenant);\r\n }\r\n\r\n private validateResolved() {\r\n if (!this.hasCachedMetadata()) {\r\n throw \"Please call ResolveEndpointsAsync first\";\r\n }\r\n }\r\n\r\n /**\r\n * A URL that is the authority set by the developer\r\n */\r\n public get CanonicalAuthority(): string {\r\n return this.canonicalAuthority;\r\n }\r\n\r\n public set CanonicalAuthority(url: string) {\r\n this.canonicalAuthority = UrlUtils.CanonicalizeUri(url);\r\n this.canonicalAuthorityUrlComponents = null;\r\n }\r\n\r\n private canonicalAuthority: string;\r\n private canonicalAuthorityUrlComponents: IUri;\r\n\r\n public get CanonicalAuthorityUrlComponents(): IUri {\r\n if (!this.canonicalAuthorityUrlComponents) {\r\n this.canonicalAuthorityUrlComponents = UrlUtils.GetUrlComponents(this.CanonicalAuthority);\r\n }\r\n\r\n return this.canonicalAuthorityUrlComponents;\r\n }\r\n\r\n // http://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata\r\n protected get DefaultOpenIdConfigurationEndpoint(): string {\r\n return (this.AuthorityType === AuthorityType.Adfs)? `${this.CanonicalAuthority}${WELL_KNOWN_SUFFIX}` : `${this.CanonicalAuthority}v2.0/${WELL_KNOWN_SUFFIX}`;\r\n }\r\n\r\n /**\r\n * Given a string, validate that it is of the form https://domain/path\r\n */\r\n private validateAsUri() {\r\n let components;\r\n try {\r\n components = this.CanonicalAuthorityUrlComponents;\r\n } catch (e) {\r\n throw ClientConfigurationErrorMessage.invalidAuthorityType;\r\n }\r\n\r\n if (!components.Protocol || components.Protocol.toLowerCase() !== \"https:\") {\r\n throw ClientConfigurationErrorMessage.authorityUriInsecure;\r\n }\r\n\r\n if (!components.PathSegments || components.PathSegments.length < 1) {\r\n throw ClientConfigurationErrorMessage.authorityUriInvalidPath;\r\n }\r\n }\r\n\r\n /**\r\n * Calls the OIDC endpoint and returns the response\r\n */\r\n private DiscoverEndpoints(openIdConfigurationEndpoint: string, telemetryManager: TelemetryManager, correlationId: string): Promise<ITenantDiscoveryResponse> {\r\n const client = new XhrClient();\r\n\r\n const httpMethod = NetworkRequestType.GET;\r\n const httpEvent: HttpEvent = telemetryManager.createAndStartHttpEvent(correlationId, httpMethod, openIdConfigurationEndpoint, \"openIdConfigurationEndpoint\");\r\n\r\n return client.sendRequestAsync(openIdConfigurationEndpoint, httpMethod, /* enableCaching: */ true)\r\n .then((response: XhrResponse) => {\r\n httpEvent.httpResponseStatus = response.statusCode;\r\n telemetryManager.stopEvent(httpEvent);\r\n return <ITenantDiscoveryResponse>{\r\n AuthorizationEndpoint: response.body[\"authorization_endpoint\"],\r\n EndSessionEndpoint: response.body[\"end_session_endpoint\"],\r\n Issuer: response.body[\"issuer\"]\r\n };\r\n })\r\n .catch(err => {\r\n httpEvent.serverErrorCode = err;\r\n telemetryManager.stopEvent(httpEvent);\r\n throw err;\r\n });\r\n }\r\n\r\n /**\r\n * Returns a promise.\r\n * Checks to see if the authority is in the cache\r\n * Discover endpoints via openid-configuration\r\n * If successful, caches the endpoint for later use in OIDC\r\n */\r\n public async resolveEndpointsAsync(telemetryManager: TelemetryManager, correlationId: string): Promise<ITenantDiscoveryResponse> {\r\n if (this.IsValidationEnabled) {\r\n const host = this.canonicalAuthorityUrlComponents.HostNameAndPort;\r\n if (TrustedAuthority.getTrustedHostList().length === 0) {\r\n await TrustedAuthority.setTrustedAuthoritiesFromNetwork(this.canonicalAuthority, telemetryManager, correlationId);\r\n }\r\n\r\n if (!TrustedAuthority.IsInTrustedHostList(host)) {\r\n throw ClientConfigurationError.createUntrustedAuthorityError(host);\r\n }\r\n }\r\n const openIdConfigurationEndpointResponse = this.GetOpenIdConfigurationEndpoint();\r\n this.tenantDiscoveryResponse = await this.DiscoverEndpoints(openIdConfigurationEndpointResponse, telemetryManager, correlationId);\r\n\r\n return this.tenantDiscoveryResponse;\r\n }\r\n\r\n /**\r\n * Checks if there is a cached tenant discovery response with required fields.\r\n */\r\n public hasCachedMetadata(): boolean {\r\n return !!(this.tenantDiscoveryResponse &&\r\n this.tenantDiscoveryResponse.AuthorizationEndpoint &&\r\n this.tenantDiscoveryResponse.EndSessionEndpoint &&\r\n this.tenantDiscoveryResponse.Issuer);\r\n }\r\n\r\n /**\r\n * Returns a promise which resolves to the OIDC endpoint\r\n * Only responds with the endpoint\r\n */\r\n public GetOpenIdConfigurationEndpoint(): string {\r\n return this.DefaultOpenIdConfigurationEndpoint;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\n/**\r\n * @hidden\r\n */\r\nimport { Authority } from \"./Authority\";\r\nimport { StringUtils } from \"../utils/StringUtils\";\r\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\r\nimport { ITenantDiscoveryResponse, OpenIdConfiguration } from \"./ITenantDiscoveryResponse\";\r\nimport TelemetryManager from \"../telemetry/TelemetryManager\";\r\n\r\nexport class AuthorityFactory {\r\n private static metadataMap = new Map<string, ITenantDiscoveryResponse>();\r\n\r\n public static async saveMetadataFromNetwork(authorityInstance: Authority, telemetryManager: TelemetryManager, correlationId: string): Promise<ITenantDiscoveryResponse> {\r\n const metadata = await authorityInstance.resolveEndpointsAsync(telemetryManager, correlationId);\r\n this.metadataMap.set(authorityInstance.CanonicalAuthority, metadata);\r\n return metadata;\r\n }\r\n\r\n public static getMetadata(authorityUrl: string): ITenantDiscoveryResponse {\r\n return this.metadataMap.get(authorityUrl);\r\n }\r\n\r\n public static saveMetadataFromConfig(authorityUrl: string, authorityMetadataJson: string): void {\r\n try {\r\n if (authorityMetadataJson) {\r\n const parsedMetadata = JSON.parse(authorityMetadataJson) as OpenIdConfiguration;\r\n\r\n if (!parsedMetadata.authorization_endpoint || !parsedMetadata.end_session_endpoint || !parsedMetadata.issuer) {\r\n throw ClientConfigurationError.createInvalidAuthorityMetadataError();\r\n }\r\n\r\n this.metadataMap.set(authorityUrl, {\r\n AuthorizationEndpoint: parsedMetadata.authorization_endpoint,\r\n EndSessionEndpoint: parsedMetadata.end_session_endpoint,\r\n Issuer: parsedMetadata.issuer\r\n });\r\n }\r\n } catch (e) {\r\n throw ClientConfigurationError.createInvalidAuthorityMetadataError();\r\n }\r\n }\r\n\r\n /**\r\n * Create an authority object of the correct type based on the url\r\n * Performs basic authority validation - checks to see if the authority is of a valid type (eg aad, b2c)\r\n */\r\n public static CreateInstance(authorityUrl: string, validateAuthority: boolean, authorityMetadata?: string): Authority {\r\n if (StringUtils.isEmpty(authorityUrl)) {\r\n return null;\r\n }\r\n\r\n if (authorityMetadata) {\r\n // todo: log statements\r\n this.saveMetadataFromConfig(authorityUrl, authorityMetadata);\r\n }\r\n return new Authority(authorityUrl, validateAuthority, this.metadataMap.get(authorityUrl));\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport TelemetryManager from \"../telemetry/TelemetryManager\";\r\nimport { XhrClient, XhrResponse } from \"../XHRClient\";\r\nimport HttpEvent from \"../telemetry/HttpEvent\";\r\nimport { AAD_INSTANCE_DISCOVERY_ENDPOINT, NetworkRequestType } from \"../utils/Constants\";\r\nimport { UrlUtils } from \"../utils/UrlUtils\";\r\n\r\nexport class TrustedAuthority {\r\n private static TrustedHostList: Array<string> = [];\r\n\r\n /**\r\n * \r\n * @param validateAuthority \r\n * @param knownAuthorities \r\n */\r\n public static setTrustedAuthoritiesFromConfig(validateAuthority: boolean, knownAuthorities: Array<string>): void{\r\n if (validateAuthority && !this.getTrustedHostList().length){\r\n knownAuthorities.forEach(function(authority) {\r\n TrustedAuthority.TrustedHostList.push(authority.toLowerCase());\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * \r\n * @param telemetryManager \r\n * @param correlationId \r\n */\r\n private static async getAliases(authorityToVerify: string, telemetryManager: TelemetryManager, correlationId?: string): Promise<Array<object>> {\r\n const client: XhrClient = new XhrClient();\r\n\r\n const httpMethod = NetworkRequestType.GET;\r\n const instanceDiscoveryEndpoint = `${AAD_INSTANCE_DISCOVERY_ENDPOINT}${authorityToVerify}oauth2/v2.0/authorize`;\r\n const httpEvent: HttpEvent = telemetryManager.createAndStartHttpEvent(correlationId, httpMethod, instanceDiscoveryEndpoint, \"getAliases\");\r\n return client.sendRequestAsync(instanceDiscoveryEndpoint, httpMethod, true)\r\n .then((response: XhrResponse) => {\r\n httpEvent.httpResponseStatus = response.statusCode;\r\n telemetryManager.stopEvent(httpEvent);\r\n return response.body[\"metadata\"];\r\n })\r\n .catch(err => {\r\n httpEvent.serverErrorCode = err;\r\n telemetryManager.stopEvent(httpEvent);\r\n throw err;\r\n });\r\n }\r\n\r\n /**\r\n * \r\n * @param telemetryManager \r\n * @param correlationId \r\n */\r\n public static async setTrustedAuthoritiesFromNetwork(authorityToVerify: string, telemetryManager: TelemetryManager, correlationId?: string): Promise<void> {\r\n const metadata = await this.getAliases(authorityToVerify, telemetryManager, correlationId);\r\n metadata.forEach(function(entry: object){\r\n const authorities: Array<string> = entry[\"aliases\"];\r\n authorities.forEach(function(authority: string) {\r\n TrustedAuthority.TrustedHostList.push(authority.toLowerCase());\r\n });\r\n });\r\n\r\n const host = UrlUtils.GetUrlComponents(authorityToVerify).HostNameAndPort;\r\n if (TrustedAuthority.getTrustedHostList().length && !TrustedAuthority.IsInTrustedHostList(host)){\r\n // Custom Domain scenario, host is trusted because Instance Discovery call succeeded\r\n TrustedAuthority.TrustedHostList.push(host.toLowerCase());\r\n }\r\n } \r\n\r\n public static getTrustedHostList(): Array<string> {\r\n return this.TrustedHostList;\r\n }\r\n\r\n /**\r\n * Checks to see if the host is in a list of trusted hosts\r\n * @param host \r\n */\r\n public static IsInTrustedHostList(host: string): boolean {\r\n return this.TrustedHostList.indexOf(host.toLowerCase()) > -1;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AccessTokenKey } from \"./AccessTokenKey\";\r\nimport { AccessTokenValue } from \"./AccessTokenValue\";\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class AccessTokenCacheItem {\r\n\r\n key: AccessTokenKey;\r\n value: AccessTokenValue;\r\n\r\n constructor(key: AccessTokenKey, value: AccessTokenValue) {\r\n this.key = key;\r\n this.value = value;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { CryptoUtils } from \"../utils/CryptoUtils\";\r\nimport { UrlUtils } from \"../utils/UrlUtils\";\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class AccessTokenKey {\r\n\r\n authority: string;\r\n clientId: string;\r\n scopes: string;\r\n homeAccountIdentifier: string;\r\n\r\n constructor(authority: string, clientId: string, scopes: string, uid: string, utid: string) {\r\n this.authority = UrlUtils.CanonicalizeUri(authority);\r\n this.clientId = clientId;\r\n this.scopes = scopes;\r\n this.homeAccountIdentifier = CryptoUtils.base64Encode(uid) + \".\" + CryptoUtils.base64Encode(utid);\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class AccessTokenValue {\r\n\r\n accessToken: string;\r\n idToken: string;\r\n expiresIn: string;\r\n homeAccountIdentifier: string;\r\n\r\n constructor(accessToken: string, idToken: string, expiresIn: string, homeAccountIdentifier: string) {\r\n this.accessToken = accessToken;\r\n this.idToken = idToken;\r\n this.expiresIn = expiresIn;\r\n this.homeAccountIdentifier = homeAccountIdentifier;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { Constants, PersistentCacheKeys, TemporaryCacheKeys, ErrorCacheKeys, ServerHashParamKeys, SESSION_STORAGE} from \"../utils/Constants\";\r\nimport { AccessTokenCacheItem } from \"./AccessTokenCacheItem\";\r\nimport { CacheLocation } from \"../Configuration\";\r\nimport { BrowserStorage } from \"./BrowserStorage\";\r\nimport { RequestUtils } from \"../utils/RequestUtils\";\r\nimport { AccessTokenKey } from \"./AccessTokenKey\";\r\nimport { StringUtils } from \"../utils/StringUtils\";\r\nimport { IdToken } from \"../IdToken\";\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class AuthCache extends BrowserStorage {// Singleton\r\n\r\n private clientId: string;\r\n private rollbackEnabled: boolean;\r\n private temporaryCache: BrowserStorage;\r\n\r\n constructor(clientId: string, cacheLocation: CacheLocation, storeAuthStateInCookie: boolean) {\r\n super(cacheLocation);\r\n this.temporaryCache = new BrowserStorage(SESSION_STORAGE);\r\n this.clientId = clientId;\r\n // This is hardcoded to true for now. We may make this configurable in the future\r\n this.rollbackEnabled = true;\r\n this.migrateCacheEntries(storeAuthStateInCookie);\r\n }\r\n\r\n /**\r\n * Support roll back to old cache schema until the next major release: true by default now\r\n * @param storeAuthStateInCookie\r\n */\r\n private migrateCacheEntries(storeAuthStateInCookie: boolean) {\r\n\r\n const idTokenKey = `${Constants.cachePrefix}.${PersistentCacheKeys.IDTOKEN}`;\r\n const clientInfoKey = `${Constants.cachePrefix}.${PersistentCacheKeys.CLIENT_INFO}`;\r\n const errorKey = `${Constants.cachePrefix}.${ErrorCacheKeys.ERROR}`;\r\n const errorDescKey = `${Constants.cachePrefix}.${ErrorCacheKeys.ERROR_DESC}`;\r\n\r\n const idTokenValue = super.getItem(idTokenKey);\r\n\r\n let idToken;\r\n\r\n if (idTokenValue) {\r\n try {\r\n idToken = new IdToken(idTokenValue);\r\n } catch (e) {\r\n return;\r\n }\r\n }\r\n\r\n if (idToken && idToken.claims && idToken.claims.aud === this.clientId) {\r\n const clientInfoValue = super.getItem(clientInfoKey);\r\n const errorValue = super.getItem(errorKey);\r\n const errorDescValue = super.getItem(errorDescKey);\r\n\r\n const values = [idTokenValue, clientInfoValue, errorValue, errorDescValue];\r\n const keysToMigrate = [PersistentCacheKeys.IDTOKEN, PersistentCacheKeys.CLIENT_INFO,ErrorCacheKeys.ERROR, ErrorCacheKeys.ERROR_DESC];\r\n\r\n keysToMigrate.forEach((cacheKey, index) => this.duplicateCacheEntry(cacheKey, values[index], storeAuthStateInCookie));\r\n }\r\n }\r\n\r\n /**\r\n * Utility function to help with roll back keys\r\n * @param newKey\r\n * @param value\r\n * @param storeAuthStateInCookie\r\n */\r\n private duplicateCacheEntry(newKey: string, value: string, storeAuthStateInCookie?: boolean) {\r\n if (value) {\r\n this.setItem(newKey, value, storeAuthStateInCookie);\r\n }\r\n }\r\n\r\n /**\r\n * Prepend msal.<client-id> to each key; Skip for any JSON object as Key (defined schemas do not need the key appended: AccessToken Keys or the upcoming schema)\r\n * @param key\r\n * @param addInstanceId\r\n */\r\n private generateCacheKey(key: string, addInstanceId: boolean): string {\r\n try {\r\n // Defined schemas do not need the key appended\r\n JSON.parse(key);\r\n return key;\r\n } catch (e) {\r\n if (key.indexOf(`${Constants.cachePrefix}`) === 0 || key.indexOf(Constants.adalIdToken) === 0){\r\n return key;\r\n }\r\n return addInstanceId ? `${Constants.cachePrefix}.${this.clientId}.${key}` : `${Constants.cachePrefix}.${key}`;\r\n }\r\n }\r\n\r\n /**\r\n * Validates that the input cache key contains the account search terms (clientId and homeAccountIdentifier) and\r\n * then whether or not it contains the \"scopes\", depending on the token type being searched for. With matching account\r\n * search terms, Access Token search tries to match the \"scopes\" keyword, while Id Token search expects \"scopes\" to not be included.\r\n * @param key \r\n * @param clientId \r\n * @param homeAccountIdentifier \r\n * @param tokenType \r\n */\r\n private matchKeyForType(key:string, clientId: string, homeAccountIdentifier: string, tokenType: string): AccessTokenKey {\r\n // All valid token cache item keys are valid JSON objects, ignore keys that aren't\r\n const parsedKey = StringUtils.validateAndParseJsonCacheKey(key);\r\n\r\n if (!parsedKey) {\r\n return null;\r\n }\r\n\r\n // Does the cache item match the request account\r\n const accountMatches = key.match(clientId) && key.match(homeAccountIdentifier);\r\n // Does the cache item match the requested token type\r\n let tokenTypeMatches = false;\r\n\r\n switch (tokenType) {\r\n case ServerHashParamKeys.ACCESS_TOKEN:\r\n // Cache item is an access token if scopes are included in the cache item key\r\n tokenTypeMatches = !!key.match(Constants.scopes);\r\n break;\r\n case ServerHashParamKeys.ID_TOKEN:\r\n // Cache may be an ID token if scopes are NOT included in the cache item key\r\n tokenTypeMatches = !key.match(Constants.scopes);\r\n break;\r\n }\r\n\r\n return (accountMatches && tokenTypeMatches) ? parsedKey : null;\r\n }\r\n\r\n /**\r\n * add value to storage\r\n * @param key\r\n * @param value\r\n * @param enableCookieStorage\r\n */\r\n setItem(key: string, value: string, enableCookieStorage?: boolean): void {\r\n super.setItem(this.generateCacheKey(key, true), value, enableCookieStorage);\r\n\r\n // Values stored in cookies will have rollback disabled to minimize cookie length\r\n if (this.rollbackEnabled && !enableCookieStorage) {\r\n super.setItem(this.generateCacheKey(key, false), value, enableCookieStorage);\r\n }\r\n }\r\n\r\n /**\r\n * get one item by key from storage\r\n * @param key\r\n * @param enableCookieStorage\r\n */\r\n getItem(key: string, enableCookieStorage?: boolean): string {\r\n return super.getItem(this.generateCacheKey(key, true), enableCookieStorage);\r\n }\r\n\r\n /**\r\n * remove value from storage\r\n * @param key\r\n */\r\n removeItem(key: string): void {\r\n this.temporaryCache.removeItem(this.generateCacheKey(key, true));\r\n super.removeItem(this.generateCacheKey(key, true));\r\n if (this.rollbackEnabled) {\r\n super.removeItem(this.generateCacheKey(key, false));\r\n }\r\n }\r\n\r\n /**\r\n * Sets temporary cache value\r\n * @param key \r\n * @param value \r\n * @param enableCookieStorage \r\n */\r\n setTemporaryItem(key: string, value: string, enableCookieStorage?: boolean): void {\r\n this.temporaryCache.setItem(this.generateCacheKey(key, true), value, enableCookieStorage);\r\n }\r\n\r\n /**\r\n * Gets temporary cache value\r\n * @param key \r\n * @param enableCookieStorage \r\n */\r\n getTemporaryItem(key: string, enableCookieStorage?: boolean): string {\r\n return this.temporaryCache.getItem(this.generateCacheKey(key, true), enableCookieStorage);\r\n }\r\n\r\n /**\r\n * Reset the cache items\r\n */\r\n resetCacheItems(): void {\r\n const storage = window[this.cacheLocation];\r\n let key: string;\r\n for (key in storage) {\r\n // Check if key contains msal prefix; For now, we are clearing all cache items created by MSAL.js\r\n if (storage.hasOwnProperty(key) && (key.indexOf(Constants.cachePrefix) !== -1)) {\r\n super.removeItem(key);\r\n // TODO: Clear cache based on client id (clarify use cases where this is needed)\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Reset all temporary cache items\r\n */\r\n resetTempCacheItems(state?: string): void {\r\n const stateId = state && RequestUtils.parseLibraryState(state).id;\r\n const isTokenRenewalInProgress = this.tokenRenewalInProgress(state);\r\n\r\n const storage = window[this.cacheLocation];\r\n // check state and remove associated cache\r\n if (stateId && !isTokenRenewalInProgress) {\r\n Object.keys(storage).forEach(key => {\r\n if (key.indexOf(stateId) !== -1) {\r\n this.removeItem(key);\r\n super.clearItemCookie(key);\r\n }\r\n });\r\n }\r\n // delete the interaction status cache\r\n this.setInteractionInProgress(false);\r\n this.removeItem(TemporaryCacheKeys.REDIRECT_REQUEST);\r\n }\r\n\r\n /**\r\n * Set cookies for IE\r\n * @param cName\r\n * @param cValue\r\n * @param expires\r\n */\r\n setItemCookie(cName: string, cValue: string, expires?: number): void {\r\n super.setItemCookie(this.generateCacheKey(cName, true), cValue, expires);\r\n if (this.rollbackEnabled) {\r\n super.setItemCookie(this.generateCacheKey(cName, false), cValue, expires);\r\n }\r\n }\r\n\r\n clearItemCookie(cName: string): void {\r\n super.clearItemCookie(this.generateCacheKey(cName, true));\r\n if (this.rollbackEnabled) {\r\n super.clearItemCookie(this.generateCacheKey(cName, false));\r\n }\r\n }\r\n\r\n /**\r\n * get one item by key from cookies\r\n * @param cName\r\n */\r\n getItemCookie(cName: string): string {\r\n return super.getItemCookie(this.generateCacheKey(cName, true));\r\n }\r\n\r\n /**\r\n * Get all tokens of a certain type from the cache\r\n * @param clientId \r\n * @param homeAccountIdentifier \r\n * @param tokenType\r\n */\r\n getAllTokensByType(clientId: string, homeAccountIdentifier: string, tokenType: string): Array<AccessTokenCacheItem> {\r\n const results = Object.keys(window[this.cacheLocation]).reduce((tokens, key) => {\r\n const matchedTokenKey: AccessTokenKey = this.matchKeyForType(key, clientId, homeAccountIdentifier, tokenType);\r\n if (matchedTokenKey) {\r\n const value = this.getItem(key);\r\n if (value) {\r\n try {\r\n const newAccessTokenCacheItem = new AccessTokenCacheItem(matchedTokenKey, JSON.parse(value));\r\n return tokens.concat([ newAccessTokenCacheItem ]);\r\n } catch (err) {\r\n // Skip cache items with non-valid JSON values\r\n return tokens;\r\n }\r\n }\r\n }\r\n\r\n return tokens;\r\n }, []);\r\n return results;\r\n }\r\n\r\n /**\r\n * Get all access tokens in the cache\r\n * @param clientId\r\n * @param homeAccountIdentifier\r\n */\r\n getAllAccessTokens(clientId: string, homeAccountIdentifier: string): Array<AccessTokenCacheItem> {\r\n return this.getAllTokensByType(clientId, homeAccountIdentifier, ServerHashParamKeys.ACCESS_TOKEN);\r\n }\r\n\r\n /**\r\n * Get all id tokens in the cache in the form of AccessTokenCacheItem objects so they are \r\n * in a normalized format and can make use of the existing cached access token validation logic\r\n */\r\n getAllIdTokens(clientId: string, homeAccountIdentifier: string): Array<AccessTokenCacheItem> {\r\n return this.getAllTokensByType(clientId, homeAccountIdentifier, ServerHashParamKeys.ID_TOKEN);\r\n }\r\n\r\n /**\r\n * Get all access and ID tokens in the cache\r\n * @param clientId \r\n * @param homeAccountIdentifier \r\n */\r\n getAllTokens(clientId: string, homeAccountIdentifier: string): Array<AccessTokenCacheItem> {\r\n const accessTokens = this.getAllAccessTokens(clientId, homeAccountIdentifier);\r\n const idTokens = this.getAllIdTokens(clientId, homeAccountIdentifier);\r\n return [...accessTokens, ...idTokens];\r\n }\r\n\r\n /**\r\n * Returns whether or not interaction is currently in progress. Optionally scope it to just this clientId\r\n * @param forThisClient \r\n */\r\n isInteractionInProgress(matchClientId: boolean): boolean {\r\n const clientId = this.getInteractionInProgress();\r\n if (matchClientId) {\r\n return clientId === this.clientId;\r\n } else {\r\n return !!clientId;\r\n }\r\n }\r\n\r\n /**\r\n * Returns the clientId of the interaction currently in progress\r\n */\r\n getInteractionInProgress(): string {\r\n return this.getTemporaryItem(this.generateCacheKey(TemporaryCacheKeys.INTERACTION_STATUS, false));\r\n }\r\n\r\n /**\r\n * Sets interaction in progress state\r\n * @param isInProgress \r\n */\r\n setInteractionInProgress(newInProgressValue: boolean): void {\r\n if (newInProgressValue && !this.isInteractionInProgress(false)) {\r\n // Ensure we don't overwrite interaction in progress for a different clientId\r\n this.setTemporaryItem(this.generateCacheKey(TemporaryCacheKeys.INTERACTION_STATUS, false), this.clientId);\r\n } else if (!newInProgressValue && this.isInteractionInProgress(true)) {\r\n // Only remove if the current in progress interaction is for this clientId\r\n this.removeItem(this.generateCacheKey(TemporaryCacheKeys.INTERACTION_STATUS, false));\r\n }\r\n }\r\n\r\n /**\r\n * Return if the token renewal is still in progress\r\n * \r\n * @param stateValue\r\n */\r\n private tokenRenewalInProgress(stateValue: string): boolean {\r\n const renewStatus = this.getItem(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.RENEW_STATUS, stateValue));\r\n return !!(renewStatus && renewStatus === Constants.inProgress);\r\n }\r\n\r\n /**\r\n * Clear all cookies\r\n */\r\n public clearMsalCookie(state?: string): void {\r\n /*\r\n * If state is truthy, remove values associated with that request.\r\n * Otherwise, remove all MSAL cookies.\r\n */\r\n if (state) {\r\n this.clearItemCookie(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.NONCE_IDTOKEN, state));\r\n this.clearItemCookie(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.STATE_LOGIN, state));\r\n this.clearItemCookie(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.LOGIN_REQUEST, state));\r\n this.clearItemCookie(AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.STATE_ACQ_TOKEN, state));\r\n } else {\r\n const cookies = document.cookie.split(\";\");\r\n cookies.forEach(cookieString => {\r\n const [\r\n cookieName\r\n ] = cookieString.trim().split(\"=\");\r\n\r\n if (cookieName.indexOf(Constants.cachePrefix) > -1) {\r\n super.clearItemCookie(cookieName);\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Create acquireTokenAccountKey to cache account object\r\n * @param accountId\r\n * @param state\r\n */\r\n public static generateAcquireTokenAccountKey(accountId: string, state: string): string {\r\n const stateId = RequestUtils.parseLibraryState(state).id;\r\n return `${TemporaryCacheKeys.ACQUIRE_TOKEN_ACCOUNT}${Constants.resourceDelimiter}${accountId}${Constants.resourceDelimiter}${stateId}`;\r\n }\r\n\r\n /**\r\n * Create authorityKey to cache authority\r\n * @param state\r\n */\r\n public static generateAuthorityKey(state: string): string {\r\n return AuthCache.generateTemporaryCacheKey(TemporaryCacheKeys.AUTHORITY, state);\r\n }\r\n\r\n /**\r\n * Generates the cache key for temporary cache items, using request state\r\n * @param tempCacheKey Cache key prefix\r\n * @param state Request state value\r\n */\r\n public static generateTemporaryCacheKey(tempCacheKey: TemporaryCacheKeys, state: string): string {\r\n // Use the state id (a guid), in the interest of shorter key names, which is important for cookies.\r\n const stateId = RequestUtils.parseLibraryState(state).id;\r\n return `${tempCacheKey}${Constants.resourceDelimiter}${stateId}`;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { CacheLocation } from \"../Configuration\";\r\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\r\nimport { AuthError } from \"../error/AuthError\";\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class BrowserStorage {// Singleton\r\n\r\n protected cacheLocation: CacheLocation;\r\n\r\n constructor(cacheLocation: CacheLocation) {\r\n if (!window) {\r\n throw AuthError.createNoWindowObjectError(\"Browser storage class could not find window object\");\r\n }\r\n\r\n const storageSupported = typeof window[cacheLocation] !== \"undefined\" && window[cacheLocation] !== null;\r\n if (!storageSupported) {\r\n throw ClientConfigurationError.createStorageNotSupportedError(cacheLocation);\r\n }\r\n this.cacheLocation = cacheLocation;\r\n }\r\n\r\n /**\r\n * add value to storage\r\n * @param key\r\n * @param value\r\n * @param enableCookieStorage\r\n */\r\n setItem(key: string, value: string, enableCookieStorage?: boolean): void {\r\n window[this.cacheLocation].setItem(key, value);\r\n if (enableCookieStorage) {\r\n this.setItemCookie(key, value);\r\n }\r\n }\r\n\r\n /**\r\n * get one item by key from storage\r\n * @param key\r\n * @param enableCookieStorage\r\n */\r\n getItem(key: string, enableCookieStorage?: boolean): string {\r\n if (enableCookieStorage && this.getItemCookie(key)) {\r\n return this.getItemCookie(key);\r\n }\r\n return window[this.cacheLocation].getItem(key);\r\n }\r\n\r\n /**\r\n * remove value from storage\r\n * @param key\r\n */\r\n removeItem(key: string): void {\r\n return window[this.cacheLocation].removeItem(key);\r\n }\r\n\r\n /**\r\n * clear storage (remove all items from it)\r\n */\r\n clear(): void {\r\n return window[this.cacheLocation].clear();\r\n }\r\n\r\n /**\r\n * add value to cookies\r\n * @param cName\r\n * @param cValue\r\n * @param expires\r\n */\r\n setItemCookie(cName: string, cValue: string, expires?: number): void {\r\n let cookieStr = encodeURIComponent(cName) + \"=\" + encodeURIComponent(cValue) + \";path=/;\";\r\n if (expires) {\r\n const expireTime = this.getCookieExpirationTime(expires);\r\n cookieStr += \"expires=\" + expireTime + \";\";\r\n }\r\n\r\n document.cookie = cookieStr;\r\n }\r\n\r\n /**\r\n * get one item by key from cookies\r\n * @param cName\r\n */\r\n getItemCookie(cName: string): string {\r\n const name = encodeURIComponent(cName) + \"=\";\r\n const ca = document.cookie.split(\";\");\r\n for (let i = 0; i < ca.length; i++) {\r\n let c = ca[i];\r\n while (c.charAt(0) === \" \") {\r\n c = c.substring(1);\r\n }\r\n if (c.indexOf(name) === 0) {\r\n return decodeURIComponent(c.substring(name.length, c.length));\r\n }\r\n }\r\n return \"\";\r\n }\r\n\r\n /**\r\n * Clear an item in the cookies by key\r\n * @param cName\r\n */\r\n clearItemCookie(cName: string): void {\r\n this.setItemCookie(cName, \"\", -1);\r\n }\r\n\r\n /**\r\n * Get cookie expiration time\r\n * @param cookieLifeDays\r\n */\r\n getCookieExpirationTime(cookieLifeDays: number): string {\r\n const today = new Date();\r\n const expr = new Date(today.getTime() + cookieLifeDays * 24 * 60 * 60 * 1000);\r\n return expr.toUTCString();\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nexport const AuthErrorMessage = {\r\n unexpectedError: {\r\n code: \"unexpected_error\",\r\n desc: \"Unexpected error in authentication.\"\r\n },\r\n noWindowObjectError: {\r\n code: \"no_window_object\",\r\n desc: \"No window object available. Details:\"\r\n }\r\n};\r\n\r\n/**\r\n * General error class thrown by the MSAL.js library.\r\n */\r\nexport class AuthError extends Error {\r\n\r\n errorCode: string;\r\n errorMessage: string;\r\n\r\n constructor(errorCode: string, errorMessage?: string) {\r\n super(errorMessage);\r\n Object.setPrototypeOf(this, AuthError.prototype);\r\n\r\n this.errorCode = errorCode;\r\n this.errorMessage = errorMessage;\r\n this.name = \"AuthError\";\r\n }\r\n\r\n static createUnexpectedError(errDesc: string): AuthError {\r\n return new AuthError(AuthErrorMessage.unexpectedError.code, `${AuthErrorMessage.unexpectedError.desc}: ${errDesc}`);\r\n }\r\n\r\n static createNoWindowObjectError(errDesc: string): AuthError {\r\n return new AuthError(AuthErrorMessage.noWindowObjectError.code, `${AuthErrorMessage.noWindowObjectError.desc} ${errDesc}`);\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AuthError } from \"./AuthError\";\r\nimport { IdToken } from \"../IdToken\";\r\nimport { StringUtils } from \"../utils/StringUtils\";\r\n\r\nexport const ClientAuthErrorMessage = {\r\n endpointResolutionError: {\r\n code: \"endpoints_resolution_error\",\r\n desc: \"Error: could not resolve endpoints. Please check network and try again.\"\r\n },\r\n popUpWindowError: {\r\n code: \"popup_window_error\",\r\n desc: \"Error opening popup window. This can happen if you are using IE or if popups are blocked in the browser.\"\r\n },\r\n tokenRenewalError: {\r\n code: \"token_renewal_error\",\r\n desc: \"Token renewal operation failed due to timeout.\"\r\n },\r\n invalidIdToken: {\r\n code: \"invalid_id_token\",\r\n desc: \"Invalid ID token format.\"\r\n },\r\n invalidStateError: {\r\n code: \"invalid_state_error\",\r\n desc: \"Invalid state.\"\r\n },\r\n nonceMismatchError: {\r\n code: \"nonce_mismatch_error\",\r\n desc: \"Nonce is not matching, Nonce received: \"\r\n },\r\n loginProgressError: {\r\n code: \"login_progress_error\",\r\n desc: \"Login_In_Progress: Error during login call - login is already in progress.\"\r\n },\r\n acquireTokenProgressError: {\r\n code: \"acquiretoken_progress_error\",\r\n desc: \"AcquireToken_In_Progress: Error during login call - login is already in progress.\"\r\n },\r\n userCancelledError: {\r\n code: \"user_cancelled\",\r\n desc: \"User cancelled the flow.\"\r\n },\r\n callbackError: {\r\n code: \"callback_error\",\r\n desc: \"Error occurred in token received callback function.\"\r\n },\r\n userLoginRequiredError: {\r\n code: \"user_login_error\",\r\n desc: \"User login is required. For silent calls, request must contain either sid or login_hint\"\r\n },\r\n userDoesNotExistError: {\r\n code: \"user_non_existent\",\r\n desc: \"User object does not exist. Please call a login API.\"\r\n },\r\n clientInfoDecodingError: {\r\n code: \"client_info_decoding_error\",\r\n desc: \"The client info could not be parsed/decoded correctly. Please review the trace to determine the root cause.\"\r\n },\r\n clientInfoNotPopulatedError: {\r\n code: \"client_info_not_populated_error\",\r\n desc: \"The service did not populate client_info in the response, Please verify with the service team\"\r\n },\r\n nullOrEmptyIdToken: {\r\n code: \"null_or_empty_id_token\",\r\n desc: \"The idToken is null or empty. Please review the trace to determine the root cause.\"\r\n },\r\n idTokenNotParsed: {\r\n code: \"id_token_parsing_error\",\r\n desc: \"ID token cannot be parsed. Please review stack trace to determine root cause.\"\r\n },\r\n tokenEncodingError: {\r\n code: \"token_encoding_error\",\r\n desc: \"The token to be decoded is not encoded correctly.\"\r\n },\r\n invalidInteractionType: {\r\n code: \"invalid_interaction_type\",\r\n desc: \"The interaction type passed to the handler was incorrect or unknown\"\r\n },\r\n cacheParseError: {\r\n code: \"cannot_parse_cache\",\r\n desc: \"The cached token key is not a valid JSON and cannot be parsed\"\r\n },\r\n blockTokenRequestsInHiddenIframe: {\r\n code: \"block_token_requests\",\r\n desc: \"Token calls are blocked in hidden iframes\"\r\n }\r\n};\r\n\r\n/**\r\n * Error thrown when there is an error in the client code running on the browser.\r\n */\r\nexport class ClientAuthError extends AuthError {\r\n\r\n constructor(errorCode: string, errorMessage?: string) {\r\n super(errorCode, errorMessage);\r\n this.name = \"ClientAuthError\";\r\n\r\n Object.setPrototypeOf(this, ClientAuthError.prototype);\r\n }\r\n\r\n static createEndpointResolutionError(errDetail?: string): ClientAuthError {\r\n let errorMessage = ClientAuthErrorMessage.endpointResolutionError.desc;\r\n if (errDetail && !StringUtils.isEmpty(errDetail)) {\r\n errorMessage += ` Details: ${errDetail}`;\r\n }\r\n return new ClientAuthError(ClientAuthErrorMessage.endpointResolutionError.code, errorMessage);\r\n }\r\n\r\n static createPopupWindowError(errDetail?: string): ClientAuthError {\r\n let errorMessage = ClientAuthErrorMessage.popUpWindowError.desc;\r\n if (errDetail && !StringUtils.isEmpty(errDetail)) {\r\n errorMessage += ` Details: ${errDetail}`;\r\n }\r\n return new ClientAuthError(ClientAuthErrorMessage.popUpWindowError.code, errorMessage);\r\n }\r\n\r\n static createTokenRenewalTimeoutError(): ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.tokenRenewalError.code, ClientAuthErrorMessage.tokenRenewalError.desc);\r\n }\r\n\r\n static createInvalidIdTokenError(idToken: IdToken) : ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidIdToken.code,\r\n `${ClientAuthErrorMessage.invalidIdToken.desc} Given token: ${idToken}`);\r\n }\r\n\r\n // TODO: Is this not a security flaw to send the user the state expected??\r\n static createInvalidStateError(invalidState: string, actualState: string): ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidStateError.code,\r\n `${ClientAuthErrorMessage.invalidStateError.desc} ${invalidState}, state expected : ${actualState}.`);\r\n }\r\n\r\n // TODO: Is this not a security flaw to send the user the Nonce expected??\r\n static createNonceMismatchError(invalidNonce: string, actualNonce: string): ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.nonceMismatchError.code,\r\n `${ClientAuthErrorMessage.nonceMismatchError.desc} ${invalidNonce}, nonce expected : ${actualNonce}.`);\r\n }\r\n\r\n static createLoginInProgressError(): ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.loginProgressError.code,\r\n ClientAuthErrorMessage.loginProgressError.desc);\r\n }\r\n\r\n static createAcquireTokenInProgressError(): ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.acquireTokenProgressError.code,\r\n ClientAuthErrorMessage.acquireTokenProgressError.desc);\r\n }\r\n\r\n static createUserCancelledError(): ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.userCancelledError.code,\r\n ClientAuthErrorMessage.userCancelledError.desc);\r\n }\r\n\r\n static createErrorInCallbackFunction(errorDesc: string): ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.callbackError.code,\r\n `${ClientAuthErrorMessage.callbackError.desc} ${errorDesc}.`);\r\n }\r\n\r\n static createUserLoginRequiredError() : ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.userLoginRequiredError.code,\r\n ClientAuthErrorMessage.userLoginRequiredError.desc);\r\n }\r\n\r\n static createUserDoesNotExistError() : ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.userDoesNotExistError.code,\r\n ClientAuthErrorMessage.userDoesNotExistError.desc);\r\n }\r\n\r\n static createClientInfoDecodingError(caughtError: string) : ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.clientInfoDecodingError.code,\r\n `${ClientAuthErrorMessage.clientInfoDecodingError.desc} Failed with error: ${caughtError}`);\r\n }\r\n\r\n static createClientInfoNotPopulatedError(caughtError: string) : ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.clientInfoNotPopulatedError.code,\r\n `${ClientAuthErrorMessage.clientInfoNotPopulatedError.desc} Failed with error: ${caughtError}`);\r\n }\r\n\r\n static createIdTokenNullOrEmptyError(invalidRawTokenString: string) : ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.nullOrEmptyIdToken.code,\r\n `${ClientAuthErrorMessage.nullOrEmptyIdToken.desc} Raw ID Token Value: ${invalidRawTokenString}`);\r\n }\r\n\r\n static createIdTokenParsingError(caughtParsingError: string) : ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.idTokenNotParsed.code,\r\n `${ClientAuthErrorMessage.idTokenNotParsed.desc} Failed with error: ${caughtParsingError}`);\r\n }\r\n\r\n static createTokenEncodingError(incorrectlyEncodedToken: string) : ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.tokenEncodingError.code,\r\n `${ClientAuthErrorMessage.tokenEncodingError.desc} Attempted to decode: ${incorrectlyEncodedToken}`);\r\n }\r\n\r\n static createInvalidInteractionTypeError() : ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidInteractionType.code,\r\n ClientAuthErrorMessage.invalidInteractionType.desc);\r\n }\r\n\r\n static createCacheParseError(key: string) : ClientAuthError {\r\n const errorMessage = `invalid key: ${key}, ${ClientAuthErrorMessage.cacheParseError.desc}`;\r\n return new ClientAuthError(ClientAuthErrorMessage.cacheParseError.code,\r\n errorMessage);\r\n }\r\n\r\n static createBlockTokenRequestsInHiddenIframeError(): ClientAuthError {\r\n return new ClientAuthError(ClientAuthErrorMessage.blockTokenRequestsInHiddenIframe.code,\r\n ClientAuthErrorMessage.blockTokenRequestsInHiddenIframe.desc);\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ClientAuthError } from \"./ClientAuthError\";\r\nimport { TelemetryOptions } from \"../Configuration\";\r\n\r\ninterface IClientConfigurationErrorMessage {\r\n code: string,\r\n desc: string\r\n}\r\n\r\nexport const ClientConfigurationErrorMessage: Record<string, IClientConfigurationErrorMessage> = {\r\n configurationNotSet: {\r\n code: \"no_config_set\",\r\n desc: \"Configuration has not been set. Please call the UserAgentApplication constructor with a valid Configuration object.\"\r\n },\r\n storageNotSupported: {\r\n code: \"storage_not_supported\",\r\n desc: \"The value for the cacheLocation is not supported.\"\r\n },\r\n noRedirectCallbacksSet: {\r\n code: \"no_redirect_callbacks\",\r\n desc: \"No redirect callbacks have been set. Please call handleRedirectCallback() with the appropriate function arguments before continuing. \" +\r\n \"More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics.\"\r\n },\r\n invalidCallbackObject: {\r\n code: \"invalid_callback_object\",\r\n desc: \"The object passed for the callback was invalid. \" +\r\n \"More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics.\"\r\n },\r\n scopesRequired: {\r\n code: \"scopes_required\",\r\n desc: \"Scopes are required to obtain an access token.\"\r\n },\r\n emptyScopes: {\r\n code: \"empty_input_scopes_error\",\r\n desc: \"Scopes cannot be passed as empty array.\"\r\n },\r\n nonArrayScopes: {\r\n code: \"nonarray_input_scopes_error\",\r\n desc: \"Scopes cannot be passed as non-array.\"\r\n },\r\n invalidPrompt: {\r\n code: \"invalid_prompt_value\",\r\n desc: \"Supported prompt values are 'login', 'select_account', 'consent' and 'none'\",\r\n },\r\n invalidAuthorityType: {\r\n code: \"invalid_authority_type\",\r\n desc: \"The given authority is not a valid type of authority supported by MSAL. Please see here for valid authorities: <insert URL here>.\"\r\n },\r\n authorityUriInsecure: {\r\n code: \"authority_uri_insecure\",\r\n desc: \"Authority URIs must use https.\"\r\n },\r\n authorityUriInvalidPath: {\r\n code: \"authority_uri_invalid_path\",\r\n desc: \"Given authority URI is invalid.\"\r\n },\r\n unsupportedAuthorityValidation: {\r\n code: \"unsupported_authority_validation\",\r\n desc: \"The authority validation is not supported for this authority type.\"\r\n },\r\n untrustedAuthority: {\r\n code: \"untrusted_authority\",\r\n desc: \"The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter or set validateAuthority=false.\"\r\n },\r\n b2cAuthorityUriInvalidPath: {\r\n code: \"b2c_authority_uri_invalid_path\",\r\n desc: \"The given URI for the B2C authority is invalid.\"\r\n },\r\n b2cKnownAuthoritiesNotSet: {\r\n code: \"b2c_known_authorities_not_set\",\r\n desc: \"Must set known authorities when validateAuthority is set to True and using B2C\"\r\n },\r\n claimsRequestParsingError: {\r\n code: \"claims_request_parsing_error\",\r\n desc: \"Could not parse the given claims request object.\"\r\n },\r\n emptyRequestError: {\r\n code: \"empty_request_error\",\r\n desc: \"Request object is required.\"\r\n },\r\n invalidCorrelationIdError: {\r\n code: \"invalid_guid_sent_as_correlationId\",\r\n desc: \"Please set the correlationId as a valid guid\"\r\n },\r\n telemetryConfigError: {\r\n code: \"telemetry_config_error\",\r\n desc: \"Telemetry config is not configured with required values\"\r\n },\r\n ssoSilentError: {\r\n code: \"sso_silent_error\",\r\n desc: \"request must contain either sid or login_hint\"\r\n },\r\n invalidAuthorityMetadataError: {\r\n code: \"authority_metadata_error\",\r\n desc: \"Invalid authorityMetadata. Must be a JSON object containing authorization_endpoint, end_session_endpoint, and issuer fields.\"\r\n }\r\n};\r\n\r\n/**\r\n * Error thrown when there is an error in configuration of the .js library.\r\n */\r\nexport class ClientConfigurationError extends ClientAuthError {\r\n\r\n constructor(errorCode: string, errorMessage?: string) {\r\n super(errorCode, errorMessage);\r\n this.name = \"ClientConfigurationError\";\r\n Object.setPrototypeOf(this, ClientConfigurationError.prototype);\r\n }\r\n\r\n static createNoSetConfigurationError(): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.configurationNotSet.code,\r\n `${ClientConfigurationErrorMessage.configurationNotSet.desc}`);\r\n }\r\n\r\n static createStorageNotSupportedError(givenCacheLocation: string) : ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.storageNotSupported.code,\r\n `${ClientConfigurationErrorMessage.storageNotSupported.desc} Given location: ${givenCacheLocation}`);\r\n }\r\n\r\n static createRedirectCallbacksNotSetError(): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.noRedirectCallbacksSet.code, ClientConfigurationErrorMessage.noRedirectCallbacksSet.desc);\r\n }\r\n\r\n static createInvalidCallbackObjectError(callbackObject: object): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidCallbackObject.code,\r\n `${ClientConfigurationErrorMessage.invalidCallbackObject.desc} Given value for callback function: ${callbackObject}`);\r\n }\r\n\r\n static createEmptyScopesArrayError(scopesValue: string): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.emptyScopes.code,\r\n `${ClientConfigurationErrorMessage.emptyScopes.desc} Given value: ${scopesValue}.`);\r\n }\r\n\r\n static createScopesNonArrayError(scopesValue: string): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.nonArrayScopes.code,\r\n `${ClientConfigurationErrorMessage.nonArrayScopes.desc} Given value: ${scopesValue}.`);\r\n }\r\n\r\n static createScopesRequiredError(scopesValue: string[]): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.scopesRequired.code,\r\n `${ClientConfigurationErrorMessage.scopesRequired.desc} Given value: ${scopesValue}`);\r\n }\r\n\r\n static createInvalidPromptError(promptValue: string): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidPrompt.code,\r\n `${ClientConfigurationErrorMessage.invalidPrompt.desc} Given value: ${promptValue}`);\r\n }\r\n\r\n static createClaimsRequestParsingError(claimsRequestParseError: string): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.claimsRequestParsingError.code,\r\n `${ClientConfigurationErrorMessage.claimsRequestParsingError.desc} Given value: ${claimsRequestParseError}`);\r\n }\r\n\r\n static createEmptyRequestError(): ClientConfigurationError {\r\n const { code, desc } = ClientConfigurationErrorMessage.emptyRequestError;\r\n return new ClientConfigurationError(code, desc);\r\n }\r\n\r\n static createInvalidCorrelationIdError(): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidCorrelationIdError.code,\r\n ClientConfigurationErrorMessage.invalidCorrelationIdError.desc);\r\n }\r\n\r\n static createKnownAuthoritiesNotSetError(): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.b2cKnownAuthoritiesNotSet.code,\r\n ClientConfigurationErrorMessage.b2cKnownAuthoritiesNotSet.desc);\r\n }\r\n\r\n static createInvalidAuthorityTypeError(): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthorityType.code,\r\n ClientConfigurationErrorMessage.invalidAuthorityType.desc);\r\n }\r\n\r\n static createUntrustedAuthorityError(host: string): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.untrustedAuthority.code,\r\n `${ClientConfigurationErrorMessage.untrustedAuthority.desc} Provided Authority: ${host}`);\r\n }\r\n\r\n static createTelemetryConfigError(config: TelemetryOptions): ClientConfigurationError {\r\n const { code, desc } = ClientConfigurationErrorMessage.telemetryConfigError;\r\n const requiredKeys = {\r\n applicationName: \"string\",\r\n applicationVersion: \"string\",\r\n telemetryEmitter: \"function\"\r\n };\r\n\r\n const missingKeys = Object.keys(requiredKeys)\r\n .reduce((keys, key) => {\r\n return config[key] ? keys : keys.concat([ `${key} (${requiredKeys[key]})` ]);\r\n }, []);\r\n\r\n return new ClientConfigurationError(code, `${desc} mising values: ${missingKeys.join(\",\")}`);\r\n }\r\n\r\n static createSsoSilentError(): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.ssoSilentError.code,\r\n ClientConfigurationErrorMessage.ssoSilentError.desc);\r\n }\r\n\r\n static createInvalidAuthorityMetadataError(): ClientConfigurationError {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthorityMetadataError.code, ClientConfigurationErrorMessage.invalidAuthorityMetadataError.desc);\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ServerError } from \"./ServerError\";\r\n\r\nexport const InteractionRequiredAuthErrorMessage = {\r\n interactionRequired: {\r\n code: \"interaction_required\"\r\n },\r\n consentRequired: {\r\n code: \"consent_required\"\r\n },\r\n loginRequired: {\r\n code: \"login_required\"\r\n },\r\n};\r\n\r\n/**\r\n * Error thrown when the user is required to perform an interactive token request.\r\n */\r\nexport class InteractionRequiredAuthError extends ServerError {\r\n\r\n constructor(errorCode: string, errorMessage?: string) {\r\n super(errorCode, errorMessage);\r\n this.name = \"InteractionRequiredAuthError\";\r\n\r\n Object.setPrototypeOf(this, InteractionRequiredAuthError.prototype);\r\n }\r\n\r\n static isInteractionRequiredError(errorString: string) : boolean {\r\n const interactionRequiredCodes = [\r\n InteractionRequiredAuthErrorMessage.interactionRequired.code,\r\n InteractionRequiredAuthErrorMessage.consentRequired.code,\r\n InteractionRequiredAuthErrorMessage.loginRequired.code\r\n ];\r\n\r\n return errorString && interactionRequiredCodes.indexOf(errorString) > -1;\r\n }\r\n\r\n static createLoginRequiredAuthError(errorDesc: string): InteractionRequiredAuthError {\r\n return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.loginRequired.code, errorDesc);\r\n }\r\n\r\n static createInteractionRequiredAuthError(errorDesc: string): InteractionRequiredAuthError {\r\n return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.interactionRequired.code, errorDesc);\r\n }\r\n\r\n static createConsentRequiredAuthError(errorDesc: string): InteractionRequiredAuthError {\r\n return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.consentRequired.code, errorDesc);\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AuthError } from \"./AuthError\";\r\n\r\nexport const ServerErrorMessage = {\r\n serverUnavailable: {\r\n code: \"server_unavailable\",\r\n desc: \"Server is temporarily unavailable.\"\r\n },\r\n unknownServerError: {\r\n code: \"unknown_server_error\"\r\n },\r\n};\r\n\r\n/**\r\n * Error thrown when there is an error with the server code, for example, unavailability.\r\n */\r\nexport class ServerError extends AuthError {\r\n\r\n constructor(errorCode: string, errorMessage?: string) {\r\n super(errorCode, errorMessage);\r\n this.name = \"ServerError\";\r\n\r\n Object.setPrototypeOf(this, ServerError.prototype);\r\n }\r\n\r\n static createServerUnavailableError(): ServerError {\r\n return new ServerError(ServerErrorMessage.serverUnavailable.code,\r\n ServerErrorMessage.serverUnavailable.desc);\r\n }\r\n\r\n static createUnknownServerError(errorDesc: string): ServerError {\r\n return new ServerError(ServerErrorMessage.unknownServerError.code,\r\n errorDesc);\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\n/**\r\n * @packageDocumentation\r\n * @module @azure/msal\r\n */\r\n\r\nexport { UserAgentApplication, authResponseCallback, errorReceivedCallback, tokenReceivedCallback } from \"./UserAgentApplication\";\r\nexport { Logger } from \"./Logger\";\r\nexport { LogLevel } from \"./Logger\";\r\nexport { Account } from \"./Account\";\r\nexport { Constants, ServerHashParamKeys } from \"./utils/Constants\";\r\nexport { Authority } from \"./authority/Authority\";\r\nexport { CacheResult } from \"./UserAgentApplication\";\r\nexport { CacheLocation, Configuration } from \"./Configuration\";\r\nexport { AuthenticationParameters } from \"./AuthenticationParameters\";\r\nexport { AuthResponse } from \"./AuthResponse\";\r\nexport { CryptoUtils } from \"./utils/CryptoUtils\";\r\nexport { UrlUtils } from \"./utils/UrlUtils\";\r\nexport { WindowUtils } from \"./utils/WindowUtils\";\r\n\r\n// Errors\r\nexport { AuthError } from \"./error/AuthError\";\r\nexport { ClientAuthError } from \"./error/ClientAuthError\";\r\nexport { ServerError } from \"./error/ServerError\";\r\nexport { ClientConfigurationError } from \"./error/ClientConfigurationError\";\r\nexport { InteractionRequiredAuthError } from \"./error/InteractionRequiredAuthError\";\r\nexport { version } from \"./packageMetadata\";\r\n","/* eslint-disable header/header */\r\nexport const name = \"msal\";\r\nexport const version = \"1.4.14\";\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport TelemetryEvent from \"./TelemetryEvent\";\r\nimport { TELEMETRY_BLOB_EVENT_NAMES } from \"./TelemetryConstants\";\r\nimport { scrubTenantFromUri, hashPersonalIdentifier, prependEventNamePrefix } from \"./TelemetryUtils\";\r\n\r\nexport const EVENT_KEYS = {\r\n AUTHORITY: prependEventNamePrefix(\"authority\"),\r\n AUTHORITY_TYPE: prependEventNamePrefix(\"authority_type\"),\r\n PROMPT: prependEventNamePrefix(\"ui_behavior\"),\r\n TENANT_ID: prependEventNamePrefix(\"tenant_id\"),\r\n USER_ID: prependEventNamePrefix(\"user_id\"),\r\n WAS_SUCESSFUL: prependEventNamePrefix(\"was_successful\"),\r\n API_ERROR_CODE: prependEventNamePrefix(\"api_error_code\"),\r\n LOGIN_HINT: prependEventNamePrefix(\"login_hint\")\r\n};\r\n\r\nexport enum API_CODE {\r\n AcquireTokenRedirect = 2001,\r\n AcquireTokenSilent = 2002,\r\n AcquireTokenPopup = 2003,\r\n LoginRedirect = 2004,\r\n LoginPopup = 2005,\r\n Logout = 2006\r\n}\r\n\r\nexport enum API_EVENT_IDENTIFIER {\r\n AcquireTokenRedirect = \"AcquireTokenRedirect\",\r\n AcquireTokenSilent = \"AcquireTokenSilent\",\r\n AcquireTokenPopup = \"AcquireTokenPopup\",\r\n LoginRedirect = \"LoginRedirect\",\r\n LoginPopup = \"LoginPopup\",\r\n Logout = \"Logout\"\r\n}\r\n\r\nconst mapEventIdentiferToCode = {\r\n [API_EVENT_IDENTIFIER.AcquireTokenSilent]: API_CODE.AcquireTokenSilent,\r\n [API_EVENT_IDENTIFIER.AcquireTokenPopup]: API_CODE.AcquireTokenPopup,\r\n [API_EVENT_IDENTIFIER.AcquireTokenRedirect]: API_CODE.AcquireTokenRedirect,\r\n [API_EVENT_IDENTIFIER.LoginPopup]: API_CODE.LoginPopup,\r\n [API_EVENT_IDENTIFIER.LoginRedirect]: API_CODE.LoginRedirect,\r\n [API_EVENT_IDENTIFIER.Logout]: API_CODE.Logout\r\n};\r\n\r\nexport default class ApiEvent extends TelemetryEvent {\r\n\r\n private piiEnabled: boolean;\r\n\r\n constructor(correlationId: string, piiEnabled: boolean, apiEventIdentifier?: API_EVENT_IDENTIFIER) {\r\n super(prependEventNamePrefix(\"api_event\"), correlationId, apiEventIdentifier);\r\n if (apiEventIdentifier) {\r\n this.apiCode = mapEventIdentiferToCode[apiEventIdentifier];\r\n this.apiEventIdentifier = apiEventIdentifier;\r\n }\r\n this.piiEnabled = piiEnabled;\r\n }\r\n\r\n public set apiEventIdentifier(apiEventIdentifier: string) {\r\n this.event[TELEMETRY_BLOB_EVENT_NAMES.ApiTelemIdConstStrKey] = apiEventIdentifier;\r\n }\r\n\r\n public set apiCode(apiCode: number) {\r\n this.event[TELEMETRY_BLOB_EVENT_NAMES.ApiIdConstStrKey] = apiCode;\r\n }\r\n\r\n public set authority(uri: string) {\r\n this.event[EVENT_KEYS.AUTHORITY] = scrubTenantFromUri(uri).toLowerCase();\r\n }\r\n\r\n public set apiErrorCode(errorCode: string) {\r\n this.event[EVENT_KEYS.API_ERROR_CODE] = errorCode;\r\n }\r\n\r\n public set tenantId(tenantId: string) {\r\n this.event[EVENT_KEYS.TENANT_ID] = this.piiEnabled && tenantId ?\r\n hashPersonalIdentifier(tenantId)\r\n : null;\r\n }\r\n\r\n public set accountId(accountId: string) {\r\n this.event[EVENT_KEYS.USER_ID] = this.piiEnabled && accountId ?\r\n hashPersonalIdentifier(accountId)\r\n : null;\r\n }\r\n\r\n public set wasSuccessful(wasSuccessful: boolean) {\r\n this.event[EVENT_KEYS.WAS_SUCESSFUL] = wasSuccessful;\r\n }\r\n\r\n public get wasSuccessful(): boolean {\r\n return this.event[EVENT_KEYS.WAS_SUCESSFUL] === true;\r\n }\r\n\r\n public set loginHint(loginHint: string) {\r\n this.event[EVENT_KEYS.LOGIN_HINT] = this.piiEnabled && loginHint ?\r\n hashPersonalIdentifier(loginHint)\r\n : null;\r\n }\r\n\r\n public set authorityType(authorityType: string) {\r\n this.event[EVENT_KEYS.AUTHORITY_TYPE] = authorityType.toLowerCase();\r\n }\r\n\r\n public set promptType(promptType: string) {\r\n this.event[EVENT_KEYS.PROMPT] = promptType.toLowerCase();\r\n }\r\n\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { TELEMETRY_BLOB_EVENT_NAMES } from \"./TelemetryConstants\";\r\nimport TelemetryEvent from \"./TelemetryEvent\";\r\nimport { EventCount, TelemetryPlatform } from \"./TelemetryTypes\";\r\nimport { prependEventNamePrefix } from \"./TelemetryUtils\";\r\n\r\nexport default class DefaultEvent extends TelemetryEvent {\r\n // TODO Platform Type\r\n constructor(platform: TelemetryPlatform, correlationId: string, clientId: string, eventCount: EventCount) {\r\n super(prependEventNamePrefix(\"default_event\"), correlationId, \"DefaultEvent\");\r\n this.event[prependEventNamePrefix(\"client_id\")] = clientId;\r\n this.event[prependEventNamePrefix(\"sdk_plaform\")] = platform.sdk;\r\n this.event[prependEventNamePrefix(\"sdk_version\")] = platform.sdkVersion;\r\n this.event[prependEventNamePrefix(\"application_name\")] = platform.applicationName;\r\n this.event[prependEventNamePrefix(\"application_version\")] = platform.applicationVersion;\r\n this.event[prependEventNamePrefix(\"effective_connection_speed\")] = platform.networkInformation && platform.networkInformation.connectionSpeed;\r\n this.event[`${TELEMETRY_BLOB_EVENT_NAMES.UiEventCountTelemetryBatchKey}`] = this.getEventCount(prependEventNamePrefix(\"ui_event\"), eventCount);\r\n this.event[`${TELEMETRY_BLOB_EVENT_NAMES.HttpEventCountTelemetryBatchKey}`] = this.getEventCount(prependEventNamePrefix(\"http_event\"), eventCount);\r\n this.event[`${TELEMETRY_BLOB_EVENT_NAMES.CacheEventCountConstStrKey}`] = this.getEventCount(prependEventNamePrefix(\"cache_event\"), eventCount);\r\n // / Device id?\r\n }\r\n\r\n private getEventCount(eventName: string, eventCount: EventCount): number {\r\n if (!eventCount[eventName]) {\r\n return 0;\r\n }\r\n return eventCount[eventName];\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport TelemetryEvent from \"./TelemetryEvent\";\r\nimport { scrubTenantFromUri, prependEventNamePrefix } from \"./TelemetryUtils\";\r\nimport { ServerRequestParameters } from \"../ServerRequestParameters\";\r\nimport { StringDict } from \"../MsalTypes\";\r\n\r\nexport const EVENT_KEYS = {\r\n HTTP_PATH: prependEventNamePrefix(\"http_path\"),\r\n USER_AGENT: prependEventNamePrefix(\"user_agent\"),\r\n QUERY_PARAMETERS: prependEventNamePrefix(\"query_parameters\"),\r\n API_VERSION: prependEventNamePrefix(\"api_version\"),\r\n RESPONSE_CODE: prependEventNamePrefix(\"response_code\"),\r\n O_AUTH_ERROR_CODE: prependEventNamePrefix(\"oauth_error_code\"),\r\n HTTP_METHOD: prependEventNamePrefix(\"http_method\"),\r\n REQUEST_ID_HEADER: prependEventNamePrefix(\"request_id_header\"),\r\n SPE_INFO: prependEventNamePrefix(\"spe_info\"),\r\n SERVER_ERROR_CODE: prependEventNamePrefix(\"server_error_code\"),\r\n SERVER_SUB_ERROR_CODE: prependEventNamePrefix(\"server_sub_error_code\"),\r\n URL: prependEventNamePrefix(\"url\")\r\n};\r\n\r\nexport default class HttpEvent extends TelemetryEvent {\r\n\r\n constructor(correlationId: string, eventLabel: string) {\r\n super(prependEventNamePrefix(\"http_event\"), correlationId, eventLabel);\r\n }\r\n\r\n public set url(url: string) {\r\n const scrubbedUri = scrubTenantFromUri(url);\r\n this.event[EVENT_KEYS.URL] = scrubbedUri && scrubbedUri.toLowerCase();\r\n }\r\n\r\n public set httpPath(httpPath: string) {\r\n this.event[EVENT_KEYS.HTTP_PATH] = scrubTenantFromUri(httpPath).toLowerCase();\r\n }\r\n\r\n public set userAgent(userAgent: string) {\r\n this.event[EVENT_KEYS.USER_AGENT] = userAgent;\r\n }\r\n\r\n public set queryParams(queryParams: StringDict) {\r\n this.event[EVENT_KEYS.QUERY_PARAMETERS] = ServerRequestParameters.generateQueryParametersString(queryParams);\r\n }\r\n\r\n public set apiVersion(apiVersion: string) {\r\n this.event[EVENT_KEYS.API_VERSION] = apiVersion.toLowerCase();\r\n }\r\n\r\n public set httpResponseStatus(statusCode: number) {\r\n this.event[EVENT_KEYS.RESPONSE_CODE] = statusCode;\r\n }\r\n\r\n public set oAuthErrorCode(errorCode: string) {\r\n this.event[EVENT_KEYS.O_AUTH_ERROR_CODE] = errorCode;\r\n }\r\n\r\n public set httpMethod(httpMethod: string) {\r\n this.event[EVENT_KEYS.HTTP_METHOD] = httpMethod;\r\n }\r\n\r\n public set requestIdHeader(requestIdHeader: string) {\r\n this.event[EVENT_KEYS.REQUEST_ID_HEADER] = requestIdHeader;\r\n }\r\n\r\n /**\r\n * Indicates whether the request was executed on a ring serving SPE traffic.\r\n * An empty string indicates this occurred on an outer ring, and the string \"I\"\r\n * indicates the request occurred on the inner ring\r\n */\r\n public set speInfo(speInfo: string) {\r\n this.event[EVENT_KEYS.SPE_INFO] = speInfo;\r\n }\r\n\r\n public set serverErrorCode(errorCode: string) {\r\n this.event[EVENT_KEYS.SERVER_ERROR_CODE] = errorCode;\r\n }\r\n\r\n public set serverSubErrorCode(subErrorCode: string) {\r\n this.event[EVENT_KEYS.SERVER_SUB_ERROR_CODE] = subErrorCode;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nexport const EVENT_NAME_PREFIX = \"msal.\";\r\nexport const EVENT_NAME_KEY = \"event_name\";\r\nexport const START_TIME_KEY = \"start_time\";\r\nexport const ELAPSED_TIME_KEY = \"elapsed_time\";\r\n\r\nexport const TELEMETRY_BLOB_EVENT_NAMES = {\r\n MsalCorrelationIdConstStrKey: \"Microsoft.MSAL.correlation_id\",\r\n ApiTelemIdConstStrKey: \"msal.api_telem_id\",\r\n ApiIdConstStrKey: \"msal.api_id\",\r\n BrokerAppConstStrKey: \"Microsoft_MSAL_broker_app\",\r\n CacheEventCountConstStrKey: \"Microsoft_MSAL_cache_event_count\",\r\n HttpEventCountTelemetryBatchKey: \"Microsoft_MSAL_http_event_count\",\r\n IdpConstStrKey: \"Microsoft_MSAL_idp\",\r\n IsSilentTelemetryBatchKey: \"\",\r\n IsSuccessfulConstStrKey: \"Microsoft_MSAL_is_successful\",\r\n ResponseTimeConstStrKey: \"Microsoft_MSAL_response_time\",\r\n TenantIdConstStrKey: \"Microsoft_MSAL_tenant_id\",\r\n UiEventCountTelemetryBatchKey: \"Microsoft_MSAL_ui_event_count\"\r\n};\r\n\r\n// This is used to replace the real tenant in telemetry info\r\nexport const TENANT_PLACEHOLDER = \"<tenant>\";\r\n\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport {\r\n TELEMETRY_BLOB_EVENT_NAMES,\r\n EVENT_NAME_KEY,\r\n START_TIME_KEY,\r\n ELAPSED_TIME_KEY\r\n} from \"./TelemetryConstants\";\r\nimport { prependEventNamePrefix, startBrowserPerformanceMeasurement, endBrowserPerformanceMeasurement } from \"./TelemetryUtils\";\r\nimport { CryptoUtils } from \"../utils/CryptoUtils\";\r\n\r\nexport default class TelemetryEvent {\r\n\r\n private startTimestamp: number;\r\n // eslint-disable-next-line\r\n protected event: any; // TODO TYPE THIS\r\n public eventId: string;\r\n private label: string;\r\n\r\n constructor(eventName: string, correlationId: string, eventLabel: string) {\r\n this.eventId = CryptoUtils.createNewGuid();\r\n this.label = eventLabel;\r\n this.event = {\r\n [prependEventNamePrefix(EVENT_NAME_KEY)]: eventName,\r\n [prependEventNamePrefix(ELAPSED_TIME_KEY)]: -1,\r\n [`${TELEMETRY_BLOB_EVENT_NAMES.MsalCorrelationIdConstStrKey}`]: correlationId\r\n };\r\n }\r\n\r\n private setElapsedTime(time: Number): void {\r\n this.event[prependEventNamePrefix(ELAPSED_TIME_KEY)] = time;\r\n }\r\n\r\n public stop(): void {\r\n // Set duration of event\r\n this.setElapsedTime(+Date.now() - +this.startTimestamp);\r\n\r\n endBrowserPerformanceMeasurement(this.displayName, this.perfStartMark, this.perfEndMark);\r\n }\r\n\r\n public start(): void {\r\n this.startTimestamp = Date.now();\r\n this.event[prependEventNamePrefix(START_TIME_KEY)] = this.startTimestamp;\r\n\r\n startBrowserPerformanceMeasurement(this.perfStartMark);\r\n }\r\n\r\n public get telemetryCorrelationId(): string {\r\n return this.event[`${TELEMETRY_BLOB_EVENT_NAMES.MsalCorrelationIdConstStrKey}`];\r\n }\r\n\r\n public set telemetryCorrelationId(value: string) {\r\n this.event[`${TELEMETRY_BLOB_EVENT_NAMES.MsalCorrelationIdConstStrKey}`] = value;\r\n }\r\n\r\n public get eventName(): string {\r\n return this.event[prependEventNamePrefix(EVENT_NAME_KEY)];\r\n }\r\n\r\n public get(): object {\r\n return {\r\n ...this.event,\r\n eventId: this.eventId\r\n };\r\n }\r\n\r\n public get key(): string {\r\n return `${this.telemetryCorrelationId}_${this.eventId}-${this.eventName}`;\r\n }\r\n\r\n public get displayName(): string {\r\n return `Msal-${this.label}-${this.telemetryCorrelationId}`;\r\n }\r\n\r\n private get perfStartMark() {\r\n return `start-${this.key}`;\r\n }\r\n\r\n private get perfEndMark() {\r\n return `end-${this.key}`;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport TelemetryEvent from \"./TelemetryEvent\";\r\nimport {\r\n CompletedEvents,\r\n EventCount,\r\n EventCountByCorrelationId,\r\n InProgressEvents,\r\n TelemetryConfig,\r\n TelemetryPlatform,\r\n TelemetryEmitter\r\n} from \"./TelemetryTypes\";\r\nimport DefaultEvent from \"./DefaultEvent\";\r\nimport { Constants } from \"../utils/Constants\";\r\nimport ApiEvent, { API_EVENT_IDENTIFIER } from \"./ApiEvent\";\r\nimport { Logger } from \"../Logger\";\r\nimport HttpEvent from \"./HttpEvent\";\r\nimport { version as libraryVersion } from \"../packageMetadata\";\r\n\r\nexport default class TelemetryManager {\r\n\r\n // correlation Id to list of events\r\n private completedEvents: CompletedEvents = {};\r\n // event key to event\r\n private inProgressEvents: InProgressEvents = {};\r\n // correlation id to map of eventname to count\r\n private eventCountByCorrelationId: EventCountByCorrelationId = {};\r\n\r\n // Implement after API EVENT\r\n private onlySendFailureTelemetry: boolean = false;\r\n private telemetryPlatform: TelemetryPlatform;\r\n private clientId: string;\r\n private telemetryEmitter: TelemetryEmitter;\r\n private logger: Logger;\r\n\r\n constructor(config: TelemetryConfig, telemetryEmitter: TelemetryEmitter, logger: Logger) {\r\n // TODO THROW if bad options\r\n this.telemetryPlatform = {\r\n sdk: Constants.libraryName,\r\n sdkVersion: libraryVersion,\r\n networkInformation: {\r\n // @ts-ignore\r\n connectionSpeed: typeof navigator !== \"undefined\" && navigator.connection && navigator.connection.effectiveType\r\n },\r\n ...config.platform\r\n };\r\n this.clientId = config.clientId;\r\n this.onlySendFailureTelemetry = config.onlySendFailureTelemetry;\r\n /*\r\n * TODO, when i get to wiring this through, think about what it means if\r\n * a developer does not implement telem at all, we still instrument, but telemetryEmitter can be\r\n * optional?\r\n */\r\n this.telemetryEmitter = telemetryEmitter;\r\n this.logger = logger;\r\n }\r\n\r\n static getTelemetrymanagerStub(clientId: string, logger: Logger) : TelemetryManager {\r\n const applicationName = \"UnSetStub\";\r\n const applicationVersion = \"0.0\";\r\n const telemetryEmitter = () => {};\r\n const telemetryPlatform: TelemetryPlatform = {\r\n applicationName,\r\n applicationVersion\r\n };\r\n const telemetryManagerConfig: TelemetryConfig = {\r\n platform: telemetryPlatform,\r\n clientId: clientId\r\n };\r\n\r\n return new this(telemetryManagerConfig, telemetryEmitter, logger);\r\n }\r\n\r\n startEvent(event: TelemetryEvent): void {\r\n this.logger.verbose(`Telemetry Event started: ${event.key}`);\r\n\r\n if (!this.telemetryEmitter) {\r\n return;\r\n }\r\n\r\n event.start();\r\n this.inProgressEvents[event.key] = event;\r\n }\r\n\r\n stopEvent(event: TelemetryEvent): void {\r\n this.logger.verbose(`Telemetry Event stopped: ${event.key}`);\r\n\r\n if (!this.telemetryEmitter || !this.inProgressEvents[event.key]) {\r\n return;\r\n }\r\n event.stop();\r\n this.incrementEventCount(event);\r\n\r\n const completedEvents = this.completedEvents[event.telemetryCorrelationId];\r\n\r\n this.completedEvents[event.telemetryCorrelationId] = [...(completedEvents || []), event];\r\n\r\n delete this.inProgressEvents[event.key];\r\n }\r\n\r\n flush(correlationId: string): void {\r\n this.logger.verbose(`Flushing telemetry events: ${correlationId}`);\r\n\r\n // If there is only unfinished events should this still return them?\r\n if (!this.telemetryEmitter || !this.completedEvents[correlationId]) {\r\n return;\r\n }\r\n\r\n const orphanedEvents = this.getOrphanedEvents(correlationId);\r\n orphanedEvents.forEach(event => this.incrementEventCount(event));\r\n const eventsToFlush: Array<TelemetryEvent> = [\r\n ...this.completedEvents[correlationId],\r\n ...orphanedEvents\r\n ];\r\n\r\n delete this.completedEvents[correlationId];\r\n const eventCountsToFlush: EventCount = this.eventCountByCorrelationId[correlationId];\r\n\r\n delete this.eventCountByCorrelationId[correlationId];\r\n // TODO add funcitonality for onlyFlushFailures after implementing api event? ??\r\n\r\n if (!eventsToFlush || !eventsToFlush.length) {\r\n return;\r\n }\r\n\r\n const defaultEvent: DefaultEvent = new DefaultEvent(\r\n this.telemetryPlatform,\r\n correlationId,\r\n this.clientId,\r\n eventCountsToFlush\r\n );\r\n\r\n const eventsWithDefaultEvent = [ ...eventsToFlush, defaultEvent ];\r\n\r\n this.telemetryEmitter(eventsWithDefaultEvent.map(e => e.get()));\r\n }\r\n\r\n createAndStartApiEvent(correlationId: string, apiEventIdentifier: API_EVENT_IDENTIFIER): ApiEvent {\r\n const apiEvent = new ApiEvent(correlationId, this.logger.isPiiLoggingEnabled(), apiEventIdentifier);\r\n this.startEvent(apiEvent);\r\n return apiEvent;\r\n }\r\n\r\n stopAndFlushApiEvent(correlationId: string, apiEvent: ApiEvent, wasSuccessful: boolean, errorCode?: string): void {\r\n apiEvent.wasSuccessful = wasSuccessful;\r\n if (errorCode) {\r\n apiEvent.apiErrorCode = errorCode;\r\n }\r\n this.stopEvent(apiEvent);\r\n this.flush(correlationId);\r\n }\r\n\r\n createAndStartHttpEvent(correlation: string, httpMethod: string, url: string, eventLabel: string): HttpEvent {\r\n const httpEvent = new HttpEvent(correlation, eventLabel);\r\n httpEvent.url = url;\r\n httpEvent.httpMethod = httpMethod;\r\n this.startEvent(httpEvent);\r\n return httpEvent;\r\n }\r\n\r\n private incrementEventCount(event: TelemetryEvent): void {\r\n /*\r\n * TODO, name cache event different?\r\n * if type is cache event, change name\r\n */\r\n const eventName = event.eventName;\r\n const eventCount = this.eventCountByCorrelationId[event.telemetryCorrelationId];\r\n if (!eventCount) {\r\n this.eventCountByCorrelationId[event.telemetryCorrelationId] = {\r\n [eventName]: 1\r\n };\r\n } else {\r\n eventCount[eventName] = eventCount[eventName] ? eventCount[eventName] + 1 : 1;\r\n }\r\n }\r\n\r\n private getOrphanedEvents(correlationId: string): Array<TelemetryEvent> {\r\n return Object.keys(this.inProgressEvents)\r\n .reduce((memo, eventKey) => {\r\n if (eventKey.indexOf(correlationId) !== -1) {\r\n const event = this.inProgressEvents[eventKey];\r\n delete this.inProgressEvents[eventKey];\r\n return [...memo, event];\r\n }\r\n return memo;\r\n }, []);\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { TENANT_PLACEHOLDER, EVENT_NAME_PREFIX } from \"./TelemetryConstants\";\r\nimport { CryptoUtils } from \"../utils/CryptoUtils\";\r\nimport { UrlUtils } from \"../utils/UrlUtils\";\r\nimport { Authority } from \"../authority/Authority\";\r\n\r\nexport const scrubTenantFromUri = (uri: string): String => {\r\n\r\n const url = UrlUtils.GetUrlComponents(uri);\r\n\r\n // validate trusted host\r\n if (Authority.isAdfs(uri)) {\r\n /**\r\n * returning what was passed because the library needs to work with uris that are non\r\n * AAD trusted but passed by users such as B2C or others.\r\n * HTTP Events for instance can take a url to the open id config endpoint\r\n */\r\n return uri;\r\n }\r\n\r\n const pathParams = url.PathSegments;\r\n\r\n if (pathParams && pathParams.length >= 2) {\r\n const tenantPosition = pathParams[1] === \"tfp\" ? 2 : 1;\r\n if (tenantPosition < pathParams.length) {\r\n pathParams[tenantPosition] = TENANT_PLACEHOLDER;\r\n }\r\n }\r\n\r\n return `${url.Protocol}//${url.HostNameAndPort}/${pathParams.join(\"/\")}`;\r\n};\r\n\r\nexport const hashPersonalIdentifier = (valueToHash: string): string => {\r\n /*\r\n * TODO sha256 this\r\n * Current test runner is being funny with node libs that are webpacked anyway\r\n * need a different solution\r\n */\r\n return CryptoUtils.base64Encode(valueToHash);\r\n};\r\n\r\nexport const prependEventNamePrefix = (suffix: string): string => `${EVENT_NAME_PREFIX}${suffix || \"\"}`;\r\n\r\nexport const supportsBrowserPerformance = (): boolean => !!(\r\n typeof window !== \"undefined\" &&\r\n \"performance\" in window &&\r\n window.performance.mark && \r\n window.performance.measure\r\n);\r\n\r\nexport const endBrowserPerformanceMeasurement = (measureName: string, startMark: string, endMark: string): void => {\r\n if (supportsBrowserPerformance()) {\r\n window.performance.mark(endMark);\r\n window.performance.measure(measureName, startMark, endMark);\r\n\r\n window.performance.clearMeasures(measureName);\r\n window.performance.clearMarks(startMark);\r\n window.performance.clearMarks(endMark);\r\n }\r\n};\r\n\r\nexport const startBrowserPerformanceMeasurement = (startMark: string): void => {\r\n if (supportsBrowserPerformance()) {\r\n window.performance.mark(startMark);\r\n }\r\n};\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AccessTokenCacheItem } from \"../cache/AccessTokenCacheItem\";\r\nimport { ScopeSet } from \"../ScopeSet\";\r\nimport { UrlUtils } from \"./UrlUtils\"; \r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class AuthCacheUtils {\r\n static filterTokenCacheItemsByScope(tokenCacheItems: Array<AccessTokenCacheItem>, requestScopes: string []): Array<AccessTokenCacheItem> {\r\n return tokenCacheItems.filter((cacheItem: AccessTokenCacheItem) => {\r\n const cachedScopes = cacheItem.key.scopes.split(\" \");\r\n const searchScopes = ScopeSet.removeDefaultScopes(requestScopes);\r\n\r\n // If requestScopes contain only default scopes search for default scopes otherwise search for everything but default scopes\r\n return searchScopes.length === 0 ? ScopeSet.containsScope(cachedScopes, requestScopes): ScopeSet.containsScope(cachedScopes, searchScopes);\r\n });\r\n\r\n }\r\n\r\n static filterTokenCacheItemsByAuthority(tokenCacheItems: Array<AccessTokenCacheItem>, authority: string): Array<AccessTokenCacheItem> {\r\n return tokenCacheItems.filter((cacheItem: AccessTokenCacheItem) => UrlUtils.CanonicalizeUri(cacheItem.key.authority) === authority);\r\n }\r\n\r\n static filterTokenCacheItemsByDomain(tokenCacheItems: Array<AccessTokenCacheItem>, requestDomain: string): Array<AccessTokenCacheItem> {\r\n return tokenCacheItems.filter(cacheItem => {\r\n const cacheItemDomain = UrlUtils.GetUrlComponents(cacheItem.key.authority).HostNameAndPort;\r\n return cacheItemDomain === requestDomain;\r\n });\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\n/**\r\n * @hidden\r\n * Constants\r\n */\r\nexport class Constants {\r\n static get libraryName(): string { return \"Msal.js\"; } // used in telemetry sdkName\r\n static get claims(): string { return \"claims\"; }\r\n static get clientId(): string { return \"clientId\"; }\r\n\r\n static get adalIdToken(): string { return \"adal.idtoken\"; }\r\n static get cachePrefix(): string { return \"msal\"; }\r\n static get scopes(): string { return \"scopes\"; }\r\n\r\n static get no_account(): string { return \"NO_ACCOUNT\"; }\r\n static get upn(): string { return \"upn\"; }\r\n static get domain_hint(): string { return \"domain_hint\"; }\r\n\r\n static get prompt_select_account(): string { return \"&prompt=select_account\"; }\r\n static get prompt_none(): string { return \"&prompt=none\"; }\r\n static get prompt(): string { return \"prompt\"; }\r\n\r\n static get response_mode_fragment(): string { return \"&response_mode=fragment\"; }\r\n static get resourceDelimiter(): string { return \"|\"; }\r\n static get cacheDelimiter(): string { return \".\"; }\r\n\r\n private static _popUpWidth: number = 483;\r\n static get popUpWidth(): number { return this._popUpWidth; }\r\n static set popUpWidth(width: number) {\r\n this._popUpWidth = width;\r\n }\r\n private static _popUpHeight: number = 600;\r\n static get popUpHeight(): number { return this._popUpHeight; }\r\n static set popUpHeight(height: number) {\r\n this._popUpHeight = height;\r\n }\r\n\r\n static get login(): string { return \"LOGIN\"; }\r\n static get renewToken(): string { return \"RENEW_TOKEN\"; }\r\n static get unknown(): string { return \"UNKNOWN\"; }\r\n\r\n static get ADFS(): string { return \"adfs\"; }\r\n\r\n static get homeAccountIdentifier(): string { return \"homeAccountIdentifier\"; }\r\n\r\n static get common(): string { return \"common\"; }\r\n static get openidScope(): string { return \"openid\"; }\r\n static get profileScope(): string { return \"profile\"; }\r\n static get oidcScopes(): Array<string> { return [this.openidScope, this.profileScope] ;}\r\n\r\n static get interactionTypeRedirect(): InteractionType { return \"redirectInteraction\"; }\r\n static get interactionTypePopup(): InteractionType { return \"popupInteraction\"; }\r\n static get interactionTypeSilent(): InteractionType { return \"silentInteraction\"; }\r\n static get inProgress(): string { return \"inProgress\"; }\r\n}\r\n\r\nexport const SESSION_STORAGE = \"sessionStorage\";\r\n\r\n/**\r\n * Keys in the hashParams\r\n */\r\nexport enum ServerHashParamKeys {\r\n SCOPE = \"scope\",\r\n STATE = \"state\",\r\n ERROR = \"error\",\r\n ERROR_DESCRIPTION = \"error_description\",\r\n ACCESS_TOKEN = \"access_token\",\r\n ID_TOKEN = \"id_token\",\r\n EXPIRES_IN = \"expires_in\",\r\n SESSION_STATE = \"session_state\",\r\n CLIENT_INFO = \"client_info\"\r\n}\r\n\r\n/**\r\n * @hidden\r\n * @ignore\r\n * response_type from OpenIDConnect\r\n * References: https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html & https://tools.ietf.org/html/rfc6749#section-4.2.1\r\n *\r\n */\r\nexport const ResponseTypes = {\r\n id_token: \"id_token\",\r\n token: \"token\",\r\n id_token_token: \"id_token token\"\r\n};\r\n\r\n/**\r\n * @hidden\r\n * CacheKeys for MSAL\r\n */\r\nexport enum TemporaryCacheKeys {\r\n AUTHORITY = \"authority\",\r\n ACQUIRE_TOKEN_ACCOUNT = \"acquireTokenAccount\",\r\n SESSION_STATE = \"session.state\",\r\n STATE_LOGIN = \"state.login\",\r\n STATE_ACQ_TOKEN = \"state.acquireToken\",\r\n STATE_RENEW = \"state.renew\",\r\n NONCE_IDTOKEN = \"nonce.idtoken\",\r\n LOGIN_REQUEST = \"login.request\",\r\n RENEW_STATUS = \"token.renew.status\",\r\n URL_HASH = \"urlHash\",\r\n INTERACTION_STATUS = \"interaction.status\",\r\n REDIRECT_REQUEST = \"redirect_request\"\r\n}\r\n\r\nexport enum PersistentCacheKeys {\r\n IDTOKEN = \"idtoken\",\r\n CLIENT_INFO = \"client.info\"\r\n}\r\n\r\nexport enum ErrorCacheKeys {\r\n LOGIN_ERROR = \"login.error\",\r\n ERROR = \"error\",\r\n ERROR_DESC = \"error.description\"\r\n}\r\n\r\nexport const DEFAULT_AUTHORITY: string = \"https://login.microsoftonline.com/common/\";\r\nexport const AAD_INSTANCE_DISCOVERY_ENDPOINT: string = `${DEFAULT_AUTHORITY}/discovery/instance?api-version=1.1&authorization_endpoint=`;\r\nexport const WELL_KNOWN_SUFFIX: string = \".well-known/openid-configuration\";\r\n\r\n/**\r\n * @hidden\r\n * SSO Types - generated to populate hints\r\n */\r\nexport enum SSOTypes {\r\n ACCOUNT = \"account\",\r\n SID = \"sid\",\r\n LOGIN_HINT = \"login_hint\",\r\n ORGANIZATIONS = \"organizations\",\r\n CONSUMERS = \"consumers\",\r\n ID_TOKEN =\"id_token\",\r\n ACCOUNT_ID = \"accountIdentifier\",\r\n HOMEACCOUNT_ID = \"homeAccountIdentifier\"\r\n}\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport const BlacklistedEQParams = [\r\n SSOTypes.SID,\r\n SSOTypes.LOGIN_HINT\r\n];\r\n\r\nexport type InteractionType = \"redirectInteraction\" | \"popupInteraction\" | \"silentInteraction\";\r\n\r\nexport const NetworkRequestType = {\r\n GET: \"GET\",\r\n POST: \"POST\"\r\n};\r\n\r\n/**\r\n * we considered making this \"enum\" in the request instead of string, however it looks like the allowed list of\r\n * prompt values kept changing over past couple of years. There are some undocumented prompt values for some\r\n * internal partners too, hence the choice of generic \"string\" type instead of the \"enum\"\r\n * @hidden\r\n */\r\nexport const PromptState = {\r\n LOGIN: \"login\",\r\n SELECT_ACCOUNT: \"select_account\",\r\n CONSENT: \"consent\",\r\n NONE: \"none\"\r\n};\r\n\r\n/**\r\n * Frame name prefixes for the hidden iframe created in silent frames\r\n */\r\nexport const FramePrefix = {\r\n ID_TOKEN_FRAME: \"msalIdTokenFrame\",\r\n TOKEN_FRAME: \"msalRenewFrame\"\r\n};\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class CryptoUtils {\r\n\r\n /**\r\n * Creates a new random GUID\r\n * @returns string (GUID)\r\n */\r\n static createNewGuid(): string {\r\n /*\r\n * RFC4122: The version 4 UUID is meant for generating UUIDs from truly-random or\r\n * pseudo-random numbers.\r\n * The algorithm is as follows:\r\n * Set the two most significant bits (bits 6 and 7) of the\r\n * clock_seq_hi_and_reserved to zero and one, respectively.\r\n * Set the four most significant bits (bits 12 through 15) of the\r\n * time_hi_and_version field to the 4-bit version number from\r\n * Section 4.1.3. Version4\r\n * Set all the other bits to randomly (or pseudo-randomly) chosen\r\n * values.\r\n * UUID = time-low \"-\" time-mid \"-\"time-high-and-version \"-\"clock-seq-reserved and low(2hexOctet)\"-\" node\r\n * time-low = 4hexOctet\r\n * time-mid = 2hexOctet\r\n * time-high-and-version = 2hexOctet\r\n * clock-seq-and-reserved = hexOctet:\r\n * clock-seq-low = hexOctet\r\n * node = 6hexOctet\r\n * Format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\r\n * y could be 1000, 1001, 1010, 1011 since most significant two bits needs to be 10\r\n * y values are 8, 9, A, B\r\n */\r\n\r\n const cryptoObj: Crypto = window.crypto; // for IE 11\r\n if (cryptoObj && cryptoObj.getRandomValues) {\r\n const buffer: Uint8Array = new Uint8Array(16);\r\n cryptoObj.getRandomValues(buffer);\r\n\r\n // buffer[6] and buffer[7] represents the time_hi_and_version field. We will set the four most significant bits (4 through 7) of buffer[6] to represent decimal number 4 (UUID version number).\r\n buffer[6] |= 0x40; // buffer[6] | 01000000 will set the 6 bit to 1.\r\n buffer[6] &= 0x4f; // buffer[6] & 01001111 will set the 4, 5, and 7 bit to 0 such that bits 4-7 == 0100 = \"4\".\r\n\r\n // buffer[8] represents the clock_seq_hi_and_reserved field. We will set the two most significant bits (6 and 7) of the clock_seq_hi_and_reserved to zero and one, respectively.\r\n buffer[8] |= 0x80; // buffer[8] | 10000000 will set the 7 bit to 1.\r\n buffer[8] &= 0xbf; // buffer[8] & 10111111 will set the 6 bit to 0.\r\n\r\n return CryptoUtils.decimalToHex(buffer[0]) + CryptoUtils.decimalToHex(buffer[1])\r\n + CryptoUtils.decimalToHex(buffer[2]) + CryptoUtils.decimalToHex(buffer[3])\r\n + \"-\" + CryptoUtils.decimalToHex(buffer[4]) + CryptoUtils.decimalToHex(buffer[5])\r\n + \"-\" + CryptoUtils.decimalToHex(buffer[6]) + CryptoUtils.decimalToHex(buffer[7])\r\n + \"-\" + CryptoUtils.decimalToHex(buffer[8]) + CryptoUtils.decimalToHex(buffer[9])\r\n + \"-\" + CryptoUtils.decimalToHex(buffer[10]) + CryptoUtils.decimalToHex(buffer[11])\r\n + CryptoUtils.decimalToHex(buffer[12]) + CryptoUtils.decimalToHex(buffer[13])\r\n + CryptoUtils.decimalToHex(buffer[14]) + CryptoUtils.decimalToHex(buffer[15]);\r\n }\r\n else {\r\n const guidHolder: string = \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\";\r\n const hex: string = \"0123456789abcdef\";\r\n let r: number = 0;\r\n let guidResponse: string = \"\";\r\n for (let i: number = 0; i < 36; i++) {\r\n if (guidHolder[i] !== \"-\" && guidHolder[i] !== \"4\") {\r\n // each x and y needs to be random\r\n r = Math.random() * 16 | 0;\r\n }\r\n if (guidHolder[i] === \"x\") {\r\n guidResponse += hex[r];\r\n } else if (guidHolder[i] === \"y\") {\r\n // clock-seq-and-reserved first hex is filtered and remaining hex values are random\r\n r &= 0x3; // bit and with 0011 to set pos 2 to zero ?0??\r\n r |= 0x8; // set pos 3 to 1 as 1???\r\n guidResponse += hex[r];\r\n } else {\r\n guidResponse += guidHolder[i];\r\n }\r\n }\r\n return guidResponse;\r\n }\r\n }\r\n\r\n /**\r\n * verifies if a string is GUID\r\n * @param guid\r\n */\r\n static isGuid(guid: string): boolean {\r\n const regexGuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\r\n return regexGuid.test(guid);\r\n }\r\n\r\n /**\r\n * Decimal to Hex\r\n *\r\n * @param num\r\n */\r\n static decimalToHex(num: number): string {\r\n let hex: string = num.toString(16);\r\n while (hex.length < 2) {\r\n hex = \"0\" + hex;\r\n }\r\n return hex;\r\n }\r\n\r\n // See: https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_4_%E2%80%93_escaping_the_string_before_encoding_it\r\n\r\n /**\r\n * encoding string to base64 - platform specific check\r\n *\r\n * @param input\r\n */\r\n static base64Encode(input: string): string {\r\n return btoa(encodeURIComponent(input).replace(/%([0-9A-F]{2})/g,\r\n function toSolidBytes(match, p1) {\r\n return String.fromCharCode(Number(\"0x\" + p1));\r\n }));\r\n }\r\n\r\n /**\r\n * Decodes a base64 encoded string.\r\n *\r\n * @param input\r\n */\r\n static base64Decode(input: string): string {\r\n let encodedString = input.replace(/-/g, \"+\").replace(/_/g, \"/\");\r\n switch (encodedString.length % 4) {\r\n case 0:\r\n break;\r\n case 2:\r\n encodedString += \"==\";\r\n break;\r\n case 3:\r\n encodedString += \"=\";\r\n break;\r\n default:\r\n throw new Error(\"Invalid base64 string\");\r\n }\r\n\r\n return decodeURIComponent(atob(encodedString).split(\"\").map(function (c) {\r\n return \"%\" + (\"00\" + c.charCodeAt(0).toString(16)).slice(-2);\r\n }).join(\"\"));\r\n }\r\n\r\n /**\r\n * deserialize a string\r\n *\r\n * @param query\r\n */\r\n static deserialize(query: string): object {\r\n let match: Array<string>; // Regex for replacing addition symbol with a space\r\n const pl = /\\+/g;\r\n const search = /([^&=]+)=([^&]*)/g;\r\n const decode = (s: string) => decodeURIComponent(s.replace(pl, \" \"));\r\n const obj: {} = {};\r\n match = search.exec(query);\r\n while (match) {\r\n obj[decode(match[1])] = decode(match[2]);\r\n match = search.exec(query);\r\n }\r\n return obj;\r\n }\r\n\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AuthenticationParameters } from \"../AuthenticationParameters\";\r\nimport { Constants, PromptState, BlacklistedEQParams, InteractionType } from \"./Constants\";\r\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\r\nimport { ScopeSet } from \"../ScopeSet\";\r\nimport { StringDict } from \"../MsalTypes\";\r\nimport { StringUtils } from \"./StringUtils\";\r\nimport { CryptoUtils } from \"./CryptoUtils\";\r\nimport { TimeUtils } from \"./TimeUtils\";\r\nimport { ClientAuthError } from \"../error/ClientAuthError\";\r\n\r\nexport type LibraryStateObject = {\r\n id: string,\r\n ts: number\r\n method: string\r\n};\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class RequestUtils {\r\n\r\n /**\r\n * @ignore\r\n *\r\n * @param request\r\n * @param isLoginCall\r\n * @param cacheStorage\r\n * @param clientId\r\n *\r\n * validates all request parameters and generates a consumable request object\r\n */\r\n static validateRequest(request: AuthenticationParameters, isLoginCall: boolean, clientId: string, interactionType: InteractionType): AuthenticationParameters {\r\n\r\n // Throw error if request is empty for acquire * calls\r\n if(!isLoginCall && !request) {\r\n throw ClientConfigurationError.createEmptyRequestError();\r\n }\r\n\r\n let scopes: Array<string>;\r\n let extraQueryParameters: StringDict;\r\n\r\n if(request) {\r\n // if extraScopesToConsent is passed in loginCall, append them to the login request; Validate and filter scopes (the validate function will throw if validation fails)\r\n scopes = isLoginCall ? ScopeSet.appendScopes(request.scopes, request.extraScopesToConsent) : request.scopes;\r\n ScopeSet.validateInputScope(scopes, !isLoginCall);\r\n scopes = ScopeSet.translateClientIdIfSingleScope(scopes, clientId);\r\n\r\n // validate prompt parameter\r\n this.validatePromptParameter(request.prompt);\r\n\r\n // validate extraQueryParameters\r\n extraQueryParameters = this.validateEQParameters(request.extraQueryParameters, request.claimsRequest);\r\n\r\n // validate claimsRequest\r\n this.validateClaimsRequest(request.claimsRequest);\r\n }\r\n\r\n // validate and generate state and correlationId\r\n const state = this.validateAndGenerateState(request && request.state, interactionType);\r\n const correlationId = this.validateAndGenerateCorrelationId(request && request.correlationId);\r\n\r\n const validatedRequest: AuthenticationParameters = {\r\n ...request,\r\n extraQueryParameters,\r\n scopes,\r\n state,\r\n correlationId\r\n };\r\n \r\n return validatedRequest;\r\n }\r\n\r\n /**\r\n * @ignore\r\n *\r\n * Utility to test if valid prompt value is passed in the request\r\n * @param request\r\n */\r\n static validatePromptParameter (prompt: string): void {\r\n if(prompt) {\r\n if ([PromptState.LOGIN, PromptState.SELECT_ACCOUNT, PromptState.CONSENT, PromptState.NONE].indexOf(prompt) < 0) {\r\n throw ClientConfigurationError.createInvalidPromptError(prompt);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @ignore\r\n *\r\n * Removes unnecessary or duplicate query parameters from extraQueryParameters\r\n * @param request\r\n */\r\n static validateEQParameters(extraQueryParameters: StringDict, claimsRequest: string) : StringDict {\r\n const eQParams : StringDict = { ...extraQueryParameters};\r\n if (!eQParams) {\r\n return null;\r\n }\r\n if (claimsRequest) {\r\n // this.logger.warning(\"Removed duplicate claims from extraQueryParameters. Please use either the claimsRequest field OR pass as extraQueryParameter - not both.\");\r\n delete eQParams[Constants.claims];\r\n }\r\n BlacklistedEQParams.forEach(param => {\r\n if (eQParams[param]) {\r\n // this.logger.warning(\"Removed duplicate \" + param + \" from extraQueryParameters. Please use the \" + param + \" field in request object.\");\r\n delete eQParams[param];\r\n }\r\n });\r\n\r\n return eQParams;\r\n }\r\n\r\n /**\r\n * @ignore\r\n *\r\n * Validates the claims passed in request is a JSON\r\n * TODO: More validation will be added when the server team tells us how they have actually implemented claims\r\n * @param claimsRequest\r\n */\r\n static validateClaimsRequest(claimsRequest: string): void {\r\n if (!claimsRequest) {\r\n return;\r\n }\r\n try {\r\n JSON.parse(claimsRequest);\r\n } catch (e) {\r\n throw ClientConfigurationError.createClaimsRequestParsingError(e);\r\n }\r\n }\r\n\r\n /**\r\n * @ignore\r\n *\r\n * generate unique state per request\r\n * @param userState User-provided state value\r\n * @returns State string include library state and user state\r\n */\r\n static validateAndGenerateState(userState: string, interactionType: InteractionType): string {\r\n return !StringUtils.isEmpty(userState) ? `${RequestUtils.generateLibraryState(interactionType)}${Constants.resourceDelimiter}${userState}` : RequestUtils.generateLibraryState(interactionType);\r\n }\r\n\r\n /**\r\n * Generates the state value used by the library.\r\n *\r\n * @returns Base64 encoded string representing the state\r\n */\r\n static generateLibraryState(interactionType: InteractionType): string {\r\n const stateObject: LibraryStateObject = {\r\n id: CryptoUtils.createNewGuid(),\r\n ts: TimeUtils.now(),\r\n method: interactionType\r\n };\r\n\r\n const stateString = JSON.stringify(stateObject);\r\n\r\n return CryptoUtils.base64Encode(stateString);\r\n }\r\n\r\n /**\r\n * Decodes the state value into a StateObject\r\n *\r\n * @param state State value returned in the request\r\n * @returns Parsed values from the encoded state value\r\n */\r\n static parseLibraryState(state: string): LibraryStateObject {\r\n const libraryState = decodeURIComponent(state).split(Constants.resourceDelimiter)[0];\r\n\r\n if (CryptoUtils.isGuid(libraryState)) {\r\n // If state is guid, assume timestamp is now and is redirect, as redirect should be only method where this can happen.\r\n return {\r\n id: libraryState,\r\n ts: TimeUtils.now(),\r\n method: Constants.interactionTypeRedirect\r\n };\r\n }\r\n\r\n try {\r\n const stateString = CryptoUtils.base64Decode(libraryState);\r\n\r\n const stateObject = JSON.parse(stateString);\r\n\r\n return stateObject;\r\n } catch (e) {\r\n throw ClientAuthError.createInvalidStateError(state, null);\r\n }\r\n }\r\n\r\n /**\r\n * @ignore\r\n *\r\n * validate correlationId and generate if not valid or not set by the user\r\n * @param correlationId\r\n */\r\n static validateAndGenerateCorrelationId(correlationId: string): string {\r\n // validate user set correlationId or set one for the user if null\r\n if(correlationId && !CryptoUtils.isGuid(correlationId)) {\r\n throw ClientConfigurationError.createInvalidCorrelationIdError();\r\n }\r\n return CryptoUtils.isGuid(correlationId)? correlationId : CryptoUtils.createNewGuid();\r\n }\r\n\r\n /**\r\n * Create a request signature\r\n * @param request\r\n */\r\n static createRequestSignature(request: AuthenticationParameters): string {\r\n return `${request.scopes.join(\" \").toLowerCase()}${Constants.resourceDelimiter}${request.authority}`;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AuthResponse } from \"../AuthResponse\";\r\nimport { Account } from \"../Account\";\r\nimport { IdToken } from \"../IdToken\";\r\nimport { ResponseTypes, ServerHashParamKeys } from \"./Constants\";\r\nimport { ServerRequestParameters } from \"../ServerRequestParameters\";\r\n\r\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class ResponseUtils {\r\n\r\n static setResponseIdToken(originalResponse: AuthResponse, idTokenObj: IdToken) : AuthResponse {\r\n if (!originalResponse) {\r\n return null;\r\n } else if (!idTokenObj) {\r\n return originalResponse;\r\n }\r\n\r\n const exp = Number(idTokenObj.expiration);\r\n if (exp && !originalResponse.expiresOn) {\r\n originalResponse.expiresOn = new Date(exp * 1000);\r\n }\r\n \r\n return {\r\n ...originalResponse,\r\n idToken: idTokenObj,\r\n idTokenClaims: idTokenObj.claims,\r\n uniqueId: idTokenObj.objectId || idTokenObj.subject,\r\n tenantId: idTokenObj.tenantId,\r\n };\r\n }\r\n\r\n static buildAuthResponse(idToken: IdToken, authResponse: AuthResponse, serverAuthenticationRequest: ServerRequestParameters, account: Account, scopes: Array<string>, accountState: string): AuthResponse {\r\n switch(serverAuthenticationRequest.responseType) {\r\n case ResponseTypes.id_token:\r\n let idTokenResponse: AuthResponse = {\r\n ...authResponse,\r\n tokenType: ServerHashParamKeys.ID_TOKEN,\r\n account: account,\r\n scopes: scopes,\r\n accountState: accountState\r\n };\r\n \r\n idTokenResponse = ResponseUtils.setResponseIdToken(idTokenResponse, idToken);\r\n return (idTokenResponse.idToken) ? idTokenResponse : null;\r\n case ResponseTypes.id_token_token:\r\n const idTokeTokenResponse = ResponseUtils.setResponseIdToken(authResponse, idToken);\r\n return (idTokeTokenResponse && idTokeTokenResponse.accessToken && idTokeTokenResponse.idToken) ? idTokeTokenResponse : null;\r\n case ResponseTypes.token:\r\n const tokenResponse = ResponseUtils.setResponseIdToken(authResponse, idToken);\r\n return tokenResponse;\r\n default: \r\n return null;\r\n }\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AccessTokenKey } from \"../cache/AccessTokenKey\";\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class StringUtils {\r\n /**\r\n * Check if a string is empty\r\n *\r\n * @param str\r\n */\r\n static isEmpty(str: string): boolean {\r\n return (typeof str === \"undefined\" || !str || 0 === str.length);\r\n }\r\n\r\n /**\r\n * Check if a string's value is a valid JSON object\r\n *\r\n * @param str\r\n */\r\n static validateAndParseJsonCacheKey(str: string): AccessTokenKey {\r\n try {\r\n const parsedKey = JSON.parse(str);\r\n /**\r\n * There are edge cases in which JSON.parse will successfully parse a non-valid JSON object \r\n * (e.g. JSON.parse will parse an escaped string into an unescaped string), so adding a type check\r\n * of the parsed value is necessary in order to be certain that the string represents a valid JSON object.\r\n *\r\n */\r\n return (parsedKey && typeof parsedKey === \"object\") ? parsedKey : null;\r\n } catch (error) {\r\n return null;\r\n }\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class TimeUtils {\r\n /**\r\n * Returns time in seconds for expiration based on string value passed in.\r\n *\r\n * @param expiresIn\r\n */\r\n static parseExpiresIn(expiresIn: string): number {\r\n // if AAD did not send \"expires_in\" property, use default expiration of 3599 seconds, for some reason AAD sends 3599 as \"expires_in\" value instead of 3600\r\n const expires = expiresIn || \"3599\";\r\n return parseInt(expires, 10);\r\n }\r\n\r\n /**\r\n * Return the current time in Unix time (seconds). Date.getTime() returns in milliseconds.\r\n */\r\n static now(): number {\r\n return Math.round(new Date().getTime() / 1000.0);\r\n }\r\n\r\n /**\r\n * Returns the amount of time in milliseconds since the page loaded.\r\n */\r\n static relativeNowMs(): number {\r\n return window.performance.now();\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { CryptoUtils } from \"./CryptoUtils\";\r\nimport { StringUtils } from \"./StringUtils\";\r\nimport { TimeUtils } from \"./TimeUtils\";\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class TokenUtils {\r\n\r\n /**\r\n * decode a JWT\r\n *\r\n * @param jwtToken\r\n */\r\n static decodeJwt(jwtToken: string): object {\r\n if (StringUtils.isEmpty(jwtToken)) {\r\n return null;\r\n }\r\n const idTokenPartsRegex = /^([^\\.\\s]*)\\.([^\\.\\s]+)\\.([^\\.\\s]*)$/;\r\n const matches = idTokenPartsRegex.exec(jwtToken);\r\n if (!matches || matches.length < 4) {\r\n // this._requestContext.logger.warn(\"The returned id_token is not parseable.\");\r\n return null;\r\n }\r\n const crackedToken = {\r\n header: matches[1],\r\n JWSPayload: matches[2],\r\n JWSSig: matches[3]\r\n };\r\n return crackedToken;\r\n }\r\n\r\n /**\r\n * Evaluates whether token cache item expiration is within expiration offset range\r\n * @param tokenCacheItem \r\n */\r\n static validateExpirationIsWithinOffset(expiration: number, tokenRenewalOffsetSeconds: number): Boolean {\r\n const offset = tokenRenewalOffsetSeconds || 300;\r\n return expiration && (expiration > TimeUtils.now() + offset);\r\n }\r\n\r\n /**\r\n * Extract IdToken by decoding the RAWIdToken\r\n *\r\n * @param encodedIdToken\r\n */\r\n static extractIdToken(encodedIdToken: string): object {\r\n // id token will be decoded to get the username\r\n const decodedToken = this.decodeJwt(encodedIdToken);\r\n if (!decodedToken) {\r\n return null;\r\n }\r\n try {\r\n const base64IdToken = decodedToken[\"JWSPayload\"];\r\n const base64Decoded = CryptoUtils.base64Decode(base64IdToken);\r\n if (!base64Decoded) {\r\n // this._requestContext.logger.info(\"The returned id_token could not be base64 url safe decoded.\");\r\n return null;\r\n }\r\n // ECMA script has JSON built-in support\r\n return JSON.parse(base64Decoded);\r\n } catch (err) {\r\n // this._requestContext.logger.error(\"The returned id_token could not be decoded\" + err);\r\n }\r\n\r\n return null;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { IUri } from \"../IUri\";\r\nimport { Constants, SSOTypes, ServerHashParamKeys } from \"./Constants\";\r\nimport { ServerRequestParameters } from \"../ServerRequestParameters\";\r\nimport { ScopeSet } from \"../ScopeSet\";\r\nimport { StringUtils } from \"./StringUtils\";\r\nimport { CryptoUtils } from \"./CryptoUtils\";\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class UrlUtils {\r\n\r\n /**\r\n * generates the URL with QueryString Parameters\r\n * @param scopes\r\n */\r\n static createNavigateUrl(serverRequestParams: ServerRequestParameters): string {\r\n const str = this.createNavigationUrlString(serverRequestParams);\r\n let authEndpoint: string = serverRequestParams.authorityInstance.AuthorizationEndpoint;\r\n // if the endpoint already has queryparams, lets add to it, otherwise add the first one\r\n if (authEndpoint.indexOf(\"?\") < 0) {\r\n authEndpoint += \"?\";\r\n } else {\r\n authEndpoint += \"&\";\r\n }\r\n\r\n const requestUrl: string = `${authEndpoint}${str.join(\"&\")}`;\r\n return requestUrl;\r\n }\r\n\r\n /**\r\n * Generate the array of all QueryStringParams to be sent to the server\r\n * @param scopes\r\n */\r\n static createNavigationUrlString(serverRequestParams: ServerRequestParameters): Array<string> {\r\n const scopes = ScopeSet.appendDefaultScopes(serverRequestParams.scopes);\r\n\r\n const str: Array<string> = [];\r\n str.push(\"response_type=\" + serverRequestParams.responseType);\r\n str.push(\"scope=\" + encodeURIComponent(ScopeSet.parseScope(scopes)));\r\n str.push(\"client_id=\" + encodeURIComponent(serverRequestParams.clientId));\r\n str.push(\"redirect_uri=\" + encodeURIComponent(serverRequestParams.redirectUri));\r\n\r\n str.push(\"state=\" + encodeURIComponent(serverRequestParams.state));\r\n str.push(\"nonce=\" + encodeURIComponent(serverRequestParams.nonce));\r\n\r\n str.push(\"client_info=1\");\r\n str.push(`x-client-SKU=${serverRequestParams.xClientSku}`);\r\n str.push(`x-client-Ver=${serverRequestParams.xClientVer}`);\r\n if (serverRequestParams.promptValue) {\r\n str.push(\"prompt=\" + encodeURIComponent(serverRequestParams.promptValue));\r\n }\r\n\r\n if (serverRequestParams.claimsValue) {\r\n str.push(\"claims=\" + encodeURIComponent(serverRequestParams.claimsValue));\r\n }\r\n\r\n if (serverRequestParams.queryParameters) {\r\n str.push(serverRequestParams.queryParameters);\r\n }\r\n\r\n if (serverRequestParams.extraQueryParameters) {\r\n str.push(serverRequestParams.extraQueryParameters);\r\n }\r\n\r\n str.push(\"client-request-id=\" + encodeURIComponent(serverRequestParams.correlationId));\r\n return str;\r\n }\r\n\r\n /**\r\n * Returns current window URL as redirect uri\r\n */\r\n static getCurrentUrl(): string {\r\n return window.location.href.split(\"?\")[0].split(\"#\")[0];\r\n }\r\n\r\n /**\r\n * Returns given URL with query string removed\r\n */\r\n static removeHashFromUrl(url: string): string {\r\n return url.split(\"#\")[0];\r\n }\r\n\r\n /**\r\n * Given a url like https://a:b/common/d?e=f#g, and a tenantId, returns https://a:b/tenantId/d\r\n * @param href The url\r\n * @param tenantId The tenant id to replace\r\n */\r\n static replaceTenantPath(url: string, tenantId: string): string {\r\n const lowerCaseUrl = url.toLowerCase();\r\n const urlObject = this.GetUrlComponents(lowerCaseUrl);\r\n const pathArray = urlObject.PathSegments;\r\n if (tenantId && (pathArray.length !== 0 && (pathArray[0] === Constants.common || pathArray[0] === SSOTypes.ORGANIZATIONS || pathArray[0] === SSOTypes.CONSUMERS))) {\r\n pathArray[0] = tenantId;\r\n }\r\n return this.constructAuthorityUriFromObject(urlObject, pathArray);\r\n }\r\n\r\n static constructAuthorityUriFromObject(urlObject: IUri, pathArray: string[]): string {\r\n return this.CanonicalizeUri(urlObject.Protocol + \"//\" + urlObject.HostNameAndPort + \"/\" + pathArray.join(\"/\"));\r\n }\r\n \r\n /**\r\n * Checks if an authority is common (ex. https://a:b/common/)\r\n * @param url The url\r\n * @returns true if authority is common and false otherwise \r\n */\r\n static isCommonAuthority(url: string): boolean {\r\n const authority = this.CanonicalizeUri(url);\r\n const pathArray = this.GetUrlComponents(authority).PathSegments;\r\n return (pathArray.length !== 0 && pathArray[0] === Constants.common);\r\n }\r\n\r\n /**\r\n * Checks if an authority is for organizations (ex. https://a:b/organizations/)\r\n * @param url The url\r\n * @returns true if authority is for and false otherwise \r\n */\r\n static isOrganizationsAuthority(url: string): boolean {\r\n const authority = this.CanonicalizeUri(url);\r\n const pathArray = this.GetUrlComponents(authority).PathSegments;\r\n return (pathArray.length !== 0 && pathArray[0] === SSOTypes.ORGANIZATIONS);\r\n }\r\n\r\n /**\r\n * Checks if an authority is for consumers (ex. https://a:b/consumers/)\r\n * @param url The url\r\n * @returns true if authority is for and false otherwise \r\n */\r\n static isConsumersAuthority(url: string): boolean {\r\n const authority = this.CanonicalizeUri(url);\r\n const pathArray = this.GetUrlComponents(authority).PathSegments;\r\n return (pathArray.length !== 0 && pathArray[0] === SSOTypes.CONSUMERS);\r\n }\r\n\r\n /**\r\n * Parses out the components from a url string.\r\n * @returns An object with the various components. Please cache this value insted of calling this multiple times on the same url.\r\n */\r\n static GetUrlComponents(url: string): IUri {\r\n if (!url) {\r\n throw \"Url required\";\r\n }\r\n\r\n // https://gist.github.com/curtisz/11139b2cfcaef4a261e0\r\n const regEx = RegExp(\"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\\\?([^#]*))?(#(.*))?\");\r\n\r\n const match = url.match(regEx);\r\n\r\n if (!match || match.length < 6) {\r\n throw \"Valid url required\";\r\n }\r\n\r\n const urlComponents = <IUri>{\r\n Protocol: match[1],\r\n HostNameAndPort: match[4],\r\n AbsolutePath: match[5]\r\n };\r\n\r\n let pathSegments = urlComponents.AbsolutePath.split(\"/\");\r\n pathSegments = pathSegments.filter((val) => val && val.length > 0); // remove empty elements\r\n urlComponents.PathSegments = pathSegments;\r\n\r\n if (match[6]){\r\n urlComponents.Search = match[6];\r\n }\r\n if (match[8]){\r\n urlComponents.Hash = match[8];\r\n }\r\n \r\n return urlComponents;\r\n }\r\n\r\n /**\r\n * Given a url or path, append a trailing slash if one doesnt exist\r\n *\r\n * @param url\r\n */\r\n static CanonicalizeUri(url: string): string {\r\n if (url) {\r\n let lowerCaseUrl = url.toLowerCase();\r\n\r\n if (!UrlUtils.endsWith(lowerCaseUrl, \"/\")) {\r\n lowerCaseUrl += \"/\";\r\n }\r\n\r\n return lowerCaseUrl;\r\n }\r\n\r\n return url;\r\n }\r\n\r\n /**\r\n * Checks to see if the url ends with the suffix\r\n * Required because we are compiling for es5 instead of es6\r\n * @param url\r\n * @param str\r\n */\r\n // TODO: Rename this, not clear what it is supposed to do\r\n static endsWith(url: string, suffix: string): boolean {\r\n if (!url || !suffix) {\r\n return false;\r\n }\r\n\r\n return url.indexOf(suffix, url.length - suffix.length) !== -1;\r\n }\r\n\r\n /**\r\n * Utils function to remove the login_hint and domain_hint from the i/p extraQueryParameters\r\n * @param url\r\n * @param name\r\n */\r\n static urlRemoveQueryStringParameter(url: string, name: string): string {\r\n if (StringUtils.isEmpty(url)) {\r\n return url;\r\n }\r\n\r\n let updatedUrl = url;\r\n let regex = new RegExp(\"(\\\\&\" + name + \"=)[^\\&]+\");\r\n updatedUrl = url.replace(regex, \"\");\r\n // name=value&\r\n regex = new RegExp(\"(\" + name + \"=)[^\\&]+&\");\r\n updatedUrl = url.replace(regex, \"\");\r\n // name=value\r\n regex = new RegExp(\"(\" + name + \"=)[^\\&]+\");\r\n updatedUrl = url.replace(regex, \"\");\r\n return updatedUrl;\r\n }\r\n\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * Returns the anchor part(#) of the URL\r\n */\r\n static getHashFromUrl(urlStringOrFragment: string): string {\r\n const hashIndex1 = urlStringOrFragment.indexOf(\"#\");\r\n const hashIndex2 = urlStringOrFragment.indexOf(\"#/\");\r\n if (hashIndex2 > -1) {\r\n return urlStringOrFragment.substring(hashIndex2 + 2);\r\n } else if (hashIndex1 > -1) {\r\n return urlStringOrFragment.substring(hashIndex1 + 1);\r\n }\r\n return urlStringOrFragment;\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Check if the url contains a hash with known properties\r\n * @ignore\r\n */\r\n static urlContainsHash(urlString: string): boolean {\r\n const parameters = UrlUtils.deserializeHash(urlString);\r\n return (\r\n parameters.hasOwnProperty(ServerHashParamKeys.ERROR_DESCRIPTION) ||\r\n parameters.hasOwnProperty(ServerHashParamKeys.ERROR) ||\r\n parameters.hasOwnProperty(ServerHashParamKeys.ACCESS_TOKEN) ||\r\n parameters.hasOwnProperty(ServerHashParamKeys.ID_TOKEN)\r\n );\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Returns deserialized portion of URL hash\r\n * @ignore\r\n */\r\n static deserializeHash(urlFragment: string): object {\r\n const hash = UrlUtils.getHashFromUrl(urlFragment);\r\n return CryptoUtils.deserialize(hash);\r\n }\r\n\r\n /**\r\n * @ignore\r\n * @param {string} URI\r\n * @returns {string} host from the URI\r\n *\r\n * extract URI from the host\r\n */\r\n static getHostFromUri(uri: string): string {\r\n // remove http:// or https:// from uri\r\n let extractedUri = String(uri).replace(/^(https?:)\\/\\//, \"\");\r\n extractedUri = extractedUri.split(\"/\")[0];\r\n return extractedUri;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ClientAuthError } from \"../error/ClientAuthError\";\r\nimport { UrlUtils } from \"./UrlUtils\";\r\nimport { Logger } from \"../Logger\";\r\nimport { AuthCache } from \"../cache/AuthCache\";\r\nimport { TemporaryCacheKeys, Constants } from \"./Constants\";\r\nimport { TimeUtils } from \"./TimeUtils\";\r\n\r\nexport class WindowUtils {\r\n /**\r\n * @hidden\r\n * Interval in milliseconds that we poll a window\r\n * @ignore\r\n */\r\n private static POLLING_INTERVAL_MS = 50;\r\n\r\n /**\r\n * @hidden\r\n * Checks if the current page is running in an iframe.\r\n * @ignore\r\n */\r\n static isInIframe(): boolean {\r\n return window.parent !== window;\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Check if the current page is running in a popup.\r\n * @ignore\r\n */\r\n static isInPopup(): boolean {\r\n return !!(window.opener && window.opener !== window);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * @param prefix\r\n * @param scopes\r\n * @param authority\r\n */\r\n static generateFrameName(prefix: string, requestSignature: string): string {\r\n return `${prefix}${Constants.resourceDelimiter}${requestSignature}`;\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Polls an iframe until it loads a url with a hash\r\n * @ignore\r\n */\r\n static monitorIframeForHash(contentWindow: Window, timeout: number, urlNavigate: string, logger: Logger): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n /*\r\n * Polling for iframes can be purely timing based,\r\n * since we don't need to account for interaction.\r\n */\r\n const nowMark = TimeUtils.relativeNowMs();\r\n const timeoutMark = nowMark + timeout;\r\n\r\n logger.verbose(\"monitorWindowForIframe polling started\");\r\n\r\n const intervalId = setInterval(() => {\r\n if (TimeUtils.relativeNowMs() > timeoutMark) {\r\n logger.error(\"monitorIframeForHash unable to find hash in url, timing out\");\r\n logger.errorPii(`monitorIframeForHash polling timed out for url: ${urlNavigate}`);\r\n clearInterval(intervalId);\r\n reject(ClientAuthError.createTokenRenewalTimeoutError());\r\n return;\r\n }\r\n\r\n let href;\r\n\r\n try {\r\n /*\r\n * Will throw if cross origin,\r\n * which should be caught and ignored\r\n * since we need the interval to keep running while on STS UI.\r\n */\r\n href = contentWindow.location.href;\r\n } catch (e) {}\r\n\r\n if (href && UrlUtils.urlContainsHash(href)) {\r\n logger.verbose(\"monitorIframeForHash found url in hash\");\r\n clearInterval(intervalId);\r\n resolve(contentWindow.location.hash);\r\n } \r\n }, WindowUtils.POLLING_INTERVAL_MS);\r\n });\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Polls a popup until it loads a url with a hash\r\n * @ignore\r\n */\r\n static monitorPopupForHash(contentWindow: Window, timeout: number, urlNavigate: string, logger: Logger): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n /*\r\n * Polling for popups needs to be tick-based,\r\n * since a non-trivial amount of time can be spent on interaction (which should not count against the timeout).\r\n */\r\n const maxTicks = timeout / WindowUtils.POLLING_INTERVAL_MS;\r\n let ticks = 0;\r\n\r\n logger.verbose(\"monitorWindowForHash polling started\");\r\n\r\n const intervalId = setInterval(() => {\r\n if (contentWindow.closed) {\r\n logger.error(\"monitorWindowForHash window closed\");\r\n clearInterval(intervalId);\r\n reject(ClientAuthError.createUserCancelledError());\r\n return;\r\n }\r\n\r\n let href;\r\n try {\r\n /*\r\n * Will throw if cross origin,\r\n * which should be caught and ignored\r\n * since we need the interval to keep running while on STS UI.\r\n */\r\n href = contentWindow.location.href;\r\n } catch (e) {}\r\n\r\n // Don't process blank pages or cross domain\r\n if (!href || href === \"about:blank\") {\r\n return;\r\n }\r\n\r\n /*\r\n * Only run clock when we are on same domain for popups\r\n * as popup operations can take a long time.\r\n */\r\n ticks++;\r\n\r\n if (href && UrlUtils.urlContainsHash(href)) {\r\n logger.verbose(\"monitorPopupForHash found url in hash\");\r\n clearInterval(intervalId);\r\n const hash = contentWindow.location.hash;\r\n WindowUtils.clearUrlFragment(contentWindow);\r\n resolve(hash);\r\n } else if (ticks > maxTicks) {\r\n logger.error(\"monitorPopupForHash unable to find hash in url, timing out\");\r\n logger.errorPii(`monitorPopupForHash polling timed out for url: ${urlNavigate}`);\r\n clearInterval(intervalId);\r\n reject(ClientAuthError.createTokenRenewalTimeoutError());\r\n }\r\n }, WindowUtils.POLLING_INTERVAL_MS);\r\n });\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Loads iframe with authorization endpoint URL\r\n * @ignore\r\n */\r\n static loadFrame(urlNavigate: string, frameName: string, timeoutMs: number, logger: Logger): Promise<HTMLIFrameElement> {\r\n /*\r\n * This trick overcomes iframe navigation in IE\r\n * IE does not load the page consistently in iframe\r\n */\r\n logger.infoPii(\"LoadFrame: \" + frameName);\r\n\r\n return new Promise((resolve, reject) => {\r\n setTimeout(() => {\r\n const frameHandle = this.loadFrameSync(urlNavigate, frameName, logger);\r\n\r\n if (!frameHandle) {\r\n reject(`Unable to load iframe with name: ${frameName}`);\r\n return;\r\n }\r\n\r\n resolve(frameHandle);\r\n }, timeoutMs);\r\n });\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Loads the iframe synchronously when the navigateTimeFrame is set to `0`\r\n * @param urlNavigate\r\n * @param frameName\r\n * @param logger\r\n */\r\n static loadFrameSync(urlNavigate: string, frameName: string, logger: Logger): HTMLIFrameElement{\r\n const frameHandle = WindowUtils.addHiddenIFrame(frameName, logger);\r\n\r\n // returning to handle null in loadFrame, also to avoid null object access errors\r\n if (!frameHandle) {\r\n return null;\r\n }\r\n else if (frameHandle.src === \"\" || frameHandle.src === \"about:blank\") {\r\n frameHandle.src = urlNavigate;\r\n logger.infoPii(\"Frame Name : \" + frameName + \" Navigated to: \" + urlNavigate);\r\n }\r\n\r\n return frameHandle;\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Adds the hidden iframe for silent token renewal.\r\n * @ignore\r\n */\r\n static addHiddenIFrame(iframeId: string, logger: Logger): HTMLIFrameElement {\r\n if (typeof iframeId === \"undefined\") {\r\n return null;\r\n }\r\n\r\n logger.infoPii(\"Add msal frame to document:\" + iframeId);\r\n let adalFrame = document.getElementById(iframeId) as HTMLIFrameElement;\r\n if (!adalFrame) {\r\n if (document.createElement &&\r\n document.documentElement &&\r\n (window.navigator.userAgent.indexOf(\"MSIE 5.0\") === -1)) {\r\n const ifr = document.createElement(\"iframe\");\r\n ifr.setAttribute(\"id\", iframeId);\r\n ifr.setAttribute(\"aria-hidden\", \"true\");\r\n ifr.style.visibility = \"hidden\";\r\n ifr.style.position = \"absolute\";\r\n ifr.style.width = ifr.style.height = \"0\";\r\n ifr.style.border = \"0\";\r\n ifr.setAttribute(\"sandbox\", \"allow-scripts allow-same-origin allow-forms\");\r\n adalFrame = (document.getElementsByTagName(\"body\")[0].appendChild(ifr) as HTMLIFrameElement);\r\n } else if (document.body && document.body.insertAdjacentHTML) {\r\n document.body.insertAdjacentHTML(\"beforeend\", \"<iframe name='\" + iframeId + \"' id='\" + iframeId + \"' style='display:none'></iframe>\");\r\n }\r\n\r\n if (window.frames && window.frames[iframeId]) {\r\n adalFrame = window.frames[iframeId];\r\n }\r\n }\r\n\r\n return adalFrame;\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Removes a hidden iframe from the page.\r\n * @ignore\r\n */\r\n static removeHiddenIframe(iframe: HTMLIFrameElement): void {\r\n if (document.body === iframe.parentNode) {\r\n document.body.removeChild(iframe);\r\n }\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Find and return the iframe element with the given hash\r\n * @ignore\r\n */\r\n static getIframeWithHash(hash: string): HTMLIFrameElement {\r\n const iframes = document.getElementsByTagName(\"iframe\");\r\n const iframeArray: Array<HTMLIFrameElement> = Array.apply(null, Array(iframes.length)).map((iframe: HTMLIFrameElement, index: number) => iframes.item(index)); // eslint-disable-line prefer-spread\r\n\r\n return iframeArray.filter((iframe: HTMLIFrameElement) => {\r\n try {\r\n return iframe.contentWindow.location.hash === hash;\r\n } catch (e) {\r\n return false;\r\n }\r\n })[0];\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Returns an array of all the popups opened by MSAL\r\n * @ignore\r\n */\r\n static getPopups(): Array<Window> {\r\n if (!window.openedWindows) {\r\n window.openedWindows = [];\r\n }\r\n\r\n return window.openedWindows;\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Find and return the popup with the given hash\r\n * @ignore\r\n */\r\n static getPopUpWithHash(hash: string): Window {\r\n return WindowUtils.getPopups().filter(popup => {\r\n try {\r\n return popup.location.hash === hash;\r\n } catch (e) {\r\n return false;\r\n }\r\n })[0];\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Add the popup to the known list of popups\r\n * @ignore\r\n */\r\n static trackPopup(popup: Window): void {\r\n WindowUtils.getPopups().push(popup);\r\n }\r\n\r\n /**\r\n * @hidden\r\n * Close all popups\r\n * @ignore\r\n */\r\n static closePopups(): void {\r\n WindowUtils.getPopups().forEach(popup => popup.close());\r\n }\r\n\r\n /**\r\n * @ignore\r\n *\r\n * blocks any login/acquireToken calls to reload from within a hidden iframe (generated for silent calls)\r\n */\r\n static blockReloadInHiddenIframes(): void {\r\n // return an error if called from the hidden iframe created by the msal js silent calls\r\n if (UrlUtils.urlContainsHash(window.location.hash) && WindowUtils.isInIframe()) {\r\n throw ClientAuthError.createBlockTokenRequestsInHiddenIframeError();\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @param cacheStorage\r\n */\r\n static checkIfBackButtonIsPressed(cacheStorage: AuthCache): void {\r\n const redirectCache = cacheStorage.getItem(TemporaryCacheKeys.REDIRECT_REQUEST);\r\n\r\n // if redirect request is set and there is no hash\r\n if(redirectCache && !UrlUtils.urlContainsHash(window.location.hash)) {\r\n const splitCache = redirectCache.split(Constants.resourceDelimiter);\r\n splitCache.shift();\r\n const state = splitCache.length > 0 ? splitCache.join(Constants.resourceDelimiter): null;\r\n cacheStorage.resetTempCacheItems(state);\r\n }\r\n }\r\n\r\n /**\r\n * Removes url fragment from browser url\r\n */\r\n static clearUrlFragment(contentWindow: Window): void {\r\n contentWindow.location.hash = \"\";\r\n // Office.js sets history.replaceState to null\r\n if (typeof contentWindow.history.replaceState === \"function\") {\r\n // Full removes \"#\" from url\r\n contentWindow.history.replaceState(null, null, `${contentWindow.location.pathname}${contentWindow.location.search}`);\r\n }\r\n }\r\n}\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(432);\n"],"sourceRoot":""} |