{"version":3,"sources":["webpack:///./node_modules/msal/lib-es6/utils/StringUtils.js","webpack:///./node_modules/msal/lib-es6/telemetry/ApiEvent.js","webpack:///./node_modules/msal/lib-es6/authority/AuthorityFactory.js","webpack:///./node_modules/msal/lib-es6/utils/TimeUtils.js","webpack:///./node_modules/msal/lib-es6/Logger.js","webpack:///./node_modules/msal/lib-es6/utils/UrlUtils.js","webpack:///./node_modules/msal/lib-es6/error/ServerError.js","webpack:///./node_modules/msal/lib-es6/utils/TokenUtils.js","webpack:///./node_modules/msal/lib-es6/cache/AuthCache.js","webpack:///./node_modules/msal/lib-es6/telemetry/HttpEvent.js","webpack:///./node_modules/msal/lib-es6/cache/AccessTokenKey.js","webpack:///./node_modules/msal/lib-es6/error/AuthError.js","webpack:///./node_modules/msal/lib-es6/Configuration.js","webpack:///./node_modules/msal/lib-es6/cache/BrowserStorage.js","webpack:///./node_modules/msal/lib-es6/telemetry/DefaultEvent.js","webpack:///./node_modules/msal/lib-es6/index.js","webpack:///./node_modules/msal/lib-es6/error/ClientConfigurationError.js","webpack:///./node_modules/msal/lib-es6/UserAgentApplication.js","webpack:///./node_modules/msal/lib-es6/telemetry/TelemetryUtils.js","webpack:///./node_modules/msal/lib-es6/authority/Authority.js","webpack:///./node_modules/msal/lib-es6/AuthResponse.js","webpack:///./node_modules/msal/lib-es6/cache/AccessTokenCacheItem.js","webpack:///./node_modules/msal/lib-es6/utils/CryptoUtils.js","webpack:///./node_modules/msal/lib-es6/utils/RequestUtils.js","webpack:///./node_modules/msal/lib-es6/utils/ResponseUtils.js","webpack:///./node_modules/msal/lib-es6/telemetry/TelemetryConstants.js","webpack:///./node_modules/msal/lib-es6/utils/Constants.js","webpack:///./node_modules/msal/lib-es6/telemetry/TelemetryEvent.js","webpack:///./node_modules/msal/lib-es6/IdToken.js","webpack:///./node_modules/msal/lib-es6/authority/B2cAuthority.js","webpack:///./node_modules/msal/lib-es6/ServerRequestParameters.js","webpack:///./node_modules/msal/lib-es6/telemetry/TelemetryManager.js","webpack:///./node_modules/msal/lib-es6/ClientInfo.js","webpack:///./node_modules/msal/lib-es6/Account.js","webpack:///./node_modules/msal/lib-es6/error/InteractionRequiredAuthError.js","webpack:///./node_modules/msal/lib-es6/XHRClient.js","webpack:///./node_modules/msal/lib-es6/utils/WindowUtils.js","webpack:///./node_modules/msal/lib-es6/authority/AadAuthority.js","webpack:///./node_modules/msal/lib-es6/cache/AccessTokenValue.js","webpack:///./node_modules/msal/lib-es6/error/ClientAuthError.js","webpack:///./node_modules/msal/lib-es6/ScopeSet.js"],"names":["StringUtils","isEmpty","str","length","_a","API_CODE","API_EVENT_IDENTIFIER","EVENT_KEYS","AUTHORITY","AUTHORITY_TYPE","PROMPT","TENANT_ID","USER_ID","WAS_SUCESSFUL","API_ERROR_CODE","LOGIN_HINT","mapEventIdentiferToCode","AcquireTokenSilent","AcquireTokenPopup","AcquireTokenRedirect","LoginPopup","LoginRedirect","Logout","ApiEvent","_super","correlationId","piiEnabled","apiEventIdentifier","_this","call","this","apiCode","Object","defineProperty","prototype","set","event","ApiTelemIdConstStrKey","enumerable","configurable","ApiIdConstStrKey","uri","toLowerCase","errorCode","tenantId","accountId","get","wasSuccessful","loginHint","authorityType","promptType","AuthorityFactory","setKnownAuthorities","validateAuthority","knownAuthorities","keys","forEach","authority","saveMetadataFromNetwork","authorityInstance","telemetryManager","metadata","label","resolveEndpointsAsync","sent","metadataMap","CanonicalAuthority","getMetadata","authorityUrl","saveMetadataFromConfig","authorityMetadataJson","parsedMetadata","JSON","parse","authorization_endpoint","end_session_endpoint","issuer","createInvalidAuthorityMetadataError","AuthorizationEndpoint","EndSessionEndpoint","Issuer","e","detectAuthorityFromUrl","CanonicalizeUri","components","GetUrlComponents","pathSegments","PathSegments","Adfs","B2C","Aad","CreateInstance","authorityMetadata","type","createInvalidAuthorityTypeError","Map","TimeUtils","parseExpiresIn","expiresIn","parseInt","now","Math","round","Date","getTime","LogLevel","Logger","localCallback","options","level","Info","_b","_c","piiLoggingEnabled","logMessage","logLevel","containsPii","log","timestamp","toUTCString","executeCallback","message","error","Error","errorPii","warning","Warning","warningPii","info","infoPii","verbose","Verbose","verbosePii","isPiiLoggingEnabled","UrlUtils","createNavigateUrl","serverRequestParams","createNavigationUrlString","authEndpoint","indexOf","requestUrl","join","scopes","clientId","push","responseType","translateclientIdUsedInScope","encodeURIComponent","parseScope","redirectUri","state","nonce","xClientSku","xClientVer","promptValue","claimsValue","queryParameters","extraQueryParameters","clientIdIndex","splice","getCurrentUrl","window","location","href","split","removeHashFromUrl","url","replaceTenantPath","urlObject","pathArray","common","constructAuthorityUriFromObject","Protocol","HostNameAndPort","regEx","RegExp","match","urlComponents","AbsolutePath","filter","val","Search","Hash","endsWith","suffix","urlRemoveQueryStringParameter","name","regex","replace","getHashFromUrl","urlStringOrFragment","hashIndex1","hashIndex2","substring","urlContainsHash","urlString","parameters","deserializeHash","hasOwnProperty","ERROR_DESCRIPTION","ERROR","ACCESS_TOKEN","ID_TOKEN","urlFragment","hash","deserialize","getHostFromUri","extractedUri","String","ServerErrorMessage","serverUnavailable","code","desc","unknownServerError","ServerError","errorMessage","setPrototypeOf","createServerUnavailableError","createUnknownServerError","errorDesc","TokenUtils","decodeJwt","jwtToken","idTokenPartsRegex","matches","exec","crackedToken","header","JWSPayload","JWSSig","extractIdToken","encodedIdToken","decodedToken","base64IdToken","base64Decoded","base64Decode","err","AuthCache","cacheLocation","storeAuthStateInCookie","rollbackEnabled","migrateCacheEntries","idTokenKey","cachePrefix","IDTOKEN","clientInfoKey","CLIENT_INFO","errorKey","errorDescKey","ERROR_DESC","idTokenValue","getItem","clientInfoValue","errorValue","errorDescValue","values","keysToMigrate","cacheKey","index","duplicateCacheEntry","newKey","value","setItem","generateCacheKey","key","addInstanceId","adalIdToken","enableCookieStorage","removeItem","resetCacheItems","storage","resetTempCacheItems","tokenRenewalInProgress","setItemCookie","clearMsalCookie","INTERACTION_STATUS","REDIRECT_REQUEST","cName","cValue","expires","getItemCookie","getAllAccessTokens","homeAccountIdentifier","results","reduce","tokens","keyMatches","parseAtKey","newAccessTokenCacheItem","concat","createCacheParseError","stateValue","renewStatus","RENEW_STATUS","inProgress","clearItemCookie","NONCE_IDTOKEN","STATE_LOGIN","LOGIN_REQUEST","STATE_ACQ_TOKEN","generateAcquireTokenAccountKey","ACQUIRE_TOKEN_ACCOUNT","resourceDelimiter","generateAuthorityKey","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","HttpEvent","eventLabel","scrubbedUri","httpPath","userAgent","queryParams","generateQueryParametersString","apiVersion","statusCode","httpMethod","requestIdHeader","speInfo","subErrorCode","AccessTokenKey","uid","utid","base64Encode","AuthErrorMessage","unexpectedError","noWindowObjectError","AuthError","createUnexpectedError","errDesc","createNoWindowObjectError","FRAME_TIMEOUT","OFFSET","NAVIGATE_FRAME_WAIT","DEFAULT_AUTH_OPTIONS","postLogoutRedirectUri","navigateToLoginRequestUrl","DEFAULT_CACHE_OPTIONS","DEFAULT_SYSTEM_OPTIONS","logger","loadFrameTimeout","tokenRenewalOffsetSeconds","navigateFrameWait","DEFAULT_FRAMEWORK_OPTIONS","isAngular","unprotectedResources","Array","protectedResourceMap","buildConfiguration","auth","cache","system","_d","framework","overlayedConfig","BrowserStorage","storageSupported","createStorageNotSupportedError","clear","cookieStr","expireTime","getCookieExpirationTime","document","cookie","ca","i","c","charAt","cookieLifeDays","today","expr","DefaultEvent","platform","eventCount","sdk","sdkVersion","applicationName","applicationVersion","networkInformation","connectionSpeed","UiEventCountTelemetryBatchKey","getEventCount","HttpEventCountTelemetryBatchKey","CacheEventCountConstStrKey","eventName","ClientConfigurationErrorMessage","configurationNotSet","storageNotSupported","noRedirectCallbacksSet","invalidCallbackObject","scopesRequired","emptyScopes","nonArrayScopes","clientScope","invalidPrompt","invalidAuthorityType","authorityUriInsecure","authorityUriInvalidPath","unsupportedAuthorityValidation","untrustedAuthority","b2cAuthorityUriInvalidPath","b2cKnownAuthoritiesNotSet","claimsRequestParsingError","emptyRequestError","invalidCorrelationIdError","telemetryConfigError","ssoSilentError","invalidAuthorityMetadataError","ClientConfigurationError","createNoSetConfigurationError","givenCacheLocation","createRedirectCallbacksNotSetError","createInvalidCallbackObjectError","callbackObject","createEmptyScopesArrayError","scopesValue","createScopesNonArrayError","createClientIdSingleScopeError","createScopesRequiredError","createInvalidPromptError","createClaimsRequestParsingError","claimsRequestParseError","createEmptyRequestError","createInvalidCorrelationIdError","createKnownAuthoritiesNotSetError","createUntrustedAuthorityError","createTelemetryConfigError","config","requiredKeys","telemetryEmitter","missingKeys","createSsoSilentError","DEFAULT_AUTHORITY","ResponseTypes","id_token","token","id_token_token","UserAgentApplication","configuration","authResponseCallback","tokenReceivedCallback","errorReceivedCallback","inCookie","getTelemetryManagerFromConfig","telemetry","cacheStorage","activeRenewals","renewStates","callbackMappedToRenewStates","promiseMappedToRenewStates","msal","urlHash","checkIfBackButtonIsPressed","stateInfo","getResponseState","method","interactionTypeRedirect","handleRedirectAuthenticationResponse","getAuthorityInstance","handleRedirectCallback","authOrTokenCallback","redirectError","authErrorHandler","redirectResponse","authResponseHandler","interactionType","response","resolve","interactionTypePopup","createInvalidInteractionTypeError","authErr","reject","accountState","loginRedirect","userRequest","request","validateRequest","acquireTokenInteractive","acquireTokenRedirect","loginPopup","apiEvent","createAndStartApiEvent","Promise","then","resp","stopAndFlushApiEvent","catch","acquireTokenPopup","isLoginCall","blockReloadInHiddenIframes","account","interactionProgress","thrownError","createLoginInProgressError","createAcquireTokenInProgressError","stateOnlyResponse","getAccountState","getAccount","isSSOParam","acquireTokenHelper","createUserLoginRequiredError","extractADALIdToken","tokenRequest","buildIDTokenRequest","silentLogin","acquireTokenSilent","scope","serverAuthenticationRequest","acquireTokenAuthority","popUpWindow","loginStartPage","urlNavigate","error_1","navigate","err_1","trys","hasCachedMetadata","getTokenType","redirectStartPage","getRedirectUri","updateCacheEntries","populateQueryParams","response_mode_fragment","requestType","login","renewToken","registerCallback","openPopup","popUpWidth","popUpHeight","trackPopup","popUpWindowError","createPopupWindowError","monitorWindowForHash","handleAuthenticationResponse","broadcast","closePopups","close","onRedirectNavigate","navigateWindow","createEndpointResolutionError","toString","ssoSilent","sid","interactionTypeSilent","requestSignature","createRequestSignature","adalIdTokenObject","userContainedClaims","cacheResultResponse","err_2","claimsRequest","forceRefresh","getCachedToken","renewIdToken","res","title","winLeft","screenLeft","screenX","winTop","screenTop","screenY","width","innerWidth","documentElement","clientWidth","body","height","innerHeight","clientHeight","left","top_1","popupWindow","open","focus","loadIframeTimeout","frameName","expectedState","iframe","error_2","loadFrame","loadFrameSync","contentWindow","removeHiddenIframe","assign","logout","logoutAsync","requestCorrelationId","correlationIdParam","postLogoutQueryParam","error_3","createNewGuid","clearCache","getPostLogoutRedirectUri","accessTokenItems","stringify","clearCacheForScope","accessToken","isCallback","processCallBack","parentCallback","saveTokenFromHash","parent","tokenType","createErrorInCallbackFunction","locationHash","tokenResponseCallback","loginRequestUrl","currentUrl","finalRedirectUrl","loginRequestUrlComponents","stateResponse","STATE","parsedState","parseLibraryState","unknown","ts","stateMatch","silentAuthenticationState","statesInParentContext","accessTokenCacheItem","tokenCacheItems","filteredItems","cacheItem","cachedScopes","containsScope","createMultipleMatchingTokensInCacheError","authorityList","getUniqueAuthority","createMultipleAuthoritiesInCacheError","expired","Number","offset","idTokenObj","idToken","aState","uniqueId","idTokenClaims","claims","expiresOn","fromCache","setResponseIdToken","accessTokenCacheItems","property","flags","element","generateFrameName","TOKEN_FRAME","addHiddenIFrame","prompt","prompt_none","ID_TOKEN_FRAME","saveAccessToken","clientInfo","expiration","accessTokenResponse","clientObj","SCOPE","consentedScopes","isIntersectingScopes","EXPIRES_IN","accessTokenKey","accessTokenValue","rawIdToken","hashParams","authorityKey","acquireTokenAccountKey","LOGIN_ERROR","no_account","hashErr","hashErrDesc","isInteractionRequiredError","SESSION_STATE","populateAuthority","createClientInfoNotPopulatedError","createAccount","accountKey","acquireTokenAccountKey_noaccount","cachedAccount","acquireTokenAccount","compareAccounts","createNonceMismatchError","createInvalidIdTokenError","createInvalidStateError","cachedAuthority","rawClientInfo","splitIndex","getAllAccounts","accounts","getUniqueAccounts","uniqueAccounts","data","evt","CustomEvent","detail","dispatchEvent","getCachedTokenInternal","accountObject","newAuthority","getScopesForEndpoint","endpoint","size","_i","from","getLoginInProgress","setInteractionInProgress","setloginInProgress","loginInProgress","getAcquireTokenInProgress","setAcquireTokenInProgress","acquireTokenInProgress","getLogger","setLogger","reqRedirectUri","getCurrentConfiguration","silentCall","setAccountCache","getAccountId","setAuthorityCache","getTelemetrymanagerStub","telemetryPlatform","telemetryManagerConfig","scrubTenantFromUri","toLocaleLowerCase","pathParams","tenantPosition","hashPersonalIdentifier","valueToHash","prependEventNamePrefix","supportsBrowserPerformance","performance","mark","measure","endBrowserPerformanceMeasurement","measureName","startMark","endMark","clearMeasures","clearMarks","startBrowserPerformanceMeasurement","AuthorityType","Authority","IsValidationEnabled","validateAsUri","tenantDiscoveryResponse","CanonicalAuthorityUrlComponents","validateResolved","Tenant","canonicalAuthority","canonicalAuthorityUrlComponents","DiscoverEndpoints","openIdConfigurationEndpoint","client","httpEvent","startEvent","sendRequestAsync","httpResponseStatus","stopEvent","serverErrorCode","openIdConfigurationEndpointResponse","GetOpenIdConfigurationEndpointAsync","buildResponseStateOnly","AccessTokenCacheItem","CryptoUtils","cryptoObj","crypto","getRandomValues","buffer","Uint8Array","decimalToHex","guidHolder","hex","r","guidResponse","random","isGuid","guid","regexGuid","test","num","input","btoa","p1","fromCharCode","encodedString","decodeURIComponent","atob","map","charCodeAt","slice","query","pl","search","decode","s","obj","RequestUtils","appendScopes","extraScopesToConsent","validateInputScope","validatePromptParameter","validateEQParameters","validateClaimsRequest","validateAndGenerateState","validateAndGenerateCorrelationId","validatedRequest","LOGIN","SELECT_ACCOUNT","CONSENT","NONE","eQParams","param","userState","generateLibraryState","stateObject","id","stateString","libraryState","ResponseUtils","originalResponse","exp","objectId","subject","EVENT_NAME_PREFIX","EVENT_NAME_KEY","START_TIME_KEY","ELAPSED_TIME_KEY","TELEMETRY_BLOB_EVENT_NAMES","MsalCorrelationIdConstStrKey","BrokerAppConstStrKey","IdpConstStrKey","IsSilentTelemetryBatchKey","IsSuccessfulConstStrKey","ResponseTimeConstStrKey","TenantIdConstStrKey","TENANT_PLACEHOLDER","ServerHashParamKeys","TemporaryCacheKeys","PersistentCacheKeys","ErrorCacheKeys","Constants","_popUpWidth","_popUpHeight","SSOTypes","AADTrustedHostList","BlacklistedEQParams","SID","PromptState","FramePrefix","libraryVersion","TelemetryEvent","eventId","setElapsedTime","time","stop","startTimestamp","displayName","perfStartMark","perfEndMark","start","telemetryCorrelationId","IdToken","createIdTokenNullOrEmptyError","version","preferredName","homeObjectId","cloudInstance","createIdTokenParsingError","B2CTrustedHostList","B2cAuthority","IsInTrustedHostList","DefaultOpenIdConfigurationEndpoint","host","B2C_PREFIX","ServerRequestParameters","trimAndConvertArrayToLowerCase","constructUnifiedCacheQueryParameter","addHintParameters","idTokenObject","ssoType","ssoData","serverReqParam","userName","upn","addSSOParameter","qParams","populateSID","populateLoginHint","ssoParam","paramsString","domain_hint","TelemetryManager","completedEvents","inProgressEvents","eventCountByCorrelationId","onlySendFailureTelemetry","libraryName","navigator","connection","effectiveType","incrementEventCount","flush","orphanedEvents","getOrphanedEvents","eventsToFlush","eventCountsToFlush","defaultEvent","eventsWithDefaultEvent","apiErrorCode","createAndStartHttpEvent","correlation","memo","eventKey","event_1","ClientInfo","decodedClientInfo","createClientInfoDecodingError","_uid","_utid","Account","accountIdentifier","environment","a1","a2","InteractionRequiredAuthErrorMessage","interactionRequired","consentRequired","loginRequired","InteractionRequiredAuthError","errorString","interactionRequiredCodes","createLoginRequiredAuthError","createInteractionRequiredAuthError","createConsentRequiredAuthError","XhrClient","enableCaching","xhr","XMLHttpRequest","onload","ev","jsonResponse","status","handleError","responseText","onerror","send","WindowUtils","isInIframe","isInPopup","opener","prefix","timeout","isSilentCall","maxTicks","POLLING_INTERVAL_MS","ticks","intervalId","setInterval","closed","clearInterval","createUserCancelledError","createTokenRenewalTimeoutError","timeoutMs","setTimeout","frameHandle","src","iframeId","adalFrame","getElementById","createElement","ifr","setAttribute","style","visibility","position","border","getElementsByTagName","appendChild","insertAdjacentHTML","frames","parentNode","removeChild","getIframeWithHash","iframes","iframeArray","apply","item","getPopups","openedWindows","getPopUpWithHash","popup","createBlockTokenRequestsInHiddenIframeError","redirectCache","splitCache","AadAuthority","AadInstanceDiscoveryEndpoint","AadInstanceDiscoveryEndpointUrl","tenant_discovery_endpoint","AccessTokenValue","ClientAuthErrorMessage","multipleMatchingTokens","multipleCacheAuthorities","endpointResolutionError","tokenRenewalError","invalidIdToken","invalidStateError","nonceMismatchError","loginProgressError","acquireTokenProgressError","userCancelledError","callbackError","userLoginRequiredError","userDoesNotExistError","clientInfoDecodingError","clientInfoNotPopulatedError","nullOrEmptyIdToken","idTokenNotParsed","tokenEncodingError","invalidInteractionType","cacheParseError","blockTokenRequestsInHiddenIframe","ClientAuthError","errDetail","invalidState","actualState","invalidNonce","actualNonce","createUserDoesNotExistError","caughtError","invalidRawTokenString","caughtParsingError","createTokenEncodingError","incorrectlyEncodedToken","ScopeSet","convertedCachedScopes","requestScopes","every","trimAndConvertToLowerCase","trim","removeElement","scopeVal","scopeList","isArray","getScopeFromState","reqScopes","reqExtraScopesToConsent","convertedExtraScopes","convertedReqScopes"],"mappings":"4GAAA,mDAOA,IAAIA,EAA6B,WAC7B,SAASA,KAUT,OAHAA,EAAYC,QAAU,SAAUC,GAC5B,MAAuB,qBAARA,IAAwBA,GAAO,IAAMA,EAAIC,QAErDH,EAXqB,I,oCCPhC,oJAAII,EAeOC,EASAC,EAxBX,gDAKWC,EAAa,CACpBC,UAAW,oCAAuB,aAClCC,eAAgB,oCAAuB,kBACvCC,OAAQ,oCAA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xHkQ,EAAqBngC,KAAKu1B,+BAA+ByK,EAAU/P,SACvE,OAAOiQ,EAAuBC,EAAmBhwB,OAAO+vB,GAAwBC,EAEpF,OAAO,MAEJd,EAtIkB","file":"js/npm.msal.35a1ef3edd7c0984a4b8.1741903125656.js","sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * @hidden\r\n */\r\nvar StringUtils = /** @class */ (function () {\r\n function StringUtils() {\r\n }\r\n /**\r\n * Check if a string is empty\r\n *\r\n * @param str\r\n */\r\n StringUtils.isEmpty = function (str) {\r\n return (typeof str === \"undefined\" || !str || 0 === str.length);\r\n };\r\n return StringUtils;\r\n}());\r\nexport { StringUtils };\r\n//# sourceMappingURL=StringUtils.js.map","var _a;\r\nimport * as tslib_1 from \"tslib\";\r\nimport TelemetryEvent from \"./TelemetryEvent\";\r\nimport { TELEMETRY_BLOB_EVENT_NAMES } from \"./TelemetryConstants\";\r\nimport { scrubTenantFromUri, hashPersonalIdentifier, prependEventNamePrefix } from \"./TelemetryUtils\";\r\nexport var 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\nexport var API_CODE;\r\n(function (API_CODE) {\r\n API_CODE[API_CODE[\"AcquireTokenRedirect\"] = 2001] = \"AcquireTokenRedirect\";\r\n API_CODE[API_CODE[\"AcquireTokenSilent\"] = 2002] = \"AcquireTokenSilent\";\r\n API_CODE[API_CODE[\"AcquireTokenPopup\"] = 2003] = \"AcquireTokenPopup\";\r\n API_CODE[API_CODE[\"LoginRedirect\"] = 2004] = \"LoginRedirect\";\r\n API_CODE[API_CODE[\"LoginPopup\"] = 2005] = \"LoginPopup\";\r\n API_CODE[API_CODE[\"Logout\"] = 2006] = \"Logout\";\r\n})(API_CODE || (API_CODE = {}));\r\nexport var API_EVENT_IDENTIFIER;\r\n(function (API_EVENT_IDENTIFIER) {\r\n API_EVENT_IDENTIFIER[\"AcquireTokenRedirect\"] = \"AcquireTokenRedirect\";\r\n API_EVENT_IDENTIFIER[\"AcquireTokenSilent\"] = \"AcquireTokenSilent\";\r\n API_EVENT_IDENTIFIER[\"AcquireTokenPopup\"] = \"AcquireTokenPopup\";\r\n API_EVENT_IDENTIFIER[\"LoginRedirect\"] = \"LoginRedirect\";\r\n API_EVENT_IDENTIFIER[\"LoginPopup\"] = \"LoginPopup\";\r\n API_EVENT_IDENTIFIER[\"Logout\"] = \"Logout\";\r\n})(API_EVENT_IDENTIFIER || (API_EVENT_IDENTIFIER = {}));\r\nvar mapEventIdentiferToCode = (_a = {},\r\n _a[API_EVENT_IDENTIFIER.AcquireTokenSilent] = API_CODE.AcquireTokenSilent,\r\n _a[API_EVENT_IDENTIFIER.AcquireTokenPopup] = API_CODE.AcquireTokenPopup,\r\n _a[API_EVENT_IDENTIFIER.AcquireTokenRedirect] = API_CODE.AcquireTokenRedirect,\r\n _a[API_EVENT_IDENTIFIER.LoginPopup] = API_CODE.LoginPopup,\r\n _a[API_EVENT_IDENTIFIER.LoginRedirect] = API_CODE.LoginRedirect,\r\n _a[API_EVENT_IDENTIFIER.Logout] = API_CODE.Logout,\r\n _a);\r\nvar ApiEvent = /** @class */ (function (_super) {\r\n tslib_1.__extends(ApiEvent, _super);\r\n function ApiEvent(correlationId, piiEnabled, apiEventIdentifier) {\r\n var _this = _super.call(this, prependEventNamePrefix(\"api_event\"), correlationId, apiEventIdentifier) || this;\r\n if (apiEventIdentifier) {\r\n _this.apiCode = mapEventIdentiferToCode[apiEventIdentifier];\r\n _this.apiEventIdentifier = apiEventIdentifier;\r\n }\r\n _this.piiEnabled = piiEnabled;\r\n return _this;\r\n }\r\n Object.defineProperty(ApiEvent.prototype, \"apiEventIdentifier\", {\r\n set: function (apiEventIdentifier) {\r\n this.event[TELEMETRY_BLOB_EVENT_NAMES.ApiTelemIdConstStrKey] = apiEventIdentifier;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ApiEvent.prototype, \"apiCode\", {\r\n set: function (apiCode) {\r\n this.event[TELEMETRY_BLOB_EVENT_NAMES.ApiIdConstStrKey] = apiCode;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ApiEvent.prototype, \"authority\", {\r\n set: function (uri) {\r\n this.event[EVENT_KEYS.AUTHORITY] = scrubTenantFromUri(uri).toLowerCase();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ApiEvent.prototype, \"apiErrorCode\", {\r\n set: function (errorCode) {\r\n this.event[EVENT_KEYS.API_ERROR_CODE] = errorCode;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ApiEvent.prototype, \"tenantId\", {\r\n set: function (tenantId) {\r\n this.event[EVENT_KEYS.TENANT_ID] = this.piiEnabled && tenantId ?\r\n hashPersonalIdentifier(tenantId)\r\n : null;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ApiEvent.prototype, \"accountId\", {\r\n set: function (accountId) {\r\n this.event[EVENT_KEYS.USER_ID] = this.piiEnabled && accountId ?\r\n hashPersonalIdentifier(accountId)\r\n : null;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ApiEvent.prototype, \"wasSuccessful\", {\r\n get: function () {\r\n return this.event[EVENT_KEYS.WAS_SUCESSFUL] === true;\r\n },\r\n set: function (wasSuccessful) {\r\n this.event[EVENT_KEYS.WAS_SUCESSFUL] = wasSuccessful;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ApiEvent.prototype, \"loginHint\", {\r\n set: function (loginHint) {\r\n this.event[EVENT_KEYS.LOGIN_HINT] = this.piiEnabled && loginHint ?\r\n hashPersonalIdentifier(loginHint)\r\n : null;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ApiEvent.prototype, \"authorityType\", {\r\n set: function (authorityType) {\r\n this.event[EVENT_KEYS.AUTHORITY_TYPE] = authorityType.toLowerCase();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ApiEvent.prototype, \"promptType\", {\r\n set: function (promptType) {\r\n this.event[EVENT_KEYS.PROMPT] = promptType.toLowerCase();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return ApiEvent;\r\n}(TelemetryEvent));\r\nexport default ApiEvent;\r\n//# sourceMappingURL=ApiEvent.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport * as tslib_1 from \"tslib\";\r\n/**\r\n * @hidden\r\n */\r\nimport { AadAuthority } from \"./AadAuthority\";\r\nimport { B2cAuthority, B2CTrustedHostList } from \"./B2cAuthority\";\r\nimport { AuthorityType } from \"./Authority\";\r\nimport { StringUtils } from \"../utils/StringUtils\";\r\nimport { UrlUtils } from \"../utils/UrlUtils\";\r\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\r\nvar AuthorityFactory = /** @class */ (function () {\r\n function AuthorityFactory() {\r\n }\r\n /**\r\n * Use when Authority is B2C and validateAuthority is set to True to provide list of allowed domains.\r\n */\r\n AuthorityFactory.setKnownAuthorities = function (validateAuthority, knownAuthorities) {\r\n if (validateAuthority && !Object.keys(B2CTrustedHostList).length) {\r\n knownAuthorities.forEach(function (authority) {\r\n B2CTrustedHostList[authority] = authority;\r\n });\r\n }\r\n };\r\n AuthorityFactory.saveMetadataFromNetwork = function (authorityInstance, telemetryManager, correlationId) {\r\n return tslib_1.__awaiter(this, void 0, void 0, function () {\r\n var metadata;\r\n return tslib_1.__generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, authorityInstance.resolveEndpointsAsync(telemetryManager, correlationId)];\r\n case 1:\r\n metadata = _a.sent();\r\n this.metadataMap.set(authorityInstance.CanonicalAuthority, metadata);\r\n return [2 /*return*/, metadata];\r\n }\r\n });\r\n });\r\n };\r\n AuthorityFactory.getMetadata = function (authorityUrl) {\r\n return this.metadataMap.get(authorityUrl);\r\n };\r\n AuthorityFactory.saveMetadataFromConfig = function (authorityUrl, authorityMetadataJson) {\r\n try {\r\n if (authorityMetadataJson) {\r\n var parsedMetadata = JSON.parse(authorityMetadataJson);\r\n if (!parsedMetadata.authorization_endpoint || !parsedMetadata.end_session_endpoint || !parsedMetadata.issuer) {\r\n throw ClientConfigurationError.createInvalidAuthorityMetadataError();\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 }\r\n catch (e) {\r\n throw ClientConfigurationError.createInvalidAuthorityMetadataError();\r\n }\r\n };\r\n /**\r\n * Parse the url and determine the type of authority\r\n */\r\n AuthorityFactory.detectAuthorityFromUrl = function (authorityUrl) {\r\n authorityUrl = UrlUtils.CanonicalizeUri(authorityUrl);\r\n var components = UrlUtils.GetUrlComponents(authorityUrl);\r\n var pathSegments = components.PathSegments;\r\n if (pathSegments[0] === \"adfs\") {\r\n return AuthorityType.Adfs;\r\n }\r\n else if (Object.keys(B2CTrustedHostList).length) {\r\n return AuthorityType.B2C;\r\n }\r\n // Defaults to Aad\r\n return AuthorityType.Aad;\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 AuthorityFactory.CreateInstance = function (authorityUrl, validateAuthority, authorityMetadata) {\r\n if (StringUtils.isEmpty(authorityUrl)) {\r\n return null;\r\n }\r\n if (authorityMetadata) {\r\n // todo: log statements\r\n this.saveMetadataFromConfig(authorityUrl, authorityMetadata);\r\n }\r\n var type = AuthorityFactory.detectAuthorityFromUrl(authorityUrl);\r\n // Depending on above detection, create the right type.\r\n switch (type) {\r\n case AuthorityType.B2C:\r\n return new B2cAuthority(authorityUrl, validateAuthority, this.getMetadata(authorityUrl));\r\n case AuthorityType.Aad:\r\n return new AadAuthority(authorityUrl, validateAuthority, this.getMetadata(authorityUrl));\r\n default:\r\n throw ClientConfigurationError.createInvalidAuthorityTypeError();\r\n }\r\n };\r\n AuthorityFactory.metadataMap = new Map();\r\n return AuthorityFactory;\r\n}());\r\nexport { AuthorityFactory };\r\n//# sourceMappingURL=AuthorityFactory.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * @hidden\r\n */\r\nvar TimeUtils = /** @class */ (function () {\r\n function TimeUtils() {\r\n }\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 TimeUtils.parseExpiresIn = function (expiresIn) {\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 if (!expiresIn) {\r\n expiresIn = \"3599\";\r\n }\r\n return parseInt(expiresIn, 10);\r\n };\r\n /**\r\n * Return the current time in Unix time (seconds). Date.getTime() returns in milliseconds.\r\n */\r\n TimeUtils.now = function () {\r\n return Math.round(new Date().getTime() / 1000.0);\r\n };\r\n return TimeUtils;\r\n}());\r\nexport { TimeUtils };\r\n//# sourceMappingURL=TimeUtils.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport { StringUtils } from \"./utils/StringUtils\";\r\nimport { libraryVersion } from \"./utils/Constants\";\r\nexport var LogLevel;\r\n(function (LogLevel) {\r\n LogLevel[LogLevel[\"Error\"] = 0] = \"Error\";\r\n LogLevel[LogLevel[\"Warning\"] = 1] = \"Warning\";\r\n LogLevel[LogLevel[\"Info\"] = 2] = \"Info\";\r\n LogLevel[LogLevel[\"Verbose\"] = 3] = \"Verbose\";\r\n})(LogLevel || (LogLevel = {}));\r\nvar Logger = /** @class */ (function () {\r\n function Logger(localCallback, options) {\r\n if (options === void 0) { options = {}; }\r\n /**\r\n * @hidden\r\n */\r\n this.level = LogLevel.Info;\r\n var _a = options.correlationId, correlationId = _a === void 0 ? \"\" : _a, _b = options.level, level = _b === void 0 ? LogLevel.Info : _b, _c = options.piiLoggingEnabled, piiLoggingEnabled = _c === void 0 ? false : _c;\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 * @hidden\r\n */\r\n Logger.prototype.logMessage = function (logLevel, logMessage, containsPii) {\r\n if ((logLevel > this.level) || (!this.piiLoggingEnabled && containsPii)) {\r\n return;\r\n }\r\n var timestamp = new Date().toUTCString();\r\n var log;\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 * @hidden\r\n */\r\n Logger.prototype.executeCallback = function (level, message, containsPii) {\r\n if (this.localCallback) {\r\n this.localCallback(level, message, containsPii);\r\n }\r\n };\r\n /**\r\n * @hidden\r\n */\r\n Logger.prototype.error = function (message) {\r\n this.logMessage(LogLevel.Error, message, false);\r\n };\r\n /**\r\n * @hidden\r\n */\r\n Logger.prototype.errorPii = function (message) {\r\n this.logMessage(LogLevel.Error, message, true);\r\n };\r\n /**\r\n * @hidden\r\n */\r\n Logger.prototype.warning = function (message) {\r\n this.logMessage(LogLevel.Warning, message, false);\r\n };\r\n /**\r\n * @hidden\r\n */\r\n Logger.prototype.warningPii = function (message) {\r\n this.logMessage(LogLevel.Warning, message, true);\r\n };\r\n /**\r\n * @hidden\r\n */\r\n Logger.prototype.info = function (message) {\r\n this.logMessage(LogLevel.Info, message, false);\r\n };\r\n /**\r\n * @hidden\r\n */\r\n Logger.prototype.infoPii = function (message) {\r\n this.logMessage(LogLevel.Info, message, true);\r\n };\r\n /**\r\n * @hidden\r\n */\r\n Logger.prototype.verbose = function (message) {\r\n this.logMessage(LogLevel.Verbose, message, false);\r\n };\r\n /**\r\n * @hidden\r\n */\r\n Logger.prototype.verbosePii = function (message) {\r\n this.logMessage(LogLevel.Verbose, message, true);\r\n };\r\n Logger.prototype.isPiiLoggingEnabled = function () {\r\n return this.piiLoggingEnabled;\r\n };\r\n return Logger;\r\n}());\r\nexport { Logger };\r\n//# sourceMappingURL=Logger.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport { Constants, ServerHashParamKeys } from \"./Constants\";\r\nimport { ScopeSet } from \"../ScopeSet\";\r\nimport { StringUtils } from \"./StringUtils\";\r\nimport { CryptoUtils } from \"./CryptoUtils\";\r\n/**\r\n * @hidden\r\n */\r\nvar UrlUtils = /** @class */ (function () {\r\n function UrlUtils() {\r\n }\r\n /**\r\n * generates the URL with QueryString Parameters\r\n * @param scopes\r\n */\r\n UrlUtils.createNavigateUrl = function (serverRequestParams) {\r\n var str = this.createNavigationUrlString(serverRequestParams);\r\n var authEndpoint = 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 }\r\n else {\r\n authEndpoint += \"&\";\r\n }\r\n var requestUrl = \"\" + authEndpoint + str.join(\"&\");\r\n return requestUrl;\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 UrlUtils.createNavigationUrlString = function (serverRequestParams) {\r\n var scopes = serverRequestParams.scopes;\r\n if (scopes.indexOf(serverRequestParams.clientId) === -1) {\r\n scopes.push(serverRequestParams.clientId);\r\n }\r\n var str = [];\r\n str.push(\"response_type=\" + serverRequestParams.responseType);\r\n this.translateclientIdUsedInScope(scopes, serverRequestParams.clientId);\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 str.push(\"state=\" + encodeURIComponent(serverRequestParams.state));\r\n str.push(\"nonce=\" + encodeURIComponent(serverRequestParams.nonce));\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 if (serverRequestParams.claimsValue) {\r\n str.push(\"claims=\" + encodeURIComponent(serverRequestParams.claimsValue));\r\n }\r\n if (serverRequestParams.queryParameters) {\r\n str.push(serverRequestParams.queryParameters);\r\n }\r\n if (serverRequestParams.extraQueryParameters) {\r\n str.push(serverRequestParams.extraQueryParameters);\r\n }\r\n str.push(\"client-request-id=\" + encodeURIComponent(serverRequestParams.correlationId));\r\n return str;\r\n };\r\n /**\r\n * append the required scopes: https://openid.net/specs/openid-connect-basic-1_0.html#Scopes\r\n * @param scopes\r\n */\r\n UrlUtils.translateclientIdUsedInScope = function (scopes, clientId) {\r\n var clientIdIndex = scopes.indexOf(clientId);\r\n if (clientIdIndex >= 0) {\r\n scopes.splice(clientIdIndex, 1);\r\n if (scopes.indexOf(\"openid\") === -1) {\r\n scopes.push(\"openid\");\r\n }\r\n if (scopes.indexOf(\"profile\") === -1) {\r\n scopes.push(\"profile\");\r\n }\r\n }\r\n };\r\n /**\r\n * Returns current window URL as redirect uri\r\n */\r\n UrlUtils.getCurrentUrl = function () {\r\n return window.location.href.split(\"?\")[0].split(\"#\")[0];\r\n };\r\n /**\r\n * Returns given URL with query string removed\r\n */\r\n UrlUtils.removeHashFromUrl = function (url) {\r\n return url.split(\"#\")[0];\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 UrlUtils.replaceTenantPath = function (url, tenantId) {\r\n url = url.toLowerCase();\r\n var urlObject = this.GetUrlComponents(url);\r\n var pathArray = urlObject.PathSegments;\r\n if (tenantId && (pathArray.length !== 0 && pathArray[0] === Constants.common)) {\r\n pathArray[0] = tenantId;\r\n }\r\n return this.constructAuthorityUriFromObject(urlObject, pathArray);\r\n };\r\n UrlUtils.constructAuthorityUriFromObject = function (urlObject, pathArray) {\r\n return this.CanonicalizeUri(urlObject.Protocol + \"//\" + urlObject.HostNameAndPort + \"/\" + pathArray.join(\"/\"));\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 UrlUtils.GetUrlComponents = function (url) {\r\n if (!url) {\r\n throw \"Url required\";\r\n }\r\n // https://gist.github.com/curtisz/11139b2cfcaef4a261e0\r\n var regEx = RegExp(\"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\\\?([^#]*))?(#(.*))?\");\r\n var match = url.match(regEx);\r\n if (!match || match.length < 6) {\r\n throw \"Valid url required\";\r\n }\r\n var urlComponents = {\r\n Protocol: match[1],\r\n HostNameAndPort: match[4],\r\n AbsolutePath: match[5]\r\n };\r\n var pathSegments = urlComponents.AbsolutePath.split(\"/\");\r\n pathSegments = pathSegments.filter(function (val) { return val && val.length > 0; }); // remove empty elements\r\n urlComponents.PathSegments = pathSegments;\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 return urlComponents;\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 UrlUtils.CanonicalizeUri = function (url) {\r\n if (url) {\r\n url = url.toLowerCase();\r\n }\r\n if (url && !UrlUtils.endsWith(url, \"/\")) {\r\n url += \"/\";\r\n }\r\n return url;\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 UrlUtils.endsWith = function (url, suffix) {\r\n if (!url || !suffix) {\r\n return false;\r\n }\r\n return url.indexOf(suffix, url.length - suffix.length) !== -1;\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 UrlUtils.urlRemoveQueryStringParameter = function (url, name) {\r\n if (StringUtils.isEmpty(url)) {\r\n return url;\r\n }\r\n var regex = new RegExp(\"(\\\\&\" + name + \"=)[^\\&]+\");\r\n url = url.replace(regex, \"\");\r\n // name=value&\r\n regex = new RegExp(\"(\" + name + \"=)[^\\&]+&\");\r\n url = url.replace(regex, \"\");\r\n // name=value\r\n regex = new RegExp(\"(\" + name + \"=)[^\\&]+\");\r\n url = url.replace(regex, \"\");\r\n return url;\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 UrlUtils.getHashFromUrl = function (urlStringOrFragment) {\r\n var hashIndex1 = urlStringOrFragment.indexOf(\"#\");\r\n var hashIndex2 = urlStringOrFragment.indexOf(\"#/\");\r\n if (hashIndex2 > -1) {\r\n return urlStringOrFragment.substring(hashIndex2 + 2);\r\n }\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 * @hidden\r\n * Check if the url contains a hash with known properties\r\n * @ignore\r\n */\r\n UrlUtils.urlContainsHash = function (urlString) {\r\n var parameters = UrlUtils.deserializeHash(urlString);\r\n return (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 * @hidden\r\n * Returns deserialized portion of URL hash\r\n * @ignore\r\n */\r\n UrlUtils.deserializeHash = function (urlFragment) {\r\n var hash = UrlUtils.getHashFromUrl(urlFragment);\r\n return CryptoUtils.deserialize(hash);\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 UrlUtils.getHostFromUri = function (uri) {\r\n // remove http:// or https:// from uri\r\n var extractedUri = String(uri).replace(/^(https?:)\\/\\//, \"\");\r\n extractedUri = extractedUri.split(\"/\")[0];\r\n return extractedUri;\r\n };\r\n return UrlUtils;\r\n}());\r\nexport { UrlUtils };\r\n//# sourceMappingURL=UrlUtils.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport * as tslib_1 from \"tslib\";\r\nimport { AuthError } from \"./AuthError\";\r\nexport var 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 * Error thrown when there is an error with the server code, for example, unavailability.\r\n */\r\nvar ServerError = /** @class */ (function (_super) {\r\n tslib_1.__extends(ServerError, _super);\r\n function ServerError(errorCode, errorMessage) {\r\n var _this = _super.call(this, errorCode, errorMessage) || this;\r\n _this.name = \"ServerError\";\r\n Object.setPrototypeOf(_this, ServerError.prototype);\r\n return _this;\r\n }\r\n ServerError.createServerUnavailableError = function () {\r\n return new ServerError(ServerErrorMessage.serverUnavailable.code, ServerErrorMessage.serverUnavailable.desc);\r\n };\r\n ServerError.createUnknownServerError = function (errorDesc) {\r\n return new ServerError(ServerErrorMessage.unknownServerError.code, errorDesc);\r\n };\r\n return ServerError;\r\n}(AuthError));\r\nexport { ServerError };\r\n//# sourceMappingURL=ServerError.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport { CryptoUtils } from \"./CryptoUtils\";\r\nimport { StringUtils } from \"./StringUtils\";\r\n/**\r\n * @hidden\r\n */\r\nvar TokenUtils = /** @class */ (function () {\r\n function TokenUtils() {\r\n }\r\n /**\r\n * decode a JWT\r\n *\r\n * @param jwtToken\r\n */\r\n TokenUtils.decodeJwt = function (jwtToken) {\r\n if (StringUtils.isEmpty(jwtToken)) {\r\n return null;\r\n }\r\n var idTokenPartsRegex = /^([^\\.\\s]*)\\.([^\\.\\s]+)\\.([^\\.\\s]*)$/;\r\n var 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 var 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 * Extract IdToken by decoding the RAWIdToken\r\n *\r\n * @param encodedIdToken\r\n */\r\n TokenUtils.extractIdToken = function (encodedIdToken) {\r\n // id token will be decoded to get the username\r\n var decodedToken = this.decodeJwt(encodedIdToken);\r\n if (!decodedToken) {\r\n return null;\r\n }\r\n try {\r\n var base64IdToken = decodedToken.JWSPayload;\r\n var 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 }\r\n catch (err) {\r\n // this._requestContext.logger.error(\"The returned id_token could not be decoded\" + err);\r\n }\r\n return null;\r\n };\r\n return TokenUtils;\r\n}());\r\nexport { TokenUtils };\r\n//# sourceMappingURL=TokenUtils.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport * as tslib_1 from \"tslib\";\r\nimport { Constants, PersistentCacheKeys, TemporaryCacheKeys, ErrorCacheKeys } from \"../utils/Constants\";\r\nimport { AccessTokenCacheItem } from \"./AccessTokenCacheItem\";\r\nimport { BrowserStorage } from \"./BrowserStorage\";\r\nimport { ClientAuthError } from \"../error/ClientAuthError\";\r\n/**\r\n * @hidden\r\n */\r\nvar AuthCache = /** @class */ (function (_super) {\r\n tslib_1.__extends(AuthCache, _super);\r\n function AuthCache(clientId, cacheLocation, storeAuthStateInCookie) {\r\n var _this = _super.call(this, cacheLocation) || this;\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 return _this;\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 AuthCache.prototype.migrateCacheEntries = function (storeAuthStateInCookie) {\r\n var _this = this;\r\n var idTokenKey = Constants.cachePrefix + \".\" + PersistentCacheKeys.IDTOKEN;\r\n var clientInfoKey = Constants.cachePrefix + \".\" + PersistentCacheKeys.CLIENT_INFO;\r\n var errorKey = Constants.cachePrefix + \".\" + ErrorCacheKeys.ERROR;\r\n var errorDescKey = Constants.cachePrefix + \".\" + ErrorCacheKeys.ERROR_DESC;\r\n var idTokenValue = _super.prototype.getItem.call(this, idTokenKey);\r\n var clientInfoValue = _super.prototype.getItem.call(this, clientInfoKey);\r\n var errorValue = _super.prototype.getItem.call(this, errorKey);\r\n var errorDescValue = _super.prototype.getItem.call(this, errorDescKey);\r\n var values = [idTokenValue, clientInfoValue, errorValue, errorDescValue];\r\n var keysToMigrate = [PersistentCacheKeys.IDTOKEN, PersistentCacheKeys.CLIENT_INFO, ErrorCacheKeys.ERROR, ErrorCacheKeys.ERROR_DESC];\r\n keysToMigrate.forEach(function (cacheKey, index) { return _this.duplicateCacheEntry(cacheKey, values[index], storeAuthStateInCookie); });\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 AuthCache.prototype.duplicateCacheEntry = function (newKey, value, storeAuthStateInCookie) {\r\n if (value) {\r\n this.setItem(newKey, value, storeAuthStateInCookie);\r\n }\r\n };\r\n /**\r\n * Prepend msal. 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 AuthCache.prototype.generateCacheKey = function (key, addInstanceId) {\r\n try {\r\n // Defined schemas do not need the key appended\r\n JSON.parse(key);\r\n return key;\r\n }\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 * add value to storage\r\n * @param key\r\n * @param value\r\n * @param enableCookieStorage\r\n */\r\n AuthCache.prototype.setItem = function (key, value, enableCookieStorage, state) {\r\n _super.prototype.setItem.call(this, this.generateCacheKey(key, true), value, enableCookieStorage);\r\n if (this.rollbackEnabled) {\r\n _super.prototype.setItem.call(this, this.generateCacheKey(key, false), value, enableCookieStorage);\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 AuthCache.prototype.getItem = function (key, enableCookieStorage) {\r\n return _super.prototype.getItem.call(this, this.generateCacheKey(key, true), enableCookieStorage);\r\n };\r\n /**\r\n * remove value from storage\r\n * @param key\r\n */\r\n AuthCache.prototype.removeItem = function (key) {\r\n _super.prototype.removeItem.call(this, this.generateCacheKey(key, true));\r\n if (this.rollbackEnabled) {\r\n _super.prototype.removeItem.call(this, this.generateCacheKey(key, false));\r\n }\r\n };\r\n /**\r\n * Reset the cache items\r\n */\r\n AuthCache.prototype.resetCacheItems = function () {\r\n var storage = window[this.cacheLocation];\r\n var key;\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.prototype.removeItem.call(this, 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 * Reset all temporary cache items\r\n */\r\n AuthCache.prototype.resetTempCacheItems = function (state) {\r\n var storage = window[this.cacheLocation];\r\n var key;\r\n // check state and remove associated cache\r\n for (key in storage) {\r\n if ((!state || key.indexOf(state) !== -1) && !this.tokenRenewalInProgress(state)) {\r\n this.removeItem(key);\r\n this.setItemCookie(key, \"\", -1);\r\n this.clearMsalCookie(state);\r\n }\r\n }\r\n // delete the interaction status cache\r\n this.removeItem(TemporaryCacheKeys.INTERACTION_STATUS);\r\n this.removeItem(TemporaryCacheKeys.REDIRECT_REQUEST);\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 AuthCache.prototype.setItemCookie = function (cName, cValue, expires) {\r\n _super.prototype.setItemCookie.call(this, this.generateCacheKey(cName, true), cValue, expires);\r\n if (this.rollbackEnabled) {\r\n _super.prototype.setItemCookie.call(this, this.generateCacheKey(cName, false), cValue, expires);\r\n }\r\n };\r\n /**\r\n * get one item by key from cookies\r\n * @param cName\r\n */\r\n AuthCache.prototype.getItemCookie = function (cName) {\r\n return _super.prototype.getItemCookie.call(this, this.generateCacheKey(cName, true));\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 AuthCache.prototype.getAllAccessTokens = function (clientId, homeAccountIdentifier) {\r\n var _this = this;\r\n var results = Object.keys(window[this.cacheLocation]).reduce(function (tokens, key) {\r\n var keyMatches = key.match(clientId) && key.match(homeAccountIdentifier) && key.match(Constants.scopes);\r\n if (keyMatches) {\r\n var value = _this.getItem(key);\r\n if (value) {\r\n try {\r\n var parseAtKey = JSON.parse(key);\r\n var newAccessTokenCacheItem = new AccessTokenCacheItem(parseAtKey, JSON.parse(value));\r\n return tokens.concat([newAccessTokenCacheItem]);\r\n }\r\n catch (e) {\r\n throw ClientAuthError.createCacheParseError(key);\r\n }\r\n }\r\n }\r\n return tokens;\r\n }, []);\r\n return results;\r\n };\r\n /**\r\n * Return if the token renewal is still in progress\r\n * @param stateValue\r\n */\r\n AuthCache.prototype.tokenRenewalInProgress = function (stateValue) {\r\n var renewStatus = this.getItem(TemporaryCacheKeys.RENEW_STATUS + \"|\" + stateValue);\r\n return !!(renewStatus && renewStatus === Constants.inProgress);\r\n };\r\n /**\r\n * Clear all cookies\r\n */\r\n AuthCache.prototype.clearMsalCookie = function (state) {\r\n this.clearItemCookie(TemporaryCacheKeys.NONCE_IDTOKEN + \"|\" + state);\r\n this.clearItemCookie(TemporaryCacheKeys.STATE_LOGIN + \"|\" + state);\r\n this.clearItemCookie(TemporaryCacheKeys.LOGIN_REQUEST + \"|\" + state);\r\n this.clearItemCookie(TemporaryCacheKeys.STATE_ACQ_TOKEN + \"|\" + state);\r\n };\r\n /**\r\n * Create acquireTokenAccountKey to cache account object\r\n * @param accountId\r\n * @param state\r\n */\r\n AuthCache.generateAcquireTokenAccountKey = function (accountId, state) {\r\n return \"\" + TemporaryCacheKeys.ACQUIRE_TOKEN_ACCOUNT + Constants.resourceDelimiter + accountId + Constants.resourceDelimiter + state;\r\n };\r\n /**\r\n * Create authorityKey to cache authority\r\n * @param state\r\n */\r\n AuthCache.generateAuthorityKey = function (state) {\r\n return \"\" + TemporaryCacheKeys.AUTHORITY + Constants.resourceDelimiter + state;\r\n };\r\n return AuthCache;\r\n}(BrowserStorage));\r\nexport { AuthCache };\r\n//# sourceMappingURL=AuthCache.js.map","import * as tslib_1 from \"tslib\";\r\nimport TelemetryEvent from \"./TelemetryEvent\";\r\nimport { scrubTenantFromUri, prependEventNamePrefix } from \"./TelemetryUtils\";\r\nimport { ServerRequestParameters } from \"../ServerRequestParameters\";\r\nexport var 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\nvar HttpEvent = /** @class */ (function (_super) {\r\n tslib_1.__extends(HttpEvent, _super);\r\n function HttpEvent(correlationId, eventLabel) {\r\n return _super.call(this, prependEventNamePrefix(\"http_event\"), correlationId, eventLabel) || this;\r\n }\r\n Object.defineProperty(HttpEvent.prototype, \"url\", {\r\n set: function (url) {\r\n var scrubbedUri = scrubTenantFromUri(url);\r\n this.event[EVENT_KEYS.URL] = scrubbedUri && scrubbedUri.toLowerCase();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HttpEvent.prototype, \"httpPath\", {\r\n set: function (httpPath) {\r\n this.event[EVENT_KEYS.HTTP_PATH] = scrubTenantFromUri(httpPath).toLowerCase();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HttpEvent.prototype, \"userAgent\", {\r\n set: function (userAgent) {\r\n this.event[EVENT_KEYS.USER_AGENT] = userAgent;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HttpEvent.prototype, \"queryParams\", {\r\n set: function (queryParams) {\r\n this.event[EVENT_KEYS.QUERY_PARAMETERS] = ServerRequestParameters.generateQueryParametersString(queryParams);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HttpEvent.prototype, \"apiVersion\", {\r\n set: function (apiVersion) {\r\n this.event[EVENT_KEYS.API_VERSION] = apiVersion.toLowerCase();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HttpEvent.prototype, \"httpResponseStatus\", {\r\n set: function (statusCode) {\r\n this.event[EVENT_KEYS.RESPONSE_CODE] = statusCode;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HttpEvent.prototype, \"oAuthErrorCode\", {\r\n set: function (errorCode) {\r\n this.event[EVENT_KEYS.O_AUTH_ERROR_CODE] = errorCode;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HttpEvent.prototype, \"httpMethod\", {\r\n set: function (httpMethod) {\r\n this.event[EVENT_KEYS.HTTP_METHOD] = httpMethod;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HttpEvent.prototype, \"requestIdHeader\", {\r\n set: function (requestIdHeader) {\r\n this.event[EVENT_KEYS.REQUEST_ID_HEADER] = requestIdHeader;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HttpEvent.prototype, \"speInfo\", {\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 set: function (speInfo) {\r\n this.event[EVENT_KEYS.SPE_INFO] = speInfo;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HttpEvent.prototype, \"serverErrorCode\", {\r\n set: function (errorCode) {\r\n this.event[EVENT_KEYS.SERVER_ERROR_CODE] = errorCode;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HttpEvent.prototype, \"serverSubErrorCode\", {\r\n set: function (subErrorCode) {\r\n this.event[EVENT_KEYS.SERVER_SUB_ERROR_CODE] = subErrorCode;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return HttpEvent;\r\n}(TelemetryEvent));\r\nexport default HttpEvent;\r\n//# sourceMappingURL=HttpEvent.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport { CryptoUtils } from \"../utils/CryptoUtils\";\r\nimport { UrlUtils } from \"../utils/UrlUtils\";\r\n/**\r\n * @hidden\r\n */\r\nvar AccessTokenKey = /** @class */ (function () {\r\n function AccessTokenKey(authority, clientId, scopes, uid, utid) {\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 return AccessTokenKey;\r\n}());\r\nexport { AccessTokenKey };\r\n//# sourceMappingURL=AccessTokenKey.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport * as tslib_1 from \"tslib\";\r\nexport var 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 * General error class thrown by the MSAL.js library.\r\n */\r\nvar AuthError = /** @class */ (function (_super) {\r\n tslib_1.__extends(AuthError, _super);\r\n function AuthError(errorCode, errorMessage) {\r\n var _this = _super.call(this, errorMessage) || this;\r\n Object.setPrototypeOf(_this, AuthError.prototype);\r\n _this.errorCode = errorCode;\r\n _this.errorMessage = errorMessage;\r\n _this.name = \"AuthError\";\r\n return _this;\r\n }\r\n AuthError.createUnexpectedError = function (errDesc) {\r\n return new AuthError(AuthErrorMessage.unexpectedError.code, AuthErrorMessage.unexpectedError.desc + \": \" + errDesc);\r\n };\r\n AuthError.createNoWindowObjectError = function (errDesc) {\r\n return new AuthError(AuthErrorMessage.noWindowObjectError.code, AuthErrorMessage.noWindowObjectError.desc + \" \" + errDesc);\r\n };\r\n return AuthError;\r\n}(Error));\r\nexport { AuthError };\r\n//# sourceMappingURL=AuthError.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport * as tslib_1 from \"tslib\";\r\nimport { Logger } from \"./Logger\";\r\nimport { UrlUtils } from \"./utils/UrlUtils\";\r\n/**\r\n * Defaults for the Configuration Options\r\n */\r\nvar FRAME_TIMEOUT = 6000;\r\nvar OFFSET = 300;\r\nvar NAVIGATE_FRAME_WAIT = 500;\r\nvar DEFAULT_AUTH_OPTIONS = {\r\n clientId: \"\",\r\n authority: null,\r\n validateAuthority: true,\r\n authorityMetadata: \"\",\r\n knownAuthorities: [],\r\n redirectUri: function () { return UrlUtils.getCurrentUrl(); },\r\n postLogoutRedirectUri: function () { return UrlUtils.getCurrentUrl(); },\r\n navigateToLoginRequestUrl: true\r\n};\r\nvar DEFAULT_CACHE_OPTIONS = {\r\n cacheLocation: \"sessionStorage\",\r\n storeAuthStateInCookie: false\r\n};\r\nvar DEFAULT_SYSTEM_OPTIONS = {\r\n logger: new Logger(null),\r\n loadFrameTimeout: FRAME_TIMEOUT,\r\n tokenRenewalOffsetSeconds: OFFSET,\r\n navigateFrameWait: NAVIGATE_FRAME_WAIT\r\n};\r\nvar DEFAULT_FRAMEWORK_OPTIONS = {\r\n isAngular: false,\r\n unprotectedResources: new Array(),\r\n protectedResourceMap: new Map()\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\nexport function buildConfiguration(_a) {\r\n var auth = _a.auth, _b = _a.cache, cache = _b === void 0 ? {} : _b, _c = _a.system, system = _c === void 0 ? {} : _c, _d = _a.framework, framework = _d === void 0 ? {} : _d;\r\n var overlayedConfig = {\r\n auth: tslib_1.__assign({}, DEFAULT_AUTH_OPTIONS, auth),\r\n cache: tslib_1.__assign({}, DEFAULT_CACHE_OPTIONS, cache),\r\n system: tslib_1.__assign({}, DEFAULT_SYSTEM_OPTIONS, system),\r\n framework: tslib_1.__assign({}, DEFAULT_FRAMEWORK_OPTIONS, framework)\r\n };\r\n return overlayedConfig;\r\n}\r\n//# sourceMappingURL=Configuration.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\r\nimport { AuthError } from \"../error/AuthError\";\r\n/**\r\n * @hidden\r\n */\r\nvar BrowserStorage = /** @class */ (function () {\r\n function BrowserStorage(cacheLocation) {\r\n if (!window) {\r\n throw AuthError.createNoWindowObjectError(\"Browser storage class could not find window object\");\r\n }\r\n var 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 * add value to storage\r\n * @param key\r\n * @param value\r\n * @param enableCookieStorage\r\n */\r\n BrowserStorage.prototype.setItem = function (key, value, enableCookieStorage) {\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 * get one item by key from storage\r\n * @param key\r\n * @param enableCookieStorage\r\n */\r\n BrowserStorage.prototype.getItem = function (key, enableCookieStorage) {\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 * remove value from storage\r\n * @param key\r\n */\r\n BrowserStorage.prototype.removeItem = function (key) {\r\n return window[this.cacheLocation].removeItem(key);\r\n };\r\n /**\r\n * clear storage (remove all items from it)\r\n */\r\n BrowserStorage.prototype.clear = function () {\r\n return window[this.cacheLocation].clear();\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 BrowserStorage.prototype.setItemCookie = function (cName, cValue, expires) {\r\n var cookieStr = cName + \"=\" + cValue + \";path=/;\";\r\n if (expires) {\r\n var expireTime = this.getCookieExpirationTime(expires);\r\n cookieStr += \"expires=\" + expireTime + \";\";\r\n }\r\n document.cookie = cookieStr;\r\n };\r\n /**\r\n * get one item by key from cookies\r\n * @param cName\r\n */\r\n BrowserStorage.prototype.getItemCookie = function (cName) {\r\n var name = cName + \"=\";\r\n var ca = document.cookie.split(\";\");\r\n for (var i = 0; i < ca.length; i++) {\r\n var 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 c.substring(name.length, c.length);\r\n }\r\n }\r\n return \"\";\r\n };\r\n /**\r\n * Clear an item in the cookies by key\r\n * @param cName\r\n */\r\n BrowserStorage.prototype.clearItemCookie = function (cName) {\r\n this.setItemCookie(cName, \"\", -1);\r\n };\r\n /**\r\n * Get cookie expiration time\r\n * @param cookieLifeDays\r\n */\r\n BrowserStorage.prototype.getCookieExpirationTime = function (cookieLifeDays) {\r\n var today = new Date();\r\n var expr = new Date(today.getTime() + cookieLifeDays * 24 * 60 * 60 * 1000);\r\n return expr.toUTCString();\r\n };\r\n return BrowserStorage;\r\n}());\r\nexport { BrowserStorage };\r\n//# sourceMappingURL=BrowserStorage.js.map","import * as tslib_1 from \"tslib\";\r\nimport { TELEMETRY_BLOB_EVENT_NAMES } from \"./TelemetryConstants\";\r\nimport TelemetryEvent from \"./TelemetryEvent\";\r\nimport { prependEventNamePrefix } from \"./TelemetryUtils\";\r\nvar DefaultEvent = /** @class */ (function (_super) {\r\n tslib_1.__extends(DefaultEvent, _super);\r\n // TODO Platform Type\r\n function DefaultEvent(platform, correlationId, clientId, eventCount) {\r\n var _this = _super.call(this, prependEventNamePrefix(\"default_event\"), correlationId, \"DefaultEvent\") || this;\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 return _this;\r\n // / Device id?\r\n }\r\n DefaultEvent.prototype.getEventCount = function (eventName, eventCount) {\r\n if (!eventCount[eventName]) {\r\n return 0;\r\n }\r\n return eventCount[eventName];\r\n };\r\n return DefaultEvent;\r\n}(TelemetryEvent));\r\nexport default DefaultEvent;\r\n//# sourceMappingURL=DefaultEvent.js.map","export { UserAgentApplication } 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 { CryptoUtils } from \"./utils/CryptoUtils\";\r\nexport { UrlUtils } from \"./utils/UrlUtils\";\r\nexport { WindowUtils } from \"./utils/WindowUtils\";\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\n//# sourceMappingURL=index.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport * as tslib_1 from \"tslib\";\r\nimport { ClientAuthError } from \"./ClientAuthError\";\r\n;\r\nexport var ClientConfigurationErrorMessage = {\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 clientScope: {\r\n code: \"clientid_input_scopes_error\",\r\n desc: \"Client ID can only be provided as a single scope.\"\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: .\"\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. If using B2C, please include this authority in the knownAuthorities config parameter.\"\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 * Error thrown when there is an error in configuration of the .js library.\r\n */\r\nvar ClientConfigurationError = /** @class */ (function (_super) {\r\n tslib_1.__extends(ClientConfigurationError, _super);\r\n function ClientConfigurationError(errorCode, errorMessage) {\r\n var _this = _super.call(this, errorCode, errorMessage) || this;\r\n _this.name = \"ClientConfigurationError\";\r\n Object.setPrototypeOf(_this, ClientConfigurationError.prototype);\r\n return _this;\r\n }\r\n ClientConfigurationError.createNoSetConfigurationError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.configurationNotSet.code, \"\" + ClientConfigurationErrorMessage.configurationNotSet.desc);\r\n };\r\n ClientConfigurationError.createStorageNotSupportedError = function (givenCacheLocation) {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.storageNotSupported.code, ClientConfigurationErrorMessage.storageNotSupported.desc + \" Given location: \" + givenCacheLocation);\r\n };\r\n ClientConfigurationError.createRedirectCallbacksNotSetError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.noRedirectCallbacksSet.code, ClientConfigurationErrorMessage.noRedirectCallbacksSet.desc);\r\n };\r\n ClientConfigurationError.createInvalidCallbackObjectError = function (callbackObject) {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidCallbackObject.code, ClientConfigurationErrorMessage.invalidCallbackObject.desc + \" Given value for callback function: \" + callbackObject);\r\n };\r\n ClientConfigurationError.createEmptyScopesArrayError = function (scopesValue) {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.emptyScopes.code, ClientConfigurationErrorMessage.emptyScopes.desc + \" Given value: \" + scopesValue + \".\");\r\n };\r\n ClientConfigurationError.createScopesNonArrayError = function (scopesValue) {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.nonArrayScopes.code, ClientConfigurationErrorMessage.nonArrayScopes.desc + \" Given value: \" + scopesValue + \".\");\r\n };\r\n ClientConfigurationError.createClientIdSingleScopeError = function (scopesValue) {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.clientScope.code, ClientConfigurationErrorMessage.clientScope.desc + \" Given value: \" + scopesValue + \".\");\r\n };\r\n ClientConfigurationError.createScopesRequiredError = function (scopesValue) {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.scopesRequired.code, ClientConfigurationErrorMessage.scopesRequired.desc + \" Given value: \" + scopesValue);\r\n };\r\n ClientConfigurationError.createInvalidPromptError = function (promptValue) {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidPrompt.code, ClientConfigurationErrorMessage.invalidPrompt.desc + \" Given value: \" + promptValue);\r\n };\r\n ClientConfigurationError.createClaimsRequestParsingError = function (claimsRequestParseError) {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.claimsRequestParsingError.code, ClientConfigurationErrorMessage.claimsRequestParsingError.desc + \" Given value: \" + claimsRequestParseError);\r\n };\r\n ClientConfigurationError.createEmptyRequestError = function () {\r\n var _a = ClientConfigurationErrorMessage.emptyRequestError, code = _a.code, desc = _a.desc;\r\n return new ClientConfigurationError(code, desc);\r\n };\r\n ClientConfigurationError.createInvalidCorrelationIdError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidCorrelationIdError.code, ClientConfigurationErrorMessage.invalidCorrelationIdError.desc);\r\n };\r\n ClientConfigurationError.createKnownAuthoritiesNotSetError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.b2cKnownAuthoritiesNotSet.code, ClientConfigurationErrorMessage.b2cKnownAuthoritiesNotSet.desc);\r\n };\r\n ClientConfigurationError.createInvalidAuthorityTypeError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthorityType.code, ClientConfigurationErrorMessage.invalidAuthorityType.desc);\r\n };\r\n ClientConfigurationError.createUntrustedAuthorityError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.untrustedAuthority.code, ClientConfigurationErrorMessage.untrustedAuthority.desc);\r\n };\r\n ClientConfigurationError.createTelemetryConfigError = function (config) {\r\n var _a = ClientConfigurationErrorMessage.telemetryConfigError, code = _a.code, desc = _a.desc;\r\n var requiredKeys = {\r\n applicationName: \"string\",\r\n applicationVersion: \"string\",\r\n telemetryEmitter: \"function\"\r\n };\r\n var missingKeys = Object.keys(requiredKeys)\r\n .reduce(function (keys, key) {\r\n return config[key] ? keys : keys.concat([key + \" (\" + requiredKeys[key] + \")\"]);\r\n }, []);\r\n return new ClientConfigurationError(code, desc + \" mising values: \" + missingKeys.join(\",\"));\r\n };\r\n ClientConfigurationError.createSsoSilentError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.ssoSilentError.code, ClientConfigurationErrorMessage.ssoSilentError.desc);\r\n };\r\n ClientConfigurationError.createInvalidAuthorityMetadataError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthorityMetadataError.code, ClientConfigurationErrorMessage.invalidAuthorityMetadataError.desc);\r\n };\r\n return ClientConfigurationError;\r\n}(ClientAuthError));\r\nexport { ClientConfigurationError };\r\n//# sourceMappingURL=ClientConfigurationError.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport * as tslib_1 from \"tslib\";\r\nimport { AccessTokenKey } from \"./cache/AccessTokenKey\";\r\nimport { AccessTokenValue } from \"./cache/AccessTokenValue\";\r\nimport { ServerRequestParameters } from \"./ServerRequestParameters\";\r\nimport { ClientInfo } from \"./ClientInfo\";\r\nimport { IdToken } from \"./IdToken\";\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 { buildConfiguration } from \"./Configuration\";\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 { buildResponseStateOnly } from \"./AuthResponse\";\r\nimport TelemetryManager from \"./telemetry/TelemetryManager\";\r\nimport { API_EVENT_IDENTIFIER } from \"./telemetry/ApiEvent\";\r\nimport { Constants, ServerHashParamKeys, TemporaryCacheKeys, PersistentCacheKeys, ErrorCacheKeys, FramePrefix } from \"./utils/Constants\";\r\nimport { CryptoUtils } from \"./utils/CryptoUtils\";\r\n// default authority\r\nvar DEFAULT_AUTHORITY = \"https://login.microsoftonline.com/common\";\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 * Since we support only implicit flow in this library, we restrict the response_type support to only 'token' and 'id_token'\r\n *\r\n */\r\nvar 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 * UserAgentApplication class\r\n *\r\n * Object Instance that the developer can use to make loginXX OR acquireTokenXX functions\r\n */\r\nvar UserAgentApplication = /** @class */ (function () {\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 function UserAgentApplication(configuration) {\r\n // callbacks for token/error\r\n this.authResponseCallback = null;\r\n this.tokenReceivedCallback = null;\r\n this.errorReceivedCallback = null;\r\n // Set the Configuration\r\n this.config = buildConfiguration(configuration);\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 this.telemetryManager = this.getTelemetryManagerFromConfig(this.config.system.telemetry, this.clientId);\r\n AuthorityFactory.setKnownAuthorities(this.config.auth.validateAuthority, this.config.auth.knownAuthorities);\r\n AuthorityFactory.saveMetadataFromConfig(this.config.auth.authority, this.config.auth.authorityMetadata);\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 // Initialize window handling code\r\n window.activeRenewals = {};\r\n window.renewStates = [];\r\n window.callbackMappedToRenewStates = {};\r\n window.promiseMappedToRenewStates = {};\r\n window.msal = this;\r\n var urlHash = window.location.hash;\r\n var urlContainsHash = UrlUtils.urlContainsHash(urlHash);\r\n // check if back button is pressed\r\n WindowUtils.checkIfBackButtonIsPressed(this.cacheStorage);\r\n // On the server 302 - Redirect, handle this\r\n if (urlContainsHash) {\r\n var stateInfo = this.getResponseState(urlHash);\r\n if (stateInfo.method === Constants.interactionTypeRedirect) {\r\n this.handleRedirectAuthenticationResponse(urlHash);\r\n }\r\n }\r\n }\r\n Object.defineProperty(UserAgentApplication.prototype, \"authority\", {\r\n /**\r\n * Method to manage the authority URL.\r\n *\r\n * @returns {string} authority\r\n */\r\n get: function () {\r\n return this.authorityInstance.CanonicalAuthority;\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 set: function (val) {\r\n this.authorityInstance = AuthorityFactory.CreateInstance(val, this.config.auth.validateAuthority);\r\n },\r\n enumerable: true,\r\n configurable: true\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 UserAgentApplication.prototype.getAuthorityInstance = function () {\r\n return this.authorityInstance;\r\n };\r\n UserAgentApplication.prototype.handleRedirectCallback = function (authOrTokenCallback, errorReceivedCallback) {\r\n if (!authOrTokenCallback) {\r\n throw ClientConfigurationError.createInvalidCallbackObjectError(authOrTokenCallback);\r\n }\r\n // Set callbacks\r\n if (errorReceivedCallback) {\r\n this.tokenReceivedCallback = authOrTokenCallback;\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 }\r\n else {\r\n this.authResponseCallback = authOrTokenCallback;\r\n }\r\n if (this.redirectError) {\r\n this.authErrorHandler(Constants.interactionTypeRedirect, this.redirectError, this.redirectResponse);\r\n }\r\n else if (this.redirectResponse) {\r\n this.authResponseHandler(Constants.interactionTypeRedirect, this.redirectResponse);\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 UserAgentApplication.prototype.urlContainsHash = function (hash) {\r\n return UrlUtils.urlContainsHash(hash);\r\n };\r\n UserAgentApplication.prototype.authResponseHandler = function (interactionType, response, resolve) {\r\n if (interactionType === Constants.interactionTypeRedirect) {\r\n if (this.errorReceivedCallback) {\r\n this.tokenReceivedCallback(response);\r\n }\r\n else if (this.authResponseCallback) {\r\n this.authResponseCallback(null, response);\r\n }\r\n }\r\n else if (interactionType === Constants.interactionTypePopup) {\r\n resolve(response);\r\n }\r\n else {\r\n throw ClientAuthError.createInvalidInteractionTypeError();\r\n }\r\n };\r\n UserAgentApplication.prototype.authErrorHandler = function (interactionType, authErr, response, reject) {\r\n // set interaction_status to complete\r\n this.cacheStorage.removeItem(TemporaryCacheKeys.INTERACTION_STATUS);\r\n if (interactionType === Constants.interactionTypeRedirect) {\r\n if (this.errorReceivedCallback) {\r\n this.errorReceivedCallback(authErr, response.accountState);\r\n }\r\n else {\r\n this.authResponseCallback(authErr, response);\r\n }\r\n }\r\n else if (interactionType === Constants.interactionTypePopup) {\r\n reject(authErr);\r\n }\r\n else {\r\n throw ClientAuthError.createInvalidInteractionTypeError();\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 UserAgentApplication.prototype.loginRedirect = function (userRequest) {\r\n // validate request\r\n var request = RequestUtils.validateRequest(userRequest, true, this.clientId, Constants.interactionTypeRedirect);\r\n this.acquireTokenInteractive(Constants.interactionTypeRedirect, true, request, null, null);\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 UserAgentApplication.prototype.acquireTokenRedirect = function (userRequest) {\r\n // validate request\r\n var request = RequestUtils.validateRequest(userRequest, false, this.clientId, Constants.interactionTypeRedirect);\r\n this.acquireTokenInteractive(Constants.interactionTypeRedirect, false, request, null, null);\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.} - 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 UserAgentApplication.prototype.loginPopup = function (userRequest) {\r\n var _this = this;\r\n // validate request\r\n var request = RequestUtils.validateRequest(userRequest, true, this.clientId, Constants.interactionTypePopup);\r\n var apiEvent = this.telemetryManager.createAndStartApiEvent(request.correlationId, API_EVENT_IDENTIFIER.LoginPopup);\r\n return new Promise(function (resolve, reject) {\r\n _this.acquireTokenInteractive(Constants.interactionTypePopup, true, request, resolve, reject);\r\n })\r\n .then(function (resp) {\r\n _this.telemetryManager.stopAndFlushApiEvent(request.correlationId, apiEvent, true);\r\n return resp;\r\n })\r\n .catch(function (error) {\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 * 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.} - 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 UserAgentApplication.prototype.acquireTokenPopup = function (userRequest) {\r\n var _this = this;\r\n this.logger.verbose(\"AcquireTokenPopup has been called\");\r\n // validate request\r\n var request = RequestUtils.validateRequest(userRequest, false, this.clientId, Constants.interactionTypePopup);\r\n var apiEvent = this.telemetryManager.createAndStartApiEvent(request.correlationId, API_EVENT_IDENTIFIER.AcquireTokenPopup);\r\n return new Promise(function (resolve, reject) {\r\n _this.acquireTokenInteractive(Constants.interactionTypePopup, false, request, resolve, reject);\r\n })\r\n .then(function (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(function (error) {\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 // #region Acquire Token\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 UserAgentApplication.prototype.acquireTokenInteractive = function (interactionType, isLoginCall, request, resolve, reject) {\r\n var _this = this;\r\n this.logger.verbose(\"AcquireTokenInteractive has been called\");\r\n // block the request if made from the hidden iframe\r\n WindowUtils.blockReloadInHiddenIframes();\r\n var interactionProgress = this.cacheStorage.getItem(TemporaryCacheKeys.INTERACTION_STATUS);\r\n if (interactionType === Constants.interactionTypeRedirect) {\r\n this.cacheStorage.setItem(TemporaryCacheKeys.REDIRECT_REQUEST, \"\" + Constants.inProgress + Constants.resourceDelimiter + request.state);\r\n }\r\n // If already in progress, do not proceed\r\n if (interactionProgress === Constants.inProgress) {\r\n var thrownError = isLoginCall ? ClientAuthError.createLoginInProgressError() : ClientAuthError.createAcquireTokenInProgressError();\r\n var stateOnlyResponse = buildResponseStateOnly(this.getAccountState(request.state));\r\n this.cacheStorage.resetTempCacheItems(request.state);\r\n this.authErrorHandler(interactionType, thrownError, stateOnlyResponse, reject);\r\n return;\r\n }\r\n // Get the account object if a session exists\r\n var account;\r\n if (request && request.account && !isLoginCall) {\r\n account = request.account;\r\n this.logger.verbose(\"Account set from request\");\r\n }\r\n else {\r\n account = this.getAccount();\r\n this.logger.verbose(\"Account set from MSAL Cache\");\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 var adalIdToken = this.extractADALIdToken();\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 var tokenRequest = this.buildIDTokenRequest(request);\r\n this.silentLogin = true;\r\n this.acquireTokenSilent(tokenRequest).then(function (response) {\r\n _this.silentLogin = false;\r\n _this.logger.info(\"Unified cache call is successful\");\r\n _this.authResponseHandler(interactionType, response, resolve);\r\n return;\r\n }, function (error) {\r\n _this.silentLogin = false;\r\n _this.logger.error(\"Error occurred during unified cache ATS: \" + error);\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 var stateOnlyResponse = buildResponseStateOnly(this.getAccountState(request.state));\r\n this.cacheStorage.resetTempCacheItems(request.state);\r\n this.authErrorHandler(interactionType, ClientAuthError.createUserLoginRequiredError(), stateOnlyResponse, 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 * @hidden\r\n * @ignore\r\n * Helper function to acquireToken\r\n *\r\n */\r\n UserAgentApplication.prototype.acquireTokenHelper = function (account, interactionType, isLoginCall, request, resolve, reject) {\r\n return tslib_1.__awaiter(this, void 0, void 0, function () {\r\n var scope, serverAuthenticationRequest, acquireTokenAuthority, popUpWindow, responseType, loginStartPage, urlNavigate, hash, error_1, navigate, err_1;\r\n return tslib_1.__generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n // Track the acquireToken progress\r\n this.cacheStorage.setItem(TemporaryCacheKeys.INTERACTION_STATUS, Constants.inProgress);\r\n scope = request.scopes ? request.scopes.join(\" \").toLowerCase() : this.clientId.toLowerCase();\r\n acquireTokenAuthority = (request && request.authority) ? AuthorityFactory.CreateInstance(request.authority, this.config.auth.validateAuthority, request.authorityMetadata) : this.authorityInstance;\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 11, , 12]);\r\n if (!!acquireTokenAuthority.hasCachedMetadata()) return [3 /*break*/, 3];\r\n this.logger.verbose(\"No cached metadata for authority\");\r\n return [4 /*yield*/, AuthorityFactory.saveMetadataFromNetwork(acquireTokenAuthority, this.telemetryManager, request.correlationId)];\r\n case 2:\r\n _a.sent();\r\n return [3 /*break*/, 4];\r\n case 3:\r\n this.logger.verbose(\"Cached metadata found for authority\");\r\n _a.label = 4;\r\n case 4:\r\n responseType = isLoginCall ? ResponseTypes.id_token : this.getTokenType(account, request.scopes, false);\r\n loginStartPage = request.redirectStartPage || window.location.href;\r\n serverAuthenticationRequest = new ServerRequestParameters(acquireTokenAuthority, this.clientId, responseType, this.getRedirectUri(request && request.redirectUri), request.scopes, request.state, request.correlationId);\r\n this.updateCacheEntries(serverAuthenticationRequest, account, isLoginCall, loginStartPage);\r\n // populate QueryParameters (sid/login_hint) and any other extraQueryParameters set by the developer\r\n serverAuthenticationRequest.populateQueryParams(account, request);\r\n 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(\"\" + TemporaryCacheKeys.STATE_ACQ_TOKEN + Constants.resourceDelimiter + request.state, serverAuthenticationRequest.state, this.inCookie);\r\n }\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 // Register callback to capture results from server\r\n this.registerCallback(serverAuthenticationRequest.state, scope, resolve, reject);\r\n }\r\n else {\r\n throw ClientAuthError.createInvalidInteractionTypeError();\r\n }\r\n if (!(interactionType === Constants.interactionTypePopup)) return [3 /*break*/, 9];\r\n // Generate a popup window\r\n try {\r\n popUpWindow = this.openPopup(urlNavigate, \"msal\", Constants.popUpWidth, Constants.popUpHeight);\r\n // Push popup window handle onto stack for tracking\r\n WindowUtils.trackPopup(popUpWindow);\r\n }\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 [2 /*return*/];\r\n }\r\n }\r\n if (!popUpWindow) return [3 /*break*/, 8];\r\n _a.label = 5;\r\n case 5:\r\n _a.trys.push([5, 7, , 8]);\r\n return [4 /*yield*/, WindowUtils.monitorWindowForHash(popUpWindow, this.config.system.loadFrameTimeout, urlNavigate, this.logger)];\r\n case 6:\r\n hash = _a.sent();\r\n this.handleAuthenticationResponse(hash);\r\n // Request completed successfully, set to completed\r\n this.cacheStorage.removeItem(TemporaryCacheKeys.INTERACTION_STATUS);\r\n this.logger.info(\"Closing popup window\");\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 WindowUtils.closePopups();\r\n }\r\n return [3 /*break*/, 8];\r\n case 7:\r\n error_1 = _a.sent();\r\n if (reject) {\r\n reject(error_1);\r\n }\r\n if (this.config.framework.isAngular) {\r\n this.broadcast(\"msal:popUpClosed\", error_1.errorCode + Constants.resourceDelimiter + error_1.errorMessage);\r\n }\r\n else {\r\n // Request failed, set to canceled\r\n this.cacheStorage.removeItem(TemporaryCacheKeys.INTERACTION_STATUS);\r\n popUpWindow.close();\r\n }\r\n return [3 /*break*/, 8];\r\n case 8: return [3 /*break*/, 10];\r\n case 9:\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 navigate = request.onRedirectNavigate(urlNavigate);\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 }\r\n else {\r\n this.logger.verbose(\"onRedirectNavigate returned false, stopping navigation\");\r\n }\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 _a.label = 10;\r\n case 10: return [3 /*break*/, 12];\r\n case 11:\r\n err_1 = _a.sent();\r\n this.logger.error(err_1);\r\n this.cacheStorage.resetTempCacheItems(request.state);\r\n this.authErrorHandler(interactionType, ClientAuthError.createEndpointResolutionError(err_1.toString), buildResponseStateOnly(request.state), reject);\r\n if (popUpWindow) {\r\n popUpWindow.close();\r\n }\r\n return [3 /*break*/, 12];\r\n case 12: return [2 /*return*/];\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 UserAgentApplication.prototype.ssoSilent = function (request) {\r\n // throw an error on an empty request\r\n if (!request) {\r\n throw ClientConfigurationError.createEmptyRequestError();\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 return this.acquireTokenSilent(tslib_1.__assign({}, request, { scopes: [this.clientId] }));\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.} - 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 UserAgentApplication.prototype.acquireTokenSilent = function (userRequest) {\r\n var _this = this;\r\n this.logger.verbose(\"AcquireTokenSilent has been called\");\r\n // validate the request\r\n var request = RequestUtils.validateRequest(userRequest, false, this.clientId, Constants.interactionTypeSilent);\r\n var apiEvent = this.telemetryManager.createAndStartApiEvent(request.correlationId, API_EVENT_IDENTIFIER.AcquireTokenSilent);\r\n var requestSignature = RequestUtils.createRequestSignature(request);\r\n return new Promise(function (resolve, reject) { return tslib_1.__awaiter(_this, void 0, void 0, function () {\r\n var scope, account, adalIdToken, responseType, serverAuthenticationRequest, adalIdTokenObject, userContainedClaims, authErr, cacheResultResponse, logMessage, err_2;\r\n return tslib_1.__generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n // block the request if made from the hidden iframe\r\n WindowUtils.blockReloadInHiddenIframes();\r\n scope = request.scopes.join(\" \").toLowerCase();\r\n this.logger.verbosePii(\"Serialized scopes: \" + scope);\r\n if (request.account) {\r\n account = request.account;\r\n this.logger.verbose(\"Account set from request\");\r\n }\r\n else {\r\n account = this.getAccount();\r\n this.logger.verbose(\"Account set from MSAL Cache\");\r\n }\r\n adalIdToken = this.cacheStorage.getItem(Constants.adalIdToken);\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 [2 /*return*/, reject(ClientAuthError.createUserLoginRequiredError())];\r\n }\r\n responseType = this.getTokenType(account, request.scopes, true);\r\n this.logger.verbose(\"Response type: \" + responseType);\r\n serverAuthenticationRequest = new ServerRequestParameters(AuthorityFactory.CreateInstance(request.authority, this.config.auth.validateAuthority, request.authorityMetadata), this.clientId, responseType, this.getRedirectUri(request.redirectUri), request.scopes, request.state, request.correlationId);\r\n this.logger.verbose(\"Finished building server authentication request\");\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 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 userContainedClaims = request.claimsRequest || serverAuthenticationRequest.claimsValue;\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 }\r\n catch (e) {\r\n authErr = e;\r\n }\r\n }\r\n if (!cacheResultResponse) return [3 /*break*/, 1];\r\n this.logger.verbose(\"Token is already in cache for scope: \" + scope);\r\n resolve(cacheResultResponse);\r\n return [2 /*return*/, null];\r\n case 1:\r\n if (!authErr) return [3 /*break*/, 2];\r\n this.logger.infoPii(authErr.errorCode + \":\" + authErr.errorMessage);\r\n reject(authErr);\r\n return [2 /*return*/, null];\r\n case 2:\r\n logMessage = void 0;\r\n if (userContainedClaims) {\r\n logMessage = \"Skipped cache lookup since claims were given\";\r\n }\r\n else if (request.forceRefresh) {\r\n logMessage = \"Skipped cache lookup since request.forceRefresh option was set to true\";\r\n }\r\n else {\r\n logMessage = \"Token is not in cache for scope: \" + scope;\r\n }\r\n this.logger.verbose(logMessage);\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 ? AuthorityFactory.CreateInstance(request.authority, this.config.auth.validateAuthority, request.authorityMetadata) : this.authorityInstance;\r\n }\r\n this.logger.verbosePii(\"Authority instance: \" + serverAuthenticationRequest.authority);\r\n _a.label = 3;\r\n case 3:\r\n _a.trys.push([3, 7, , 8]);\r\n if (!!serverAuthenticationRequest.authorityInstance.hasCachedMetadata()) return [3 /*break*/, 5];\r\n this.logger.verbose(\"No cached metadata for authority\");\r\n return [4 /*yield*/, AuthorityFactory.saveMetadataFromNetwork(serverAuthenticationRequest.authorityInstance, this.telemetryManager, request.correlationId)];\r\n case 4:\r\n _a.sent();\r\n this.logger.verbose(\"Authority has been updated with endpoint discovery response\");\r\n return [3 /*break*/, 6];\r\n case 5:\r\n this.logger.verbose(\"Cached metadata found for authority\");\r\n _a.label = 6;\r\n case 6:\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(\"Renew token for scope and authority: \" + requestSignature + \" is 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 && request.scopes.indexOf(this.clientId) > -1 && request.scopes.length === 1) {\r\n /*\r\n * App uses idToken to send to api endpoints\r\n * Default scope is tracked as clientId to store this token\r\n */\r\n this.logger.verbose(\"Renewing idToken\");\r\n this.silentLogin = true;\r\n this.renewIdToken(requestSignature, resolve, reject, account, serverAuthenticationRequest);\r\n }\r\n else {\r\n // renew access token\r\n this.logger.verbose(\"Renewing accesstoken\");\r\n this.renewToken(requestSignature, resolve, reject, account, serverAuthenticationRequest);\r\n }\r\n }\r\n return [3 /*break*/, 8];\r\n case 7:\r\n err_2 = _a.sent();\r\n this.logger.error(err_2);\r\n reject(ClientAuthError.createEndpointResolutionError(err_2.toString()));\r\n return [2 /*return*/, null];\r\n case 8: return [2 /*return*/];\r\n }\r\n });\r\n }); })\r\n .then(function (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(function (error) {\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 // #endregion\r\n // #region Popup Window Creation\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 UserAgentApplication.prototype.openPopup = function (urlNavigate, title, popUpWidth, popUpHeight) {\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 var winLeft = window.screenLeft ? window.screenLeft : window.screenX;\r\n var 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 var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;\r\n var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;\r\n var left = ((width / 2) - (popUpWidth / 2)) + winLeft;\r\n var top_1 = ((height / 2) - (popUpHeight / 2)) + winTop;\r\n // open the window\r\n var popupWindow = window.open(urlNavigate, title, \"width=\" + popUpWidth + \", height=\" + popUpHeight + \", top=\" + top_1 + \", 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 return popupWindow;\r\n }\r\n catch (e) {\r\n this.logger.error(\"error opening popup \" + e.message);\r\n this.cacheStorage.removeItem(TemporaryCacheKeys.INTERACTION_STATUS);\r\n throw ClientAuthError.createPopupWindowError(e.toString());\r\n }\r\n };\r\n // #endregion\r\n // #region Iframe Management\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 UserAgentApplication.prototype.loadIframeTimeout = function (urlNavigate, frameName, requestSignature) {\r\n return tslib_1.__awaiter(this, void 0, void 0, function () {\r\n var expectedState, iframe, _a, hash, error_2;\r\n return tslib_1.__generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n expectedState = window.activeRenewals[requestSignature];\r\n this.logger.verbosePii(\"Set loading state to pending for: \" + requestSignature + \":\" + expectedState);\r\n this.cacheStorage.setItem(\"\" + TemporaryCacheKeys.RENEW_STATUS + Constants.resourceDelimiter + expectedState, Constants.inProgress);\r\n if (!this.config.system.navigateFrameWait) return [3 /*break*/, 2];\r\n return [4 /*yield*/, WindowUtils.loadFrame(urlNavigate, frameName, this.config.system.navigateFrameWait, this.logger)];\r\n case 1:\r\n _a = _b.sent();\r\n return [3 /*break*/, 3];\r\n case 2:\r\n _a = WindowUtils.loadFrameSync(urlNavigate, frameName, this.logger);\r\n _b.label = 3;\r\n case 3:\r\n iframe = _a;\r\n _b.label = 4;\r\n case 4:\r\n _b.trys.push([4, 6, , 7]);\r\n return [4 /*yield*/, WindowUtils.monitorWindowForHash(iframe.contentWindow, this.config.system.loadFrameTimeout, urlNavigate, this.logger, true)];\r\n case 5:\r\n hash = _b.sent();\r\n if (hash) {\r\n this.handleAuthenticationResponse(hash);\r\n }\r\n return [3 /*break*/, 7];\r\n case 6:\r\n error_2 = _b.sent();\r\n if (this.cacheStorage.getItem(\"\" + TemporaryCacheKeys.RENEW_STATUS + Constants.resourceDelimiter + 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_2);\r\n }\r\n this.cacheStorage.removeItem(\"\" + TemporaryCacheKeys.RENEW_STATUS + Constants.resourceDelimiter + expectedState);\r\n }\r\n WindowUtils.removeHiddenIframe(iframe);\r\n throw error_2;\r\n case 7:\r\n WindowUtils.removeHiddenIframe(iframe);\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n // #endregion\r\n // #region General Helpers\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 UserAgentApplication.prototype.navigateWindow = function (urlNavigate, popupWindow) {\r\n // Navigate if valid URL\r\n if (urlNavigate && !StringUtils.isEmpty(urlNavigate)) {\r\n var navigateWindow = popupWindow ? popupWindow : window;\r\n var logMessage = 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 * @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 UserAgentApplication.prototype.registerCallback = function (expectedState, requestSignature, resolve, reject) {\r\n var _this = this;\r\n // track active renewals\r\n window.activeRenewals[requestSignature] = expectedState;\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 // Store the server response in the current window??\r\n if (!window.callbackMappedToRenewStates[expectedState]) {\r\n window.callbackMappedToRenewStates[expectedState] = function (response, error) {\r\n // reset active renewals\r\n window.activeRenewals[requestSignature] = null;\r\n // for all promiseMappedtoRenewStates for a given 'state' - call the reject/resolve with error/token respectively\r\n for (var 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 }\r\n else if (response) {\r\n window.promiseMappedToRenewStates[expectedState][i].resolve(response);\r\n }\r\n else {\r\n _this.cacheStorage.resetTempCacheItems(expectedState);\r\n throw AuthError.createUnexpectedError(\"Error and response are both null\");\r\n }\r\n }\r\n catch (e) {\r\n _this.logger.warning(e);\r\n }\r\n }\r\n // reset\r\n window.promiseMappedToRenewStates[expectedState] = null;\r\n window.callbackMappedToRenewStates[expectedState] = null;\r\n };\r\n }\r\n };\r\n // #endregion\r\n // #region Logout\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 UserAgentApplication.prototype.logout = function (correlationId) {\r\n this.logoutAsync(correlationId);\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 UserAgentApplication.prototype.logoutAsync = function (correlationId) {\r\n return tslib_1.__awaiter(this, void 0, void 0, function () {\r\n var requestCorrelationId, apiEvent, correlationIdParam, postLogoutQueryParam, urlNavigate, error_3;\r\n return tslib_1.__generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n requestCorrelationId = correlationId || CryptoUtils.createNewGuid();\r\n apiEvent = this.telemetryManager.createAndStartApiEvent(requestCorrelationId, API_EVENT_IDENTIFIER.Logout);\r\n this.clearCache();\r\n this.account = null;\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 5, , 6]);\r\n if (!!this.authorityInstance.hasCachedMetadata()) return [3 /*break*/, 3];\r\n this.logger.verbose(\"No cached metadata for authority\");\r\n return [4 /*yield*/, AuthorityFactory.saveMetadataFromNetwork(this.authorityInstance, this.telemetryManager, correlationId)];\r\n case 2:\r\n _a.sent();\r\n return [3 /*break*/, 4];\r\n case 3:\r\n this.logger.verbose(\"Cached metadata found for authority\");\r\n _a.label = 4;\r\n case 4:\r\n correlationIdParam = \"client-request-id=\" + requestCorrelationId;\r\n postLogoutQueryParam = this.getPostLogoutRedirectUri()\r\n ? \"&post_logout_redirect_uri=\" + encodeURIComponent(this.getPostLogoutRedirectUri())\r\n : \"\";\r\n urlNavigate = this.authorityInstance.EndSessionEndpoint\r\n ? this.authorityInstance.EndSessionEndpoint + \"?\" + correlationIdParam + postLogoutQueryParam\r\n : this.authority + \"oauth2/v2.0/logout?\" + correlationIdParam + postLogoutQueryParam;\r\n this.telemetryManager.stopAndFlushApiEvent(requestCorrelationId, apiEvent, true);\r\n this.navigateWindow(urlNavigate);\r\n return [3 /*break*/, 6];\r\n case 5:\r\n error_3 = _a.sent();\r\n this.telemetryManager.stopAndFlushApiEvent(requestCorrelationId, apiEvent, false, error_3.errorCode);\r\n return [3 /*break*/, 6];\r\n case 6: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * @hidden\r\n * Clear all access tokens in the cache.\r\n * @ignore\r\n */\r\n UserAgentApplication.prototype.clearCache = function () {\r\n window.renewStates = [];\r\n var accessTokenItems = this.cacheStorage.getAllAccessTokens(Constants.clientId, Constants.homeAccountIdentifier);\r\n for (var i = 0; i < accessTokenItems.length; i++) {\r\n this.cacheStorage.removeItem(JSON.stringify(accessTokenItems[i].key));\r\n }\r\n this.cacheStorage.resetCacheItems();\r\n // state not being sent would mean this call may not be needed; check later\r\n this.cacheStorage.clearMsalCookie();\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 UserAgentApplication.prototype.clearCacheForScope = function (accessToken) {\r\n var accessTokenItems = this.cacheStorage.getAllAccessTokens(Constants.clientId, Constants.homeAccountIdentifier);\r\n for (var i = 0; i < accessTokenItems.length; i++) {\r\n var token = accessTokenItems[i];\r\n if (token.value.accessToken === accessToken) {\r\n this.cacheStorage.removeItem(JSON.stringify(token.key));\r\n }\r\n }\r\n };\r\n // #endregion\r\n // #region Response\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 UserAgentApplication.prototype.isCallback = function (hash) {\r\n this.logger.info(\"isCallback will be deprecated in favor of urlContainsHash in MSAL.js v2.0.\");\r\n return UrlUtils.urlContainsHash(hash);\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 UserAgentApplication.prototype.processCallBack = function (hash, stateInfo, parentCallback) {\r\n this.logger.info(\"Processing the callback from redirect response\");\r\n // get the state info from the hash\r\n if (!stateInfo) {\r\n stateInfo = this.getResponseState(hash);\r\n }\r\n var response;\r\n var authErr;\r\n // Save the token info from the hash\r\n try {\r\n response = this.saveTokenFromHash(hash, stateInfo);\r\n }\r\n catch (err) {\r\n authErr = err;\r\n }\r\n try {\r\n // Clear the cookie in the hash\r\n this.cacheStorage.clearMsalCookie(stateInfo.state);\r\n var accountState = 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 }\r\n else {\r\n this.logger.verbose(\"acquiring token interactive in progress\");\r\n }\r\n response.tokenType = ServerHashParamKeys.ACCESS_TOKEN;\r\n }\r\n else if (stateInfo.requestType === Constants.login) {\r\n response.tokenType = ServerHashParamKeys.ID_TOKEN;\r\n }\r\n if (!parentCallback) {\r\n this.redirectResponse = response;\r\n return;\r\n }\r\n }\r\n else if (!parentCallback) {\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 parentCallback(response, authErr);\r\n }\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 * @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 UserAgentApplication.prototype.handleAuthenticationResponse = function (hash) {\r\n // retrieve the hash\r\n var locationHash = hash || window.location.hash;\r\n // if (window.parent !== window), by using self, window.parent becomes equal to window in getResponseState method specifically\r\n var stateInfo = this.getResponseState(locationHash);\r\n var tokenResponseCallback = window.callbackMappedToRenewStates[stateInfo.state];\r\n this.processCallBack(locationHash, stateInfo, tokenResponseCallback);\r\n // If current window is opener, close all windows\r\n WindowUtils.closePopups();\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 UserAgentApplication.prototype.handleRedirectAuthenticationResponse = function (hash) {\r\n this.logger.info(\"Returned from redirect url\");\r\n // clear hash from window\r\n window.location.hash = \"\";\r\n // if (window.parent !== window), by using self, window.parent becomes equal to window in getResponseState method specifically\r\n var stateInfo = this.getResponseState(hash);\r\n // if set to navigate to loginRequest page post login\r\n if (this.config.auth.navigateToLoginRequestUrl && window.parent === window) {\r\n var loginRequestUrl = this.cacheStorage.getItem(\"\" + TemporaryCacheKeys.LOGIN_REQUEST + Constants.resourceDelimiter + stateInfo.state, this.inCookie);\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 }\r\n else {\r\n var currentUrl = UrlUtils.removeHashFromUrl(window.location.href);\r\n var finalRedirectUrl = UrlUtils.removeHashFromUrl(loginRequestUrl);\r\n if (currentUrl !== finalRedirectUrl) {\r\n window.location.assign(\"\" + finalRedirectUrl + hash);\r\n return;\r\n }\r\n else {\r\n var loginRequestUrlComponents = UrlUtils.GetUrlComponents(loginRequestUrl);\r\n if (loginRequestUrlComponents.Hash) {\r\n window.location.hash = loginRequestUrlComponents.Hash;\r\n }\r\n }\r\n }\r\n }\r\n this.processCallBack(hash, stateInfo, null);\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 UserAgentApplication.prototype.getResponseState = function (hash) {\r\n var parameters = UrlUtils.deserializeHash(hash);\r\n var stateResponse;\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 var parsedState = RequestUtils.parseLibraryState(parameters.state);\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 }\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 // loginRedirect\r\n if (stateResponse.state === this.cacheStorage.getItem(\"\" + TemporaryCacheKeys.STATE_LOGIN + Constants.resourceDelimiter + stateResponse.state, this.inCookie) || stateResponse.state === this.silentAuthenticationState) {\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(\"\" + TemporaryCacheKeys.STATE_ACQ_TOKEN + Constants.resourceDelimiter + stateResponse.state, this.inCookie)) {\r\n stateResponse.requestType = Constants.renewToken;\r\n stateResponse.stateMatch = true;\r\n return stateResponse;\r\n }\r\n // external api requests may have many renewtoken requests for different resource\r\n if (!stateResponse.stateMatch) {\r\n stateResponse.requestType = window.requestType;\r\n var statesInParentContext = window.renewStates;\r\n for (var i = 0; i < statesInParentContext.length; i++) {\r\n if (statesInParentContext[i] === stateResponse.state) {\r\n stateResponse.stateMatch = true;\r\n break;\r\n }\r\n }\r\n }\r\n return stateResponse;\r\n };\r\n // #endregion\r\n // #region Token Processing (Extract to TokenProcessing.ts)\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 UserAgentApplication.prototype.getCachedToken = function (serverAuthenticationRequest, account) {\r\n var accessTokenCacheItem = null;\r\n var scopes = serverAuthenticationRequest.scopes;\r\n // filter by clientId and account\r\n var tokenCacheItems = this.cacheStorage.getAllAccessTokens(this.clientId, account ? account.homeAccountIdentifier : null);\r\n // No match found after initial filtering\r\n if (tokenCacheItems.length === 0) {\r\n return null;\r\n }\r\n var filteredItems = [];\r\n // if no authority passed\r\n if (!serverAuthenticationRequest.authority) {\r\n // filter by scope\r\n for (var i = 0; i < tokenCacheItems.length; i++) {\r\n var cacheItem = tokenCacheItems[i];\r\n var cachedScopes = cacheItem.key.scopes.split(\" \");\r\n if (ScopeSet.containsScope(cachedScopes, scopes)) {\r\n filteredItems.push(cacheItem);\r\n }\r\n }\r\n // if only one cached token found\r\n if (filteredItems.length === 1) {\r\n accessTokenCacheItem = filteredItems[0];\r\n serverAuthenticationRequest.authorityInstance = AuthorityFactory.CreateInstance(accessTokenCacheItem.key.authority, this.config.auth.validateAuthority);\r\n }\r\n // if more than one cached token is found\r\n else if (filteredItems.length > 1) {\r\n throw ClientAuthError.createMultipleMatchingTokensInCacheError(scopes.toString());\r\n }\r\n // if no match found, check if there was a single authority used\r\n else {\r\n var authorityList = this.getUniqueAuthority(tokenCacheItems, \"authority\");\r\n if (authorityList.length > 1) {\r\n throw ClientAuthError.createMultipleAuthoritiesInCacheError(scopes.toString());\r\n }\r\n serverAuthenticationRequest.authorityInstance = AuthorityFactory.CreateInstance(authorityList[0], this.config.auth.validateAuthority);\r\n }\r\n }\r\n // if an authority is passed in the API\r\n else {\r\n // filter by authority and scope\r\n for (var i = 0; i < tokenCacheItems.length; i++) {\r\n var cacheItem = tokenCacheItems[i];\r\n var cachedScopes = cacheItem.key.scopes.split(\" \");\r\n if (ScopeSet.containsScope(cachedScopes, scopes) && UrlUtils.CanonicalizeUri(cacheItem.key.authority) === serverAuthenticationRequest.authority) {\r\n filteredItems.push(cacheItem);\r\n }\r\n }\r\n // no match\r\n if (filteredItems.length === 0) {\r\n return null;\r\n }\r\n // if only one cachedToken Found\r\n else if (filteredItems.length === 1) {\r\n accessTokenCacheItem = filteredItems[0];\r\n }\r\n else {\r\n // if more than one cached token is found\r\n throw ClientAuthError.createMultipleMatchingTokensInCacheError(scopes.toString());\r\n }\r\n }\r\n if (accessTokenCacheItem != null) {\r\n var expired = Number(accessTokenCacheItem.value.expiresIn);\r\n // If expiration is within offset, it will force renew\r\n var offset = this.config.system.tokenRenewalOffsetSeconds || 300;\r\n if (expired && (expired > TimeUtils.now() + offset)) {\r\n var idTokenObj = new IdToken(accessTokenCacheItem.value.idToken);\r\n if (!account) {\r\n account = this.getAccount();\r\n if (!account) {\r\n throw AuthError.createUnexpectedError(\"Account should not be null here.\");\r\n }\r\n }\r\n var aState = this.getAccountState(serverAuthenticationRequest.state);\r\n var response = {\r\n uniqueId: \"\",\r\n tenantId: \"\",\r\n tokenType: (accessTokenCacheItem.value.idToken === accessTokenCacheItem.value.accessToken) ? ServerHashParamKeys.ID_TOKEN : ServerHashParamKeys.ACCESS_TOKEN,\r\n idToken: idTokenObj,\r\n idTokenClaims: idTokenObj.claims,\r\n accessToken: accessTokenCacheItem.value.accessToken,\r\n scopes: accessTokenCacheItem.key.scopes.split(\" \"),\r\n expiresOn: new Date(expired * 1000),\r\n account: account,\r\n accountState: aState,\r\n fromCache: true\r\n };\r\n ResponseUtils.setResponseIdToken(response, idTokenObj);\r\n return response;\r\n }\r\n else {\r\n this.cacheStorage.removeItem(JSON.stringify(filteredItems[0].key));\r\n return null;\r\n }\r\n }\r\n else {\r\n return null;\r\n }\r\n };\r\n /**\r\n * @hidden\r\n * Used to get a unique list of authorities from the cache\r\n * @param {Array} accessTokenCacheItems - accessTokenCacheItems saved in the cache\r\n * @ignore\r\n */\r\n UserAgentApplication.prototype.getUniqueAuthority = function (accessTokenCacheItems, property) {\r\n var authorityList = [];\r\n var flags = [];\r\n accessTokenCacheItems.forEach(function (element) {\r\n if (element.key.hasOwnProperty(property) && (flags.indexOf(element.key[property]) === -1)) {\r\n flags.push(element.key[property]);\r\n authorityList.push(element.key[property]);\r\n }\r\n });\r\n return authorityList;\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 UserAgentApplication.prototype.extractADALIdToken = function () {\r\n var adalIdToken = this.cacheStorage.getItem(Constants.adalIdToken);\r\n if (!StringUtils.isEmpty(adalIdToken)) {\r\n return TokenUtils.extractIdToken(adalIdToken);\r\n }\r\n return null;\r\n };\r\n /**\r\n * @hidden\r\n * Acquires access token using a hidden iframe.\r\n * @ignore\r\n */\r\n UserAgentApplication.prototype.renewToken = function (requestSignature, resolve, reject, account, serverAuthenticationRequest) {\r\n this.logger.verbose(\"renewToken is called for scope and authority: \" + requestSignature);\r\n var frameName = WindowUtils.generateFrameName(FramePrefix.TOKEN_FRAME, requestSignature);\r\n WindowUtils.addHiddenIFrame(frameName, this.logger);\r\n this.updateCacheEntries(serverAuthenticationRequest, account, false);\r\n this.logger.verbosePii(\"Renew token Expected state: \" + serverAuthenticationRequest.state);\r\n // Build urlNavigate with \"prompt=none\" and navigate to URL in hidden iFrame\r\n var urlNavigate = UrlUtils.urlRemoveQueryStringParameter(UrlUtils.createNavigateUrl(serverAuthenticationRequest), Constants.prompt) + Constants.prompt_none + Constants.response_mode_fragment;\r\n window.renewStates.push(serverAuthenticationRequest.state);\r\n window.requestType = Constants.renewToken;\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(function (error) { return reject(error); });\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 UserAgentApplication.prototype.renewIdToken = function (requestSignature, resolve, reject, account, serverAuthenticationRequest) {\r\n this.logger.info(\"renewidToken is called\");\r\n var frameName = WindowUtils.generateFrameName(FramePrefix.ID_TOKEN_FRAME, requestSignature);\r\n WindowUtils.addHiddenIFrame(frameName, this.logger);\r\n this.updateCacheEntries(serverAuthenticationRequest, account, false);\r\n this.logger.verbose(\"Renew Idtoken Expected state: \" + serverAuthenticationRequest.state);\r\n // Build urlNavigate with \"prompt=none\" and navigate to URL in hidden iFrame\r\n var urlNavigate = UrlUtils.urlRemoveQueryStringParameter(UrlUtils.createNavigateUrl(serverAuthenticationRequest), Constants.prompt) + Constants.prompt_none + Constants.response_mode_fragment;\r\n if (this.silentLogin) {\r\n window.requestType = Constants.login;\r\n this.silentAuthenticationState = serverAuthenticationRequest.state;\r\n }\r\n else {\r\n window.requestType = Constants.renewToken;\r\n window.renewStates.push(serverAuthenticationRequest.state);\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(function (error) { return reject(error); });\r\n };\r\n /**\r\n * @hidden\r\n *\r\n * This method must be called for processing the response received from AAD. It extracts the hash, processes the token or error, saves it in the cache and calls the registered callbacks with the result.\r\n * @param {string} authority authority received in the redirect response from AAD.\r\n * @param {TokenResponse} requestInfo an object created from the redirect response from AAD comprising of the keys - parameters, requestType, stateMatch, stateResponse and valid.\r\n * @param {Account} account account object for which scopes are consented for. The default account is the logged in account.\r\n * @param {ClientInfo} clientInfo clientInfo received as part of the response comprising of fields uid and utid.\r\n * @param {IdToken} idToken idToken received as part of the response.\r\n * @ignore\r\n * @private\r\n */\r\n /* tslint:disable:no-string-literal */\r\n UserAgentApplication.prototype.saveAccessToken = function (response, authority, parameters, clientInfo, idTokenObj) {\r\n var scope;\r\n var accessTokenResponse = tslib_1.__assign({}, response);\r\n var clientObj = new ClientInfo(clientInfo);\r\n var expiration;\r\n // if the response contains \"scope\"\r\n if (parameters.hasOwnProperty(ServerHashParamKeys.SCOPE)) {\r\n // read the scopes\r\n scope = parameters[ServerHashParamKeys.SCOPE];\r\n var consentedScopes = scope.split(\" \");\r\n // retrieve all access tokens from the cache, remove the dup scores\r\n var accessTokenCacheItems = this.cacheStorage.getAllAccessTokens(this.clientId, authority);\r\n for (var i = 0; i < accessTokenCacheItems.length; i++) {\r\n var accessTokenCacheItem = accessTokenCacheItems[i];\r\n if (accessTokenCacheItem.key.homeAccountIdentifier === response.account.homeAccountIdentifier) {\r\n var 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 // Generate and cache accessTokenKey and accessTokenValue\r\n var expiresIn = TimeUtils.parseExpiresIn(parameters[ServerHashParamKeys.EXPIRES_IN]);\r\n var parsedState = RequestUtils.parseLibraryState(parameters[ServerHashParamKeys.STATE]);\r\n expiration = parsedState.ts + expiresIn;\r\n var accessTokenKey = new AccessTokenKey(authority, this.clientId, scope, clientObj.uid, clientObj.utid);\r\n var accessTokenValue = new AccessTokenValue(parameters[ServerHashParamKeys.ACCESS_TOKEN], idTokenObj.rawIdToken, expiration.toString(), clientInfo);\r\n this.cacheStorage.setItem(JSON.stringify(accessTokenKey), JSON.stringify(accessTokenValue));\r\n accessTokenResponse.accessToken = parameters[ServerHashParamKeys.ACCESS_TOKEN];\r\n accessTokenResponse.scopes = consentedScopes;\r\n }\r\n // if the response does not contain \"scope\" - scope is usually client_id and the token will be id_token\r\n else {\r\n scope = this.clientId;\r\n // Generate and cache accessTokenKey and accessTokenValue\r\n var accessTokenKey = new AccessTokenKey(authority, this.clientId, scope, clientObj.uid, clientObj.utid);\r\n expiration = Number(idTokenObj.expiration);\r\n var accessTokenValue = new AccessTokenValue(parameters[ServerHashParamKeys.ID_TOKEN], parameters[ServerHashParamKeys.ID_TOKEN], expiration.toString(), clientInfo);\r\n this.cacheStorage.setItem(JSON.stringify(accessTokenKey), JSON.stringify(accessTokenValue));\r\n accessTokenResponse.scopes = [scope];\r\n accessTokenResponse.accessToken = parameters[ServerHashParamKeys.ID_TOKEN];\r\n }\r\n if (expiration) {\r\n accessTokenResponse.expiresOn = new Date(expiration * 1000);\r\n }\r\n else {\r\n this.logger.error(\"Could not parse expiresIn parameter\");\r\n }\r\n return accessTokenResponse;\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 UserAgentApplication.prototype.saveTokenFromHash = function (hash, stateInfo) {\r\n this.logger.info(\"State status:\" + stateInfo.stateMatch + \"; Request type:\" + stateInfo.requestType);\r\n var response = {\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 var error;\r\n var hashParams = UrlUtils.deserializeHash(hash);\r\n var authorityKey = \"\";\r\n var acquireTokenAccountKey = \"\";\r\n var idTokenObj = null;\r\n // If server returns an error\r\n if (hashParams.hasOwnProperty(ServerHashParamKeys.ERROR_DESCRIPTION) || hashParams.hasOwnProperty(ServerHashParamKeys.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 // login\r\n if (stateInfo.requestType === Constants.login) {\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 // acquireToken\r\n if (stateInfo.requestType === Constants.renewToken) {\r\n authorityKey = AuthCache.generateAuthorityKey(stateInfo.state);\r\n var account = this.getAccount();\r\n var accountId = void 0;\r\n if (account && !StringUtils.isEmpty(account.homeAccountIdentifier)) {\r\n accountId = account.homeAccountIdentifier;\r\n }\r\n else {\r\n accountId = Constants.no_account;\r\n }\r\n acquireTokenAccountKey = AuthCache.generateAcquireTokenAccountKey(accountId, stateInfo.state);\r\n }\r\n var _a = ServerHashParamKeys.ERROR, hashErr = hashParams[_a], _b = ServerHashParamKeys.ERROR_DESCRIPTION, hashErrDesc = hashParams[_b];\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 }\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 // 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.cacheStorage.setItem(\"\" + TemporaryCacheKeys.SESSION_STATE + Constants.resourceDelimiter + stateInfo.state, hashParams[ServerHashParamKeys.SESSION_STATE]);\r\n }\r\n response.accountState = this.getAccountState(stateInfo.state);\r\n var clientInfo = \"\";\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 if (hashParams.hasOwnProperty(ServerHashParamKeys.SCOPE)) {\r\n response.scopes = hashParams[ServerHashParamKeys.SCOPE].split(\" \");\r\n }\r\n // retrieve the id_token from response if present\r\n if (hashParams.hasOwnProperty(ServerHashParamKeys.ID_TOKEN)) {\r\n idTokenObj = new IdToken(hashParams[ServerHashParamKeys.ID_TOKEN]);\r\n response.idToken = idTokenObj;\r\n response.idTokenClaims = idTokenObj.claims;\r\n }\r\n else {\r\n idTokenObj = new IdToken(this.cacheStorage.getItem(PersistentCacheKeys.IDTOKEN));\r\n response = ResponseUtils.setResponseIdToken(response, idTokenObj);\r\n }\r\n // set authority\r\n var authority = this.populateAuthority(stateInfo.state, this.inCookie, this.cacheStorage, idTokenObj);\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 clientInfo = hashParams[ServerHashParamKeys.CLIENT_INFO];\r\n }\r\n else {\r\n this.logger.warning(\"ClientInfo not received in the response from AAD\");\r\n throw ClientAuthError.createClientInfoNotPopulatedError(\"ClientInfo not received in the response from the server\");\r\n }\r\n response.account = Account.createAccount(idTokenObj, new ClientInfo(clientInfo));\r\n var accountKey = void 0;\r\n if (response.account && !StringUtils.isEmpty(response.account.homeAccountIdentifier)) {\r\n accountKey = response.account.homeAccountIdentifier;\r\n }\r\n else {\r\n accountKey = Constants.no_account;\r\n }\r\n acquireTokenAccountKey = AuthCache.generateAcquireTokenAccountKey(accountKey, stateInfo.state);\r\n var acquireTokenAccountKey_noaccount = AuthCache.generateAcquireTokenAccountKey(Constants.no_account, stateInfo.state);\r\n var cachedAccount = this.cacheStorage.getItem(acquireTokenAccountKey);\r\n var acquireTokenAccount = void 0;\r\n // Check with the account in the Cache\r\n if (!StringUtils.isEmpty(cachedAccount)) {\r\n acquireTokenAccount = JSON.parse(cachedAccount);\r\n if (response.account && acquireTokenAccount && Account.compareAccounts(response.account, acquireTokenAccount)) {\r\n response = this.saveAccessToken(response, authority, hashParams, clientInfo, idTokenObj);\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(\"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 response = this.saveAccessToken(response, authority, hashParams, clientInfo, idTokenObj);\r\n }\r\n }\r\n // Process id_token\r\n if (hashParams.hasOwnProperty(ServerHashParamKeys.ID_TOKEN)) {\r\n this.logger.info(\"Fragment has id token\");\r\n // set the idToken\r\n idTokenObj = new IdToken(hashParams[ServerHashParamKeys.ID_TOKEN]);\r\n response = ResponseUtils.setResponseIdToken(response, idTokenObj);\r\n if (hashParams.hasOwnProperty(ServerHashParamKeys.CLIENT_INFO)) {\r\n clientInfo = hashParams[ServerHashParamKeys.CLIENT_INFO];\r\n }\r\n else {\r\n this.logger.warning(\"ClientInfo not received in the response from AAD\");\r\n }\r\n // set authority\r\n var authority = this.populateAuthority(stateInfo.state, this.inCookie, this.cacheStorage, idTokenObj);\r\n this.account = Account.createAccount(idTokenObj, new ClientInfo(clientInfo));\r\n response.account = this.account;\r\n if (idTokenObj && idTokenObj.nonce) {\r\n // check nonce integrity if idToken has nonce - throw an error if not matched\r\n if (idTokenObj.nonce !== this.cacheStorage.getItem(\"\" + TemporaryCacheKeys.NONCE_IDTOKEN + Constants.resourceDelimiter + stateInfo.state, this.inCookie)) {\r\n this.account = null;\r\n this.cacheStorage.setItem(ErrorCacheKeys.LOGIN_ERROR, \"Nonce Mismatch. Expected Nonce: \" + this.cacheStorage.getItem(\"\" + TemporaryCacheKeys.NONCE_IDTOKEN + Constants.resourceDelimiter + stateInfo.state, this.inCookie) + \",\" + \"Actual Nonce: \" + idTokenObj.nonce);\r\n this.logger.error(\"Nonce Mismatch.Expected Nonce: \" + this.cacheStorage.getItem(\"\" + TemporaryCacheKeys.NONCE_IDTOKEN + Constants.resourceDelimiter + stateInfo.state, this.inCookie) + \",\" + \"Actual Nonce: \" + idTokenObj.nonce);\r\n error = ClientAuthError.createNonceMismatchError(this.cacheStorage.getItem(\"\" + TemporaryCacheKeys.NONCE_IDTOKEN + Constants.resourceDelimiter + stateInfo.state, this.inCookie), idTokenObj.nonce);\r\n }\r\n // Save the token\r\n else {\r\n this.cacheStorage.setItem(PersistentCacheKeys.IDTOKEN, hashParams[ServerHashParamKeys.ID_TOKEN]);\r\n this.cacheStorage.setItem(PersistentCacheKeys.CLIENT_INFO, clientInfo);\r\n // Save idToken as access token for app itself\r\n this.saveAccessToken(response, authority, hashParams, clientInfo, idTokenObj);\r\n }\r\n }\r\n else {\r\n authorityKey = stateInfo.state;\r\n acquireTokenAccountKey = stateInfo.state;\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 authorityKey = stateInfo.state;\r\n acquireTokenAccountKey = stateInfo.state;\r\n var expectedState = this.cacheStorage.getItem(\"\" + TemporaryCacheKeys.STATE_LOGIN + Constants.resourceDelimiter + 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 // Set status to completed\r\n this.cacheStorage.removeItem(\"\" + TemporaryCacheKeys.RENEW_STATUS + Constants.resourceDelimiter + stateInfo.state);\r\n this.cacheStorage.resetTempCacheItems(stateInfo.state);\r\n // this is required if navigateToLoginRequestUrl=false\r\n if (this.inCookie) {\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 if (!response) {\r\n throw AuthError.createUnexpectedError(\"Response is null\");\r\n }\r\n return response;\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 UserAgentApplication.prototype.populateAuthority = function (state, inCookie, cacheStorage, idTokenObj) {\r\n var authorityKey = AuthCache.generateAuthorityKey(state);\r\n var cachedAuthority = cacheStorage.getItem(authorityKey, inCookie);\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 /* tslint:enable:no-string-literal */\r\n // #endregion\r\n // #region Account\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 UserAgentApplication.prototype.getAccount = function () {\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 // frame is used to get idToken and populate the account for the given session\r\n var rawIdToken = this.cacheStorage.getItem(PersistentCacheKeys.IDTOKEN);\r\n var rawClientInfo = this.cacheStorage.getItem(PersistentCacheKeys.CLIENT_INFO);\r\n if (!StringUtils.isEmpty(rawIdToken) && !StringUtils.isEmpty(rawClientInfo)) {\r\n var idToken = new IdToken(rawIdToken);\r\n var 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 * @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 UserAgentApplication.prototype.getAccountState = function (state) {\r\n if (state) {\r\n var 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 * Use to get a list of unique accounts in MSAL cache based on homeAccountIdentifier.\r\n *\r\n * @param {@link Array} Account - all unique accounts in MSAL cache.\r\n */\r\n UserAgentApplication.prototype.getAllAccounts = function () {\r\n var accounts = [];\r\n var accessTokenCacheItems = this.cacheStorage.getAllAccessTokens(Constants.clientId, Constants.homeAccountIdentifier);\r\n for (var i = 0; i < accessTokenCacheItems.length; i++) {\r\n var idToken = new IdToken(accessTokenCacheItems[i].value.idToken);\r\n var clientInfo = new ClientInfo(accessTokenCacheItems[i].value.homeAccountIdentifier);\r\n var account = Account.createAccount(idToken, clientInfo);\r\n accounts.push(account);\r\n }\r\n return this.getUniqueAccounts(accounts);\r\n };\r\n /**\r\n * @hidden\r\n *\r\n * Used to filter accounts based on homeAccountIdentifier\r\n * @param {Array} Accounts - accounts saved in the cache\r\n * @ignore\r\n */\r\n UserAgentApplication.prototype.getUniqueAccounts = function (accounts) {\r\n if (!accounts || accounts.length <= 1) {\r\n return accounts;\r\n }\r\n var flags = [];\r\n var uniqueAccounts = [];\r\n for (var 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 return uniqueAccounts;\r\n };\r\n // #endregion\r\n // #region Angular\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 UserAgentApplication.prototype.broadcast = function (eventName, data) {\r\n var evt = new CustomEvent(eventName, { detail: data });\r\n window.dispatchEvent(evt);\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 UserAgentApplication.prototype.getCachedTokenInternal = function (scopes, account, state, correlationId) {\r\n // Get the current session's account object\r\n var accountObject = account || this.getAccount();\r\n if (!accountObject) {\r\n return null;\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 var newAuthority = this.authorityInstance ? this.authorityInstance : AuthorityFactory.CreateInstance(this.authority, this.config.auth.validateAuthority);\r\n var responseType = this.getTokenType(accountObject, scopes, true);\r\n var serverAuthenticationRequest = new ServerRequestParameters(newAuthority, this.clientId, responseType, this.getRedirectUri(), scopes, state, correlationId);\r\n // get cached token\r\n return this.getCachedToken(serverAuthenticationRequest, account);\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 UserAgentApplication.prototype.getScopesForEndpoint = function (endpoint) {\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 (var 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 // process all protected resources and send the matched one\r\n if (this.config.framework.protectedResourceMap.size > 0) {\r\n for (var _i = 0, _a = Array.from(this.config.framework.protectedResourceMap.keys()); _i < _a.length; _i++) {\r\n var key = _a[_i];\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 * 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(this.clientId);\r\n }\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(this.clientId);\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 * Return boolean flag to developer to help inform if login is in progress\r\n * @returns {boolean} true/false\r\n */\r\n UserAgentApplication.prototype.getLoginInProgress = function () {\r\n return this.cacheStorage.getItem(TemporaryCacheKeys.INTERACTION_STATUS) === Constants.inProgress;\r\n };\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * @param loginInProgress\r\n */\r\n UserAgentApplication.prototype.setInteractionInProgress = function (inProgress) {\r\n if (inProgress) {\r\n this.cacheStorage.setItem(TemporaryCacheKeys.INTERACTION_STATUS, Constants.inProgress);\r\n }\r\n else {\r\n this.cacheStorage.removeItem(TemporaryCacheKeys.INTERACTION_STATUS);\r\n }\r\n };\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * @param loginInProgress\r\n */\r\n UserAgentApplication.prototype.setloginInProgress = function (loginInProgress) {\r\n this.setInteractionInProgress(loginInProgress);\r\n };\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * returns the status of acquireTokenInProgress\r\n */\r\n UserAgentApplication.prototype.getAcquireTokenInProgress = function () {\r\n return this.cacheStorage.getItem(TemporaryCacheKeys.INTERACTION_STATUS) === Constants.inProgress;\r\n };\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * @param acquireTokenInProgress\r\n */\r\n UserAgentApplication.prototype.setAcquireTokenInProgress = function (acquireTokenInProgress) {\r\n this.setInteractionInProgress(acquireTokenInProgress);\r\n };\r\n /**\r\n * @hidden\r\n * @ignore\r\n *\r\n * returns the logger handle\r\n */\r\n UserAgentApplication.prototype.getLogger = function () {\r\n return this.logger;\r\n };\r\n /**\r\n * Sets the logger callback.\r\n * @param logger Logger callback\r\n */\r\n UserAgentApplication.prototype.setLogger = function (logger) {\r\n this.logger = logger;\r\n };\r\n // #endregion\r\n // #region Getters and Setters\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 UserAgentApplication.prototype.getRedirectUri = function (reqRedirectUri) {\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 * 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 UserAgentApplication.prototype.getPostLogoutRedirectUri = function () {\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 * Use to get the current {@link Configuration} object in MSAL\r\n *\r\n * @returns {@link Configuration}\r\n */\r\n UserAgentApplication.prototype.getCurrentConfiguration = function () {\r\n if (!this.config) {\r\n throw ClientConfigurationError.createNoSetConfigurationError();\r\n }\r\n return this.config;\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 * @param silentCall\r\n *\r\n * @returns {string} token type: id_token or access_token\r\n *\r\n */\r\n UserAgentApplication.prototype.getTokenType = function (accountObject, scopes, silentCall) {\r\n /*\r\n * if account is passed and matches the account object/or set to getAccount() from cache\r\n * if client-id is passed as scope, get id_token else token/id_token_token (in case no session exists)\r\n */\r\n var tokenType;\r\n // acquireTokenSilent\r\n if (silentCall) {\r\n if (Account.compareAccounts(accountObject, this.getAccount())) {\r\n tokenType = (scopes.indexOf(this.config.auth.clientId) > -1) ? ResponseTypes.id_token : ResponseTypes.token;\r\n }\r\n else {\r\n tokenType = (scopes.indexOf(this.config.auth.clientId) > -1) ? ResponseTypes.id_token : ResponseTypes.id_token_token;\r\n }\r\n return tokenType;\r\n }\r\n // all other cases\r\n else {\r\n if (!Account.compareAccounts(accountObject, this.getAccount())) {\r\n tokenType = ResponseTypes.id_token_token;\r\n }\r\n else {\r\n tokenType = (scopes.indexOf(this.clientId) > -1) ? ResponseTypes.id_token : ResponseTypes.token;\r\n }\r\n return tokenType;\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 UserAgentApplication.prototype.setAccountCache = function (account, state) {\r\n // Cache acquireTokenAccountKey\r\n var accountId = account ? this.getAccountId(account) : Constants.no_account;\r\n var acquireTokenAccountKey = AuthCache.generateAcquireTokenAccountKey(accountId, state);\r\n this.cacheStorage.setItem(acquireTokenAccountKey, JSON.stringify(account));\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 UserAgentApplication.prototype.setAuthorityCache = function (state, authority) {\r\n // Cache authorityKey\r\n var authorityKey = AuthCache.generateAuthorityKey(state);\r\n this.cacheStorage.setItem(authorityKey, UrlUtils.CanonicalizeUri(authority), this.inCookie);\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 UserAgentApplication.prototype.updateCacheEntries = function (serverAuthenticationRequest, account, isLoginCall, loginStartPage) {\r\n // Cache Request Originator Page\r\n if (loginStartPage) {\r\n this.cacheStorage.setItem(\"\" + TemporaryCacheKeys.LOGIN_REQUEST + Constants.resourceDelimiter + serverAuthenticationRequest.state, loginStartPage, this.inCookie);\r\n }\r\n // Cache account and authority\r\n if (isLoginCall) {\r\n // Cache the state\r\n this.cacheStorage.setItem(\"\" + TemporaryCacheKeys.STATE_LOGIN + Constants.resourceDelimiter + serverAuthenticationRequest.state, serverAuthenticationRequest.state, this.inCookie);\r\n }\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 // Cache nonce\r\n this.cacheStorage.setItem(\"\" + TemporaryCacheKeys.NONCE_IDTOKEN + Constants.resourceDelimiter + serverAuthenticationRequest.state, serverAuthenticationRequest.nonce, this.inCookie);\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 UserAgentApplication.prototype.getAccountId = function (account) {\r\n // return `${account.accountIdentifier}` + Constants.resourceDelimiter + `${account.homeAccountIdentifier}`;\r\n var accountId;\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 return accountId;\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 UserAgentApplication.prototype.buildIDTokenRequest = function (request) {\r\n var tokenRequest = {\r\n scopes: [this.clientId],\r\n authority: this.authority,\r\n account: this.getAccount(),\r\n extraQueryParameters: request.extraQueryParameters,\r\n correlationId: request.correlationId\r\n };\r\n return tokenRequest;\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 UserAgentApplication.prototype.getTelemetryManagerFromConfig = function (config, clientId) {\r\n if (!config) { // if unset\r\n return TelemetryManager.getTelemetrymanagerStub(clientId, this.logger);\r\n }\r\n // if set then validate\r\n var applicationName = config.applicationName, applicationVersion = config.applicationVersion, telemetryEmitter = config.telemetryEmitter;\r\n if (!applicationName || !applicationVersion || !telemetryEmitter) {\r\n throw ClientConfigurationError.createTelemetryConfigError(config);\r\n }\r\n // if valid then construct\r\n var telemetryPlatform = {\r\n applicationName: applicationName,\r\n applicationVersion: applicationVersion\r\n };\r\n var telemetryManagerConfig = {\r\n platform: telemetryPlatform,\r\n clientId: clientId\r\n };\r\n return new TelemetryManager(telemetryManagerConfig, telemetryEmitter, this.logger);\r\n };\r\n return UserAgentApplication;\r\n}());\r\nexport { UserAgentApplication };\r\n//# sourceMappingURL=UserAgentApplication.js.map","import { AADTrustedHostList } from \"../utils/Constants\";\r\nimport { TENANT_PLACEHOLDER, EVENT_NAME_PREFIX } from \"./TelemetryConstants\";\r\nimport { CryptoUtils } from \"../utils/CryptoUtils\";\r\nimport { UrlUtils } from \"../utils/UrlUtils\";\r\nexport var scrubTenantFromUri = function (uri) {\r\n var url = UrlUtils.GetUrlComponents(uri);\r\n // validate trusted host\r\n if (!AADTrustedHostList[url.HostNameAndPort.toLocaleLowerCase()]) {\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 var pathParams = url.PathSegments;\r\n if (pathParams && pathParams.length >= 2) {\r\n var tenantPosition = pathParams[1] === \"tfp\" ? 2 : 1;\r\n if (tenantPosition < pathParams.length) {\r\n pathParams[tenantPosition] = TENANT_PLACEHOLDER;\r\n }\r\n }\r\n return url.Protocol + \"//\" + url.HostNameAndPort + \"/\" + pathParams.join(\"/\");\r\n};\r\nexport var hashPersonalIdentifier = function (valueToHash) {\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\nexport var prependEventNamePrefix = function (suffix) { return \"\" + EVENT_NAME_PREFIX + (suffix || \"\"); };\r\nexport var supportsBrowserPerformance = function () { return !!(typeof window !== \"undefined\" &&\r\n \"performance\" in window &&\r\n window.performance.mark &&\r\n window.performance.measure); };\r\nexport var endBrowserPerformanceMeasurement = function (measureName, startMark, endMark) {\r\n if (supportsBrowserPerformance()) {\r\n window.performance.mark(endMark);\r\n window.performance.measure(measureName, startMark, endMark);\r\n window.performance.clearMeasures(measureName);\r\n window.performance.clearMarks(startMark);\r\n window.performance.clearMarks(endMark);\r\n }\r\n};\r\nexport var startBrowserPerformanceMeasurement = function (startMark) {\r\n if (supportsBrowserPerformance()) {\r\n window.performance.mark(startMark);\r\n }\r\n};\r\n//# sourceMappingURL=TelemetryUtils.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport * as tslib_1 from \"tslib\";\r\nimport { ClientConfigurationErrorMessage } from \"../error/ClientConfigurationError\";\r\nimport { XhrClient } from \"../XHRClient\";\r\nimport { UrlUtils } from \"../utils/UrlUtils\";\r\nimport HttpEvent from \"../telemetry/HttpEvent\";\r\n/**\r\n * @hidden\r\n */\r\nexport var AuthorityType;\r\n(function (AuthorityType) {\r\n AuthorityType[AuthorityType[\"Aad\"] = 0] = \"Aad\";\r\n AuthorityType[AuthorityType[\"Adfs\"] = 1] = \"Adfs\";\r\n AuthorityType[AuthorityType[\"B2C\"] = 2] = \"B2C\";\r\n})(AuthorityType || (AuthorityType = {}));\r\n/**\r\n * @hidden\r\n */\r\nvar Authority = /** @class */ (function () {\r\n function Authority(authority, validateAuthority, authorityMetadata) {\r\n this.IsValidationEnabled = validateAuthority;\r\n this.CanonicalAuthority = authority;\r\n this.validateAsUri();\r\n this.tenantDiscoveryResponse = authorityMetadata;\r\n }\r\n Object.defineProperty(Authority.prototype, \"Tenant\", {\r\n get: function () {\r\n return this.CanonicalAuthorityUrlComponents.PathSegments[0];\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Authority.prototype, \"AuthorizationEndpoint\", {\r\n get: function () {\r\n this.validateResolved();\r\n return this.tenantDiscoveryResponse.AuthorizationEndpoint.replace(/{tenant}|{tenantid}/g, this.Tenant);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Authority.prototype, \"EndSessionEndpoint\", {\r\n get: function () {\r\n this.validateResolved();\r\n return this.tenantDiscoveryResponse.EndSessionEndpoint.replace(/{tenant}|{tenantid}/g, this.Tenant);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Authority.prototype, \"SelfSignedJwtAudience\", {\r\n get: function () {\r\n this.validateResolved();\r\n return this.tenantDiscoveryResponse.Issuer.replace(/{tenant}|{tenantid}/g, this.Tenant);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Authority.prototype.validateResolved = function () {\r\n if (!this.hasCachedMetadata()) {\r\n throw \"Please call ResolveEndpointsAsync first\";\r\n }\r\n };\r\n Object.defineProperty(Authority.prototype, \"CanonicalAuthority\", {\r\n /**\r\n * A URL that is the authority set by the developer\r\n */\r\n get: function () {\r\n return this.canonicalAuthority;\r\n },\r\n set: function (url) {\r\n this.canonicalAuthority = UrlUtils.CanonicalizeUri(url);\r\n this.canonicalAuthorityUrlComponents = null;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Authority.prototype, \"CanonicalAuthorityUrlComponents\", {\r\n get: function () {\r\n if (!this.canonicalAuthorityUrlComponents) {\r\n this.canonicalAuthorityUrlComponents = UrlUtils.GetUrlComponents(this.CanonicalAuthority);\r\n }\r\n return this.canonicalAuthorityUrlComponents;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Authority.prototype, \"DefaultOpenIdConfigurationEndpoint\", {\r\n /**\r\n * // http://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata\r\n */\r\n get: function () {\r\n return this.CanonicalAuthority + \"v2.0/.well-known/openid-configuration\";\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Given a string, validate that it is of the form https://domain/path\r\n */\r\n Authority.prototype.validateAsUri = function () {\r\n var components;\r\n try {\r\n components = this.CanonicalAuthorityUrlComponents;\r\n }\r\n catch (e) {\r\n throw ClientConfigurationErrorMessage.invalidAuthorityType;\r\n }\r\n if (!components.Protocol || components.Protocol.toLowerCase() !== \"https:\") {\r\n throw ClientConfigurationErrorMessage.authorityUriInsecure;\r\n }\r\n if (!components.PathSegments || components.PathSegments.length < 1) {\r\n throw ClientConfigurationErrorMessage.authorityUriInvalidPath;\r\n }\r\n };\r\n /**\r\n * Calls the OIDC endpoint and returns the response\r\n */\r\n Authority.prototype.DiscoverEndpoints = function (openIdConfigurationEndpoint, telemetryManager, correlationId) {\r\n var client = new XhrClient();\r\n var httpMethod = \"GET\";\r\n var httpEvent = new HttpEvent(correlationId, \"openIdConfigurationEndpoint\");\r\n httpEvent.url = openIdConfigurationEndpoint;\r\n httpEvent.httpMethod = httpMethod;\r\n telemetryManager.startEvent(httpEvent);\r\n return client.sendRequestAsync(openIdConfigurationEndpoint, httpMethod, /* enableCaching: */ true)\r\n .then(function (response) {\r\n httpEvent.httpResponseStatus = response.statusCode;\r\n telemetryManager.stopEvent(httpEvent);\r\n return {\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(function (err) {\r\n httpEvent.serverErrorCode = err;\r\n telemetryManager.stopEvent(httpEvent);\r\n throw err;\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 Authority.prototype.resolveEndpointsAsync = function (telemetryManager, correlationId) {\r\n return tslib_1.__awaiter(this, void 0, void 0, function () {\r\n var openIdConfigurationEndpointResponse, _a;\r\n return tslib_1.__generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0: return [4 /*yield*/, this.GetOpenIdConfigurationEndpointAsync(telemetryManager, correlationId)];\r\n case 1:\r\n openIdConfigurationEndpointResponse = _b.sent();\r\n _a = this;\r\n return [4 /*yield*/, this.DiscoverEndpoints(openIdConfigurationEndpointResponse, telemetryManager, correlationId)];\r\n case 2:\r\n _a.tenantDiscoveryResponse = _b.sent();\r\n return [2 /*return*/, this.tenantDiscoveryResponse];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Checks if there is a cached tenant discovery response with required fields.\r\n */\r\n Authority.prototype.hasCachedMetadata = function () {\r\n return !!(this.tenantDiscoveryResponse &&\r\n this.tenantDiscoveryResponse.AuthorizationEndpoint &&\r\n this.tenantDiscoveryResponse.EndSessionEndpoint &&\r\n this.tenantDiscoveryResponse.Issuer);\r\n };\r\n return Authority;\r\n}());\r\nexport { Authority };\r\n//# sourceMappingURL=Authority.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nexport function buildResponseStateOnly(state) {\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//# sourceMappingURL=AuthResponse.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * @hidden\r\n */\r\nvar AccessTokenCacheItem = /** @class */ (function () {\r\n function AccessTokenCacheItem(key, value) {\r\n this.key = key;\r\n this.value = value;\r\n }\r\n return AccessTokenCacheItem;\r\n}());\r\nexport { AccessTokenCacheItem };\r\n//# sourceMappingURL=AccessTokenCacheItem.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * @hidden\r\n */\r\nvar CryptoUtils = /** @class */ (function () {\r\n function CryptoUtils() {\r\n }\r\n /**\r\n * Creates a new random GUID\r\n * @returns string (GUID)\r\n */\r\n CryptoUtils.createNewGuid = function () {\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 var cryptoObj = window.crypto; // for IE 11\r\n if (cryptoObj && cryptoObj.getRandomValues) {\r\n var buffer = new Uint8Array(16);\r\n cryptoObj.getRandomValues(buffer);\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 // 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 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 var guidHolder = \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\";\r\n var hex = \"0123456789abcdef\";\r\n var r = 0;\r\n var guidResponse = \"\";\r\n for (var i = 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 }\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 }\r\n else {\r\n guidResponse += guidHolder[i];\r\n }\r\n }\r\n return guidResponse;\r\n }\r\n };\r\n /**\r\n * verifies if a string is GUID\r\n * @param guid\r\n */\r\n CryptoUtils.isGuid = function (guid) {\r\n var 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 * Decimal to Hex\r\n *\r\n * @param num\r\n */\r\n CryptoUtils.decimalToHex = function (num) {\r\n var hex = num.toString(16);\r\n while (hex.length < 2) {\r\n hex = \"0\" + hex;\r\n }\r\n return hex;\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 * encoding string to base64 - platform specific check\r\n *\r\n * @param input\r\n */\r\n CryptoUtils.base64Encode = function (input) {\r\n return btoa(encodeURIComponent(input).replace(/%([0-9A-F]{2})/g, function toSolidBytes(match, p1) {\r\n return String.fromCharCode(Number(\"0x\" + p1));\r\n }));\r\n };\r\n /**\r\n * Decodes a base64 encoded string.\r\n *\r\n * @param input\r\n */\r\n CryptoUtils.base64Decode = function (input) {\r\n var 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 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 * deserialize a string\r\n *\r\n * @param query\r\n */\r\n CryptoUtils.deserialize = function (query) {\r\n var match; // Regex for replacing addition symbol with a space\r\n var pl = /\\+/g;\r\n var search = /([^&=]+)=([^&]*)/g;\r\n var decode = function (s) { return decodeURIComponent(decodeURIComponent(s.replace(pl, \" \"))); }; // Some values (e.g. state) may need to be decoded twice\r\n var 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 return CryptoUtils;\r\n}());\r\nexport { CryptoUtils };\r\n//# sourceMappingURL=CryptoUtils.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport * as tslib_1 from \"tslib\";\r\nimport { Constants, PromptState, BlacklistedEQParams } from \"../utils/Constants\";\r\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\r\nimport { ScopeSet } from \"../ScopeSet\";\r\nimport { StringUtils } from \"../utils/StringUtils\";\r\nimport { CryptoUtils } from \"../utils/CryptoUtils\";\r\nimport { TimeUtils } from \"./TimeUtils\";\r\nimport { ClientAuthError } from \"../error/ClientAuthError\";\r\n/**\r\n * @hidden\r\n */\r\nvar RequestUtils = /** @class */ (function () {\r\n function 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 RequestUtils.validateRequest = function (request, isLoginCall, clientId, interactionType) {\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 var scopes;\r\n var extraQueryParameters;\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, clientId);\r\n // validate prompt parameter\r\n this.validatePromptParameter(request.prompt);\r\n // validate extraQueryParameters\r\n extraQueryParameters = this.validateEQParameters(request.extraQueryParameters, request.claimsRequest);\r\n // validate claimsRequest\r\n this.validateClaimsRequest(request.claimsRequest);\r\n }\r\n // validate and generate state and correlationId\r\n var state = this.validateAndGenerateState(request && request.state, interactionType);\r\n var correlationId = this.validateAndGenerateCorrelationId(request && request.correlationId);\r\n var validatedRequest = tslib_1.__assign({}, request, { extraQueryParameters: extraQueryParameters,\r\n scopes: scopes,\r\n state: state,\r\n correlationId: correlationId });\r\n return validatedRequest;\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 RequestUtils.validatePromptParameter = function (prompt) {\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 * @ignore\r\n *\r\n * Removes unnecessary or duplicate query parameters from extraQueryParameters\r\n * @param request\r\n */\r\n RequestUtils.validateEQParameters = function (extraQueryParameters, claimsRequest) {\r\n var eQParams = tslib_1.__assign({}, 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(function (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 return eQParams;\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 RequestUtils.validateClaimsRequest = function (claimsRequest) {\r\n if (!claimsRequest) {\r\n return;\r\n }\r\n var claims;\r\n try {\r\n claims = JSON.parse(claimsRequest);\r\n }\r\n catch (e) {\r\n throw ClientConfigurationError.createClaimsRequestParsingError(e);\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 RequestUtils.validateAndGenerateState = function (userState, interactionType) {\r\n return !StringUtils.isEmpty(userState) ? \"\" + RequestUtils.generateLibraryState(interactionType) + Constants.resourceDelimiter + userState : RequestUtils.generateLibraryState(interactionType);\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 RequestUtils.generateLibraryState = function (interactionType) {\r\n var stateObject = {\r\n id: CryptoUtils.createNewGuid(),\r\n ts: TimeUtils.now(),\r\n method: interactionType\r\n };\r\n var stateString = JSON.stringify(stateObject);\r\n return CryptoUtils.base64Encode(stateString);\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 RequestUtils.parseLibraryState = function (state) {\r\n var libraryState = decodeURIComponent(state).split(Constants.resourceDelimiter)[0];\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 try {\r\n var stateString = CryptoUtils.base64Decode(libraryState);\r\n var stateObject = JSON.parse(stateString);\r\n return stateObject;\r\n }\r\n catch (e) {\r\n throw ClientAuthError.createInvalidStateError(state, null);\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 RequestUtils.validateAndGenerateCorrelationId = function (correlationId) {\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 * Create a request signature\r\n * @param request\r\n */\r\n RequestUtils.createRequestSignature = function (request) {\r\n return \"\" + request.scopes.join(\" \").toLowerCase() + Constants.resourceDelimiter + request.authority;\r\n };\r\n return RequestUtils;\r\n}());\r\nexport { RequestUtils };\r\n//# sourceMappingURL=RequestUtils.js.map","import * as tslib_1 from \"tslib\";\r\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * @hidden\r\n */\r\nvar ResponseUtils = /** @class */ (function () {\r\n function ResponseUtils() {\r\n }\r\n ResponseUtils.setResponseIdToken = function (originalResponse, idTokenObj) {\r\n if (!originalResponse) {\r\n return null;\r\n }\r\n else if (!idTokenObj) {\r\n return originalResponse;\r\n }\r\n var exp = Number(idTokenObj.expiration);\r\n if (exp && !originalResponse.expiresOn) {\r\n originalResponse.expiresOn = new Date(exp * 1000);\r\n }\r\n return tslib_1.__assign({}, originalResponse, { idToken: idTokenObj, idTokenClaims: idTokenObj.claims, uniqueId: idTokenObj.objectId || idTokenObj.subject, tenantId: idTokenObj.tenantId });\r\n };\r\n return ResponseUtils;\r\n}());\r\nexport { ResponseUtils };\r\n//# sourceMappingURL=ResponseUtils.js.map","export var EVENT_NAME_PREFIX = \"msal.\";\r\nexport var EVENT_NAME_KEY = \"event_name\";\r\nexport var START_TIME_KEY = \"start_time\";\r\nexport var ELAPSED_TIME_KEY = \"elapsed_time\";\r\nexport var 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// This is used to replace the real tenant in telemetry info\r\nexport var TENANT_PLACEHOLDER = \"\";\r\n//# sourceMappingURL=TelemetryConstants.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * @hidden\r\n * Constants\r\n */\r\nvar Constants = /** @class */ (function () {\r\n function Constants() {\r\n }\r\n Object.defineProperty(Constants, \"libraryName\", {\r\n get: function () { return \"Msal.js\"; } // used in telemetry sdkName\r\n ,\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"claims\", {\r\n get: function () { return \"claims\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"clientId\", {\r\n get: function () { return \"clientId\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"adalIdToken\", {\r\n get: function () { return \"adal.idtoken\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"cachePrefix\", {\r\n get: function () { return \"msal\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"scopes\", {\r\n get: function () { return \"scopes\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"no_account\", {\r\n get: function () { return \"NO_ACCOUNT\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"upn\", {\r\n get: function () { return \"upn\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"domain_hint\", {\r\n get: function () { return \"domain_hint\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"prompt_select_account\", {\r\n get: function () { return \"&prompt=select_account\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"prompt_none\", {\r\n get: function () { return \"&prompt=none\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"prompt\", {\r\n get: function () { return \"prompt\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"response_mode_fragment\", {\r\n get: function () { return \"&response_mode=fragment\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"resourceDelimiter\", {\r\n get: function () { return \"|\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"cacheDelimiter\", {\r\n get: function () { return \".\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"popUpWidth\", {\r\n get: function () { return this._popUpWidth; },\r\n set: function (width) {\r\n this._popUpWidth = width;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"popUpHeight\", {\r\n get: function () { return this._popUpHeight; },\r\n set: function (height) {\r\n this._popUpHeight = height;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"login\", {\r\n get: function () { return \"LOGIN\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"renewToken\", {\r\n get: function () { return \"RENEW_TOKEN\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"unknown\", {\r\n get: function () { return \"UNKNOWN\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"homeAccountIdentifier\", {\r\n get: function () { return \"homeAccountIdentifier\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"common\", {\r\n get: function () { return \"common\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"openidScope\", {\r\n get: function () { return \"openid\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"profileScope\", {\r\n get: function () { return \"profile\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"interactionTypeRedirect\", {\r\n get: function () { return \"redirectInteraction\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"interactionTypePopup\", {\r\n get: function () { return \"popupInteraction\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"interactionTypeSilent\", {\r\n get: function () { return \"silentInteraction\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Constants, \"inProgress\", {\r\n get: function () { return \"inProgress\"; },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Constants._popUpWidth = 483;\r\n Constants._popUpHeight = 600;\r\n return Constants;\r\n}());\r\nexport { Constants };\r\n/**\r\n * Keys in the hashParams\r\n */\r\nexport var ServerHashParamKeys;\r\n(function (ServerHashParamKeys) {\r\n ServerHashParamKeys[\"SCOPE\"] = \"scope\";\r\n ServerHashParamKeys[\"STATE\"] = \"state\";\r\n ServerHashParamKeys[\"ERROR\"] = \"error\";\r\n ServerHashParamKeys[\"ERROR_DESCRIPTION\"] = \"error_description\";\r\n ServerHashParamKeys[\"ACCESS_TOKEN\"] = \"access_token\";\r\n ServerHashParamKeys[\"ID_TOKEN\"] = \"id_token\";\r\n ServerHashParamKeys[\"EXPIRES_IN\"] = \"expires_in\";\r\n ServerHashParamKeys[\"SESSION_STATE\"] = \"session_state\";\r\n ServerHashParamKeys[\"CLIENT_INFO\"] = \"client_info\";\r\n})(ServerHashParamKeys || (ServerHashParamKeys = {}));\r\n;\r\n/**\r\n * @hidden\r\n * CacheKeys for MSAL\r\n */\r\nexport var TemporaryCacheKeys;\r\n(function (TemporaryCacheKeys) {\r\n TemporaryCacheKeys[\"AUTHORITY\"] = \"authority\";\r\n TemporaryCacheKeys[\"ACQUIRE_TOKEN_ACCOUNT\"] = \"acquireTokenAccount\";\r\n TemporaryCacheKeys[\"SESSION_STATE\"] = \"session.state\";\r\n TemporaryCacheKeys[\"STATE_LOGIN\"] = \"state.login\";\r\n TemporaryCacheKeys[\"STATE_ACQ_TOKEN\"] = \"state.acquireToken\";\r\n TemporaryCacheKeys[\"STATE_RENEW\"] = \"state.renew\";\r\n TemporaryCacheKeys[\"NONCE_IDTOKEN\"] = \"nonce.idtoken\";\r\n TemporaryCacheKeys[\"LOGIN_REQUEST\"] = \"login.request\";\r\n TemporaryCacheKeys[\"RENEW_STATUS\"] = \"token.renew.status\";\r\n TemporaryCacheKeys[\"URL_HASH\"] = \"urlHash\";\r\n TemporaryCacheKeys[\"INTERACTION_STATUS\"] = \"interaction_status\";\r\n TemporaryCacheKeys[\"REDIRECT_REQUEST\"] = \"redirect_request\";\r\n})(TemporaryCacheKeys || (TemporaryCacheKeys = {}));\r\nexport var PersistentCacheKeys;\r\n(function (PersistentCacheKeys) {\r\n PersistentCacheKeys[\"IDTOKEN\"] = \"idtoken\";\r\n PersistentCacheKeys[\"CLIENT_INFO\"] = \"client.info\";\r\n})(PersistentCacheKeys || (PersistentCacheKeys = {}));\r\nexport var ErrorCacheKeys;\r\n(function (ErrorCacheKeys) {\r\n ErrorCacheKeys[\"LOGIN_ERROR\"] = \"login.error\";\r\n ErrorCacheKeys[\"ERROR\"] = \"error\";\r\n ErrorCacheKeys[\"ERROR_DESC\"] = \"error.description\";\r\n})(ErrorCacheKeys || (ErrorCacheKeys = {}));\r\nexport var AADTrustedHostList = {\r\n \"login.windows.net\": \"login.windows.net\",\r\n \"login.chinacloudapi.cn\": \"login.chinacloudapi.cn\",\r\n \"login.cloudgovapi.us\": \"login.cloudgovapi.us\",\r\n \"login.microsoftonline.com\": \"login.microsoftonline.com\",\r\n \"login.microsoftonline.de\": \"login.microsoftonline.de\",\r\n \"login.microsoftonline.us\": \"login.microsoftonline.us\"\r\n};\r\n/**\r\n * @hidden\r\n * SSO Types - generated to populate hints\r\n */\r\nexport var SSOTypes;\r\n(function (SSOTypes) {\r\n SSOTypes[\"ACCOUNT\"] = \"account\";\r\n SSOTypes[\"SID\"] = \"sid\";\r\n SSOTypes[\"LOGIN_HINT\"] = \"login_hint\";\r\n SSOTypes[\"ID_TOKEN\"] = \"id_token\";\r\n SSOTypes[\"ACCOUNT_ID\"] = \"accountIdentifier\";\r\n SSOTypes[\"HOMEACCOUNT_ID\"] = \"homeAccountIdentifier\";\r\n})(SSOTypes || (SSOTypes = {}));\r\n;\r\n/**\r\n * @hidden\r\n */\r\nexport var BlacklistedEQParams = [\r\n SSOTypes.SID,\r\n SSOTypes.LOGIN_HINT\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 var 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 * Frame name prefixes for the hidden iframe created in silent frames\r\n */\r\nexport var FramePrefix = {\r\n ID_TOKEN_FRAME: \"msalIdTokenFrame\",\r\n TOKEN_FRAME: \"msalRenewFrame\"\r\n};\r\n/**\r\n * MSAL JS Library Version\r\n */\r\nexport function libraryVersion() {\r\n return \"1.3.2\";\r\n}\r\n//# sourceMappingURL=Constants.js.map","import * as tslib_1 from \"tslib\";\r\nimport { TELEMETRY_BLOB_EVENT_NAMES } from \"./TelemetryConstants\";\r\nimport { EVENT_NAME_KEY, START_TIME_KEY, ELAPSED_TIME_KEY } from \"./TelemetryConstants\";\r\nimport { prependEventNamePrefix, startBrowserPerformanceMeasurement, endBrowserPerformanceMeasurement } from \"./TelemetryUtils\";\r\nimport { CryptoUtils } from \"../utils/CryptoUtils\";\r\nvar TelemetryEvent = /** @class */ (function () {\r\n function TelemetryEvent(eventName, correlationId, eventLabel) {\r\n var _a;\r\n this.eventId = CryptoUtils.createNewGuid();\r\n this.label = eventLabel;\r\n this.event = (_a = {},\r\n _a[prependEventNamePrefix(EVENT_NAME_KEY)] = eventName,\r\n _a[prependEventNamePrefix(ELAPSED_TIME_KEY)] = -1,\r\n _a[\"\" + TELEMETRY_BLOB_EVENT_NAMES.MsalCorrelationIdConstStrKey] = correlationId,\r\n _a);\r\n }\r\n TelemetryEvent.prototype.setElapsedTime = function (time) {\r\n this.event[prependEventNamePrefix(ELAPSED_TIME_KEY)] = time;\r\n };\r\n TelemetryEvent.prototype.stop = function () {\r\n // Set duration of event\r\n this.setElapsedTime(+Date.now() - +this.startTimestamp);\r\n endBrowserPerformanceMeasurement(this.displayName, this.perfStartMark, this.perfEndMark);\r\n };\r\n TelemetryEvent.prototype.start = function () {\r\n this.startTimestamp = Date.now();\r\n this.event[prependEventNamePrefix(START_TIME_KEY)] = this.startTimestamp;\r\n startBrowserPerformanceMeasurement(this.perfStartMark);\r\n };\r\n Object.defineProperty(TelemetryEvent.prototype, \"telemetryCorrelationId\", {\r\n get: function () {\r\n return this.event[\"\" + TELEMETRY_BLOB_EVENT_NAMES.MsalCorrelationIdConstStrKey];\r\n },\r\n set: function (value) {\r\n this.event[\"\" + TELEMETRY_BLOB_EVENT_NAMES.MsalCorrelationIdConstStrKey] = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(TelemetryEvent.prototype, \"eventName\", {\r\n get: function () {\r\n return this.event[prependEventNamePrefix(EVENT_NAME_KEY)];\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n TelemetryEvent.prototype.get = function () {\r\n return tslib_1.__assign({}, this.event, { eventId: this.eventId });\r\n };\r\n Object.defineProperty(TelemetryEvent.prototype, \"key\", {\r\n get: function () {\r\n return this.telemetryCorrelationId + \"_\" + this.eventId + \"-\" + this.eventName;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n ;\r\n Object.defineProperty(TelemetryEvent.prototype, \"displayName\", {\r\n get: function () {\r\n return \"Msal-\" + this.label + \"-\" + this.telemetryCorrelationId;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(TelemetryEvent.prototype, \"perfStartMark\", {\r\n get: function () {\r\n return \"start-\" + this.key;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(TelemetryEvent.prototype, \"perfEndMark\", {\r\n get: function () {\r\n return \"end-\" + this.key;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return TelemetryEvent;\r\n}());\r\nexport default TelemetryEvent;\r\n//# sourceMappingURL=TelemetryEvent.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport { ClientAuthError } from \"./error/ClientAuthError\";\r\nimport { TokenUtils } from \"./utils/TokenUtils\";\r\nimport { StringUtils } from \"./utils/StringUtils\";\r\n/**\r\n * @hidden\r\n */\r\nvar IdToken = /** @class */ (function () {\r\n /* tslint:disable:no-string-literal */\r\n function IdToken(rawIdToken) {\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);\r\n if (this.claims) {\r\n if (this.claims.hasOwnProperty(\"iss\")) {\r\n this.issuer = this.claims[\"iss\"];\r\n }\r\n if (this.claims.hasOwnProperty(\"oid\")) {\r\n this.objectId = this.claims[\"oid\"];\r\n }\r\n if (this.claims.hasOwnProperty(\"sub\")) {\r\n this.subject = this.claims[\"sub\"];\r\n }\r\n if (this.claims.hasOwnProperty(\"tid\")) {\r\n this.tenantId = this.claims[\"tid\"];\r\n }\r\n if (this.claims.hasOwnProperty(\"ver\")) {\r\n this.version = this.claims[\"ver\"];\r\n }\r\n if (this.claims.hasOwnProperty(\"preferred_username\")) {\r\n this.preferredName = this.claims[\"preferred_username\"];\r\n }\r\n if (this.claims.hasOwnProperty(\"name\")) {\r\n this.name = this.claims[\"name\"];\r\n }\r\n if (this.claims.hasOwnProperty(\"nonce\")) {\r\n this.nonce = this.claims[\"nonce\"];\r\n }\r\n if (this.claims.hasOwnProperty(\"exp\")) {\r\n this.expiration = this.claims[\"exp\"];\r\n }\r\n if (this.claims.hasOwnProperty(\"home_oid\")) {\r\n this.homeObjectId = this.claims[\"home_oid\"];\r\n }\r\n if (this.claims.hasOwnProperty(\"sid\")) {\r\n this.sid = this.claims[\"sid\"];\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 }\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 return IdToken;\r\n}());\r\nexport { IdToken };\r\n//# sourceMappingURL=IdToken.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport * as tslib_1 from \"tslib\";\r\nimport { Authority } from \"./Authority\";\r\nimport { AuthorityType } from \"./Authority\";\r\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\r\nexport var B2CTrustedHostList = {};\r\n/**\r\n * @hidden\r\n */\r\nvar B2cAuthority = /** @class */ (function (_super) {\r\n tslib_1.__extends(B2cAuthority, _super);\r\n function B2cAuthority(authority, validateAuthority, authorityMetadata) {\r\n return _super.call(this, authority, validateAuthority, authorityMetadata) || this;\r\n }\r\n Object.defineProperty(B2cAuthority.prototype, \"AuthorityType\", {\r\n get: function () {\r\n return AuthorityType.B2C;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Returns a promise with the TenantDiscoveryEndpoint\r\n */\r\n B2cAuthority.prototype.GetOpenIdConfigurationEndpointAsync = function (telemetryManager, correlationId) {\r\n return tslib_1.__awaiter(this, void 0, void 0, function () {\r\n return tslib_1.__generator(this, function (_a) {\r\n if (!this.IsValidationEnabled || this.IsInTrustedHostList(this.CanonicalAuthorityUrlComponents.HostNameAndPort)) {\r\n return [2 /*return*/, this.DefaultOpenIdConfigurationEndpoint];\r\n }\r\n throw ClientConfigurationError.createUntrustedAuthorityError();\r\n });\r\n });\r\n };\r\n /**\r\n * Checks to see if the host is in a list of trusted hosts\r\n * @param {string} The host to look up\r\n */\r\n B2cAuthority.prototype.IsInTrustedHostList = function (host) {\r\n if (this.IsValidationEnabled && !Object.keys(B2CTrustedHostList).length) {\r\n throw ClientConfigurationError.createKnownAuthoritiesNotSetError();\r\n }\r\n return B2CTrustedHostList[host.toLowerCase()];\r\n };\r\n B2cAuthority.B2C_PREFIX = \"tfp\";\r\n return B2cAuthority;\r\n}(Authority));\r\nexport { B2cAuthority };\r\n//# sourceMappingURL=B2cAuthority.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport { CryptoUtils } from \"./utils/CryptoUtils\";\r\nimport { SSOTypes, Constants, PromptState, libraryVersion } from \"./utils/Constants\";\r\nimport { StringUtils } from \"./utils/StringUtils\";\r\nimport { ScopeSet } from \"./ScopeSet\";\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\nvar ServerRequestParameters = /** @class */ (function () {\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 function ServerRequestParameters(authority, clientId, responseType, redirectUri, scopes, state, correlationId) {\r\n this.authorityInstance = authority;\r\n this.clientId = clientId;\r\n this.nonce = CryptoUtils.createNewGuid();\r\n // set scope to clientId if null\r\n this.scopes = scopes ? scopes.slice() : [clientId];\r\n this.scopes = ScopeSet.trimAndConvertArrayToLowerCase(this.scopes);\r\n // set state (already set at top level)\r\n this.state = state;\r\n // set correlationId\r\n this.correlationId = correlationId;\r\n // telemetry information\r\n this.xClientSku = \"MSAL.JS\";\r\n this.xClientVer = libraryVersion();\r\n this.responseType = responseType;\r\n this.redirectUri = redirectUri;\r\n }\r\n Object.defineProperty(ServerRequestParameters.prototype, \"authority\", {\r\n get: function () {\r\n return this.authorityInstance ? this.authorityInstance.CanonicalAuthority : null;\r\n },\r\n enumerable: true,\r\n configurable: true\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 ServerRequestParameters.prototype.populateQueryParams = function (account, request, adalIdTokenObject, silentCall) {\r\n var queryParameters = {};\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 // Add claims challenge to serverRequestParameters if passed\r\n if (request.claimsRequest) {\r\n this.claimsValue = request.claimsRequest;\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 if (adalIdTokenObject) {\r\n queryParameters = this.constructUnifiedCacheQueryParameter(null, adalIdTokenObject);\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 // sanity check for developer passed extraQueryParameters\r\n var eQParams = request ? request.extraQueryParameters : null;\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 // #region QueryParam helpers\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 ServerRequestParameters.prototype.constructUnifiedCacheQueryParameter = function (request, idTokenObject) {\r\n // preference order: account > sid > login_hint\r\n var ssoType;\r\n var ssoData;\r\n var serverReqParam = {};\r\n // if account info is passed, account.sid > account.login_hint\r\n if (request) {\r\n if (request.account) {\r\n var 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 serverReqParam = this.addSSOParameter(ssoType, ssoData);\r\n return serverReqParam;\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 ServerRequestParameters.prototype.addHintParameters = function (account, qParams) {\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 if (account && !qParams[SSOTypes.SID]) {\r\n // sid - populate only if login_hint is not already populated and the account has sid\r\n var 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 var 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 return qParams;\r\n };\r\n /**\r\n * Add SID to extraQueryParameters\r\n * @param sid\r\n */\r\n ServerRequestParameters.prototype.addSSOParameter = function (ssoType, ssoData, ssoParam) {\r\n if (!ssoParam) {\r\n ssoParam = {};\r\n }\r\n if (!ssoData) {\r\n return ssoParam;\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 return ssoParam;\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 ServerRequestParameters.generateQueryParametersString = function (queryParameters, silentCall) {\r\n var paramsString = null;\r\n if (queryParameters) {\r\n Object.keys(queryParameters).forEach(function (key) {\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 if (paramsString == null) {\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 return paramsString;\r\n };\r\n // #endregion\r\n /**\r\n * Check to see if there are SSO params set in the Request\r\n * @param request\r\n */\r\n ServerRequestParameters.isSSOParam = function (request) {\r\n return request && (request.account || request.sid || request.loginHint);\r\n };\r\n return ServerRequestParameters;\r\n}());\r\nexport { ServerRequestParameters };\r\n//# sourceMappingURL=ServerRequestParameters.js.map","import * as tslib_1 from \"tslib\";\r\nimport DefaultEvent from \"./DefaultEvent\";\r\nimport { libraryVersion, Constants } from \"../utils/Constants\";\r\nimport ApiEvent from \"./ApiEvent\";\r\nimport HttpEvent from \"./HttpEvent\";\r\n// for use in cache events\r\nvar MSAL_CACHE_EVENT_VALUE_PREFIX = \"msal.token\";\r\nvar MSAL_CACHE_EVENT_NAME = \"msal.cache_event\";\r\nvar TelemetryManager = /** @class */ (function () {\r\n function TelemetryManager(config, telemetryEmitter, logger) {\r\n // correlation Id to list of events\r\n this.completedEvents = {};\r\n // event key to event\r\n this.inProgressEvents = {};\r\n // correlation id to map of eventname to count\r\n this.eventCountByCorrelationId = {};\r\n // Implement after API EVENT\r\n this.onlySendFailureTelemetry = false;\r\n // TODO THROW if bad options\r\n this.telemetryPlatform = tslib_1.__assign({ sdk: Constants.libraryName, sdkVersion: libraryVersion(), networkInformation: {\r\n // @ts-ignore\r\n connectionSpeed: typeof navigator !== \"undefined\" && navigator.connection && navigator.connection.effectiveType\r\n } }, config.platform);\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 TelemetryManager.getTelemetrymanagerStub = function (clientId, logger) {\r\n var applicationName = \"UnSetStub\";\r\n var applicationVersion = \"0.0\";\r\n var telemetryEmitter = function () { };\r\n var telemetryPlatform = {\r\n applicationName: applicationName,\r\n applicationVersion: applicationVersion\r\n };\r\n var telemetryManagerConfig = {\r\n platform: telemetryPlatform,\r\n clientId: clientId\r\n };\r\n return new this(telemetryManagerConfig, telemetryEmitter, logger);\r\n };\r\n TelemetryManager.prototype.startEvent = function (event) {\r\n this.logger.verbose(\"Telemetry Event started: \" + event.key);\r\n if (!this.telemetryEmitter) {\r\n return;\r\n }\r\n event.start();\r\n this.inProgressEvents[event.key] = event;\r\n };\r\n TelemetryManager.prototype.stopEvent = function (event) {\r\n this.logger.verbose(\"Telemetry Event stopped: \" + event.key);\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 var completedEvents = this.completedEvents[event.telemetryCorrelationId];\r\n this.completedEvents[event.telemetryCorrelationId] = (completedEvents || []).concat([event]);\r\n delete this.inProgressEvents[event.key];\r\n };\r\n TelemetryManager.prototype.flush = function (correlationId) {\r\n var _this = this;\r\n this.logger.verbose(\"Flushing telemetry events: \" + correlationId);\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 var orphanedEvents = this.getOrphanedEvents(correlationId);\r\n orphanedEvents.forEach(function (event) { return _this.incrementEventCount(event); });\r\n var eventsToFlush = this.completedEvents[correlationId].concat(orphanedEvents);\r\n delete this.completedEvents[correlationId];\r\n var eventCountsToFlush = this.eventCountByCorrelationId[correlationId];\r\n delete this.eventCountByCorrelationId[correlationId];\r\n // TODO add funcitonality for onlyFlushFailures after implementing api event? ??\r\n if (!eventsToFlush || !eventsToFlush.length) {\r\n return;\r\n }\r\n var defaultEvent = new DefaultEvent(this.telemetryPlatform, correlationId, this.clientId, eventCountsToFlush);\r\n var eventsWithDefaultEvent = eventsToFlush.concat([defaultEvent]);\r\n this.telemetryEmitter(eventsWithDefaultEvent.map(function (e) { return e.get(); }));\r\n };\r\n TelemetryManager.prototype.createAndStartApiEvent = function (correlationId, apiEventIdentifier) {\r\n var apiEvent = new ApiEvent(correlationId, this.logger.isPiiLoggingEnabled(), apiEventIdentifier);\r\n this.startEvent(apiEvent);\r\n return apiEvent;\r\n };\r\n TelemetryManager.prototype.stopAndFlushApiEvent = function (correlationId, apiEvent, wasSuccessful, errorCode) {\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 TelemetryManager.prototype.createAndStartHttpEvent = function (correlation, httpMethod, url, eventLabel) {\r\n var 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 TelemetryManager.prototype.incrementEventCount = function (event) {\r\n var _a;\r\n /*\r\n * TODO, name cache event different?\r\n * if type is cache event, change name\r\n */\r\n var eventName = event.eventName;\r\n var eventCount = this.eventCountByCorrelationId[event.telemetryCorrelationId];\r\n if (!eventCount) {\r\n this.eventCountByCorrelationId[event.telemetryCorrelationId] = (_a = {},\r\n _a[eventName] = 1,\r\n _a);\r\n }\r\n else {\r\n eventCount[eventName] = eventCount[eventName] ? eventCount[eventName] + 1 : 1;\r\n }\r\n };\r\n TelemetryManager.prototype.getOrphanedEvents = function (correlationId) {\r\n var _this = this;\r\n return Object.keys(this.inProgressEvents)\r\n .reduce(function (memo, eventKey) {\r\n if (eventKey.indexOf(correlationId) !== -1) {\r\n var event_1 = _this.inProgressEvents[eventKey];\r\n delete _this.inProgressEvents[eventKey];\r\n return memo.concat([event_1]);\r\n }\r\n return memo;\r\n }, []);\r\n };\r\n return TelemetryManager;\r\n}());\r\nexport default TelemetryManager;\r\n//# sourceMappingURL=TelemetryManager.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport { CryptoUtils } from \"./utils/CryptoUtils\";\r\nimport { ClientAuthError } from \"./error/ClientAuthError\";\r\nimport { StringUtils } from \"./utils/StringUtils\";\r\n/**\r\n * @hidden\r\n */\r\nvar ClientInfo = /** @class */ (function () {\r\n function ClientInfo(rawClientInfo) {\r\n if (!rawClientInfo || StringUtils.isEmpty(rawClientInfo)) {\r\n this.uid = \"\";\r\n this.utid = \"\";\r\n return;\r\n }\r\n try {\r\n var decodedClientInfo = CryptoUtils.base64Decode(rawClientInfo);\r\n var clientInfo = JSON.parse(decodedClientInfo);\r\n if (clientInfo) {\r\n if (clientInfo.hasOwnProperty(\"uid\")) {\r\n this.uid = clientInfo.uid;\r\n }\r\n if (clientInfo.hasOwnProperty(\"utid\")) {\r\n this.utid = clientInfo.utid;\r\n }\r\n }\r\n }\r\n catch (e) {\r\n throw ClientAuthError.createClientInfoDecodingError(e);\r\n }\r\n }\r\n Object.defineProperty(ClientInfo.prototype, \"uid\", {\r\n get: function () {\r\n return this._uid ? this._uid : \"\";\r\n },\r\n set: function (uid) {\r\n this._uid = uid;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ClientInfo.prototype, \"utid\", {\r\n get: function () {\r\n return this._utid ? this._utid : \"\";\r\n },\r\n set: function (utid) {\r\n this._utid = utid;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return ClientInfo;\r\n}());\r\nexport { ClientInfo };\r\n//# sourceMappingURL=ClientInfo.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport { CryptoUtils } from \"./utils/CryptoUtils\";\r\nimport { StringUtils } from \"./utils/StringUtils\";\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\nvar Account = /** @class */ (function () {\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 function Account(accountIdentifier, homeAccountIdentifier, userName, name, idTokenClaims, sid, environment) {\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 * @hidden\r\n * @param idToken\r\n * @param clientInfo\r\n */\r\n Account.createAccount = function (idToken, clientInfo) {\r\n // create accountIdentifier\r\n var accountIdentifier = idToken.objectId || idToken.subject;\r\n // create homeAccountIdentifier\r\n var uid = clientInfo ? clientInfo.uid : \"\";\r\n var utid = clientInfo ? clientInfo.utid : \"\";\r\n var homeAccountIdentifier;\r\n if (!StringUtils.isEmpty(uid) && !StringUtils.isEmpty(utid)) {\r\n homeAccountIdentifier = 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 * 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 Account.compareAccounts = function (a1, a2) {\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 return Account;\r\n}());\r\nexport { Account };\r\n//# sourceMappingURL=Account.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport * as tslib_1 from \"tslib\";\r\nimport { ServerError } from \"./ServerError\";\r\nexport var 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 * Error thrown when the user is required to perform an interactive token request.\r\n */\r\nvar InteractionRequiredAuthError = /** @class */ (function (_super) {\r\n tslib_1.__extends(InteractionRequiredAuthError, _super);\r\n function InteractionRequiredAuthError(errorCode, errorMessage) {\r\n var _this = _super.call(this, errorCode, errorMessage) || this;\r\n _this.name = \"InteractionRequiredAuthError\";\r\n Object.setPrototypeOf(_this, InteractionRequiredAuthError.prototype);\r\n return _this;\r\n }\r\n InteractionRequiredAuthError.isInteractionRequiredError = function (errorString) {\r\n var interactionRequiredCodes = [\r\n InteractionRequiredAuthErrorMessage.interactionRequired.code,\r\n InteractionRequiredAuthErrorMessage.consentRequired.code,\r\n InteractionRequiredAuthErrorMessage.loginRequired.code\r\n ];\r\n return errorString && interactionRequiredCodes.indexOf(errorString) > -1;\r\n };\r\n InteractionRequiredAuthError.createLoginRequiredAuthError = function (errorDesc) {\r\n return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.loginRequired.code, errorDesc);\r\n };\r\n InteractionRequiredAuthError.createInteractionRequiredAuthError = function (errorDesc) {\r\n return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.interactionRequired.code, errorDesc);\r\n };\r\n InteractionRequiredAuthError.createConsentRequiredAuthError = function (errorDesc) {\r\n return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.consentRequired.code, errorDesc);\r\n };\r\n return InteractionRequiredAuthError;\r\n}(ServerError));\r\nexport { InteractionRequiredAuthError };\r\n//# sourceMappingURL=InteractionRequiredAuthError.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\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\nvar XhrClient = /** @class */ (function () {\r\n function XhrClient() {\r\n }\r\n XhrClient.prototype.sendRequestAsync = function (url, method, enableCaching) {\r\n var _this = this;\r\n return new Promise(function (resolve, reject) {\r\n var 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 xhr.onload = function (ev) {\r\n if (xhr.status < 200 || xhr.status >= 300) {\r\n reject(_this.handleError(xhr.responseText));\r\n }\r\n var jsonResponse;\r\n try {\r\n jsonResponse = JSON.parse(xhr.responseText);\r\n }\r\n catch (e) {\r\n reject(_this.handleError(xhr.responseText));\r\n }\r\n var response = {\r\n statusCode: xhr.status,\r\n body: jsonResponse\r\n };\r\n resolve(response);\r\n };\r\n xhr.onerror = function (ev) {\r\n reject(xhr.status);\r\n };\r\n if (method === \"GET\") {\r\n xhr.send();\r\n }\r\n else {\r\n throw \"not implemented\";\r\n }\r\n });\r\n };\r\n XhrClient.prototype.handleError = function (responseText) {\r\n var jsonResponse;\r\n try {\r\n jsonResponse = JSON.parse(responseText);\r\n if (jsonResponse.error) {\r\n return jsonResponse.error;\r\n }\r\n else {\r\n throw responseText;\r\n }\r\n }\r\n catch (e) {\r\n return responseText;\r\n }\r\n };\r\n return XhrClient;\r\n}());\r\nexport { XhrClient };\r\n//# sourceMappingURL=XHRClient.js.map","import { ClientAuthError } from \"../error/ClientAuthError\";\r\nimport { UrlUtils } from \"./UrlUtils\";\r\nimport { TemporaryCacheKeys, Constants } from \"../utils/Constants\";\r\nvar WindowUtils = /** @class */ (function () {\r\n function WindowUtils() {\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 WindowUtils.isInIframe = function () {\r\n return window.parent !== window;\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 WindowUtils.isInPopup = function () {\r\n return !!(window.opener && window.opener !== window);\r\n };\r\n /**\r\n * @hidden\r\n * @param prefix\r\n * @param scopes\r\n * @param authority\r\n */\r\n WindowUtils.generateFrameName = function (prefix, requestSignature) {\r\n return \"\" + prefix + Constants.resourceDelimiter + requestSignature;\r\n };\r\n /**\r\n * @hidden\r\n * Monitors a window until it loads a url with a hash\r\n * @ignore\r\n */\r\n WindowUtils.monitorWindowForHash = function (contentWindow, timeout, urlNavigate, logger, isSilentCall) {\r\n return new Promise(function (resolve, reject) {\r\n var maxTicks = timeout / WindowUtils.POLLING_INTERVAL_MS;\r\n var ticks = 0;\r\n logger.verbose(\"monitorWindowForHash polling started\");\r\n var intervalId = setInterval(function () {\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 var 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 }\r\n catch (e) { }\r\n if (isSilentCall) {\r\n /*\r\n * Always run clock for silent calls\r\n * as silent operations should be short,\r\n * and to ensure they always at worst timeout.\r\n */\r\n ticks++;\r\n }\r\n else {\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 * 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(\"monitorWindowForHash found url in hash\");\r\n clearInterval(intervalId);\r\n resolve(contentWindow.location.hash);\r\n }\r\n else if (ticks > maxTicks) {\r\n logger.error(\"monitorWindowForHash unable to find hash in url, timing out\");\r\n logger.errorPii(\"monitorWindowForHash 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 * @hidden\r\n * Loads iframe with authorization endpoint URL\r\n * @ignore\r\n */\r\n WindowUtils.loadFrame = function (urlNavigate, frameName, timeoutMs, logger) {\r\n var _this = this;\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 return new Promise(function (resolve, reject) {\r\n setTimeout(function () {\r\n var frameHandle = _this.loadFrameSync(urlNavigate, frameName, logger);\r\n if (!frameHandle) {\r\n reject(\"Unable to load iframe with name: \" + frameName);\r\n return;\r\n }\r\n resolve(frameHandle);\r\n }, timeoutMs);\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 WindowUtils.loadFrameSync = function (urlNavigate, frameName, logger) {\r\n var frameHandle = WindowUtils.addHiddenIFrame(frameName, logger);\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 return frameHandle;\r\n };\r\n /**\r\n * @hidden\r\n * Adds the hidden iframe for silent token renewal.\r\n * @ignore\r\n */\r\n WindowUtils.addHiddenIFrame = function (iframeId, logger) {\r\n if (typeof iframeId === \"undefined\") {\r\n return null;\r\n }\r\n logger.infoPii(\"Add msal frame to document:\" + iframeId);\r\n var adalFrame = document.getElementById(iframeId);\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 var 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);\r\n }\r\n else if (document.body && document.body.insertAdjacentHTML) {\r\n document.body.insertAdjacentHTML(\"beforeend\", \"\");\r\n }\r\n if (window.frames && window.frames[iframeId]) {\r\n adalFrame = window.frames[iframeId];\r\n }\r\n }\r\n return adalFrame;\r\n };\r\n /**\r\n * @hidden\r\n * Removes a hidden iframe from the page.\r\n * @ignore\r\n */\r\n WindowUtils.removeHiddenIframe = function (iframe) {\r\n if (document.body === iframe.parentNode) {\r\n document.body.removeChild(iframe);\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 WindowUtils.getIframeWithHash = function (hash) {\r\n var iframes = document.getElementsByTagName(\"iframe\");\r\n var iframeArray = Array.apply(null, Array(iframes.length)).map(function (iframe, index) { return iframes.item(index); }); // eslint-disable-line prefer-spread\r\n return iframeArray.filter(function (iframe) {\r\n try {\r\n return iframe.contentWindow.location.hash === hash;\r\n }\r\n catch (e) {\r\n return false;\r\n }\r\n })[0];\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 WindowUtils.getPopups = function () {\r\n if (!window.openedWindows) {\r\n window.openedWindows = [];\r\n }\r\n return window.openedWindows;\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 WindowUtils.getPopUpWithHash = function (hash) {\r\n return WindowUtils.getPopups().filter(function (popup) {\r\n try {\r\n return popup.location.hash === hash;\r\n }\r\n catch (e) {\r\n return false;\r\n }\r\n })[0];\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 WindowUtils.trackPopup = function (popup) {\r\n WindowUtils.getPopups().push(popup);\r\n };\r\n /**\r\n * @hidden\r\n * Close all popups\r\n * @ignore\r\n */\r\n WindowUtils.closePopups = function () {\r\n WindowUtils.getPopups().forEach(function (popup) { return popup.close(); });\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 WindowUtils.blockReloadInHiddenIframes = function () {\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 * @param cacheStorage\r\n */\r\n WindowUtils.checkIfBackButtonIsPressed = function (cacheStorage) {\r\n var redirectCache = cacheStorage.getItem(TemporaryCacheKeys.REDIRECT_REQUEST);\r\n // if redirect request is set and there is no hash\r\n if (redirectCache && !UrlUtils.urlContainsHash(window.location.hash)) {\r\n var splitCache = redirectCache.split(Constants.resourceDelimiter);\r\n var state = splitCache.length > 1 ? splitCache[splitCache.length - 1] : null;\r\n cacheStorage.resetTempCacheItems(state);\r\n }\r\n };\r\n /**\r\n * @hidden\r\n * Interval in milliseconds that we poll a window\r\n * @ignore\r\n */\r\n WindowUtils.POLLING_INTERVAL_MS = 50;\r\n return WindowUtils;\r\n}());\r\nexport { WindowUtils };\r\n//# sourceMappingURL=WindowUtils.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport * as tslib_1 from \"tslib\";\r\nimport { Authority, AuthorityType } from \"./Authority\";\r\nimport { XhrClient } from \"../XHRClient\";\r\nimport { AADTrustedHostList } from \"../utils/Constants\";\r\n/**\r\n * @hidden\r\n */\r\nvar AadAuthority = /** @class */ (function (_super) {\r\n tslib_1.__extends(AadAuthority, _super);\r\n function AadAuthority(authority, validateAuthority, authorityMetadata) {\r\n return _super.call(this, authority, validateAuthority, authorityMetadata) || this;\r\n }\r\n Object.defineProperty(AadAuthority.prototype, \"AadInstanceDiscoveryEndpointUrl\", {\r\n get: function () {\r\n return AadAuthority.AadInstanceDiscoveryEndpoint + \"?api-version=1.0&authorization_endpoint=\" + this.CanonicalAuthority + \"oauth2/v2.0/authorize\";\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AadAuthority.prototype, \"AuthorityType\", {\r\n get: function () {\r\n return AuthorityType.Aad;\r\n },\r\n enumerable: true,\r\n configurable: true\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 AadAuthority.prototype.GetOpenIdConfigurationEndpointAsync = function (telemetryManager, correlationId) {\r\n return tslib_1.__awaiter(this, void 0, void 0, function () {\r\n var client, httpMethod, httpEvent;\r\n return tslib_1.__generator(this, function (_a) {\r\n if (!this.IsValidationEnabled || this.IsInTrustedHostList(this.CanonicalAuthorityUrlComponents.HostNameAndPort)) {\r\n return [2 /*return*/, this.DefaultOpenIdConfigurationEndpoint];\r\n }\r\n client = new XhrClient();\r\n httpMethod = \"GET\";\r\n httpEvent = telemetryManager.createAndStartHttpEvent(correlationId, httpMethod, this.AadInstanceDiscoveryEndpointUrl, \"AadInstanceDiscoveryEndpoint\");\r\n return [2 /*return*/, client.sendRequestAsync(this.AadInstanceDiscoveryEndpointUrl, httpMethod, true)\r\n .then(function (response) {\r\n httpEvent.httpResponseStatus = response.statusCode;\r\n telemetryManager.stopEvent(httpEvent);\r\n return response.body.tenant_discovery_endpoint;\r\n })\r\n .catch(function (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 * Checks to see if the host is in a list of trusted hosts\r\n * @param {string} The host to look up\r\n */\r\n AadAuthority.prototype.IsInTrustedHostList = function (host) {\r\n return AADTrustedHostList[host.toLowerCase()];\r\n };\r\n AadAuthority.AadInstanceDiscoveryEndpoint = \"https://login.microsoftonline.com/common/discovery/instance\";\r\n return AadAuthority;\r\n}(Authority));\r\nexport { AadAuthority };\r\n//# sourceMappingURL=AadAuthority.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * @hidden\r\n */\r\nvar AccessTokenValue = /** @class */ (function () {\r\n function AccessTokenValue(accessToken, idToken, expiresIn, homeAccountIdentifier) {\r\n this.accessToken = accessToken;\r\n this.idToken = idToken;\r\n this.expiresIn = expiresIn;\r\n this.homeAccountIdentifier = homeAccountIdentifier;\r\n }\r\n return AccessTokenValue;\r\n}());\r\nexport { AccessTokenValue };\r\n//# sourceMappingURL=AccessTokenValue.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport * as tslib_1 from \"tslib\";\r\nimport { AuthError } from \"./AuthError\";\r\nimport { StringUtils } from \"../utils/StringUtils\";\r\nexport var ClientAuthErrorMessage = {\r\n multipleMatchingTokens: {\r\n code: \"multiple_matching_tokens\",\r\n desc: \"The cache contains multiple tokens satisfying the requirements. \" +\r\n \"Call AcquireToken again providing more requirements like authority.\"\r\n },\r\n multipleCacheAuthorities: {\r\n code: \"multiple_authorities\",\r\n desc: \"Multiple authorities found in the cache. Pass authority in the API overload.\"\r\n },\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 * Error thrown when there is an error in the client code running on the browser.\r\n */\r\nvar ClientAuthError = /** @class */ (function (_super) {\r\n tslib_1.__extends(ClientAuthError, _super);\r\n function ClientAuthError(errorCode, errorMessage) {\r\n var _this = _super.call(this, errorCode, errorMessage) || this;\r\n _this.name = \"ClientAuthError\";\r\n Object.setPrototypeOf(_this, ClientAuthError.prototype);\r\n return _this;\r\n }\r\n ClientAuthError.createEndpointResolutionError = function (errDetail) {\r\n var 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 ClientAuthError.createMultipleMatchingTokensInCacheError = function (scope) {\r\n return new ClientAuthError(ClientAuthErrorMessage.multipleMatchingTokens.code, \"Cache error for scope \" + scope + \": \" + ClientAuthErrorMessage.multipleMatchingTokens.desc + \".\");\r\n };\r\n ClientAuthError.createMultipleAuthoritiesInCacheError = function (scope) {\r\n return new ClientAuthError(ClientAuthErrorMessage.multipleCacheAuthorities.code, \"Cache error for scope \" + scope + \": \" + ClientAuthErrorMessage.multipleCacheAuthorities.desc + \".\");\r\n };\r\n ClientAuthError.createPopupWindowError = function (errDetail) {\r\n var 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 ClientAuthError.createTokenRenewalTimeoutError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.tokenRenewalError.code, ClientAuthErrorMessage.tokenRenewalError.desc);\r\n };\r\n ClientAuthError.createInvalidIdTokenError = function (idToken) {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidIdToken.code, ClientAuthErrorMessage.invalidIdToken.desc + \" Given token: \" + idToken);\r\n };\r\n // TODO: Is this not a security flaw to send the user the state expected??\r\n ClientAuthError.createInvalidStateError = function (invalidState, actualState) {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidStateError.code, ClientAuthErrorMessage.invalidStateError.desc + \" \" + invalidState + \", state expected : \" + actualState + \".\");\r\n };\r\n // TODO: Is this not a security flaw to send the user the Nonce expected??\r\n ClientAuthError.createNonceMismatchError = function (invalidNonce, actualNonce) {\r\n return new ClientAuthError(ClientAuthErrorMessage.nonceMismatchError.code, ClientAuthErrorMessage.nonceMismatchError.desc + \" \" + invalidNonce + \", nonce expected : \" + actualNonce + \".\");\r\n };\r\n ClientAuthError.createLoginInProgressError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.loginProgressError.code, ClientAuthErrorMessage.loginProgressError.desc);\r\n };\r\n ClientAuthError.createAcquireTokenInProgressError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.acquireTokenProgressError.code, ClientAuthErrorMessage.acquireTokenProgressError.desc);\r\n };\r\n ClientAuthError.createUserCancelledError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.userCancelledError.code, ClientAuthErrorMessage.userCancelledError.desc);\r\n };\r\n ClientAuthError.createErrorInCallbackFunction = function (errorDesc) {\r\n return new ClientAuthError(ClientAuthErrorMessage.callbackError.code, ClientAuthErrorMessage.callbackError.desc + \" \" + errorDesc + \".\");\r\n };\r\n ClientAuthError.createUserLoginRequiredError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.userLoginRequiredError.code, ClientAuthErrorMessage.userLoginRequiredError.desc);\r\n };\r\n ClientAuthError.createUserDoesNotExistError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.userDoesNotExistError.code, ClientAuthErrorMessage.userDoesNotExistError.desc);\r\n };\r\n ClientAuthError.createClientInfoDecodingError = function (caughtError) {\r\n return new ClientAuthError(ClientAuthErrorMessage.clientInfoDecodingError.code, ClientAuthErrorMessage.clientInfoDecodingError.desc + \" Failed with error: \" + caughtError);\r\n };\r\n ClientAuthError.createClientInfoNotPopulatedError = function (caughtError) {\r\n return new ClientAuthError(ClientAuthErrorMessage.clientInfoNotPopulatedError.code, ClientAuthErrorMessage.clientInfoNotPopulatedError.desc + \" Failed with error: \" + caughtError);\r\n };\r\n ClientAuthError.createIdTokenNullOrEmptyError = function (invalidRawTokenString) {\r\n return new ClientAuthError(ClientAuthErrorMessage.nullOrEmptyIdToken.code, ClientAuthErrorMessage.nullOrEmptyIdToken.desc + \" Raw ID Token Value: \" + invalidRawTokenString);\r\n };\r\n ClientAuthError.createIdTokenParsingError = function (caughtParsingError) {\r\n return new ClientAuthError(ClientAuthErrorMessage.idTokenNotParsed.code, ClientAuthErrorMessage.idTokenNotParsed.desc + \" Failed with error: \" + caughtParsingError);\r\n };\r\n ClientAuthError.createTokenEncodingError = function (incorrectlyEncodedToken) {\r\n return new ClientAuthError(ClientAuthErrorMessage.tokenEncodingError.code, ClientAuthErrorMessage.tokenEncodingError.desc + \" Attempted to decode: \" + incorrectlyEncodedToken);\r\n };\r\n ClientAuthError.createInvalidInteractionTypeError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidInteractionType.code, ClientAuthErrorMessage.invalidInteractionType.desc);\r\n };\r\n ClientAuthError.createCacheParseError = function (key) {\r\n var errorMessage = \"invalid key: \" + key + \", \" + ClientAuthErrorMessage.cacheParseError.desc;\r\n return new ClientAuthError(ClientAuthErrorMessage.cacheParseError.code, errorMessage);\r\n };\r\n ClientAuthError.createBlockTokenRequestsInHiddenIframeError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.blockTokenRequestsInHiddenIframe.code, ClientAuthErrorMessage.blockTokenRequestsInHiddenIframe.desc);\r\n };\r\n return ClientAuthError;\r\n}(AuthError));\r\nexport { ClientAuthError };\r\n//# sourceMappingURL=ClientAuthError.js.map","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nimport { ClientConfigurationError } from \"./error/ClientConfigurationError\";\r\nimport { Constants } from \"./utils/Constants\";\r\nvar ScopeSet = /** @class */ (function () {\r\n function 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 ScopeSet.isIntersectingScopes = function (cachedScopes, scopes) {\r\n var convertedCachedScopes = this.trimAndConvertArrayToLowerCase(cachedScopes.slice());\r\n var requestScopes = this.trimAndConvertArrayToLowerCase(scopes.slice());\r\n for (var 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 * Check if a given scope is present in the request\r\n *\r\n * @param cachedScopes\r\n * @param scopes\r\n */\r\n ScopeSet.containsScope = function (cachedScopes, scopes) {\r\n var convertedCachedScopes = this.trimAndConvertArrayToLowerCase(cachedScopes.slice());\r\n var requestScopes = this.trimAndConvertArrayToLowerCase(scopes.slice());\r\n return requestScopes.every(function (value) { return convertedCachedScopes.indexOf(value.toString().toLowerCase()) >= 0; });\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 ScopeSet.trimAndConvertToLowerCase = function (scope) {\r\n return scope.trim().toLowerCase();\r\n };\r\n /**\r\n * Performs trimeAndConvertToLowerCase on string array\r\n * @param scopes\r\n */\r\n ScopeSet.trimAndConvertArrayToLowerCase = function (scopes) {\r\n var _this = this;\r\n return scopes.map(function (scope) { return _this.trimAndConvertToLowerCase(scope); });\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 ScopeSet.removeElement = function (scopes, scope) {\r\n var scopeVal = this.trimAndConvertToLowerCase(scope);\r\n return scopes.filter(function (value) { return value !== scopeVal; });\r\n };\r\n /**\r\n * Parse the scopes into a formatted scopeList\r\n * @param scopes\r\n */\r\n ScopeSet.parseScope = function (scopes) {\r\n var scopeList = \"\";\r\n if (scopes) {\r\n for (var i = 0; i < scopes.length; ++i) {\r\n scopeList += (i !== scopes.length - 1) ? scopes[i] + \" \" : scopes[i];\r\n }\r\n }\r\n return scopeList;\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} 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 ScopeSet.validateInputScope = function (scopes, scopesRequired, clientId) {\r\n if (!scopes) {\r\n if (scopesRequired) {\r\n throw ClientConfigurationError.createScopesRequiredError(scopes);\r\n }\r\n else {\r\n return;\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 // Check that scopes is not an empty array\r\n if (scopes.length < 1) {\r\n throw ClientConfigurationError.createEmptyScopesArrayError(scopes.toString());\r\n }\r\n // Check that clientId is passed as single scope\r\n if (scopes.indexOf(clientId) > -1) {\r\n if (scopes.length > 1) {\r\n throw ClientConfigurationError.createClientIdSingleScopeError(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 ScopeSet.getScopeFromState = function (state) {\r\n if (state) {\r\n var 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 * @ignore\r\n * Appends extraScopesToConsent if passed\r\n * @param {@link AuthenticationParameters}\r\n */\r\n ScopeSet.appendScopes = function (reqScopes, reqExtraScopesToConsent) {\r\n if (reqScopes) {\r\n var convertedExtraScopes = reqExtraScopesToConsent ? this.trimAndConvertArrayToLowerCase(reqExtraScopesToConsent.slice()) : null;\r\n var convertedReqScopes = this.trimAndConvertArrayToLowerCase(reqScopes.slice());\r\n return convertedExtraScopes ? convertedReqScopes.concat(convertedExtraScopes) : convertedReqScopes;\r\n }\r\n return null;\r\n };\r\n return ScopeSet;\r\n}());\r\nexport { ScopeSet };\r\n//# sourceMappingURL=ScopeSet.js.map"],"sourceRoot":""}