{"version":3,"sources":["webpack:///./node_modules/@azure/msal-browser/dist/index.es.js"],"names":["extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","hasOwnProperty","__extends","__","this","constructor","prototype","create","__assign","assign","t","s","i","n","arguments","length","call","apply","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","__generator","body","f","y","g","_","label","sent","trys","ops","verb","Symbol","iterator","v","op","TypeError","pop","push","__spreadArrays","il","r","k","a","j","jl","extendStatics$1","__extends$1","__assign$1","__awaiter$1","__generator$1","__spreadArrays$1","LogLevel","AuthErrorMessage","code","desc","AuthError","_super","errorCode","errorMessage","suberror","_this","errorString","name","createUnexpectedError","errDesc","Error","pkg","ClientAuthErrorMessage","ClientAuthError","createClientInfoDecodingError","caughtError","createClientInfoEmptyError","rawClientInfo","createIdTokenParsingError","caughtExtractionError","createIdTokenNullOrEmptyError","invalidRawTokenString","createEndpointDiscoveryIncompleteError","errDetail","createInvalidAuthorityTypeError","givenUrl","createHashNotDeserializedError","hashParamObj","createInvalidStateError","invalidState","createStateMismatchError","createNonceMismatchError","createAccountMismatchError","createInvalidIdTokenError","idToken","JSON","stringify","createNoTokensFoundError","createCacheParseError","cacheKey","createUserLoginRequiredError","createMultipleMatchingTokensInCacheError","createMultipleMatchingAccountsInCacheError","createTokenRequestCannotBeMadeError","createAppendEmptyScopeToSetError","givenScope","createRemoveEmptyScopeFromSetError","createAppendScopeSetError","appendError","createEmptyInputScopeSetError","givenScopeSet","createDeviceCodeCancelledError","createDeviceCodeExpiredError","createNoAccountInSilentRequestError","createNullOrUndefinedCacheRecord","createInvalidCacheEnvironmentError","createNoAccountFoundError","createCachePluginError","createNoCryptoObjectError","operationName","createInvalidCacheTypeError","createUnexpectedAccountTypeError","createUnexpectedCredentialTypeError","createInvalidAssertionError","createInvalidCredentialError","createRefreshRequiredError","StringUtils","decodeJwt","jwtToken","isEmpty","matches","exec","header","JWSPayload","JWSSig","str","startsWith","search","indexOf","endsWith","lastIndexOf","queryStringToObject","query","match","pl","decode","decodeURIComponent","replace","obj","trimArrayEntries","arr","map","entry","trim","removeEmptyStringsFromArray","filter","jsonParseHelper","parse","HeaderNames","PersistentCacheKeys","AADAuthorityConstants","AADServerParamKeys","IdTokenClaimName","ClaimsRequestKeys","Logger","loggerOptions","level","Info","localCallback","loggerCallback","piiLoggingEnabled","logLevel","logMessage","options","containsPii","timestamp","Date","toUTCString","log","correlationId","executeCallback","message","error","errorPii","warning","Warning","warningPii","info","infoPii","verbose","Verbose","verbosePii","isPiiLoggingEnabled","Constants","LIBRARY_NAME","SKU","CACHE_PREFIX","DEFAULT_AUTHORITY","DEFAULT_AUTHORITY_HOST","ADFS","AAD_INSTANCE_DISCOVERY_ENDPT","RESOURCE_DELIM","NO_ACCOUNT","CLAIMS","CONSUMER_UTID","OPENID_SCOPE","PROFILE_SCOPE","OFFLINE_ACCESS_SCOPE","CODE_RESPONSE_TYPE","CODE_GRANT_TYPE","RT_GRANT_TYPE","FRAGMENT_RESPONSE_MODE","S256_CODE_CHALLENGE_METHOD","URL_FORM_CONTENT_TYPE","AUTHORIZATION_PENDING","NOT_DEFINED","SSOTypes","PromptValue","LOGIN","SELECT_ACCOUNT","CONSENT","NONE","SID","LOGIN_HINT","ResponseMode","GrantType","CacheAccountType","Separators","CredentialType","CacheSchemaType","CacheType","CodeChallengeMethodValues","PLAIN","S256","AuthorityType","SERVER_TELEM_CONSTANTS","SCHEMA_VERSION","FAILURE_LIMIT","CACHE_KEY","CATEGORY_SEPARATOR","VALUE_SEPARATOR","ThrottlingConstants","Errors","CredentialEntity","generateAccountId","generateAccountIdForCacheKey","homeAccountId","environment","generateCredentialId","generateCredentialIdForCacheKey","credentialType","clientId","realm","familyId","generateTarget","generateTargetForCacheKey","target","generateCredentialKey","generateCredentialCacheKey","generateType","ID_TOKEN","ACCESS_TOKEN","REFRESH_TOKEN","getCredentialType","key","toLowerCase","join","CACHE_KEY_SEPARATOR","scopes","ClientConfigurationErrorMessage","ClientConfigurationError","createRedirectUriEmptyError","createPostLogoutRedirectUriEmptyError","createClaimsRequestParsingError","claimsRequestParseError","createInsecureAuthorityUriError","urlString","createUrlParseError","urlParseError","createUrlEmptyError","createScopesNonArrayError","inputScopes","createEmptyScopesArrayError","createClientIdSingleScopeError","createInvalidPromptError","promptValue","createInvalidClaimsRequestError","createEmptyLogoutRequestError","createEmptyTokenRequestError","createInvalidCodeChallengeMethodError","createInvalidCodeChallengeParamsError","createKnownAuthoritiesCloudDiscoveryMetadataError","createInvalidCloudDiscoveryMetadataError","createUntrustedAuthorityError","ScopeSet","scopeArr","filteredInput","validateInputScopes","Set","forEach","scope","add","fromString","inputScopeString","split","containsScope","lowerCaseScopesSet","printScopesLowerCase","has","containsScopeSet","scopeSet","size","asArray","every","containsOnlyDefaultScopes","defaultScopeCount","appendScope","newScope","appendScopes","newScopes","removeScope","delete","removeDefaultScopes","unionScopeSets","otherScopes","unionScopes","intersectingScopeSets","sizeOtherScopes","getScopeCount","sizeThisScopes","array","val","printScopes","UrlString","url","_urlString","getHash","canonicalizeUri","defineProperty","get","enumerable","configurable","validateAsUri","components","getUrlComponents","HostNameAndPort","PathSegments","Protocol","urlRemoveQueryStringParameter","regex","RegExp","removeHashFromUrl","replaceTenantPath","tenantId","urlObject","pathArray","COMMON","ORGANIZATIONS","constructAuthorityUriFromObject","parseHash","regEx","urlComponents","AbsolutePath","pathSegments","getDomainFromUrl","hashString","hashIndex1","hashIndex2","substring","getDeserializedHash","hash","parsedHash","deserializedHash","hashContainsKnownProperties","parameters","error_description","state","TrustedAuthority","setTrustedAuthoritiesFromConfig","knownAuthorities","cloudDiscoveryMetadata","getTrustedHostList","createCloudDiscoveryMetadataFromKnownAuthorities","parsedMetadata","saveCloudDiscoveryMetadata","metadata","setTrustedAuthoritiesFromNetwork","authorityToVerify","networkInterface","instanceDiscoveryEndpoint","response","host","_a","sendGetRequestAsync","IsInTrustedHostList","aliases","authority","TrustedHostList","authorityDomain","preferred_cache","preferred_network","keys","getCloudDiscoveryMetadata","Authority","canonicalAuthority","_canonicalAuthority","canonicalAuthorityUrlComponents","Adfs","Default","set","_canonicalAuthorityUrlComponents","discoveryComplete","replaceTenant","tenantDiscoveryResponse","authorization_endpoint","token_endpoint","end_session_endpoint","issuer","tenant","authorityType","discoverEndpoints","openIdConfigurationEndpoint","validateAndSetPreferredNetwork","preferredNetwork","resolveEndpointsAsync","openIdConfigEndpoint","defaultOpenIdConfigurationEndpoint","generateEnvironmentFromAuthority","reqEnvironment","buildClientInfo","crypto","decodedClientInfo","base64Decode","AccountEntity","generateAccountKey","generateAccountCacheKey","username","ADFS_ACCOUNT_TYPE","MSAV1_ACCOUNT_TYPE","MSA","MSSTS_ACCOUNT_TYPE","MSSTS","GENERIC_ACCOUNT_TYPE","GENERIC","getAccountInfo","accountInterface","createAccount","clientInfo","oboAssertion","account","clientInfoObj","uid","CLIENT_INFO_SEPARATOR","utid","env","claims","tid","localAccountId","oid","sid","preferred_username","emails","createADFSAccount","sub","upn","isAccountEntity","entity","AppMetadataEntity","generateAppMetadataKey","generateAppMetadataCacheKey","createAppMetadataEntity","appMetadata","isAppMetadataEntity","CacheManager","getAllAccounts","currentAccounts","getAccountsFilteredBy","accountValues","accountKey","accountObj","toObject","saveCacheRecord","cacheRecord","saveAccount","saveCredential","accessToken","saveAccessToken","refreshToken","setItem","ACCOUNT","credential","CREDENTIAL","currentTokenCache","getCredentialsFilteredBy","currentScopes","currentAccessTokens","accessTokens","tokenEntity","removeCredential","getAccount","isAppMetadata","getItem","getCredential","getAppMetadata","APP_METADATA","accountFilter","getAccountsFilteredByInternal","allCacheKeys","getKeys","matchingAccounts","matchHomeAccountId","matchEnvironment","matchRealm","getCredentialsFilteredByInternal","matchingCredentials","idTokens","refreshTokens","credType","matchOboAssertion","matchCredentialType","matchClientId","matchFamilyId","matchTarget","removeAllAccounts","removeAccount","removeAccountContext","removeItem","accountId","cacheEntity","removeAppMetadata","readCacheRecord","readAccountFromCache","readIdTokenFromCache","readAccessTokenFromCache","readRefreshTokenFromCache","readAppMetadataFromCache","idTokenKey","accessTokenFilter","credentialCache","numAccessTokens","familyRT","id","refreshTokenFilter","isAppMetadataFOCI","cloudMetadata","entityScopeSet","requestTargetScopeSet","json","propertyName","DefaultStorageClass","containsKey","clear","DEFAULT_AUTH_OPTIONS","clientCapabilities","DEFAULT_SYSTEM_OPTIONS","tokenRenewalOffsetSeconds","DEFAULT_LOGGER_IMPLEMENTATION","DEFAULT_NETWORK_IMPLEMENTATION","sendPostRequestAsync","DEFAULT_CRYPTO_IMPLEMENTATION","createNewGuid","base64Encode","generatePkceCodes","DEFAULT_LIBRARY_INFO","sku","version","cpu","os","DEFAULT_CLIENT_CREDENTIALS","clientSecret","clientAssertion","HTTP_REQUEST_TYPE","TemporaryCacheKeys","ApiId","InteractionType","ServerError","subError","ThrottlingUtils","generateThrottlingStorageKey","thumbprint","preProcess","cacheManager","THROTTLING","throttleTime","now","errorCodes","postProcess","checkResponseStatus","checkResponseForRetryAfter","thumbprintValue","calculateThrottleTime","parseInt","headers","RETRY_AFTER","error_codes","status","currentSeconds","Math","floor","min","removeThrottle","homeAccountIdentifier","NetworkManager","networkClient","sendPostRequest","tokenEndpoint","BaseClient","configuration","userAuthOptions","userSystemOptions","userLoggerOption","storageImplementation","networkImplementation","cryptoImplementation","clientCredentials","libraryInfo","serverTelemetryManager","config","authOptions","systemOptions","storageInterface","cryptoInterface","logger","cryptoUtils","networkManager","createDefaultTokenRequestHeaders","createDefaultLibraryHeaders","CONTENT_TYPE","X_MS_LIB_CAPABILITY","X_MS_LIB_CAPABILITY_VALUE","X_CLIENT_CURR_TELEM","generateCurrentRequestHeaderValue","X_CLIENT_LAST_TELEM","generateLastRequestHeaderValue","X_CLIENT_SKU","X_CLIENT_VER","X_CLIENT_OS","X_CLIENT_CPU","executePostToTokenEndpoint","queryString","clearTelemetryCache","RequestValidator","validateRedirectUri","redirectUri","validatePrompt","prompt","validateClaims","validateCodeChallengeParams","codeChallenge","codeChallengeMethod","validateCodeChallengeMethod","sanitizeEQParams","eQParams","queryParams","RequestParameterBuilder","Map","addResponseTypeCode","RESPONSE_TYPE","encodeURIComponent","addResponseMode","responseMode","RESPONSE_MODE","QUERY","addScopes","addOidcScopes","requestScopes","SCOPE","addClientId","CLIENT_ID","addRedirectUri","REDIRECT_URI","addDomainHint","domainHint","DOMAIN_HINT","addLoginHint","loginHint","addSid","addClaims","mergedClaims","addClientCapabilitiesToClaims","addCorrelationId","CLIENT_REQUEST_ID","addLibraryInfo","addPrompt","PROMPT","addState","STATE","addNonce","nonce","NONCE","addCodeChallengeParams","CODE_CHALLENGE","CODE_CHALLENGE_METHOD","addAuthorizationCode","CODE","addDeviceCode","DEVICE_CODE","addRefreshToken","addCodeVerifier","codeVerifier","CODE_VERIFIER","addClientSecret","CLIENT_SECRET","addClientAssertion","CLIENT_ASSERTION","addClientAssertionType","clientAssertionType","CLIENT_ASSERTION_TYPE","addOboAssertion","OBO_ASSERTION","addRequestTokenUse","tokenUse","REQUESTED_TOKEN_USE","addGrantType","grantType","GRANT_TYPE","addClientInfo","addExtraQueryParameters","eQparams","XMS_CC","values","createQueryString","queryParameterArray","IdToken","rawIdToken","extractIdToken","encodedIdToken","decodedToken","base64IdTokenPayload","base64Decoded","err","TimeUtils","nowSeconds","round","getTime","isTokenExpired","expiresOn","offset","expirationSec","Number","IdTokenEntity","createIdTokenEntity","idTokenEntity","secret","isIdTokenEntity","AccessTokenEntity","createAccessTokenEntity","extExpiresOn","atEntity","currentTime","cachedAt","toString","extendedExpiresOn","isAccessTokenEntity","RefreshTokenEntity","createRefreshTokenEntity","rtEntity","isRefreshTokenEntity","InteractionRequiredAuthErrorMessage","InteractionRequiredAuthSubErrorMessage","InteractionRequiredAuthError","isInteractionRequiredError","isInteractionRequiredErrorCode","isInteractionRequiredSubError","isInteractionRequiredErrorDesc","some","irErrorCode","CacheRecord","accountEntity","accessTokenEntity","refreshTokenEntity","appMetadataEntity","ProtocolUtils","setRequestState","cryptoObj","userState","meta","libraryState","generateLibraryState","stateObj","ts","stateString","parseRequestState","splitState","slice","libraryStateString","libraryStateObj","userRequestState","ResponseHandler","cacheStorage","validateServerAuthorizationCodeResponse","serverResponseHash","cachedState","client_info","validateTokenResponse","serverResponse","errString","correlation_id","trace_id","handleServerTokenResponse","serverTokenResponse","cachedNonce","idTokenObj","id_token","requestStateObj","generateCacheRecord","generateAuthenticationResult","cachedIdToken","cachedAccount","generateAccountEntity","cachedAccessToken","access_token","responseScopes","tokenExpirationSeconds","expires_in","extendedTokenExpirationSeconds","ext_expires_in","cachedRefreshToken","refresh_token","foci","cachedAppMetadata","fromTokenCache","requestState","uniqueId","idTokenClaims","fromCache","AuthorizationCodeClient","getAuthCodeUrl","request","createAuthCodeUrlQueryString","authorizationEndpoint","acquireToken","responseHandler","executeTokenRequest","handleFragmentResponse","hashFragment","hashUrlString","serverParams","getLogoutUri","logoutRequest","postLogoutUriParam","postLogoutRedirectUri","POST_LOGOUT_URI","correlationIdParam","endSessionEndpoint","requestBody","createTokenRequestBody","parameterBuilder","assertion","assertionType","AUTHORIZATION_CODE_GRANT","extraScopesToConsent","extraQueryParameters","RefreshTokenClient","DeviceCodeClient","deviceCodeResponse","getDeviceCode","deviceCodeCallback","acquireTokenWithDeviceCode","executePostRequestToDeviceCodeEndpoint","deviceCodeEndpoint","userCode","deviceCode","verificationUri","expiresIn","interval","_b","user_code","device_code","verification_uri","deviceCodeExpirationTime","pollingIntervalMilli","intervalId","setInterval","error_1","cancel","clearInterval","requestParameters","DEVICE_CODE_GRANT","acquireTokenByRefreshToken","noFamilyRTInCache","clientMismatchErrorWithFamilyRT","acquireTokenWithCachedRefreshToken","refreshTokenRequest","REFRESH_TOKEN_GRANT","SilentFlowClient","ClientCredentialClient","cachedAuthenticationResult","skipCache","getCachedAuthenticationResult","CLIENT_CREDENTIALS_GRANT","OnBehalfOfClient","idTokenObject","idTokenFilter","JWT_BEARER","ON_BEHALF_OF","acquireCachedToken","isRefreshRequired","incrementCacheHits","generateResultFromCacheRecord","forceRefresh","AuthorityFactory","createDiscoveredInstance","authorityUri","acquireTokenAuthority","e_1","createInstance","authorityUrl","ServerTelemetryManager","telemetryRequest","apiId","telemetryCacheKey","forceRefreshInt","lastRequests","getLastRequests","failedRequests","errors","platformFields","errorCount","cacheHits","cacheFailedRequest","shift","TELEMETRY","BrowserConstants","CACHE_LOCATION_LOCAL","CACHE_LOCATION_SESSION","INTERACTION_STATUS_KEY","INTERACTION_IN_PROGRESS_VALUE","INVALID_GRANT_ERROR","POPUP_WIDTH","POPUP_HEIGHT","POLL_INTERVAL_MS","MSAL_SKU","DEFAULT_REQUEST","MathUtils","decimalToHex","num","hex","GuidGenerator","generateGuid","buffer","Uint8Array","getRandomValues","guidHolder","guidResponse","random","isGuid","guid","test","BrowserStringUtils","stringToUtf8Arr","sDOMStr","nChr","nArrLen","nStrLen","nMapIdx","charCodeAt","aBytes","nIdx","nChrIdx","utf8ArrToString","sView","nPart","nLen","String","fromCharCode","Base64Encode","urlEncode","input","encode","urlEncodeArr","inputArr","base64EncArr","inputUtf8Arr","eqLen","sB64Enc","nMod3","nUint24","uint6ToB64","nUint6","Base64Decode","encodedString","base64DecToArr","base64String","nBlockSize","nInLen","nOutLen","ceil","nMod4","nOutIdx","nInIdx","b64ToUint6","charNum","BrowserAuthErrorMessage","BrowserAuthError","createPkceNotGeneratedError","createCryptoNotAvailableError","createHttpMethodNotImplementedError","method","createEmptyNavigationUriError","createEmptyHashError","hashValue","createInteractionInProgressError","createPopupWindowError","createEmptyWindowCreatedError","createUserCancelledError","createMonitorWindowTimeoutError","createRedirectInIframeError","windowParentCheck","createBlockReloadInHiddenIframeError","createIframeClosedPrematurelyError","createSilentSSOInsufficientInfoError","createSilentPromptValueError","givenPrompt","createTokenRequestCacheError","createNonBrowserEnvironmentError","PkceGenerator","generateCodes","generateCodeVerifier","generateCodeChallengeFromVerifier","verifier","challenge","pkceCodeVerifier","pkceHashedCodeVerifier","sha256Digest","BrowserCrypto","hasCryptoAPI","dataString","data","hasIECrypto","getMSCryptoDigest","getSubtleCryptoDigest","dataBuffer","window","hasBrowserCrypto","algorithm","subtle","digest","digestOperation","addEventListener","CryptoOps","browserCrypto","b64Encode","b64Decode","guidGenerator","pkceGenerator","BrowserConfigurationAuthErrorMessage","BrowserConfigurationAuthError","createStorageNotSupportedError","givenStorageLocation","createInvalidCallbackObjectError","callbackObject","createRedirectCallbacksNotSetError","BrowserStorage","cacheConfig","cryptoImpl","validateWindowStorage","cacheLocation","windowStorage","migrateCacheEntries","clientInfoKey","CLIENT_INFO","errorKey","ERROR","errorDescKey","ERROR_DESC","index","migrateCacheEntry","newKey","generateCacheKey","TEMPORARY","validateObjectKey","type","stringVal","storeAuthStateInCookie","setItemCookie","itemCookie","getItemCookie","clearItemCookie","cookieName","cookieValue","expires","cookieStr","getCookieExpirationTime","document","cookie","cookieList","charAt","clearMsalCookie","nonceKey","generateNonceKey","generateStateKey","NONCE_IDTOKEN","ORIGIN_URI","cookieLifeDays","today","getCache","setCache","ADAL_ID_TOKEN","generateAuthorityKey","stateId","AUTHORITY","REQUEST_STATE","setAuthorityCache","getCachedAuthority","updateCacheEntries","authorityInstance","resetRequestCache","REQUEST_PARAMS","URL_HASH","cleanRequest","cacheCodeRequest","authCodeRequest","getCachedRequest","encodedTokenRequest","parsedRequest","cachedAuthority","FetchClient","fetch","GET","getFetchHeaders","getHeaderDict","reqBody","POST","Headers","append","headerDict","XhrClient","sendRequestAsync","xhr","XMLHttpRequest","open","setXhrHeaders","onload","responseText","jsonResponse","networkResponse","onerror","send","setRequestHeader","headerArr","getAllResponseHeaders","parts","headerName","headerVal","BrowserUtils","navigateWindow","urlNavigate","noHistory","location","clearHash","replaceHash","urlParts","isInIframe","parent","getCurrentUri","href","getHomepage","getBrowserNetworkClient","blockReloadInHiddenIframes","blockNonBrowserEnvironment","isBrowserEnvironment","detectIEOrEdge","ua","navigator","userAgent","msie","msie11","msedge","DEFAULT_POPUP_TIMEOUT_MS","DEFAULT_IFRAME_TIMEOUT_MS","BrowserProtocolUtils","extractBrowserRequestState","parseServerResponseFromHash","locationHash","InteractionHandler","authCodeModule","storageImpl","authModule","browserStorage","handleCodeResponse","authCode","tokenResponse","RedirectHandler","initiateAuthRequest","requestUrl","redirectStartPage","isIframedApp","PopupHandler","unloadWindow","bind","popup","openPopup","monitorPopupForHash","popupWindow","timeout","maxTicks","ticks","closed","cleanPopup","contentHash","openSizedPopup","focus","currentWindow","winLeft","screenLeft","screenX","winTop","screenTop","screenY","width","innerWidth","documentElement","clientWidth","height","innerHeight","clientHeight","left","max","top","close","removeEventListener","SilentHandler","configuredLoadFrameTimeout","loadFrameTimeout","loadFrame","loadFrameSync","monitorIframeForHash","iframe","timeoutMark","performance","removeHiddenIframe","contentWindow","setTimeout","frameHandle","createHiddenIframe","src","authFrame","createElement","style","visibility","position","border","setAttribute","getElementsByTagName","appendChild","parentNode","removeChild","PublicClientApplication","loginRedirect","acquireTokenRedirect","loginPopup","acquireTokenPopup","acquireTokenSilent","silentRequest","preflightBrowserEnvironmentCheck","initializeBaseRequest","initializeServerTelemetryManager","acquireTokenSilent_silentFlow","createSilentFlowClient","ClientApplication","userInputAuth","auth","userInputCache","cache","userInputSystem","system","navigateToLoginRequestUrl","DEFAULT_CACHE_OPTIONS","DEFAULT_BROWSER_SYSTEM_OPTIONS","windowHashTimeout","iframeHashTimeout","asyncPopups","buildConfiguration","defaultAuthority","handleRedirectPromise","handleRedirectResponse","responseHash","loginRequestUrl","loginRequestUrlNormalized","currentUrlNormalized","hashKey","homepage","interactionInProgress","getRedirectResponseHash","handleHash","isResponseHash","cachedHash","serverParams_1","interactionType","REDIRECT","cachedRequest","currentAuthority","authClient","createAuthCodeClient","validRequest","interactionHandler","navigateUrl","e_2","preflightInteractiveRequest","initializeAuthorizationCodeRequest","acquireTokenPopupAsync","e_3","POPUP","ssoSilent","e_4","initializeAuthorizationRequest","SILENT","silentTokenHelper","e_5","isServerError","isInvalidGrantError","createRefreshTokenClient","silentHandler","msalFrame","logout","validLogoutRequest","logoutUri","initializeLogoutRequest","getAccountByUsername","userName","allAccounts","getAccountByHomeId","getRedirectUri","requestRedirectUri","getPostLogoutRedirectUri","requestPostLogoutRedirectUri","getDiscoveredDefaultAuthority","clientConfig","getClientConfiguration","requestAuthority","discoveredAuthority","validatedRequest","telemetryPayload","setDefaultScopes","adalIdTokenString","adalIdToken","browserState","FRAGMENT","generatedPkceParams"],"mappings":"0FAAA;;;;;;;;;;;;;;;;AAkBA,IAAIA,EAAgB,SAASC,EAAGC,GAI5B,OAHAF,EAAgBG,OAAOC,gBAClB,CAAEC,UAAW,cAAgBC,OAAS,SAAUL,EAAGC,GAAKD,EAAEI,UAAYH,IACvE,SAAUD,EAAGC,GAAK,IAAK,IAAIK,KAAKL,EAAOA,EAAEM,eAAeD,KAAIN,EAAEM,GAAKL,EAAEK,MACpDN,EAAGC,IAG5B,SAASO,EAAUR,EAAGC,GAElB,SAASQ,IAAOC,KAAKC,YAAcX,EADnCD,EAAcC,EAAGC,GAEjBD,EAAEY,UAAkB,OAANX,EAAaC,OAAOW,OAAOZ,IAAMQ,EAAGG,UAAYX,EAAEW,UAAW,IAAIH,GAGnF,IAAIK,EAAW,WAQX,OAPAA,EAAWZ,OAAOa,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAIZ,KADTW,EAAIG,UAAUF,GACOhB,OAAOU,UAAUL,eAAee,KAAKL,EAAGX,KAAIU,EAAEV,GAAKW,EAAEX,IAE9E,OAAOU,IAEKO,MAAMb,KAAMU,YAGhC,SAASI,EAAUC,EAASC,EAAYC,EAAGC,GACvC,OAAO,IAAKD,IAAMA,EAAIE,UAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,IAAW,MAAOG,GAAKL,EAAOK,IACpF,SAASC,EAASJ,GAAS,IAAMC,E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A,EAAmBjnC,eAAkBzL,KAAKuhC,cAAcje,gBAClHovB,EAAmB3d,sBAAwB/0B,KAAKmzC,yBAAyBte,EAAgBA,EAAcE,sBAAwB,IACxH2d,GAEJxD,EAjvB2B","file":"npm.azure.10b81dda5cd024292456.js","sourcesContent":["/*! @azure/msal-browser v2.2.1 2020-09-30 */\n'use strict';\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nvar __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\n\r\nfunction __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nfunction __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nfunction __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\n\n/*! @azure/msal-common v1.4.0 2020-09-30 */\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics$1 = function(d, b) {\r\n extendStatics$1 = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics$1(d, b);\r\n};\r\n\r\nfunction __extends$1(d, b) {\r\n extendStatics$1(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nvar __assign$1 = function() {\r\n __assign$1 = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign$1.apply(this, arguments);\r\n};\r\n\r\nfunction __awaiter$1(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nfunction __generator$1(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nfunction __spreadArrays$1() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * AuthErrorMessage class containing string constants used by error codes and messages.\r\n */\r\nvar AuthErrorMessage = {\r\n unexpectedError: {\r\n code: \"unexpected_error\",\r\n desc: \"Unexpected error in authentication.\"\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 __extends$1(AuthError, _super);\r\n function AuthError(errorCode, errorMessage, suberror) {\r\n var _this = this;\r\n var errorString = errorMessage ? errorCode + \": \" + errorMessage : errorCode;\r\n _this = _super.call(this, errorString) || this;\r\n Object.setPrototypeOf(_this, AuthError.prototype);\r\n _this.errorCode = errorCode;\r\n _this.errorMessage = errorMessage;\r\n _this.suberror = suberror;\r\n _this.name = \"AuthError\";\r\n return _this;\r\n }\r\n /**\r\n * Creates an error that is thrown when something unexpected happens in the library.\r\n * @param errDesc\r\n */\r\n AuthError.createUnexpectedError = function (errDesc) {\r\n return new AuthError(AuthErrorMessage.unexpectedError.code, AuthErrorMessage.unexpectedError.desc + \": \" + errDesc);\r\n };\r\n return AuthError;\r\n}(Error));\n\nvar name = \"@azure/msal-common\";\nvar author = {\n\tname: \"Microsoft\",\n\temail: \"nugetaad@microsoft.com\",\n\turl: \"https://www.microsoft.com\"\n};\nvar license = \"MIT\";\nvar repository = {\n\ttype: \"git\",\n\turl: \"https://github.com/AzureAD/microsoft-authentication-library-for-js.git\"\n};\nvar version = \"1.4.0\";\nvar description = \"Microsoft Authentication Library for js\";\nvar keywords = [\n\t\"implicit\",\n\t\"authorization code\",\n\t\"PKCE\",\n\t\"js\",\n\t\"AAD\",\n\t\"msal\",\n\t\"oauth\"\n];\nvar main = \"./dist/index.js\";\nvar module = \"./dist/index.es.js\";\nvar types = \"./dist/src/index.d.ts\";\nvar browserslist = [\n\t\"last 1 version\",\n\t\"> 1%\",\n\t\"maintained node versions\",\n\t\"not dead\"\n];\nvar engines = {\n\tnode: \">=0.8.0\"\n};\nvar directories = {\n\ttest: \"test\"\n};\nvar files = [\n\t\"dist\"\n];\nvar scripts = {\n\tclean: \"shx rm -rf dist lib\",\n\t\"clean:coverage\": \"rimraf ../../.nyc_output/*\",\n\tdoc: \"npm run doc:generate && npm run doc:deploy\",\n\t\"doc:generate\": \"typedoc --mode modules --excludePrivate --excludeProtected --excludeNotExported --out ./ref ./src/ --gitRevision dev\",\n\t\"doc:deploy\": \"gh-pages -d ref -a -e ref/msal-common\",\n\tlint: \"cd ../../ && npm run lint:common\",\n\t\"lint:fix\": \"npm run lint -- -- --fix\",\n\ttest: \"mocha\",\n\t\"test:coverage\": \"nyc --reporter=text mocha --exit\",\n\t\"test:coverage:only\": \"npm run clean:coverage && npm run test:coverage\",\n\t\"build:modules\": \"rollup -c\",\n\t\"build:modules:watch\": \"rollup -cw\",\n\tbuild: \"npm run clean && npm run build:modules\",\n\tprepack: \"npm run build\"\n};\nvar devDependencies = {\n\t\"@babel/core\": \"^7.7.2\",\n\t\"@babel/plugin-proposal-class-properties\": \"^7.7.0\",\n\t\"@babel/plugin-proposal-object-rest-spread\": \"^7.6.2\",\n\t\"@babel/polyfill\": \"^7.7.0\",\n\t\"@babel/preset-env\": \"^7.7.1\",\n\t\"@babel/preset-typescript\": \"^7.7.2\",\n\t\"@babel/register\": \"^7.7.0\",\n\t\"@istanbuljs/nyc-config-babel\": \"^2.1.1\",\n\t\"@rollup/plugin-json\": \"^4.0.0\",\n\t\"@types/chai\": \"^4.2.5\",\n\t\"@types/chai-as-promised\": \"^7.1.2\",\n\t\"@types/debug\": \"^4.1.5\",\n\t\"@types/mocha\": \"^5.2.7\",\n\t\"@types/sinon\": \"^7.5.0\",\n\t\"babel-plugin-istanbul\": \"^5.2.0\",\n\tbeachball: \"^1.32.2\",\n\tchai: \"^4.2.0\",\n\t\"chai-as-promised\": \"^7.1.1\",\n\t\"gh-pages\": \"^3.1.0\",\n\thusky: \"^3.0.9\",\n\tmocha: \"^6.2.2\",\n\tnyc: \"^14.1.1\",\n\trimraf: \"^3.0.2\",\n\trollup: \"^1.24.0\",\n\t\"rollup-plugin-typescript2\": \"^0.24.3\",\n\t\"rollup-plugin-uglify\": \"^6.0.4\",\n\tshx: \"^0.3.2\",\n\tsinon: \"^7.5.0\",\n\ttslib: \"^1.10.0\",\n\ttslint: \"^5.20.0\",\n\ttypedoc: \"^0.17.8\",\n\ttypescript: \"^3.7.5\"\n};\nvar dependencies = {\n\tdebug: \"^4.1.1\"\n};\nvar pkg = {\n\tname: name,\n\tauthor: author,\n\tlicense: license,\n\trepository: repository,\n\tversion: version,\n\tdescription: description,\n\tkeywords: keywords,\n\tmain: main,\n\tmodule: module,\n\ttypes: types,\n\tbrowserslist: browserslist,\n\tengines: engines,\n\tdirectories: directories,\n\tfiles: files,\n\tscripts: scripts,\n\tdevDependencies: devDependencies,\n\tdependencies: dependencies\n};\n\n/**\r\n * ClientAuthErrorMessage class containing string constants used by error codes and messages.\r\n */\r\nvar ClientAuthErrorMessage = {\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 clientInfoEmptyError: {\r\n code: \"client_info_empty_error\",\r\n desc: \"The client info was empty. Please review the trace to determine the root cause.\"\r\n },\r\n idTokenParsingError: {\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 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 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 invalidAuthorityType: {\r\n code: \"invalid_authority_type\",\r\n desc: \"The given authority is not a valid type of authority supported by MSAL. Please review the trace to determine the root cause.\"\r\n },\r\n hashNotDeserialized: {\r\n code: \"hash_not_deserialized\",\r\n desc: \"The hash parameters could not be deserialized. Please review the trace to determine the root cause.\"\r\n },\r\n blankGuidGenerated: {\r\n code: \"blank_guid_generated\",\r\n desc: \"The guid generated was blank. Please review the trace to determine the root cause.\"\r\n },\r\n invalidStateError: {\r\n code: \"invalid_state\",\r\n desc: \"State was not the expected format. Please check the logs to determine whether the request was sent using ProtocolUtils.setRequestState().\"\r\n },\r\n stateMismatchError: {\r\n code: \"state_mismatch\",\r\n desc: \"State mismatch error. Please check your network. Continued requests may cause cache overflow.\"\r\n },\r\n nonceMismatchError: {\r\n code: \"nonce_mismatch\",\r\n desc: \"Nonce mismatch error. This may be caused by a race condition in concurrent requests.\"\r\n },\r\n accountMismatchError: {\r\n code: \"account_mismatch\",\r\n desc: \"The cached account and account which made the token request do not match.\"\r\n },\r\n invalidIdToken: {\r\n code: \"invalid_id_token\",\r\n desc: \"Invalid ID token format.\"\r\n },\r\n noTokensFoundError: {\r\n code: \"no_tokens_found\",\r\n desc: \"No tokens were found for the given scopes, and no authorization code was passed to acquireToken. You must retrieve an authorization code before making a call to acquireToken().\"\r\n },\r\n cacheParseError: {\r\n code: \"cache_parse_error\",\r\n desc: \"Could not parse cache key.\"\r\n },\r\n userLoginRequiredError: {\r\n code: \"user_login_error\",\r\n desc: \"User login is required.\"\r\n },\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 such as authority or account.\"\r\n },\r\n multipleMatchingAccounts: {\r\n code: \"multiple_matching_accounts\",\r\n desc: \"The cache contains multiple accounts satisfying the given parameters. Please pass more info to obtain the correct account\"\r\n },\r\n tokenRequestCannotBeMade: {\r\n code: \"request_cannot_be_made\",\r\n desc: \"Token request cannot be made without authorization code or refresh token.\"\r\n },\r\n appendEmptyScopeError: {\r\n code: \"cannot_append_empty_scope\",\r\n desc: \"Cannot append null or empty scope to ScopeSet. Please check the stack trace for more info.\"\r\n },\r\n removeEmptyScopeError: {\r\n code: \"cannot_remove_empty_scope\",\r\n desc: \"Cannot remove null or empty scope from ScopeSet. Please check the stack trace for more info.\"\r\n },\r\n appendScopeSetError: {\r\n code: \"cannot_append_scopeset\",\r\n desc: \"Cannot append ScopeSet due to error.\"\r\n },\r\n emptyInputScopeSetError: {\r\n code: \"empty_input_scopeset\",\r\n desc: \"Empty input ScopeSet cannot be processed.\"\r\n },\r\n DeviceCodePollingCancelled: {\r\n code: \"device_code_polling_cancelled\",\r\n desc: \"Caller has cancelled token endpoint polling during device code flow by setting DeviceCodeRequest.cancel = true.\"\r\n },\r\n DeviceCodeExpired: {\r\n code: \"device_code_expired\",\r\n desc: \"Device code is expired.\"\r\n },\r\n NoAccountInSilentRequest: {\r\n code: \"no_account_in_silent_request\",\r\n desc: \"Please pass an account object, silent flow is not supported without account information\"\r\n },\r\n invalidCacheRecord: {\r\n code: \"invalid_cache_record\",\r\n desc: \"Cache record object was null or undefined.\"\r\n },\r\n invalidCacheEnvironment: {\r\n code: \"invalid_cache_environment\",\r\n desc: \"Invalid environment when attempting to create cache entry\"\r\n },\r\n noAccountFound: {\r\n code: \"no_account_found\",\r\n desc: \"No account found in cache for given key.\"\r\n },\r\n CachePluginError: {\r\n code: \"no cache plugin set on CacheManager\",\r\n desc: \"ICachePlugin needs to be set before using readFromStorage or writeFromStorage\"\r\n },\r\n noCryptoObj: {\r\n code: \"no_crypto_object\",\r\n desc: \"No crypto object detected. This is required for the following operation: \"\r\n },\r\n invalidCacheType: {\r\n code: \"invalid_cache_type\",\r\n desc: \"Invalid cache type\"\r\n },\r\n unexpectedAccountType: {\r\n code: \"unexpected_account_type\",\r\n desc: \"Unexpected account type.\"\r\n },\r\n unexpectedCredentialType: {\r\n code: \"unexpected_credential_type\",\r\n desc: \"Unexpected credential type.\"\r\n },\r\n invalidAssertion: {\r\n code: \"invalid_assertion\",\r\n desc: \"Client assertion must meet requirements described in https://tools.ietf.org/html/rfc7515\"\r\n },\r\n invalidClientCredential: {\r\n code: \"invalid_client_credential\",\r\n desc: \"Client credential (secret, certificate, or assertion) must not be empty when creating a confidential client. An application should at most have one credential\"\r\n },\r\n tokenRefreshRequired: {\r\n code: \"token_refresh_required\",\r\n desc: \"Cannot return token from cache because it must be refreshed. This may be due to one of the following reasons: forceRefresh parameter is set to true, claims have been requested, there is no cached access token or it is expired.\"\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 __extends$1(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 /**\r\n * Creates an error thrown when client info object doesn't decode correctly.\r\n * @param caughtError\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 /**\r\n * Creates an error thrown if the client info is empty.\r\n * @param rawClientInfo\r\n */\r\n ClientAuthError.createClientInfoEmptyError = function (rawClientInfo) {\r\n return new ClientAuthError(ClientAuthErrorMessage.clientInfoEmptyError.code, ClientAuthErrorMessage.clientInfoEmptyError.desc + \" Given Object: \" + rawClientInfo);\r\n };\r\n /**\r\n * Creates an error thrown when the id token extraction errors out.\r\n * @param err\r\n */\r\n ClientAuthError.createIdTokenParsingError = function (caughtExtractionError) {\r\n return new ClientAuthError(ClientAuthErrorMessage.idTokenParsingError.code, ClientAuthErrorMessage.idTokenParsingError.desc + \" Failed with error: \" + caughtExtractionError);\r\n };\r\n /**\r\n * Creates an error thrown when the id token string is null or empty.\r\n * @param invalidRawTokenString\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 /**\r\n * Creates an error thrown when the endpoint discovery doesn't complete correctly.\r\n */\r\n ClientAuthError.createEndpointDiscoveryIncompleteError = function (errDetail) {\r\n return new ClientAuthError(ClientAuthErrorMessage.endpointResolutionError.code, ClientAuthErrorMessage.endpointResolutionError.desc + \" Detail: \" + errDetail);\r\n };\r\n /**\r\n * Creates an error thrown if authority type is not valid.\r\n * @param invalidAuthorityError\r\n */\r\n ClientAuthError.createInvalidAuthorityTypeError = function (givenUrl) {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidAuthorityType.code, ClientAuthErrorMessage.invalidAuthorityType.desc + \" Given Url: \" + givenUrl);\r\n };\r\n /**\r\n * Creates an error thrown when the hash cannot be deserialized.\r\n * @param invalidAuthorityError\r\n */\r\n ClientAuthError.createHashNotDeserializedError = function (hashParamObj) {\r\n return new ClientAuthError(ClientAuthErrorMessage.hashNotDeserialized.code, ClientAuthErrorMessage.hashNotDeserialized.desc + \" Given Object: \" + hashParamObj);\r\n };\r\n /**\r\n * Creates an error thrown when the state cannot be parsed.\r\n * @param invalidState\r\n */\r\n ClientAuthError.createInvalidStateError = function (invalidState, errorString) {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidStateError.code, ClientAuthErrorMessage.invalidStateError.desc + \" Invalid State: \" + invalidState + \", Root Err: \" + errorString);\r\n };\r\n /**\r\n * Creates an error thrown when two states do not match.\r\n */\r\n ClientAuthError.createStateMismatchError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.stateMismatchError.code, ClientAuthErrorMessage.stateMismatchError.desc);\r\n };\r\n /**\r\n * Creates an error thrown when the nonce does not match.\r\n */\r\n ClientAuthError.createNonceMismatchError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.nonceMismatchError.code, ClientAuthErrorMessage.nonceMismatchError.desc);\r\n };\r\n /**\r\n * Creates an error thrown when the cached account and response account do not match.\r\n */\r\n ClientAuthError.createAccountMismatchError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.accountMismatchError.code, ClientAuthErrorMessage.accountMismatchError.desc);\r\n };\r\n /**\r\n * Throws error if idToken is not correctly formed\r\n * @param idToken\r\n */\r\n ClientAuthError.createInvalidIdTokenError = function (idToken) {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidIdToken.code, ClientAuthErrorMessage.invalidIdToken.desc + \" Given token: \" + JSON.stringify(idToken));\r\n };\r\n /**\r\n * Creates an error thrown when the authorization code required for a token request is null or empty.\r\n */\r\n ClientAuthError.createNoTokensFoundError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.noTokensFoundError.code, ClientAuthErrorMessage.noTokensFoundError.desc);\r\n };\r\n /**\r\n * Creates an error in cache parsing.\r\n */\r\n ClientAuthError.createCacheParseError = function (cacheKey) {\r\n return new ClientAuthError(ClientAuthErrorMessage.cacheParseError.code, ClientAuthErrorMessage.cacheParseError.desc + \" Cache key: \" + cacheKey);\r\n };\r\n /**\r\n * Throws error when renewing token without login.\r\n */\r\n ClientAuthError.createUserLoginRequiredError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.userLoginRequiredError.code, ClientAuthErrorMessage.userLoginRequiredError.desc);\r\n };\r\n /**\r\n * Throws error when multiple tokens are in cache for the given scope.\r\n * @param scope\r\n */\r\n ClientAuthError.createMultipleMatchingTokensInCacheError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.multipleMatchingTokens.code, ClientAuthErrorMessage.multipleMatchingTokens.desc + \".\");\r\n };\r\n /**\r\n * Throws error when multiple tokens are in cache for the given scope.\r\n * @param scope\r\n */\r\n ClientAuthError.createMultipleMatchingAccountsInCacheError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.multipleMatchingAccounts.code, ClientAuthErrorMessage.multipleMatchingAccounts.desc);\r\n };\r\n /**\r\n * Throws error when no auth code or refresh token is given to ServerTokenRequestParameters.\r\n */\r\n ClientAuthError.createTokenRequestCannotBeMadeError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.tokenRequestCannotBeMade.code, ClientAuthErrorMessage.tokenRequestCannotBeMade.desc);\r\n };\r\n /**\r\n * Throws error when attempting to append a null, undefined or empty scope to a set\r\n * @param givenScope\r\n */\r\n ClientAuthError.createAppendEmptyScopeToSetError = function (givenScope) {\r\n return new ClientAuthError(ClientAuthErrorMessage.appendEmptyScopeError.code, ClientAuthErrorMessage.appendEmptyScopeError.desc + \" Given Scope: \" + givenScope);\r\n };\r\n /**\r\n * Throws error when attempting to append a null, undefined or empty scope to a set\r\n * @param givenScope\r\n */\r\n ClientAuthError.createRemoveEmptyScopeFromSetError = function (givenScope) {\r\n return new ClientAuthError(ClientAuthErrorMessage.removeEmptyScopeError.code, ClientAuthErrorMessage.removeEmptyScopeError.desc + \" Given Scope: \" + givenScope);\r\n };\r\n /**\r\n * Throws error when attempting to append null or empty ScopeSet.\r\n * @param appendError\r\n */\r\n ClientAuthError.createAppendScopeSetError = function (appendError) {\r\n return new ClientAuthError(ClientAuthErrorMessage.appendScopeSetError.code, ClientAuthErrorMessage.appendScopeSetError.desc + \" Detail Error: \" + appendError);\r\n };\r\n /**\r\n * Throws error if ScopeSet is null or undefined.\r\n * @param givenScopeSet\r\n */\r\n ClientAuthError.createEmptyInputScopeSetError = function (givenScopeSet) {\r\n return new ClientAuthError(ClientAuthErrorMessage.emptyInputScopeSetError.code, ClientAuthErrorMessage.emptyInputScopeSetError.desc + \" Given ScopeSet: \" + givenScopeSet);\r\n };\r\n /**\r\n * Throws error if user sets CancellationToken.cancel = true during polling of token endpoint during device code flow\r\n */\r\n ClientAuthError.createDeviceCodeCancelledError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.DeviceCodePollingCancelled.code, \"\" + ClientAuthErrorMessage.DeviceCodePollingCancelled.desc);\r\n };\r\n /**\r\n * Throws error if device code is expired\r\n */\r\n ClientAuthError.createDeviceCodeExpiredError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.DeviceCodeExpired.code, \"\" + ClientAuthErrorMessage.DeviceCodeExpired.desc);\r\n };\r\n /**\r\n * Throws error when silent requests are made without an account object\r\n */\r\n ClientAuthError.createNoAccountInSilentRequestError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.NoAccountInSilentRequest.code, \"\" + ClientAuthErrorMessage.NoAccountInSilentRequest.desc);\r\n };\r\n /**\r\n * Throws error when cache record is null or undefined.\r\n */\r\n ClientAuthError.createNullOrUndefinedCacheRecord = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidCacheRecord.code, ClientAuthErrorMessage.invalidCacheRecord.desc);\r\n };\r\n /**\r\n * Throws error when provided environment is not part of the CloudDiscoveryMetadata object\r\n */\r\n ClientAuthError.createInvalidCacheEnvironmentError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidCacheEnvironment.code, ClientAuthErrorMessage.invalidCacheEnvironment.desc);\r\n };\r\n /**\r\n * Throws error when account is not found in cache.\r\n */\r\n ClientAuthError.createNoAccountFoundError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.noAccountFound.code, ClientAuthErrorMessage.noAccountFound.desc);\r\n };\r\n /**\r\n * Throws error if ICachePlugin not set on CacheManager.\r\n */\r\n ClientAuthError.createCachePluginError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.CachePluginError.code, \"\" + ClientAuthErrorMessage.CachePluginError.desc);\r\n };\r\n /**\r\n * Throws error if crypto object not found.\r\n * @param operationName\r\n */\r\n ClientAuthError.createNoCryptoObjectError = function (operationName) {\r\n return new ClientAuthError(ClientAuthErrorMessage.noCryptoObj.code, \"\" + ClientAuthErrorMessage.noCryptoObj.desc + operationName);\r\n };\r\n /**\r\n * Throws error if cache type is invalid.\r\n */\r\n ClientAuthError.createInvalidCacheTypeError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidCacheType.code, \"\" + ClientAuthErrorMessage.invalidCacheType.desc);\r\n };\r\n /**\r\n * Throws error if unexpected account type.\r\n */\r\n ClientAuthError.createUnexpectedAccountTypeError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.unexpectedAccountType.code, \"\" + ClientAuthErrorMessage.unexpectedAccountType.desc);\r\n };\r\n /**\r\n * Throws error if unexpected credential type.\r\n */\r\n ClientAuthError.createUnexpectedCredentialTypeError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.unexpectedCredentialType.code, \"\" + ClientAuthErrorMessage.unexpectedCredentialType.desc);\r\n };\r\n /**\r\n * Throws error if client assertion is not valid.\r\n */\r\n ClientAuthError.createInvalidAssertionError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidAssertion.code, \"\" + ClientAuthErrorMessage.invalidAssertion.desc);\r\n };\r\n /**\r\n * Throws error if client assertion is not valid.\r\n */\r\n ClientAuthError.createInvalidCredentialError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.invalidClientCredential.code, \"\" + ClientAuthErrorMessage.invalidClientCredential.desc);\r\n };\r\n /**\r\n * Throws error if token cannot be retrieved from cache due to refresh being required.\r\n */\r\n ClientAuthError.createRefreshRequiredError = function () {\r\n return new ClientAuthError(ClientAuthErrorMessage.tokenRefreshRequired.code, ClientAuthErrorMessage.tokenRefreshRequired.desc);\r\n };\r\n return ClientAuthError;\r\n}(AuthError));\n\n/**\r\n * @hidden\r\n */\r\nvar StringUtils = /** @class */ (function () {\r\n function StringUtils() {\r\n }\r\n /**\r\n * decode a JWT\r\n *\r\n * @param jwtToken\r\n */\r\n StringUtils.decodeJwt = function (jwtToken) {\r\n if (StringUtils.isEmpty(jwtToken)) {\r\n throw ClientAuthError.createIdTokenNullOrEmptyError(jwtToken);\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 throw ClientAuthError.createIdTokenParsingError(\"Given token is malformed: \" + JSON.stringify(jwtToken));\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 * 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 StringUtils.startsWith = function (str, search) {\r\n return str.indexOf(search) === 0;\r\n };\r\n StringUtils.endsWith = function (str, search) {\r\n return (str.length >= search.length) && (str.lastIndexOf(search) === (str.length - search.length));\r\n };\r\n /**\r\n * Parses string into an object.\r\n *\r\n * @param query\r\n */\r\n StringUtils.queryStringToObject = 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, \" \"))); };\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 /**\r\n * Trims entries in an array.\r\n *\r\n * @param arr\r\n */\r\n StringUtils.trimArrayEntries = function (arr) {\r\n return arr.map(function (entry) { return entry.trim(); });\r\n };\r\n /**\r\n * Removes empty strings from array\r\n * @param arr\r\n */\r\n StringUtils.removeEmptyStringsFromArray = function (arr) {\r\n return arr.filter(function (entry) {\r\n return !StringUtils.isEmpty(entry);\r\n });\r\n };\r\n /**\r\n * Attempts to parse a string into JSON\r\n * @param str\r\n */\r\n StringUtils.jsonParseHelper = function (str) {\r\n try {\r\n return JSON.parse(str);\r\n }\r\n catch (e) {\r\n return null;\r\n }\r\n };\r\n return StringUtils;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Log message level.\r\n */\r\nvar 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\n/**\r\n * Class which facilitates logging of messages to a specific place.\r\n */\r\nvar Logger = /** @class */ (function () {\r\n function Logger(loggerOptions) {\r\n // Current log level, defaults to info.\r\n this.level = LogLevel.Info;\r\n if (loggerOptions) {\r\n this.localCallback = loggerOptions.loggerCallback;\r\n this.piiLoggingEnabled = loggerOptions.piiLoggingEnabled;\r\n this.level = loggerOptions.logLevel;\r\n }\r\n }\r\n /**\r\n * Log message with required options.\r\n */\r\n Logger.prototype.logMessage = function (logMessage, options) {\r\n if ((options.logLevel > this.level) || (!this.piiLoggingEnabled && options.containsPii)) {\r\n return;\r\n }\r\n var timestamp = new Date().toUTCString();\r\n var logHeader = StringUtils.isEmpty(this.correlationId) ? \"[\" + timestamp + \"] : \" : \"[\" + timestamp + \"] : [\" + this.correlationId + \"]\";\r\n var log = logHeader + \" : \" + pkg.version + \" : \" + LogLevel[options.logLevel] + \" - \" + logMessage;\r\n // debug(`msal:${LogLevel[options.logLevel]}${options.containsPii ? \"-Pii\": \"\"}${options.context ? `:${options.context}` : \"\"}`)(logMessage);\r\n this.executeCallback(options.logLevel, log, options.containsPii);\r\n };\r\n /**\r\n * Execute callback with message.\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 * Logs error messages.\r\n */\r\n Logger.prototype.error = function (message, correlationId) {\r\n this.logMessage(message, {\r\n logLevel: LogLevel.Error,\r\n containsPii: false,\r\n correlationId: correlationId || \"\"\r\n });\r\n };\r\n /**\r\n * Logs error messages with PII.\r\n */\r\n Logger.prototype.errorPii = function (message, correlationId) {\r\n this.logMessage(message, {\r\n logLevel: LogLevel.Error,\r\n containsPii: true,\r\n correlationId: correlationId || \"\"\r\n });\r\n };\r\n /**\r\n * Logs warning messages.\r\n */\r\n Logger.prototype.warning = function (message, correlationId) {\r\n this.logMessage(message, {\r\n logLevel: LogLevel.Warning,\r\n containsPii: false,\r\n correlationId: correlationId || \"\"\r\n });\r\n };\r\n /**\r\n * Logs warning messages with PII.\r\n */\r\n Logger.prototype.warningPii = function (message, correlationId) {\r\n this.logMessage(message, {\r\n logLevel: LogLevel.Warning,\r\n containsPii: true,\r\n correlationId: correlationId || \"\"\r\n });\r\n };\r\n /**\r\n * Logs info messages.\r\n */\r\n Logger.prototype.info = function (message, correlationId) {\r\n this.logMessage(message, {\r\n logLevel: LogLevel.Info,\r\n containsPii: false,\r\n correlationId: correlationId || \"\"\r\n });\r\n };\r\n /**\r\n * Logs info messages with PII.\r\n */\r\n Logger.prototype.infoPii = function (message, correlationId) {\r\n this.logMessage(message, {\r\n logLevel: LogLevel.Info,\r\n containsPii: true,\r\n correlationId: correlationId || \"\"\r\n });\r\n };\r\n /**\r\n * Logs verbose messages.\r\n */\r\n Logger.prototype.verbose = function (message, correlationId) {\r\n this.logMessage(message, {\r\n logLevel: LogLevel.Verbose,\r\n containsPii: false,\r\n correlationId: correlationId || \"\"\r\n });\r\n };\r\n /**\r\n * Logs verbose messages with PII.\r\n */\r\n Logger.prototype.verbosePii = function (message, correlationId) {\r\n this.logMessage(message, {\r\n logLevel: LogLevel.Verbose,\r\n containsPii: true,\r\n correlationId: correlationId || \"\"\r\n });\r\n };\r\n /**\r\n * Returns whether PII Logging is enabled or not.\r\n */\r\n Logger.prototype.isPiiLoggingEnabled = function () {\r\n return this.piiLoggingEnabled || false;\r\n };\r\n return Logger;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nvar Constants = {\r\n LIBRARY_NAME: \"MSAL.JS\",\r\n SKU: \"msal.js.common\",\r\n // Prefix for all library cache entries\r\n CACHE_PREFIX: \"msal\",\r\n // default authority\r\n DEFAULT_AUTHORITY: \"https://login.microsoftonline.com/common/\",\r\n DEFAULT_AUTHORITY_HOST: \"login.microsoftonline.com\",\r\n // ADFS String\r\n ADFS: \"adfs\",\r\n // Default AAD Instance Discovery Endpoint\r\n AAD_INSTANCE_DISCOVERY_ENDPT: \"https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=\",\r\n // Resource delimiter - used for certain cache entries\r\n RESOURCE_DELIM: \"|\",\r\n // Placeholder for non-existent account ids/objects\r\n NO_ACCOUNT: \"NO_ACCOUNT\",\r\n // Claims\r\n CLAIMS: \"claims\",\r\n // Consumer UTID\r\n CONSUMER_UTID: \"9188040d-6c67-4c5b-b112-36a304b66dad\",\r\n // Default scopes\r\n OPENID_SCOPE: \"openid\",\r\n PROFILE_SCOPE: \"profile\",\r\n OFFLINE_ACCESS_SCOPE: \"offline_access\",\r\n // Default response type for authorization code flow\r\n CODE_RESPONSE_TYPE: \"code\",\r\n CODE_GRANT_TYPE: \"authorization_code\",\r\n RT_GRANT_TYPE: \"refresh_token\",\r\n FRAGMENT_RESPONSE_MODE: \"fragment\",\r\n S256_CODE_CHALLENGE_METHOD: \"S256\",\r\n URL_FORM_CONTENT_TYPE: \"application/x-www-form-urlencoded;charset=utf-8\",\r\n AUTHORIZATION_PENDING: \"authorization_pending\",\r\n NOT_DEFINED: \"not_defined\"\r\n};\r\n/**\r\n * Request header names\r\n */\r\nvar HeaderNames;\r\n(function (HeaderNames) {\r\n HeaderNames[\"CONTENT_TYPE\"] = \"Content-Type\";\r\n HeaderNames[\"X_CLIENT_CURR_TELEM\"] = \"x-client-current-telemetry\";\r\n HeaderNames[\"X_CLIENT_LAST_TELEM\"] = \"x-client-last-telemetry\";\r\n HeaderNames[\"RETRY_AFTER\"] = \"Retry-After\";\r\n HeaderNames[\"X_MS_LIB_CAPABILITY\"] = \"x-ms-lib-capability\";\r\n HeaderNames[\"X_MS_LIB_CAPABILITY_VALUE\"] = \"retry-after, h429\";\r\n})(HeaderNames || (HeaderNames = {}));\r\n/**\r\n * Persistent cache keys MSAL which stay while user is logged in.\r\n */\r\nvar PersistentCacheKeys;\r\n(function (PersistentCacheKeys) {\r\n PersistentCacheKeys[\"ID_TOKEN\"] = \"idtoken\";\r\n PersistentCacheKeys[\"CLIENT_INFO\"] = \"client.info\";\r\n PersistentCacheKeys[\"ADAL_ID_TOKEN\"] = \"adal.idtoken\";\r\n PersistentCacheKeys[\"ERROR\"] = \"error\";\r\n PersistentCacheKeys[\"ERROR_DESC\"] = \"error.description\";\r\n})(PersistentCacheKeys || (PersistentCacheKeys = {}));\r\n/**\r\n * String constants related to AAD Authority\r\n */\r\nvar AADAuthorityConstants;\r\n(function (AADAuthorityConstants) {\r\n AADAuthorityConstants[\"COMMON\"] = \"common\";\r\n AADAuthorityConstants[\"ORGANIZATIONS\"] = \"organizations\";\r\n AADAuthorityConstants[\"CONSUMERS\"] = \"consumers\";\r\n})(AADAuthorityConstants || (AADAuthorityConstants = {}));\r\n/**\r\n * Keys in the hashParams sent by AAD Server\r\n */\r\nvar AADServerParamKeys;\r\n(function (AADServerParamKeys) {\r\n AADServerParamKeys[\"CLIENT_ID\"] = \"client_id\";\r\n AADServerParamKeys[\"REDIRECT_URI\"] = \"redirect_uri\";\r\n AADServerParamKeys[\"RESPONSE_TYPE\"] = \"response_type\";\r\n AADServerParamKeys[\"RESPONSE_MODE\"] = \"response_mode\";\r\n AADServerParamKeys[\"GRANT_TYPE\"] = \"grant_type\";\r\n AADServerParamKeys[\"CLAIMS\"] = \"claims\";\r\n AADServerParamKeys[\"SCOPE\"] = \"scope\";\r\n AADServerParamKeys[\"ERROR\"] = \"error\";\r\n AADServerParamKeys[\"ERROR_DESCRIPTION\"] = \"error_description\";\r\n AADServerParamKeys[\"ACCESS_TOKEN\"] = \"access_token\";\r\n AADServerParamKeys[\"ID_TOKEN\"] = \"id_token\";\r\n AADServerParamKeys[\"REFRESH_TOKEN\"] = \"refresh_token\";\r\n AADServerParamKeys[\"EXPIRES_IN\"] = \"expires_in\";\r\n AADServerParamKeys[\"STATE\"] = \"state\";\r\n AADServerParamKeys[\"NONCE\"] = \"nonce\";\r\n AADServerParamKeys[\"PROMPT\"] = \"prompt\";\r\n AADServerParamKeys[\"SESSION_STATE\"] = \"session_state\";\r\n AADServerParamKeys[\"CLIENT_INFO\"] = \"client_info\";\r\n AADServerParamKeys[\"CODE\"] = \"code\";\r\n AADServerParamKeys[\"CODE_CHALLENGE\"] = \"code_challenge\";\r\n AADServerParamKeys[\"CODE_CHALLENGE_METHOD\"] = \"code_challenge_method\";\r\n AADServerParamKeys[\"CODE_VERIFIER\"] = \"code_verifier\";\r\n AADServerParamKeys[\"CLIENT_REQUEST_ID\"] = \"client-request-id\";\r\n AADServerParamKeys[\"X_CLIENT_SKU\"] = \"x-client-SKU\";\r\n AADServerParamKeys[\"X_CLIENT_VER\"] = \"x-client-VER\";\r\n AADServerParamKeys[\"X_CLIENT_OS\"] = \"x-client-OS\";\r\n AADServerParamKeys[\"X_CLIENT_CPU\"] = \"x-client-CPU\";\r\n AADServerParamKeys[\"POST_LOGOUT_URI\"] = \"post_logout_redirect_uri\";\r\n AADServerParamKeys[\"DEVICE_CODE\"] = \"device_code\";\r\n AADServerParamKeys[\"CLIENT_SECRET\"] = \"client_secret\";\r\n AADServerParamKeys[\"CLIENT_ASSERTION\"] = \"client_assertion\";\r\n AADServerParamKeys[\"CLIENT_ASSERTION_TYPE\"] = \"client_assertion_type\";\r\n AADServerParamKeys[\"OBO_ASSERTION\"] = \"assertion\";\r\n AADServerParamKeys[\"REQUESTED_TOKEN_USE\"] = \"requested_token_use\";\r\n AADServerParamKeys[\"ON_BEHALF_OF\"] = \"on_behalf_of\";\r\n AADServerParamKeys[\"FOCI\"] = \"foci\";\r\n})(AADServerParamKeys || (AADServerParamKeys = {}));\r\n/**\r\n * IdToken claim string constants\r\n */\r\nvar IdTokenClaimName;\r\n(function (IdTokenClaimName) {\r\n IdTokenClaimName[\"ISSUER\"] = \"iss\";\r\n IdTokenClaimName[\"OBJID\"] = \"oid\";\r\n IdTokenClaimName[\"SUBJECT\"] = \"sub\";\r\n IdTokenClaimName[\"TENANTID\"] = \"tid\";\r\n IdTokenClaimName[\"VERSION\"] = \"ver\";\r\n IdTokenClaimName[\"PREF_USERNAME\"] = \"preferred_username\";\r\n IdTokenClaimName[\"NAME\"] = \"name\";\r\n IdTokenClaimName[\"NONCE\"] = \"nonce\";\r\n IdTokenClaimName[\"EXPIRATION\"] = \"exp\";\r\n IdTokenClaimName[\"HOME_OBJID\"] = \"home_oid\";\r\n IdTokenClaimName[\"SESSIONID\"] = \"sid\";\r\n IdTokenClaimName[\"CLOUD_INSTANCE_HOSTNAME\"] = \"cloud_instance_host_name\";\r\n})(IdTokenClaimName || (IdTokenClaimName = {}));\r\nvar ClaimsRequestKeys;\r\n(function (ClaimsRequestKeys) {\r\n ClaimsRequestKeys[\"ACCESS_TOKEN\"] = \"access_token\";\r\n ClaimsRequestKeys[\"XMS_CC\"] = \"xms_cc\";\r\n})(ClaimsRequestKeys || (ClaimsRequestKeys = {}));\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 */\r\nvar PromptValue = {\r\n LOGIN: \"login\",\r\n SELECT_ACCOUNT: \"select_account\",\r\n CONSENT: \"consent\",\r\n NONE: \"none\",\r\n};\r\n/**\r\n * SSO Types - generated to populate hints\r\n */\r\nvar 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[\"DOMAIN_HINT\"] = \"domain_hint\";\r\n SSOTypes[\"ORGANIZATIONS\"] = \"organizations\";\r\n SSOTypes[\"CONSUMERS\"] = \"consumers\";\r\n SSOTypes[\"ACCOUNT_ID\"] = \"accountIdentifier\";\r\n SSOTypes[\"HOMEACCOUNT_ID\"] = \"homeAccountIdentifier\";\r\n})(SSOTypes || (SSOTypes = {}));\r\n/**\r\n * Disallowed extra query parameters.\r\n */\r\nvar BlacklistedEQParams = [\r\n SSOTypes.SID,\r\n SSOTypes.LOGIN_HINT\r\n];\r\n/**\r\n * allowed values for codeVerifier\r\n */\r\nvar CodeChallengeMethodValues = {\r\n PLAIN: \"plain\",\r\n S256: \"S256\"\r\n};\r\n/**\r\n * allowed values for response_mode\r\n */\r\nvar ResponseMode;\r\n(function (ResponseMode) {\r\n ResponseMode[\"QUERY\"] = \"query\";\r\n ResponseMode[\"FRAGMENT\"] = \"fragment\";\r\n ResponseMode[\"FORM_POST\"] = \"form_post\";\r\n})(ResponseMode || (ResponseMode = {}));\r\n/**\r\n * allowed grant_type\r\n */\r\nvar GrantType;\r\n(function (GrantType) {\r\n GrantType[\"IMPLICIT_GRANT\"] = \"implicit\";\r\n GrantType[\"AUTHORIZATION_CODE_GRANT\"] = \"authorization_code\";\r\n GrantType[\"CLIENT_CREDENTIALS_GRANT\"] = \"client_credentials\";\r\n GrantType[\"RESOURCE_OWNER_PASSWORD_GRANT\"] = \"password\";\r\n GrantType[\"REFRESH_TOKEN_GRANT\"] = \"refresh_token\";\r\n GrantType[\"DEVICE_CODE_GRANT\"] = \"device_code\";\r\n GrantType[\"JWT_BEARER\"] = \"urn:ietf:params:oauth:grant-type:jwt-bearer\";\r\n})(GrantType || (GrantType = {}));\r\n/**\r\n * Account types in Cache\r\n */\r\nvar CacheAccountType;\r\n(function (CacheAccountType) {\r\n CacheAccountType[\"MSSTS_ACCOUNT_TYPE\"] = \"MSSTS\";\r\n CacheAccountType[\"ADFS_ACCOUNT_TYPE\"] = \"ADFS\";\r\n CacheAccountType[\"MSAV1_ACCOUNT_TYPE\"] = \"MSA\";\r\n CacheAccountType[\"GENERIC_ACCOUNT_TYPE\"] = \"Generic\"; // NTLM, Kerberos, FBA, Basic etc\r\n})(CacheAccountType || (CacheAccountType = {}));\r\n/**\r\n * Separators used in cache\r\n */\r\nvar Separators;\r\n(function (Separators) {\r\n Separators[\"CACHE_KEY_SEPARATOR\"] = \"-\";\r\n Separators[\"CLIENT_INFO_SEPARATOR\"] = \".\";\r\n})(Separators || (Separators = {}));\r\n/**\r\n * Credential Type stored in the cache\r\n */\r\nvar CredentialType;\r\n(function (CredentialType) {\r\n CredentialType[\"ID_TOKEN\"] = \"IdToken\";\r\n CredentialType[\"ACCESS_TOKEN\"] = \"AccessToken\";\r\n CredentialType[\"REFRESH_TOKEN\"] = \"RefreshToken\";\r\n})(CredentialType || (CredentialType = {}));\r\n/**\r\n * Credential Type stored in the cache\r\n */\r\nvar CacheSchemaType;\r\n(function (CacheSchemaType) {\r\n CacheSchemaType[\"ACCOUNT\"] = \"Account\";\r\n CacheSchemaType[\"CREDENTIAL\"] = \"Credential\";\r\n CacheSchemaType[\"ID_TOKEN\"] = \"IdToken\";\r\n CacheSchemaType[\"ACCESS_TOKEN\"] = \"AccessToken\";\r\n CacheSchemaType[\"REFRESH_TOKEN\"] = \"RefreshToken\";\r\n CacheSchemaType[\"APP_METADATA\"] = \"AppMetadata\";\r\n CacheSchemaType[\"TEMPORARY\"] = \"TempCache\";\r\n CacheSchemaType[\"TELEMETRY\"] = \"Telemetry\";\r\n CacheSchemaType[\"UNDEFINED\"] = \"Undefined\";\r\n CacheSchemaType[\"THROTTLING\"] = \"Throttling\";\r\n})(CacheSchemaType || (CacheSchemaType = {}));\r\n/**\r\n * Combine all cache types\r\n */\r\nvar CacheType;\r\n(function (CacheType) {\r\n CacheType[CacheType[\"ADFS\"] = 1001] = \"ADFS\";\r\n CacheType[CacheType[\"MSA\"] = 1002] = \"MSA\";\r\n CacheType[CacheType[\"MSSTS\"] = 1003] = \"MSSTS\";\r\n CacheType[CacheType[\"GENERIC\"] = 1004] = \"GENERIC\";\r\n CacheType[CacheType[\"ACCESS_TOKEN\"] = 2001] = \"ACCESS_TOKEN\";\r\n CacheType[CacheType[\"REFRESH_TOKEN\"] = 2002] = \"REFRESH_TOKEN\";\r\n CacheType[CacheType[\"ID_TOKEN\"] = 2003] = \"ID_TOKEN\";\r\n CacheType[CacheType[\"APP_METADATA\"] = 3001] = \"APP_METADATA\";\r\n CacheType[CacheType[\"UNDEFINED\"] = 9999] = \"UNDEFINED\";\r\n})(CacheType || (CacheType = {}));\r\n/**\r\n * More Cache related constants\r\n */\r\nvar APP_METADATA = \"appmetadata\";\r\nvar ClientInfo = \"client_info\";\r\nvar THE_FAMILY_ID = \"1\";\r\nvar SERVER_TELEM_CONSTANTS = {\r\n SCHEMA_VERSION: 2,\r\n FAILURE_LIMIT: 3,\r\n CACHE_KEY: \"server-telemetry\",\r\n CATEGORY_SEPARATOR: \"|\",\r\n VALUE_SEPARATOR: \",\"\r\n};\r\n/**\r\n * Constants related to throttling\r\n */\r\nvar ThrottlingConstants = {\r\n // Default time to throttle RequestThumbprint in seconds\r\n DEFAULT_THROTTLE_TIME_SECONDS: 60,\r\n // Default maximum time to throttle in seconds, overrides what the server sends back\r\n DEFAULT_MAX_THROTTLE_TIME_SECONDS: 3600,\r\n // Prefix for storing throttling entries\r\n THROTTLING_PREFIX: \"throttling\"\r\n};\r\nvar Errors = {\r\n INVALID_GRANT_ERROR: \"invalid_grant\",\r\n CLIENT_MISMATCH_ERROR: \"client_mismatch\",\r\n};\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Base type for credentials to be stored in the cache: eg: ACCESS_TOKEN, ID_TOKEN etc\r\n *\r\n * Key:Value Schema:\r\n *\r\n * Key: -----\r\n *\r\n * Value Schema:\r\n * {\r\n * homeAccountId: home account identifier for the auth scheme,\r\n * environment: entity that issued the token, represented as a full host\r\n * credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other\r\n * clientId: client ID of the application\r\n * secret: Actual credential as a string\r\n * familyId: Family ID identifier, usually only used for refresh tokens\r\n * realm: Full tenant or organizational identifier that the account belongs to\r\n * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.\r\n * oboAssertion: access token passed in as part of OBO request\r\n * }\r\n */\r\nvar CredentialEntity = /** @class */ (function () {\r\n function CredentialEntity() {\r\n }\r\n /**\r\n * Generate Account Id key component as per the schema: -\r\n */\r\n CredentialEntity.prototype.generateAccountId = function () {\r\n return CredentialEntity.generateAccountIdForCacheKey(this.homeAccountId, this.environment);\r\n };\r\n /**\r\n * Generate Credential Id key component as per the schema: --\r\n */\r\n CredentialEntity.prototype.generateCredentialId = function () {\r\n return CredentialEntity.generateCredentialIdForCacheKey(this.credentialType, this.clientId, this.realm, this.familyId);\r\n };\r\n /**\r\n * Generate target key component as per schema: \r\n */\r\n CredentialEntity.prototype.generateTarget = function () {\r\n return CredentialEntity.generateTargetForCacheKey(this.target);\r\n };\r\n /**\r\n * generates credential key\r\n */\r\n CredentialEntity.prototype.generateCredentialKey = function () {\r\n return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId);\r\n };\r\n /**\r\n * returns the type of the cache (in this case credential)\r\n */\r\n CredentialEntity.prototype.generateType = function () {\r\n switch (this.credentialType) {\r\n case CredentialType.ID_TOKEN:\r\n return CacheType.ID_TOKEN;\r\n case CredentialType.ACCESS_TOKEN:\r\n return CacheType.ACCESS_TOKEN;\r\n case CredentialType.REFRESH_TOKEN:\r\n return CacheType.REFRESH_TOKEN;\r\n default: {\r\n throw ClientAuthError.createUnexpectedCredentialTypeError();\r\n }\r\n }\r\n };\r\n /**\r\n * helper function to return `CredentialType`\r\n * @param key\r\n */\r\n CredentialEntity.getCredentialType = function (key) {\r\n if (key.indexOf(CredentialType.ACCESS_TOKEN.toLowerCase()) !== -1) {\r\n return CredentialType.ACCESS_TOKEN;\r\n }\r\n else if (key.indexOf(CredentialType.ID_TOKEN.toLowerCase()) !== -1) {\r\n return CredentialType.ID_TOKEN;\r\n }\r\n else if (key.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) !== -1) {\r\n return CredentialType.REFRESH_TOKEN;\r\n }\r\n return Constants.NOT_DEFINED;\r\n };\r\n /**\r\n * generates credential key\r\n */\r\n CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId) {\r\n var credentialKey = [\r\n this.generateAccountIdForCacheKey(homeAccountId, environment),\r\n this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),\r\n this.generateTargetForCacheKey(target),\r\n ];\r\n return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\r\n };\r\n /**\r\n * generates Account Id for keys\r\n * @param homeAccountId\r\n * @param environment\r\n */\r\n CredentialEntity.generateAccountIdForCacheKey = function (homeAccountId, environment) {\r\n var accountId = [homeAccountId, environment];\r\n return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\r\n };\r\n /**\r\n * Generates Credential Id for keys\r\n * @param credentialType\r\n * @param realm\r\n * @param clientId\r\n * @param familyId\r\n */\r\n CredentialEntity.generateCredentialIdForCacheKey = function (credentialType, clientId, realm, familyId) {\r\n var clientOrFamilyId = credentialType === CredentialType.REFRESH_TOKEN\r\n ? familyId || clientId\r\n : clientId;\r\n var credentialId = [\r\n credentialType,\r\n clientOrFamilyId,\r\n realm || \"\",\r\n ];\r\n return credentialId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\r\n };\r\n /**\r\n * Generate target key component as per schema: \r\n */\r\n CredentialEntity.generateTargetForCacheKey = function (scopes) {\r\n return (scopes || \"\").toLowerCase();\r\n };\r\n return CredentialEntity;\r\n}());\n\n/**\r\n * ClientConfigurationErrorMessage class containing string constants used by error codes and messages.\r\n */\r\nvar ClientConfigurationErrorMessage = {\r\n redirectUriNotSet: {\r\n code: \"redirect_uri_empty\",\r\n desc: \"A redirect URI is required for all calls, and none has been set.\"\r\n },\r\n postLogoutUriNotSet: {\r\n code: \"post_logout_uri_empty\",\r\n desc: \"A post logout redirect has not been set.\"\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 authorityUriInsecure: {\r\n code: \"authority_uri_insecure\",\r\n desc: \"Authority URIs must use https. Please see here for valid authority configuration options: https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-js-initializing-client-applications#configuration-options\"\r\n },\r\n urlParseError: {\r\n code: \"url_parse_error\",\r\n desc: \"URL could not be parsed into appropriate segments.\"\r\n },\r\n urlEmptyError: {\r\n code: \"empty_url_error\",\r\n desc: \"URL was empty or null.\"\r\n },\r\n emptyScopesError: {\r\n code: \"empty_input_scopes_error\",\r\n desc: \"Scopes cannot be passed as null, undefined or empty array because they are required to obtain an access token.\"\r\n },\r\n nonArrayScopesError: {\r\n code: \"nonarray_input_scopes_error\",\r\n desc: \"Scopes cannot be passed as non-array.\"\r\n },\r\n clientIdSingleScopeError: {\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'. Please see here for valid configuration options: https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-js-initializing-client-applications#configuration-options\",\r\n },\r\n invalidClaimsRequest: {\r\n code: \"invalid_claims\",\r\n desc: \"Given claims parameter must be a stringified JSON object.\"\r\n },\r\n tokenRequestEmptyError: {\r\n code: \"token_request_empty\",\r\n desc: \"Token request was empty and not found in cache.\"\r\n },\r\n logoutRequestEmptyError: {\r\n code: \"logout_request_empty\",\r\n desc: \"The logout request was null or undefined.\"\r\n },\r\n invalidCodeChallengeMethod: {\r\n code: \"invalid_code_challenge_method\",\r\n desc: \"code_challenge_method passed is invalid. Valid values are \\\"plain\\\" and \\\"S256\\\".\"\r\n },\r\n invalidCodeChallengeParams: {\r\n code: \"pkce_params_missing\",\r\n desc: \"Both params: code_challenge and code_challenge_method are to be passed if to be sent in the request\"\r\n },\r\n knownAuthoritiesAndCloudDiscoveryMetadata: {\r\n code: \"invalid_known_authorities\",\r\n desc: \"knownAuthorities and cloudDiscoveryMetadata cannot both be provided. Please provide cloudDiscoveryMetadata object for AAD, knownAuthorities otherwise.\"\r\n },\r\n invalidCloudDiscoveryMetadata: {\r\n code: \"invalid_cloud_discovery_metadata\",\r\n desc: \"Invalid cloudDiscoveryMetadata provided. Must be a JSON object containing tenant_discovery_endpoint and metadata fields\"\r\n },\r\n untrustedAuthority: {\r\n code: \"untrusted_authority\",\r\n desc: \"The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter.\"\r\n }\r\n};\r\n/**\r\n * Error thrown when there is an error in configuration of the MSAL.js library.\r\n */\r\nvar ClientConfigurationError = /** @class */ (function (_super) {\r\n __extends$1(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 /**\r\n * Creates an error thrown when the redirect uri is empty (not set by caller)\r\n */\r\n ClientConfigurationError.createRedirectUriEmptyError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.redirectUriNotSet.code, ClientConfigurationErrorMessage.redirectUriNotSet.desc);\r\n };\r\n /**\r\n * Creates an error thrown when the post-logout redirect uri is empty (not set by caller)\r\n */\r\n ClientConfigurationError.createPostLogoutRedirectUriEmptyError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.postLogoutUriNotSet.code, ClientConfigurationErrorMessage.postLogoutUriNotSet.desc);\r\n };\r\n /**\r\n * Creates an error thrown when the claims request could not be successfully parsed\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 /**\r\n * Creates an error thrown if authority uri is given an insecure protocol.\r\n * @param urlString\r\n */\r\n ClientConfigurationError.createInsecureAuthorityUriError = function (urlString) {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.authorityUriInsecure.code, ClientConfigurationErrorMessage.authorityUriInsecure.desc + \" Given URI: \" + urlString);\r\n };\r\n /**\r\n * Creates an error thrown if URL string does not parse into separate segments.\r\n * @param urlString\r\n */\r\n ClientConfigurationError.createUrlParseError = function (urlParseError) {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.urlParseError.code, ClientConfigurationErrorMessage.urlParseError.desc + \" Given Error: \" + urlParseError);\r\n };\r\n /**\r\n * Creates an error thrown if URL string is empty or null.\r\n * @param urlString\r\n */\r\n ClientConfigurationError.createUrlEmptyError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.urlEmptyError.code, ClientConfigurationErrorMessage.urlEmptyError.desc);\r\n };\r\n /**\r\n * Error thrown when scopes are not an array\r\n * @param inputScopes\r\n */\r\n ClientConfigurationError.createScopesNonArrayError = function (inputScopes) {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.nonArrayScopesError.code, ClientConfigurationErrorMessage.nonArrayScopesError.desc + \" Given Scopes: \" + inputScopes);\r\n };\r\n /**\r\n * Error thrown when scopes are empty.\r\n * @param scopesValue\r\n */\r\n ClientConfigurationError.createEmptyScopesArrayError = function (inputScopes) {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.emptyScopesError.code, ClientConfigurationErrorMessage.emptyScopesError.desc + \" Given Scopes: \" + inputScopes);\r\n };\r\n /**\r\n * Error thrown when client id scope is not provided as single scope.\r\n * @param inputScopes\r\n */\r\n ClientConfigurationError.createClientIdSingleScopeError = function (inputScopes) {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.clientIdSingleScopeError.code, ClientConfigurationErrorMessage.clientIdSingleScopeError.desc + \" Given Scopes: \" + inputScopes);\r\n };\r\n /**\r\n * Error thrown when prompt is not an allowed type.\r\n * @param promptValue\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 /**\r\n * Creates error thrown when claims parameter is not a stringified JSON object\r\n */\r\n ClientConfigurationError.createInvalidClaimsRequestError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidClaimsRequest.code, ClientConfigurationErrorMessage.invalidClaimsRequest.desc);\r\n };\r\n /**\r\n * Throws error when token request is empty and nothing cached in storage.\r\n */\r\n ClientConfigurationError.createEmptyLogoutRequestError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.logoutRequestEmptyError.code, ClientConfigurationErrorMessage.logoutRequestEmptyError.desc);\r\n };\r\n /**\r\n * Throws error when token request is empty and nothing cached in storage.\r\n */\r\n ClientConfigurationError.createEmptyTokenRequestError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.tokenRequestEmptyError.code, ClientConfigurationErrorMessage.tokenRequestEmptyError.desc);\r\n };\r\n /**\r\n * Throws error when an invalid code_challenge_method is passed by the user\r\n */\r\n ClientConfigurationError.createInvalidCodeChallengeMethodError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidCodeChallengeMethod.code, ClientConfigurationErrorMessage.invalidCodeChallengeMethod.desc);\r\n };\r\n /**\r\n * Throws error when both params: code_challenge and code_challenge_method are not passed together\r\n */\r\n ClientConfigurationError.createInvalidCodeChallengeParamsError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidCodeChallengeParams.code, ClientConfigurationErrorMessage.invalidCodeChallengeParams.desc);\r\n };\r\n /**\r\n * Throws an error when the user passes both knownAuthorities and cloudDiscoveryMetadata\r\n */\r\n ClientConfigurationError.createKnownAuthoritiesCloudDiscoveryMetadataError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.knownAuthoritiesAndCloudDiscoveryMetadata.code, ClientConfigurationErrorMessage.knownAuthoritiesAndCloudDiscoveryMetadata.desc);\r\n };\r\n /**\r\n * Throws an error when the user passes invalid cloudDiscoveryMetadata\r\n */\r\n ClientConfigurationError.createInvalidCloudDiscoveryMetadataError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidCloudDiscoveryMetadata.code, ClientConfigurationErrorMessage.invalidCloudDiscoveryMetadata.desc);\r\n };\r\n /**\r\n * Throws error when provided authority is not a member of the trusted host list\r\n */\r\n ClientConfigurationError.createUntrustedAuthorityError = function () {\r\n return new ClientConfigurationError(ClientConfigurationErrorMessage.untrustedAuthority.code, ClientConfigurationErrorMessage.untrustedAuthority.desc);\r\n };\r\n return ClientConfigurationError;\r\n}(ClientAuthError));\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * The ScopeSet class creates a set of scopes. Scopes are case-insensitive, unique values, so the Set object in JS makes\r\n * the most sense to implement for this class. All scopes are trimmed and converted to lower case strings in intersection and union functions\r\n * to ensure uniqueness of strings.\r\n */\r\nvar ScopeSet = /** @class */ (function () {\r\n function ScopeSet(inputScopes) {\r\n var _this = this;\r\n // Filter empty string and null/undefined array items\r\n var scopeArr = inputScopes ? StringUtils.trimArrayEntries(__spreadArrays$1(inputScopes)) : [];\r\n var filteredInput = scopeArr ? StringUtils.removeEmptyStringsFromArray(scopeArr) : [];\r\n // Validate and filter scopes (validate function throws if validation fails)\r\n this.validateInputScopes(filteredInput);\r\n this.scopes = new Set(); // Iterator in constructor not supported by IE11\r\n filteredInput.forEach(function (scope) { return _this.scopes.add(scope); });\r\n }\r\n /**\r\n * Factory method to create ScopeSet from space-delimited string\r\n * @param inputScopeString\r\n * @param appClientId\r\n * @param scopesRequired\r\n */\r\n ScopeSet.fromString = function (inputScopeString) {\r\n inputScopeString = inputScopeString || \"\";\r\n var inputScopes = inputScopeString.split(\" \");\r\n return new ScopeSet(inputScopes);\r\n };\r\n /**\r\n * Used to validate the scopes input parameter requested by the developer.\r\n * @param {Array} inputScopes - 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 */\r\n ScopeSet.prototype.validateInputScopes = function (inputScopes) {\r\n // Check if scopes are required but not given or is an empty array\r\n if (!inputScopes || inputScopes.length < 1) {\r\n throw ClientConfigurationError.createEmptyScopesArrayError(inputScopes);\r\n }\r\n };\r\n /**\r\n * Check if a given scope is present in this set of scopes.\r\n * @param scope\r\n */\r\n ScopeSet.prototype.containsScope = function (scope) {\r\n var lowerCaseScopes = this.printScopesLowerCase().split(\" \");\r\n var lowerCaseScopesSet = new ScopeSet(lowerCaseScopes);\r\n // compare lowercase scopes\r\n return !StringUtils.isEmpty(scope) ? lowerCaseScopesSet.scopes.has(scope.toLowerCase()) : false;\r\n };\r\n /**\r\n * Check if a set of scopes is present in this set of scopes.\r\n * @param scopeSet\r\n */\r\n ScopeSet.prototype.containsScopeSet = function (scopeSet) {\r\n var _this = this;\r\n if (!scopeSet || scopeSet.scopes.size <= 0) {\r\n return false;\r\n }\r\n return (this.scopes.size >= scopeSet.scopes.size && scopeSet.asArray().every(function (scope) { return _this.containsScope(scope); }));\r\n };\r\n /**\r\n * Check if set of scopes contains only the defaults\r\n */\r\n ScopeSet.prototype.containsOnlyDefaultScopes = function () {\r\n var defaultScopeCount = 0;\r\n if (this.containsScope(Constants.OPENID_SCOPE)) {\r\n defaultScopeCount += 1;\r\n }\r\n if (this.containsScope(Constants.PROFILE_SCOPE)) {\r\n defaultScopeCount += 1;\r\n }\r\n if (this.containsScope(Constants.OFFLINE_ACCESS_SCOPE)) {\r\n defaultScopeCount += 1;\r\n }\r\n return this.scopes.size === defaultScopeCount;\r\n };\r\n /**\r\n * Appends single scope if passed\r\n * @param newScope\r\n */\r\n ScopeSet.prototype.appendScope = function (newScope) {\r\n if (!StringUtils.isEmpty(newScope)) {\r\n this.scopes.add(newScope.trim());\r\n }\r\n };\r\n /**\r\n * Appends multiple scopes if passed\r\n * @param newScopes\r\n */\r\n ScopeSet.prototype.appendScopes = function (newScopes) {\r\n var _this = this;\r\n try {\r\n newScopes.forEach(function (newScope) { return _this.appendScope(newScope); });\r\n }\r\n catch (e) {\r\n throw ClientAuthError.createAppendScopeSetError(e);\r\n }\r\n };\r\n /**\r\n * Removes element from set of scopes.\r\n * @param scope\r\n */\r\n ScopeSet.prototype.removeScope = function (scope) {\r\n if (StringUtils.isEmpty(scope)) {\r\n throw ClientAuthError.createRemoveEmptyScopeFromSetError(scope);\r\n }\r\n this.scopes.delete(scope.trim());\r\n };\r\n /**\r\n * Removes default scopes from set of scopes\r\n * Primarily used to prevent cache misses if the default scopes are not returned from the server\r\n */\r\n ScopeSet.prototype.removeDefaultScopes = function () {\r\n this.scopes.delete(Constants.OFFLINE_ACCESS_SCOPE);\r\n this.scopes.delete(Constants.OPENID_SCOPE);\r\n this.scopes.delete(Constants.PROFILE_SCOPE);\r\n };\r\n /**\r\n * Combines an array of scopes with the current set of scopes.\r\n * @param otherScopes\r\n */\r\n ScopeSet.prototype.unionScopeSets = function (otherScopes) {\r\n if (!otherScopes) {\r\n throw ClientAuthError.createEmptyInputScopeSetError(otherScopes);\r\n }\r\n var unionScopes = new Set(); // Iterator in constructor not supported in IE11\r\n otherScopes.scopes.forEach(function (scope) { return unionScopes.add(scope.toLowerCase()); });\r\n this.scopes.forEach(function (scope) { return unionScopes.add(scope.toLowerCase()); });\r\n return unionScopes;\r\n };\r\n /**\r\n * Check if scopes intersect between this set and another.\r\n * @param otherScopes\r\n */\r\n ScopeSet.prototype.intersectingScopeSets = function (otherScopes) {\r\n if (!otherScopes) {\r\n throw ClientAuthError.createEmptyInputScopeSetError(otherScopes);\r\n }\r\n var unionScopes = this.unionScopeSets(otherScopes);\r\n // Do not allow default scopes to be the only intersecting scopes\r\n if (!otherScopes.containsOnlyDefaultScopes()) {\r\n otherScopes.removeDefaultScopes();\r\n }\r\n var sizeOtherScopes = otherScopes.getScopeCount();\r\n var sizeThisScopes = this.getScopeCount();\r\n var sizeUnionScopes = unionScopes.size;\r\n return sizeUnionScopes < (sizeThisScopes + sizeOtherScopes);\r\n };\r\n /**\r\n * Returns size of set of scopes.\r\n */\r\n ScopeSet.prototype.getScopeCount = function () {\r\n return this.scopes.size;\r\n };\r\n /**\r\n * Returns the scopes as an array of string values\r\n */\r\n ScopeSet.prototype.asArray = function () {\r\n var array = [];\r\n this.scopes.forEach(function (val) { return array.push(val); });\r\n return array;\r\n };\r\n /**\r\n * Prints scopes into a space-delimited string\r\n */\r\n ScopeSet.prototype.printScopes = function () {\r\n if (this.scopes) {\r\n var scopeArr = this.asArray();\r\n return scopeArr.join(\" \");\r\n }\r\n return \"\";\r\n };\r\n /**\r\n * Prints scopes into a space-delimited lower-case string (used for caching)\r\n */\r\n ScopeSet.prototype.printScopesLowerCase = function () {\r\n return this.printScopes().toLowerCase();\r\n };\r\n return ScopeSet;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Authority types supported by MSAL.\r\n */\r\nvar AuthorityType;\r\n(function (AuthorityType) {\r\n AuthorityType[AuthorityType[\"Default\"] = 0] = \"Default\";\r\n AuthorityType[AuthorityType[\"Adfs\"] = 1] = \"Adfs\";\r\n})(AuthorityType || (AuthorityType = {}));\n\n/**\r\n * Url object class which can perform various transformations on url strings.\r\n */\r\nvar UrlString = /** @class */ (function () {\r\n function UrlString(url) {\r\n this._urlString = url;\r\n if (StringUtils.isEmpty(this._urlString)) {\r\n // Throws error if url is empty\r\n throw ClientConfigurationError.createUrlEmptyError();\r\n }\r\n if (StringUtils.isEmpty(this.getHash())) {\r\n this._urlString = UrlString.canonicalizeUri(url);\r\n }\r\n }\r\n Object.defineProperty(UrlString.prototype, \"urlString\", {\r\n get: function () {\r\n return this._urlString;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Ensure urls are lower case and end with a / character.\r\n * @param url\r\n */\r\n UrlString.canonicalizeUri = function (url) {\r\n if (url) {\r\n url = url.toLowerCase();\r\n }\r\n if (url && !StringUtils.endsWith(url, \"/\")) {\r\n url += \"/\";\r\n }\r\n return url;\r\n };\r\n /**\r\n * Throws if urlString passed is not a valid authority URI string.\r\n */\r\n UrlString.prototype.validateAsUri = function () {\r\n // Attempts to parse url for uri components\r\n var components;\r\n try {\r\n components = this.getUrlComponents();\r\n }\r\n catch (e) {\r\n throw ClientConfigurationError.createUrlParseError(e);\r\n }\r\n // Throw error if URI or path segments are not parseable.\r\n if (!components.HostNameAndPort || !components.PathSegments || components.PathSegments.length < 1) {\r\n throw ClientConfigurationError.createUrlParseError(\"Given url string: \" + this.urlString);\r\n }\r\n // Throw error if uri is insecure.\r\n if (!components.Protocol || components.Protocol.toLowerCase() !== \"https:\") {\r\n throw ClientConfigurationError.createInsecureAuthorityUriError(this.urlString);\r\n }\r\n };\r\n /**\r\n * Function to remove query string params from url. Returns the new url.\r\n * @param url\r\n * @param name\r\n */\r\n UrlString.prototype.urlRemoveQueryStringParameter = function (name) {\r\n var regex = new RegExp(\"(\\\\&\" + name + \"=)[^\\&]+\");\r\n this._urlString = this.urlString.replace(regex, \"\");\r\n // name=value&\r\n regex = new RegExp(\"(\" + name + \"=)[^\\&]+&\");\r\n this._urlString = this.urlString.replace(regex, \"\");\r\n // name=value\r\n regex = new RegExp(\"(\" + name + \"=)[^\\&]+\");\r\n this._urlString = this.urlString.replace(regex, \"\");\r\n return this.urlString;\r\n };\r\n UrlString.removeHashFromUrl = function (url) {\r\n return UrlString.canonicalizeUri(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 UrlString.prototype.replaceTenantPath = function (tenantId) {\r\n var urlObject = this.getUrlComponents();\r\n var pathArray = urlObject.PathSegments;\r\n if (tenantId && (pathArray.length !== 0 && (pathArray[0] === AADAuthorityConstants.COMMON || pathArray[0] === AADAuthorityConstants.ORGANIZATIONS))) {\r\n pathArray[0] = tenantId;\r\n }\r\n return UrlString.constructAuthorityUriFromObject(urlObject);\r\n };\r\n /**\r\n * Returns the anchor part(#) of the URL\r\n */\r\n UrlString.prototype.getHash = function () {\r\n return UrlString.parseHash(this.urlString);\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 UrlString.prototype.getUrlComponents = function () {\r\n // https://gist.github.com/curtisz/11139b2cfcaef4a261e0\r\n var regEx = RegExp(\"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\\\?([^#]*))?(#(.*))?\");\r\n // If url string does not match regEx, we throw an error\r\n var match = this.urlString.match(regEx);\r\n if (!match) {\r\n throw ClientConfigurationError.createUrlParseError(\"Given url string: \" + this.urlString);\r\n }\r\n // Url component object\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 return urlComponents;\r\n };\r\n UrlString.getDomainFromUrl = function (url) {\r\n var regEx = RegExp(\"^([^:/?#]+://)?([^/?#]*)\");\r\n var match = url.match(regEx);\r\n if (!match) {\r\n throw ClientConfigurationError.createUrlParseError(\"Given url string: \" + url);\r\n }\r\n return match[2];\r\n };\r\n /**\r\n * Parses hash string from given string. Returns empty string if no hash symbol is found.\r\n * @param hashString\r\n */\r\n UrlString.parseHash = function (hashString) {\r\n var hashIndex1 = hashString.indexOf(\"#\");\r\n var hashIndex2 = hashString.indexOf(\"#/\");\r\n if (hashIndex2 > -1) {\r\n return hashString.substring(hashIndex2 + 2);\r\n }\r\n else if (hashIndex1 > -1) {\r\n return hashString.substring(hashIndex1 + 1);\r\n }\r\n return \"\";\r\n };\r\n UrlString.constructAuthorityUriFromObject = function (urlObject) {\r\n return new UrlString(urlObject.Protocol + \"//\" + urlObject.HostNameAndPort + \"/\" + urlObject.PathSegments.join(\"/\"));\r\n };\r\n /**\r\n * Returns URL hash as server auth code response object.\r\n */\r\n UrlString.getDeserializedHash = function (hash) {\r\n // Check if given hash is empty\r\n if (StringUtils.isEmpty(hash)) {\r\n return {};\r\n }\r\n // Strip the # symbol if present\r\n var parsedHash = UrlString.parseHash(hash);\r\n // If # symbol was not present, above will return empty string, so give original hash value\r\n var deserializedHash = StringUtils.queryStringToObject(StringUtils.isEmpty(parsedHash) ? hash : parsedHash);\r\n // Check if deserialization didn't work\r\n if (!deserializedHash) {\r\n throw ClientAuthError.createHashNotDeserializedError(JSON.stringify(deserializedHash));\r\n }\r\n return deserializedHash;\r\n };\r\n /**\r\n * Check if the hash of the URL string contains known properties\r\n */\r\n UrlString.hashContainsKnownProperties = function (hash) {\r\n if (StringUtils.isEmpty(hash)) {\r\n return false;\r\n }\r\n var parameters = UrlString.getDeserializedHash(hash);\r\n return !!(parameters.code ||\r\n parameters.error_description ||\r\n parameters.error ||\r\n parameters.state);\r\n };\r\n return UrlString;\r\n}());\n\nvar TrustedAuthority = /** @class */ (function () {\r\n function TrustedAuthority() {\r\n }\r\n /**\r\n * Set the CloudDiscoveryMetadata object from knownAuthorities or cloudDiscoveryMetadata passed into the app config\r\n * @param knownAuthorities\r\n * @param cloudDiscoveryMetadata\r\n */\r\n TrustedAuthority.setTrustedAuthoritiesFromConfig = function (knownAuthorities, cloudDiscoveryMetadata) {\r\n if (!this.getTrustedHostList().length) {\r\n if (knownAuthorities.length > 0 && !StringUtils.isEmpty(cloudDiscoveryMetadata)) {\r\n throw ClientConfigurationError.createKnownAuthoritiesCloudDiscoveryMetadataError();\r\n }\r\n this.createCloudDiscoveryMetadataFromKnownAuthorities(knownAuthorities);\r\n try {\r\n if (cloudDiscoveryMetadata) {\r\n var parsedMetadata = JSON.parse(cloudDiscoveryMetadata);\r\n this.saveCloudDiscoveryMetadata(parsedMetadata.metadata);\r\n }\r\n }\r\n catch (e) {\r\n throw ClientConfigurationError.createInvalidCloudDiscoveryMetadataError();\r\n }\r\n }\r\n };\r\n /**\r\n * Called to get metadata from network if CloudDiscoveryMetadata was not populated by config\r\n * @param networkInterface\r\n */\r\n TrustedAuthority.setTrustedAuthoritiesFromNetwork = function (authorityToVerify, networkInterface) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var instanceDiscoveryEndpoint, response, metadata, e_1, host;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n instanceDiscoveryEndpoint = \"\" + Constants.AAD_INSTANCE_DISCOVERY_ENDPT + authorityToVerify.urlString + \"oauth2/v2.0/authorize\";\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 3, , 4]);\r\n return [4 /*yield*/, networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint)];\r\n case 2:\r\n response = _a.sent();\r\n metadata = response.body.metadata;\r\n this.saveCloudDiscoveryMetadata(metadata);\r\n return [3 /*break*/, 4];\r\n case 3:\r\n e_1 = _a.sent();\r\n return [2 /*return*/];\r\n case 4:\r\n host = authorityToVerify.getUrlComponents().HostNameAndPort;\r\n if (this.getTrustedHostList().length > 0 && !this.IsInTrustedHostList(host)) {\r\n // Custom Domain scenario, host is trusted because Instance Discovery call succeeded \r\n this.createCloudDiscoveryMetadataFromKnownAuthorities([host]);\r\n }\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n *\r\n * @param metadata\r\n */\r\n TrustedAuthority.saveCloudDiscoveryMetadata = function (metadata) {\r\n metadata.forEach(function (entry) {\r\n var authorities = entry.aliases;\r\n authorities.forEach(function (authority) {\r\n TrustedAuthority.TrustedHostList[authority.toLowerCase()] = entry;\r\n });\r\n });\r\n };\r\n /**\r\n * Create a generic metadata object for each host passed to knownAuthorities.\r\n * This is mostly useful for B2C or ADFS scenarios\r\n * @param knownAuthorities\r\n */\r\n TrustedAuthority.createCloudDiscoveryMetadataFromKnownAuthorities = function (knownAuthorities) {\r\n var _this = this;\r\n knownAuthorities.forEach(function (authority) {\r\n var authorityDomain = UrlString.getDomainFromUrl(authority).toLowerCase();\r\n _this.TrustedHostList[authorityDomain] = {\r\n preferred_cache: authorityDomain,\r\n preferred_network: authorityDomain,\r\n aliases: [authorityDomain]\r\n };\r\n });\r\n };\r\n TrustedAuthority.getTrustedHostList = function () {\r\n return Object.keys(this.TrustedHostList);\r\n };\r\n /**\r\n * Get metadata for the provided host\r\n * @param host\r\n */\r\n TrustedAuthority.getCloudDiscoveryMetadata = function (host) {\r\n return this.TrustedHostList[host.toLowerCase()] || null;\r\n };\r\n /**\r\n * Checks to see if the host is in a list of trusted hosts\r\n * @param host\r\n */\r\n TrustedAuthority.IsInTrustedHostList = function (host) {\r\n return Object.keys(this.TrustedHostList).indexOf(host.toLowerCase()) > -1;\r\n };\r\n TrustedAuthority.TrustedHostList = {};\r\n return TrustedAuthority;\r\n}());\n\n/**\r\n * The authority class validates the authority URIs used by the user, and retrieves the OpenID Configuration Data from the\r\n * endpoint. It will store the pertinent config data in this object for use during token calls.\r\n */\r\nvar Authority = /** @class */ (function () {\r\n function Authority(authority, networkInterface) {\r\n this.canonicalAuthority = authority;\r\n this._canonicalAuthority.validateAsUri();\r\n this.networkInterface = networkInterface;\r\n }\r\n Object.defineProperty(Authority.prototype, \"authorityType\", {\r\n // See above for AuthorityType\r\n get: function () {\r\n var pathSegments = this.canonicalAuthorityUrlComponents.PathSegments;\r\n if (pathSegments.length && pathSegments[0].toLowerCase() === Constants.ADFS) {\r\n return AuthorityType.Adfs;\r\n }\r\n return AuthorityType.Default;\r\n },\r\n enumerable: true,\r\n configurable: true\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.urlString;\r\n },\r\n /**\r\n * Sets canonical authority.\r\n */\r\n set: function (url) {\r\n this._canonicalAuthority = new UrlString(url);\r\n this._canonicalAuthority.validateAsUri();\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 /**\r\n * Get authority components.\r\n */\r\n get: function () {\r\n if (!this._canonicalAuthorityUrlComponents) {\r\n this._canonicalAuthorityUrlComponents = this._canonicalAuthority.getUrlComponents();\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, \"tenant\", {\r\n /**\r\n * Get tenant for authority.\r\n */\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 /**\r\n * OAuth /authorize endpoint for requests\r\n */\r\n get: function () {\r\n if (this.discoveryComplete()) {\r\n return this.replaceTenant(this.tenantDiscoveryResponse.authorization_endpoint);\r\n }\r\n else {\r\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Authority.prototype, \"tokenEndpoint\", {\r\n /**\r\n * OAuth /token endpoint for requests\r\n */\r\n get: function () {\r\n if (this.discoveryComplete()) {\r\n return this.replaceTenant(this.tenantDiscoveryResponse.token_endpoint);\r\n }\r\n else {\r\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Authority.prototype, \"deviceCodeEndpoint\", {\r\n get: function () {\r\n if (this.discoveryComplete()) {\r\n return this.tenantDiscoveryResponse.token_endpoint.replace(\"/token\", \"/devicecode\");\r\n }\r\n else {\r\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Authority.prototype, \"endSessionEndpoint\", {\r\n /**\r\n * OAuth logout endpoint for requests\r\n */\r\n get: function () {\r\n if (this.discoveryComplete()) {\r\n return this.replaceTenant(this.tenantDiscoveryResponse.end_session_endpoint);\r\n }\r\n else {\r\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Authority.prototype, \"selfSignedJwtAudience\", {\r\n /**\r\n * OAuth issuer for requests\r\n */\r\n get: function () {\r\n if (this.discoveryComplete()) {\r\n return this.replaceTenant(this.tenantDiscoveryResponse.issuer);\r\n }\r\n else {\r\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Replaces tenant in url path with current tenant. Defaults to common.\r\n * @param urlString\r\n */\r\n Authority.prototype.replaceTenant = function (urlString) {\r\n return urlString.replace(/{tenant}|{tenantid}/g, this.tenant);\r\n };\r\n Object.defineProperty(Authority.prototype, \"defaultOpenIdConfigurationEndpoint\", {\r\n /**\r\n * The default open id configuration endpoint for any canonical authority.\r\n */\r\n get: function () {\r\n if (this.authorityType === AuthorityType.Adfs) {\r\n return this.canonicalAuthority + \".well-known/openid-configuration\";\r\n }\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 * Boolean that returns whethr or not tenant discovery has been completed.\r\n */\r\n Authority.prototype.discoveryComplete = function () {\r\n return !!this.tenantDiscoveryResponse;\r\n };\r\n /**\r\n * Gets OAuth endpoints from the given OpenID configuration endpoint.\r\n * @param openIdConfigurationEndpoint\r\n */\r\n Authority.prototype.discoverEndpoints = function (openIdConfigurationEndpoint) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n return __generator$1(this, function (_a) {\r\n return [2 /*return*/, this.networkInterface.sendGetRequestAsync(openIdConfigurationEndpoint)];\r\n });\r\n });\r\n };\r\n Object.defineProperty(Authority.prototype, \"aadInstanceDiscoveryEndpointUrl\", {\r\n // Default AAD Instance Discovery Endpoint\r\n get: function () {\r\n return \"\" + Constants.AAD_INSTANCE_DISCOVERY_ENDPT + this.canonicalAuthority + \"oauth2/v2.0/authorize\";\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Authority.prototype.validateAndSetPreferredNetwork = function () {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var host, preferredNetwork;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n host = this.canonicalAuthorityUrlComponents.HostNameAndPort;\r\n if (!(TrustedAuthority.getTrustedHostList().length === 0)) return [3 /*break*/, 2];\r\n return [4 /*yield*/, TrustedAuthority.setTrustedAuthoritiesFromNetwork(this._canonicalAuthority, this.networkInterface)];\r\n case 1:\r\n _a.sent();\r\n _a.label = 2;\r\n case 2:\r\n if (!TrustedAuthority.IsInTrustedHostList(host)) {\r\n throw ClientConfigurationError.createUntrustedAuthorityError();\r\n }\r\n preferredNetwork = TrustedAuthority.getCloudDiscoveryMetadata(host).preferred_network;\r\n if (host !== preferredNetwork) {\r\n this.canonicalAuthority = this.canonicalAuthority.replace(host, preferredNetwork);\r\n }\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Perform endpoint discovery to discover the /authorize, /token and logout endpoints.\r\n */\r\n Authority.prototype.resolveEndpointsAsync = function () {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var openIdConfigEndpoint, response;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, this.validateAndSetPreferredNetwork()];\r\n case 1:\r\n _a.sent();\r\n openIdConfigEndpoint = this.defaultOpenIdConfigurationEndpoint;\r\n return [4 /*yield*/, this.discoverEndpoints(openIdConfigEndpoint)];\r\n case 2:\r\n response = _a.sent();\r\n this.tenantDiscoveryResponse = response.body;\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * helper function to generate environment from authority object\r\n * @param authority\r\n */\r\n Authority.generateEnvironmentFromAuthority = function (authority) {\r\n var reqEnvironment = authority.canonicalAuthorityUrlComponents.HostNameAndPort;\r\n return TrustedAuthority.getCloudDiscoveryMetadata(reqEnvironment) ? TrustedAuthority.getCloudDiscoveryMetadata(reqEnvironment).preferred_cache : \"\";\r\n };\r\n return Authority;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Function to build a client info object\r\n * @param rawClientInfo\r\n * @param crypto\r\n */\r\nfunction buildClientInfo(rawClientInfo, crypto) {\r\n if (StringUtils.isEmpty(rawClientInfo)) {\r\n throw ClientAuthError.createClientInfoEmptyError(rawClientInfo);\r\n }\r\n try {\r\n var decodedClientInfo = crypto.base64Decode(rawClientInfo);\r\n return JSON.parse(decodedClientInfo);\r\n }\r\n catch (e) {\r\n throw ClientAuthError.createClientInfoDecodingError(e);\r\n }\r\n}\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Type that defines required and optional parameters for an Account field (based on universal cache schema implemented by all MSALs).\r\n *\r\n * Key : Value Schema\r\n *\r\n * Key: --\r\n *\r\n * Value Schema:\r\n * {\r\n * homeAccountId: home account identifier for the auth scheme,\r\n * environment: entity that issued the token, represented as a full host\r\n * realm: Full tenant or organizational identifier that the account belongs to\r\n * localAccountId: Original tenant-specific accountID, usually used for legacy cases\r\n * username: primary username that represents the user, usually corresponds to preferred_username in the v2 endpt\r\n * authorityType: Accounts authority type as a string\r\n * name: Full name for the account, including given name and family name,\r\n * clientInfo: Full base64 encoded client info received from ESTS\r\n * lastModificationTime: last time this entity was modified in the cache\r\n * lastModificationApp:\r\n * oboAssertion: access token passed in as part of OBO request\r\n * }\r\n */\r\nvar AccountEntity = /** @class */ (function () {\r\n function AccountEntity() {\r\n }\r\n /**\r\n * Generate Account Id key component as per the schema: -\r\n */\r\n AccountEntity.prototype.generateAccountId = function () {\r\n var accountId = [this.homeAccountId, this.environment];\r\n return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\r\n };\r\n /**\r\n * Generate Account Cache Key as per the schema: --\r\n */\r\n AccountEntity.prototype.generateAccountKey = function () {\r\n return AccountEntity.generateAccountCacheKey({\r\n homeAccountId: this.homeAccountId,\r\n environment: this.environment,\r\n tenantId: this.realm,\r\n username: this.username\r\n });\r\n };\r\n /**\r\n * returns the type of the cache (in this case account)\r\n */\r\n AccountEntity.prototype.generateType = function () {\r\n switch (this.authorityType) {\r\n case CacheAccountType.ADFS_ACCOUNT_TYPE:\r\n return CacheType.ADFS;\r\n case CacheAccountType.MSAV1_ACCOUNT_TYPE:\r\n return CacheType.MSA;\r\n case CacheAccountType.MSSTS_ACCOUNT_TYPE:\r\n return CacheType.MSSTS;\r\n case CacheAccountType.GENERIC_ACCOUNT_TYPE:\r\n return CacheType.GENERIC;\r\n default: {\r\n throw ClientAuthError.createUnexpectedAccountTypeError();\r\n }\r\n }\r\n };\r\n /**\r\n * Returns the AccountInfo interface for this account.\r\n */\r\n AccountEntity.prototype.getAccountInfo = function () {\r\n return {\r\n homeAccountId: this.homeAccountId,\r\n environment: this.environment,\r\n tenantId: this.realm,\r\n username: this.username,\r\n name: this.name\r\n };\r\n };\r\n /**\r\n * Generates account key from interface\r\n * @param accountInterface\r\n */\r\n AccountEntity.generateAccountCacheKey = function (accountInterface) {\r\n var accountKey = [\r\n accountInterface.homeAccountId,\r\n accountInterface.environment || \"\",\r\n accountInterface.tenantId || \"\",\r\n ];\r\n return accountKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\r\n };\r\n /**\r\n * Build Account cache from IdToken, clientInfo and authority/policy\r\n * @param clientInfo\r\n * @param authority\r\n * @param idToken\r\n * @param policy\r\n */\r\n AccountEntity.createAccount = function (clientInfo, authority, idToken, crypto, oboAssertion) {\r\n var account = new AccountEntity();\r\n account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;\r\n account.clientInfo = clientInfo;\r\n var clientInfoObj = buildClientInfo(clientInfo, crypto);\r\n account.homeAccountId = \"\" + clientInfoObj.uid + Separators.CLIENT_INFO_SEPARATOR + clientInfoObj.utid;\r\n var env = Authority.generateEnvironmentFromAuthority(authority);\r\n if (StringUtils.isEmpty(env)) {\r\n throw ClientAuthError.createInvalidCacheEnvironmentError();\r\n }\r\n account.environment = env;\r\n // non AAD scenarios can have empty realm\r\n account.realm = idToken.claims.tid || \"\";\r\n account.oboAssertion = oboAssertion;\r\n if (idToken) {\r\n // How do you account for MSA CID here?\r\n var localAccountId = !StringUtils.isEmpty(idToken.claims.oid)\r\n ? idToken.claims.oid\r\n : idToken.claims.sid;\r\n account.localAccountId = localAccountId;\r\n /*\r\n * In B2C scenarios the emails claim is used instead of preferred_username and it is an array. In most cases it will contain a single email.\r\n * This field should not be relied upon if a custom policy is configured to return more than 1 email.\r\n */\r\n account.username = idToken.claims.preferred_username || (idToken.claims.emails ? idToken.claims.emails[0] : \"\");\r\n account.name = idToken.claims.name;\r\n }\r\n return account;\r\n };\r\n /**\r\n * Build ADFS account type\r\n * @param authority\r\n * @param idToken\r\n */\r\n AccountEntity.createADFSAccount = function (authority, idToken, oboAssertion) {\r\n var account = new AccountEntity();\r\n account.authorityType = CacheAccountType.ADFS_ACCOUNT_TYPE;\r\n account.homeAccountId = idToken.claims.sub;\r\n // non AAD scenarios can have empty realm\r\n account.realm = \"\";\r\n account.oboAssertion = oboAssertion;\r\n var env = Authority.generateEnvironmentFromAuthority(authority);\r\n if (StringUtils.isEmpty(env)) {\r\n throw ClientAuthError.createInvalidCacheEnvironmentError();\r\n }\r\n account.environment = env;\r\n account.username = idToken.claims.upn;\r\n /*\r\n * add uniqueName to claims\r\n * account.name = idToken.claims.uniqueName;\r\n */\r\n return account;\r\n };\r\n /**\r\n * Validates an entity: checks for all expected params\r\n * @param entity\r\n */\r\n AccountEntity.isAccountEntity = function (entity) {\r\n return (entity.hasOwnProperty(\"homeAccountId\") &&\r\n entity.hasOwnProperty(\"environment\") &&\r\n entity.hasOwnProperty(\"realm\") &&\r\n entity.hasOwnProperty(\"localAccountId\") &&\r\n entity.hasOwnProperty(\"username\") &&\r\n entity.hasOwnProperty(\"authorityType\"));\r\n };\r\n return AccountEntity;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * APP_METADATA Cache\r\n *\r\n * Key:Value Schema:\r\n *\r\n * Key: appmetadata--\r\n *\r\n * Value:\r\n * {\r\n * clientId: client ID of the application\r\n * environment: entity that issued the token, represented as a full host\r\n * familyId: Family ID identifier, '1' represents Microsoft Family\r\n * }\r\n */\r\nvar AppMetadataEntity = /** @class */ (function () {\r\n function AppMetadataEntity() {\r\n }\r\n /**\r\n * Generate AppMetadata Cache Key as per the schema: appmetadata--\r\n */\r\n AppMetadataEntity.prototype.generateAppMetadataKey = function () {\r\n return AppMetadataEntity.generateAppMetadataCacheKey(this.environment, this.clientId);\r\n };\r\n /**\r\n * Generate AppMetadata Cache Key\r\n */\r\n AppMetadataEntity.generateAppMetadataCacheKey = function (environment, clientId) {\r\n var appMetaDataKeyArray = [\r\n APP_METADATA,\r\n environment,\r\n clientId,\r\n ];\r\n return appMetaDataKeyArray.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\r\n };\r\n /**\r\n * Creates AppMetadataEntity\r\n * @param clientId\r\n * @param environment\r\n * @param familyId\r\n */\r\n AppMetadataEntity.createAppMetadataEntity = function (clientId, environment, familyId) {\r\n var appMetadata = new AppMetadataEntity();\r\n appMetadata.clientId = clientId;\r\n appMetadata.environment = environment;\r\n if (familyId) {\r\n appMetadata.familyId = familyId;\r\n }\r\n return appMetadata;\r\n };\r\n /**\r\n * Validates an entity: checks for all expected params\r\n * @param entity\r\n */\r\n AppMetadataEntity.isAppMetadataEntity = function (key, entity) {\r\n return (key.indexOf(APP_METADATA) === 0 &&\r\n entity.hasOwnProperty(\"clientId\") &&\r\n entity.hasOwnProperty(\"environment\"));\r\n };\r\n return AppMetadataEntity;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.\r\n */\r\nvar CacheManager = /** @class */ (function () {\r\n function CacheManager() {\r\n }\r\n /**\r\n * Returns all accounts in cache\r\n */\r\n CacheManager.prototype.getAllAccounts = function () {\r\n var currentAccounts = this.getAccountsFilteredBy();\r\n var accountValues = Object.keys(currentAccounts).map(function (accountKey) { return currentAccounts[accountKey]; });\r\n var numAccounts = accountValues.length;\r\n if (numAccounts < 1) {\r\n return [];\r\n }\r\n else {\r\n var allAccounts = accountValues.map(function (value) {\r\n var accountObj = new AccountEntity();\r\n accountObj = CacheManager.toObject(accountObj, value);\r\n return accountObj.getAccountInfo();\r\n });\r\n return allAccounts;\r\n }\r\n };\r\n /**\r\n * saves a cache record\r\n * @param cacheRecord\r\n */\r\n CacheManager.prototype.saveCacheRecord = function (cacheRecord) {\r\n if (!cacheRecord) {\r\n throw ClientAuthError.createNullOrUndefinedCacheRecord();\r\n }\r\n if (!!cacheRecord.account) {\r\n this.saveAccount(cacheRecord.account);\r\n }\r\n if (!!cacheRecord.idToken) {\r\n this.saveCredential(cacheRecord.idToken);\r\n }\r\n if (!!cacheRecord.accessToken) {\r\n this.saveAccessToken(cacheRecord.accessToken);\r\n }\r\n if (!!cacheRecord.refreshToken) {\r\n this.saveCredential(cacheRecord.refreshToken);\r\n }\r\n };\r\n /**\r\n * saves account into cache\r\n * @param account\r\n */\r\n CacheManager.prototype.saveAccount = function (account) {\r\n var key = account.generateAccountKey();\r\n this.setItem(key, account, CacheSchemaType.ACCOUNT);\r\n };\r\n /**\r\n * saves credential - accessToken, idToken or refreshToken into cache\r\n * @param credential\r\n */\r\n CacheManager.prototype.saveCredential = function (credential) {\r\n var key = credential.generateCredentialKey();\r\n this.setItem(key, credential, CacheSchemaType.CREDENTIAL);\r\n };\r\n /**\r\n * saves access token credential\r\n * @param credential\r\n */\r\n CacheManager.prototype.saveAccessToken = function (credential) {\r\n var _this = this;\r\n var currentTokenCache = this.getCredentialsFilteredBy({\r\n clientId: credential.clientId,\r\n credentialType: CredentialType.ACCESS_TOKEN,\r\n environment: credential.environment,\r\n homeAccountId: credential.homeAccountId,\r\n realm: credential.realm,\r\n });\r\n var currentScopes = ScopeSet.fromString(credential.target);\r\n var currentAccessTokens = Object.keys(currentTokenCache.accessTokens).map(function (key) { return currentTokenCache.accessTokens[key]; });\r\n if (currentAccessTokens) {\r\n currentAccessTokens.forEach(function (tokenEntity) {\r\n var tokenScopeSet = ScopeSet.fromString(tokenEntity.target);\r\n if (tokenScopeSet.intersectingScopeSets(currentScopes)) {\r\n _this.removeCredential(tokenEntity);\r\n }\r\n });\r\n }\r\n this.saveCredential(credential);\r\n };\r\n /**\r\n * retrieve an account entity given the cache key\r\n * @param key\r\n */\r\n CacheManager.prototype.getAccount = function (key) {\r\n // don't parse any non-account type cache entities\r\n if (CredentialEntity.getCredentialType(key) !== Constants.NOT_DEFINED || this.isAppMetadata(key)) {\r\n return null;\r\n }\r\n // Attempt retrieval\r\n var entity;\r\n try {\r\n entity = this.getItem(key, CacheSchemaType.ACCOUNT);\r\n }\r\n catch (e) {\r\n return null;\r\n }\r\n // Authority type is required for accounts, return if it is not available (not an account entity)\r\n if (!entity || StringUtils.isEmpty(entity.authorityType)) {\r\n return null;\r\n }\r\n return entity;\r\n };\r\n /**\r\n * retrieve a credential - accessToken, idToken or refreshToken; given the cache key\r\n * @param key\r\n */\r\n CacheManager.prototype.getCredential = function (key) {\r\n return this.getItem(key, CacheSchemaType.CREDENTIAL);\r\n };\r\n /**\r\n * retrieve an appmetadata entity given the cache key\r\n * @param key\r\n */\r\n CacheManager.prototype.getAppMetadata = function (key) {\r\n return this.getItem(key, CacheSchemaType.APP_METADATA);\r\n };\r\n /**\r\n * retrieve accounts matching all provided filters; if no filter is set, get all accounts\r\n * not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared\r\n * @param homeAccountId\r\n * @param environment\r\n * @param realm\r\n */\r\n CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {\r\n return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : \"\", accountFilter ? accountFilter.environment : \"\", accountFilter ? accountFilter.realm : \"\");\r\n };\r\n /**\r\n * retrieve accounts matching all provided filters; if no filter is set, get all accounts\r\n * not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared\r\n * @param homeAccountId\r\n * @param environment\r\n * @param realm\r\n */\r\n CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm) {\r\n var _this = this;\r\n var allCacheKeys = this.getKeys();\r\n var matchingAccounts = {};\r\n allCacheKeys.forEach(function (cacheKey) {\r\n var entity = _this.getAccount(cacheKey);\r\n if (!entity) {\r\n return null;\r\n }\r\n if (!StringUtils.isEmpty(homeAccountId) && !_this.matchHomeAccountId(entity, homeAccountId)) {\r\n return;\r\n }\r\n if (!StringUtils.isEmpty(environment) && !_this.matchEnvironment(entity, environment)) {\r\n return;\r\n }\r\n if (!StringUtils.isEmpty(realm) && !_this.matchRealm(entity, realm)) {\r\n return;\r\n }\r\n matchingAccounts[cacheKey] = entity;\r\n });\r\n return matchingAccounts;\r\n };\r\n /**\r\n * retrieve credentails matching all provided filters; if no filter is set, get all credentials\r\n * @param homeAccountId\r\n * @param environment\r\n * @param credentialType\r\n * @param clientId\r\n * @param realm\r\n * @param target\r\n */\r\n CacheManager.prototype.getCredentialsFilteredBy = function (filter) {\r\n return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion);\r\n };\r\n /**\r\n * Support function to help match credentials\r\n * @param homeAccountId\r\n * @param environment\r\n * @param credentialType\r\n * @param clientId\r\n * @param realm\r\n * @param target\r\n */\r\n CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion) {\r\n var _this = this;\r\n var allCacheKeys = this.getKeys();\r\n var matchingCredentials = {\r\n idTokens: {},\r\n accessTokens: {},\r\n refreshTokens: {},\r\n };\r\n allCacheKeys.forEach(function (cacheKey) {\r\n var entity;\r\n // don't parse any non-credential type cache entities\r\n var credType = CredentialEntity.getCredentialType(cacheKey);\r\n if (credType === Constants.NOT_DEFINED) {\r\n return;\r\n }\r\n // Attempt retrieval\r\n try {\r\n entity = _this.getItem(cacheKey, CacheSchemaType.CREDENTIAL);\r\n }\r\n catch (e) {\r\n return;\r\n }\r\n if (!StringUtils.isEmpty(oboAssertion) && !_this.matchOboAssertion(entity, oboAssertion)) {\r\n return;\r\n }\r\n if (!StringUtils.isEmpty(homeAccountId) && !_this.matchHomeAccountId(entity, homeAccountId)) {\r\n return;\r\n }\r\n if (!StringUtils.isEmpty(environment) && !_this.matchEnvironment(entity, environment)) {\r\n return;\r\n }\r\n if (!StringUtils.isEmpty(realm) && !_this.matchRealm(entity, realm)) {\r\n return;\r\n }\r\n if (!StringUtils.isEmpty(credentialType) && !_this.matchCredentialType(entity, credentialType)) {\r\n return;\r\n }\r\n if (!StringUtils.isEmpty(clientId) && !_this.matchClientId(entity, clientId)) {\r\n return;\r\n }\r\n if (!StringUtils.isEmpty(familyId) && !_this.matchFamilyId(entity, familyId)) {\r\n return;\r\n }\r\n /*\r\n * idTokens do not have \"target\", target specific refreshTokens do exist for some types of authentication\r\n * Resource specific refresh tokens case will be added when the support is deemed necessary\r\n */\r\n if (!StringUtils.isEmpty(target) && !_this.matchTarget(entity, target)) {\r\n return;\r\n }\r\n switch (credType) {\r\n case CredentialType.ID_TOKEN:\r\n matchingCredentials.idTokens[cacheKey] = entity;\r\n break;\r\n case CredentialType.ACCESS_TOKEN:\r\n matchingCredentials.accessTokens[cacheKey] = entity;\r\n break;\r\n case CredentialType.REFRESH_TOKEN:\r\n matchingCredentials.refreshTokens[cacheKey] = entity;\r\n break;\r\n }\r\n });\r\n return matchingCredentials;\r\n };\r\n /**\r\n * Removes all accounts and related tokens from cache.\r\n */\r\n CacheManager.prototype.removeAllAccounts = function () {\r\n var _this = this;\r\n var allCacheKeys = this.getKeys();\r\n allCacheKeys.forEach(function (cacheKey) {\r\n var entity = _this.getAccount(cacheKey);\r\n if (!entity) {\r\n return;\r\n }\r\n _this.removeAccount(cacheKey);\r\n });\r\n return true;\r\n };\r\n /**\r\n * returns a boolean if the given account is removed\r\n * @param account\r\n */\r\n CacheManager.prototype.removeAccount = function (accountKey) {\r\n var account = this.getAccount(accountKey);\r\n if (!account) {\r\n throw ClientAuthError.createNoAccountFoundError();\r\n }\r\n return (this.removeAccountContext(account) && this.removeItem(accountKey, CacheSchemaType.ACCOUNT));\r\n };\r\n /**\r\n * returns a boolean if the given account is removed\r\n * @param account\r\n */\r\n CacheManager.prototype.removeAccountContext = function (account) {\r\n var _this = this;\r\n var allCacheKeys = this.getKeys();\r\n var accountId = account.generateAccountId();\r\n allCacheKeys.forEach(function (cacheKey) {\r\n // don't parse any non-credential type cache entities\r\n if (CredentialEntity.getCredentialType(cacheKey) === Constants.NOT_DEFINED) {\r\n return;\r\n }\r\n var cacheEntity = _this.getItem(cacheKey, CacheSchemaType.CREDENTIAL);\r\n if (!!cacheEntity && accountId === cacheEntity.generateAccountId()) {\r\n _this.removeCredential(cacheEntity);\r\n }\r\n });\r\n return true;\r\n };\r\n /**\r\n * returns a boolean if the given credential is removed\r\n * @param credential\r\n */\r\n CacheManager.prototype.removeCredential = function (credential) {\r\n var key = credential.generateCredentialKey();\r\n return this.removeItem(key, CacheSchemaType.CREDENTIAL);\r\n };\r\n /**\r\n * Removes all app metadata objects from cache.\r\n */\r\n CacheManager.prototype.removeAppMetadata = function () {\r\n var _this = this;\r\n var allCacheKeys = this.getKeys();\r\n allCacheKeys.forEach(function (cacheKey) {\r\n if (_this.isAppMetadata(cacheKey)) {\r\n _this.removeItem(cacheKey, CacheSchemaType.APP_METADATA);\r\n }\r\n });\r\n return true;\r\n };\r\n /**\r\n * Retrieve the cached credentials into a cacherecord\r\n * @param account\r\n * @param clientId\r\n * @param scopes\r\n * @param environment\r\n */\r\n CacheManager.prototype.readCacheRecord = function (account, clientId, scopes, environment) {\r\n var cachedAccount = this.readAccountFromCache(account);\r\n var cachedIdToken = this.readIdTokenFromCache(clientId, account);\r\n var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes);\r\n var cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);\r\n var cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);\r\n return {\r\n account: cachedAccount,\r\n idToken: cachedIdToken,\r\n accessToken: cachedAccessToken,\r\n refreshToken: cachedRefreshToken,\r\n appMetadata: cachedAppMetadata,\r\n };\r\n };\r\n /**\r\n * Retrieve AccountEntity from cache\r\n * @param account\r\n */\r\n CacheManager.prototype.readAccountFromCache = function (account) {\r\n var accountKey = AccountEntity.generateAccountCacheKey(account);\r\n return this.getAccount(accountKey);\r\n };\r\n /**\r\n * Retrieve IdTokenEntity from cache\r\n * @param clientId\r\n * @param account\r\n * @param inputRealm\r\n */\r\n CacheManager.prototype.readIdTokenFromCache = function (clientId, account) {\r\n var idTokenKey = CredentialEntity.generateCredentialCacheKey(account.homeAccountId, account.environment, CredentialType.ID_TOKEN, clientId, account.tenantId);\r\n return this.getCredential(idTokenKey);\r\n };\r\n /**\r\n * Retrieve AccessTokenEntity from cache\r\n * @param clientId\r\n * @param account\r\n * @param scopes\r\n * @param inputRealm\r\n */\r\n CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, scopes) {\r\n var accessTokenFilter = {\r\n homeAccountId: account.homeAccountId,\r\n environment: account.environment,\r\n credentialType: CredentialType.ACCESS_TOKEN,\r\n clientId: clientId,\r\n realm: account.tenantId,\r\n target: scopes.printScopesLowerCase(),\r\n };\r\n var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);\r\n var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });\r\n var numAccessTokens = accessTokens.length;\r\n if (numAccessTokens < 1) {\r\n return null;\r\n }\r\n else if (numAccessTokens > 1) {\r\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\r\n }\r\n return accessTokens[0];\r\n };\r\n /**\r\n * Helper to retrieve the appropriate refresh token from cache\r\n * @param clientId\r\n * @param account\r\n * @param familyRT\r\n */\r\n CacheManager.prototype.readRefreshTokenFromCache = function (clientId, account, familyRT) {\r\n var id = familyRT ? THE_FAMILY_ID : null;\r\n var refreshTokenFilter = {\r\n homeAccountId: account.homeAccountId,\r\n environment: account.environment,\r\n credentialType: CredentialType.REFRESH_TOKEN,\r\n clientId: clientId,\r\n familyId: id\r\n };\r\n var credentialCache = this.getCredentialsFilteredBy(refreshTokenFilter);\r\n var refreshTokens = Object.keys(credentialCache.refreshTokens).map(function (key) { return credentialCache.refreshTokens[key]; });\r\n var numRefreshTokens = refreshTokens.length;\r\n if (numRefreshTokens < 1) {\r\n return null;\r\n }\r\n // address the else case after remove functions address environment aliases\r\n return refreshTokens[0];\r\n };\r\n /**\r\n * Retrieve AppMetadataEntity from cache\r\n */\r\n CacheManager.prototype.readAppMetadataFromCache = function (environment, clientId) {\r\n var cacheKey = AppMetadataEntity.generateAppMetadataCacheKey(environment, clientId);\r\n return this.getAppMetadata(cacheKey);\r\n };\r\n /**\r\n * Return the family_id value associated with FOCI\r\n * @param environment\r\n * @param clientId\r\n */\r\n CacheManager.prototype.isAppMetadataFOCI = function (environment, clientId) {\r\n var appMetadata = this.readAppMetadataFromCache(environment, clientId);\r\n return appMetadata && appMetadata.familyId === THE_FAMILY_ID;\r\n };\r\n /**\r\n * helper to match account ids\r\n * @param value\r\n * @param homeAccountId\r\n */\r\n CacheManager.prototype.matchHomeAccountId = function (entity, homeAccountId) {\r\n return entity.homeAccountId && homeAccountId === entity.homeAccountId;\r\n };\r\n /**\r\n * helper to match assertion\r\n * @param value\r\n * @param oboAssertion\r\n */\r\n CacheManager.prototype.matchOboAssertion = function (entity, oboAssertion) {\r\n return entity.oboAssertion && oboAssertion === entity.oboAssertion;\r\n };\r\n /**\r\n * helper to match environment\r\n * @param value\r\n * @param environment\r\n */\r\n CacheManager.prototype.matchEnvironment = function (entity, environment) {\r\n var cloudMetadata = TrustedAuthority.getCloudDiscoveryMetadata(environment);\r\n if (cloudMetadata && cloudMetadata.aliases.indexOf(entity.environment) > -1) {\r\n return true;\r\n }\r\n return false;\r\n };\r\n /**\r\n * helper to match credential type\r\n * @param entity\r\n * @param credentialType\r\n */\r\n CacheManager.prototype.matchCredentialType = function (entity, credentialType) {\r\n return (entity.credentialType && credentialType.toLowerCase() === entity.credentialType.toLowerCase());\r\n };\r\n /**\r\n * helper to match client ids\r\n * @param entity\r\n * @param clientId\r\n */\r\n CacheManager.prototype.matchClientId = function (entity, clientId) {\r\n return entity.clientId && clientId === entity.clientId;\r\n };\r\n /**\r\n * helper to match family ids\r\n * @param entity\r\n * @param familyId\r\n */\r\n CacheManager.prototype.matchFamilyId = function (entity, familyId) {\r\n return entity.familyId && familyId === entity.familyId;\r\n };\r\n /**\r\n * helper to match realm\r\n * @param entity\r\n * @param realm\r\n */\r\n CacheManager.prototype.matchRealm = function (entity, realm) {\r\n return entity.realm && realm === entity.realm;\r\n };\r\n /**\r\n * Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.\r\n * @param entity\r\n * @param target\r\n */\r\n CacheManager.prototype.matchTarget = function (entity, target) {\r\n if (entity.credentialType !== CredentialType.ACCESS_TOKEN || StringUtils.isEmpty(entity.target)) {\r\n return false;\r\n }\r\n var entityScopeSet = ScopeSet.fromString(entity.target);\r\n var requestTargetScopeSet = ScopeSet.fromString(target);\r\n if (!requestTargetScopeSet.containsOnlyDefaultScopes()) {\r\n requestTargetScopeSet.removeDefaultScopes(); // ignore default scopes\r\n }\r\n return entityScopeSet.containsScopeSet(requestTargetScopeSet);\r\n };\r\n /**\r\n * returns if a given cache entity is of the type appmetadata\r\n * @param key\r\n */\r\n CacheManager.prototype.isAppMetadata = function (key) {\r\n return key.indexOf(APP_METADATA) !== -1;\r\n };\r\n /**\r\n * Helper to convert serialized data to object\r\n * @param obj\r\n * @param json\r\n */\r\n CacheManager.toObject = function (obj, json) {\r\n for (var propertyName in json) {\r\n obj[propertyName] = json[propertyName];\r\n }\r\n return obj;\r\n };\r\n return CacheManager;\r\n}());\r\nvar DefaultStorageClass = /** @class */ (function (_super) {\r\n __extends$1(DefaultStorageClass, _super);\r\n function DefaultStorageClass() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n DefaultStorageClass.prototype.setItem = function () {\r\n var notImplErr = \"Storage interface - setItem() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n };\r\n DefaultStorageClass.prototype.getItem = function () {\r\n var notImplErr = \"Storage interface - getItem() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n };\r\n DefaultStorageClass.prototype.removeItem = function () {\r\n var notImplErr = \"Storage interface - removeItem() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n };\r\n DefaultStorageClass.prototype.containsKey = function () {\r\n var notImplErr = \"Storage interface - containsKey() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n };\r\n DefaultStorageClass.prototype.getKeys = function () {\r\n var notImplErr = \"Storage interface - getKeys() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n };\r\n DefaultStorageClass.prototype.clear = function () {\r\n var notImplErr = \"Storage interface - clear() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n };\r\n return DefaultStorageClass;\r\n}(CacheManager));\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n// Token renewal offset default in seconds\r\nvar DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;\r\nvar DEFAULT_AUTH_OPTIONS = {\r\n clientId: \"\",\r\n authority: null,\r\n knownAuthorities: [],\r\n cloudDiscoveryMetadata: \"\",\r\n clientCapabilities: []\r\n};\r\nvar DEFAULT_SYSTEM_OPTIONS = {\r\n tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC\r\n};\r\nvar DEFAULT_LOGGER_IMPLEMENTATION = {\r\n loggerCallback: function () {\r\n // allow users to not set loggerCallback\r\n },\r\n piiLoggingEnabled: false,\r\n logLevel: LogLevel.Info\r\n};\r\nvar DEFAULT_NETWORK_IMPLEMENTATION = {\r\n sendGetRequestAsync: function () {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var notImplErr;\r\n return __generator$1(this, function (_a) {\r\n notImplErr = \"Network interface - sendGetRequestAsync() has not been implemented\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n });\r\n });\r\n },\r\n sendPostRequestAsync: function () {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var notImplErr;\r\n return __generator$1(this, function (_a) {\r\n notImplErr = \"Network interface - sendPostRequestAsync() has not been implemented\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n });\r\n });\r\n }\r\n};\r\nvar DEFAULT_CRYPTO_IMPLEMENTATION = {\r\n createNewGuid: function () {\r\n var notImplErr = \"Crypto interface - createNewGuid() has not been implemented\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n },\r\n base64Decode: function () {\r\n var notImplErr = \"Crypto interface - base64Decode() has not been implemented\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n },\r\n base64Encode: function () {\r\n var notImplErr = \"Crypto interface - base64Encode() has not been implemented\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n },\r\n generatePkceCodes: function () {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var notImplErr;\r\n return __generator$1(this, function (_a) {\r\n notImplErr = \"Crypto interface - generatePkceCodes() has not been implemented\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n });\r\n });\r\n }\r\n};\r\nvar DEFAULT_LIBRARY_INFO = {\r\n sku: Constants.SKU,\r\n version: version,\r\n cpu: \"\",\r\n os: \"\"\r\n};\r\nvar DEFAULT_CLIENT_CREDENTIALS = {\r\n clientSecret: \"\",\r\n clientAssertion: null\r\n};\r\n/**\r\n * Function that sets the default options when not explicitly configured from app developer\r\n *\r\n * @param Configuration\r\n *\r\n * @returns Configuration\r\n */\r\nfunction buildClientConfiguration(_a) {\r\n var userAuthOptions = _a.authOptions, userSystemOptions = _a.systemOptions, userLoggerOption = _a.loggerOptions, storageImplementation = _a.storageInterface, networkImplementation = _a.networkInterface, cryptoImplementation = _a.cryptoInterface, clientCredentials = _a.clientCredentials, libraryInfo = _a.libraryInfo, serverTelemetryManager = _a.serverTelemetryManager;\r\n return {\r\n authOptions: __assign$1(__assign$1({}, DEFAULT_AUTH_OPTIONS), userAuthOptions),\r\n systemOptions: __assign$1(__assign$1({}, DEFAULT_SYSTEM_OPTIONS), userSystemOptions),\r\n loggerOptions: __assign$1(__assign$1({}, DEFAULT_LOGGER_IMPLEMENTATION), userLoggerOption),\r\n storageInterface: storageImplementation || new DefaultStorageClass(),\r\n networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,\r\n cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,\r\n clientCredentials: clientCredentials || DEFAULT_CLIENT_CREDENTIALS,\r\n libraryInfo: __assign$1(__assign$1({}, DEFAULT_LIBRARY_INFO), libraryInfo),\r\n serverTelemetryManager: serverTelemetryManager || null\r\n };\r\n}\n\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 __extends$1(ServerError, _super);\r\n function ServerError(errorCode, errorMessage, subError) {\r\n var _this = _super.call(this, errorCode, errorMessage) || this;\r\n _this.name = \"ServerError\";\r\n _this.subError = subError;\r\n Object.setPrototypeOf(_this, ServerError.prototype);\r\n return _this;\r\n }\r\n return ServerError;\r\n}(AuthError));\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nvar ThrottlingUtils = /** @class */ (function () {\r\n function ThrottlingUtils() {\r\n }\r\n /**\r\n * Prepares a RequestThumbprint to be stored as a key.\r\n * @param thumbprint\r\n */\r\n ThrottlingUtils.generateThrottlingStorageKey = function (thumbprint) {\r\n return ThrottlingConstants.THROTTLING_PREFIX + \".\" + JSON.stringify(thumbprint);\r\n };\r\n /**\r\n * Performs necessary throttling checks before a network request.\r\n * @param cacheManager\r\n * @param thumbprint\r\n */\r\n ThrottlingUtils.preProcess = function (cacheManager, thumbprint) {\r\n var key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);\r\n var value = cacheManager.getItem(key, CacheSchemaType.THROTTLING);\r\n if (value) {\r\n if (value.throttleTime < Date.now()) {\r\n cacheManager.removeItem(key, CacheSchemaType.THROTTLING);\r\n return;\r\n }\r\n throw new ServerError(value.errorCodes.join(\" \"), value.errorMessage, value.subError);\r\n }\r\n };\r\n /**\r\n * Performs necessary throttling checks after a network request.\r\n * @param cacheManager\r\n * @param thumbprint\r\n * @param response\r\n */\r\n ThrottlingUtils.postProcess = function (cacheManager, thumbprint, response) {\r\n if (ThrottlingUtils.checkResponseStatus(response) || ThrottlingUtils.checkResponseForRetryAfter(response)) {\r\n var thumbprintValue = {\r\n throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[HeaderNames.RETRY_AFTER])),\r\n error: response.body.error,\r\n errorCodes: response.body.error_codes,\r\n errorMessage: response.body.error_description,\r\n subError: response.body.suberror\r\n };\r\n cacheManager.setItem(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue, CacheSchemaType.THROTTLING);\r\n }\r\n };\r\n /**\r\n * Checks a NetworkResponse object's status codes against 429 or 5xx\r\n * @param response\r\n */\r\n ThrottlingUtils.checkResponseStatus = function (response) {\r\n return response.status == 429 || response.status >= 500 && response.status < 600;\r\n };\r\n /**\r\n * Checks a NetworkResponse object's RetryAfter header\r\n * @param response\r\n */\r\n ThrottlingUtils.checkResponseForRetryAfter = function (response) {\r\n if (response.headers) {\r\n return response.headers.hasOwnProperty(HeaderNames.RETRY_AFTER) && (response.status < 200 || response.status >= 300);\r\n }\r\n return false;\r\n };\r\n /**\r\n * Calculates the Unix-time value for a throttle to expire given throttleTime in seconds.\r\n * @param throttleTime\r\n */\r\n ThrottlingUtils.calculateThrottleTime = function (throttleTime) {\r\n if (throttleTime <= 0) {\r\n throttleTime = null;\r\n }\r\n var currentSeconds = Date.now() / 1000;\r\n return Math.floor(Math.min(currentSeconds + (throttleTime || ThrottlingConstants.DEFAULT_THROTTLE_TIME_SECONDS), currentSeconds + ThrottlingConstants.DEFAULT_MAX_THROTTLE_TIME_SECONDS) * 1000);\r\n };\r\n ThrottlingUtils.removeThrottle = function (cacheManager, clientId, authority, scopes, homeAccountIdentifier) {\r\n var thumbprint = {\r\n clientId: clientId,\r\n authority: authority,\r\n scopes: scopes,\r\n homeAccountIdentifier: homeAccountIdentifier\r\n };\r\n var key = this.generateThrottlingStorageKey(thumbprint);\r\n return cacheManager.removeItem(key, CacheSchemaType.THROTTLING);\r\n };\r\n return ThrottlingUtils;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nvar NetworkManager = /** @class */ (function () {\r\n function NetworkManager(networkClient, cacheManager) {\r\n this.networkClient = networkClient;\r\n this.cacheManager = cacheManager;\r\n }\r\n /**\r\n * Wraps sendPostRequestAsync with necessary preflight and postflight logic\r\n * @param thumbprint\r\n * @param tokenEndpoint\r\n * @param options\r\n */\r\n NetworkManager.prototype.sendPostRequest = function (thumbprint, tokenEndpoint, options) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var response;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n ThrottlingUtils.preProcess(this.cacheManager, thumbprint);\r\n return [4 /*yield*/, this.networkClient.sendPostRequestAsync(tokenEndpoint, options)];\r\n case 1:\r\n response = _a.sent();\r\n ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);\r\n // Placeholder for Telemetry hook\r\n return [2 /*return*/, response];\r\n }\r\n });\r\n });\r\n };\r\n return NetworkManager;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.\r\n */\r\nvar BaseClient = /** @class */ (function () {\r\n function BaseClient(configuration) {\r\n // Set the configuration\r\n this.config = buildClientConfiguration(configuration);\r\n // Initialize the logger\r\n this.logger = new Logger(this.config.loggerOptions);\r\n // Initialize crypto\r\n this.cryptoUtils = this.config.cryptoInterface;\r\n // Initialize storage interface\r\n this.cacheManager = this.config.storageInterface;\r\n // Set the network interface\r\n this.networkClient = this.config.networkInterface;\r\n // Set the NetworkManager\r\n this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);\r\n // Set TelemetryManager\r\n this.serverTelemetryManager = this.config.serverTelemetryManager;\r\n TrustedAuthority.setTrustedAuthoritiesFromConfig(this.config.authOptions.knownAuthorities, this.config.authOptions.cloudDiscoveryMetadata);\r\n this.authority = this.config.authOptions.authority;\r\n }\r\n /**\r\n * Creates default headers for requests to token endpoint\r\n */\r\n BaseClient.prototype.createDefaultTokenRequestHeaders = function () {\r\n var headers = this.createDefaultLibraryHeaders();\r\n headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;\r\n headers[HeaderNames.X_MS_LIB_CAPABILITY] = HeaderNames.X_MS_LIB_CAPABILITY_VALUE;\r\n if (this.serverTelemetryManager) {\r\n headers[HeaderNames.X_CLIENT_CURR_TELEM] = this.serverTelemetryManager.generateCurrentRequestHeaderValue();\r\n headers[HeaderNames.X_CLIENT_LAST_TELEM] = this.serverTelemetryManager.generateLastRequestHeaderValue();\r\n }\r\n return headers;\r\n };\r\n /**\r\n * addLibraryData\r\n */\r\n BaseClient.prototype.createDefaultLibraryHeaders = function () {\r\n var headers = {};\r\n // client info headers\r\n headers[AADServerParamKeys.X_CLIENT_SKU] = this.config.libraryInfo.sku;\r\n headers[AADServerParamKeys.X_CLIENT_VER] = this.config.libraryInfo.version;\r\n headers[AADServerParamKeys.X_CLIENT_OS] = this.config.libraryInfo.os;\r\n headers[AADServerParamKeys.X_CLIENT_CPU] = this.config.libraryInfo.cpu;\r\n return headers;\r\n };\r\n /**\r\n * Http post to token endpoint\r\n * @param tokenEndpoint\r\n * @param queryString\r\n * @param headers\r\n * @param thumbprint\r\n */\r\n BaseClient.prototype.executePostToTokenEndpoint = function (tokenEndpoint, queryString, headers, thumbprint) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var response;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers })];\r\n case 1:\r\n response = _a.sent();\r\n if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {\r\n // Telemetry data successfully logged by server, clear Telemetry cache\r\n this.config.serverTelemetryManager.clearTelemetryCache();\r\n }\r\n return [2 /*return*/, response];\r\n }\r\n });\r\n });\r\n };\r\n return BaseClient;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Validates server consumable params from the \"request\" objects\r\n */\r\nvar RequestValidator = /** @class */ (function () {\r\n function RequestValidator() {\r\n }\r\n /**\r\n * Utility to check if the `redirectUri` in the request is a non-null value\r\n * @param redirectUri\r\n */\r\n RequestValidator.validateRedirectUri = function (redirectUri) {\r\n if (StringUtils.isEmpty(redirectUri)) {\r\n throw ClientConfigurationError.createRedirectUriEmptyError();\r\n }\r\n };\r\n /**\r\n * Utility to validate prompt sent by the user in the request\r\n * @param prompt\r\n */\r\n RequestValidator.validatePrompt = function (prompt) {\r\n if ([\r\n PromptValue.LOGIN,\r\n PromptValue.SELECT_ACCOUNT,\r\n PromptValue.CONSENT,\r\n PromptValue.NONE\r\n ].indexOf(prompt) < 0) {\r\n throw ClientConfigurationError.createInvalidPromptError(prompt);\r\n }\r\n };\r\n RequestValidator.validateClaims = function (claims) {\r\n try {\r\n JSON.parse(claims);\r\n }\r\n catch (e) {\r\n throw ClientConfigurationError.createInvalidClaimsRequestError();\r\n }\r\n };\r\n /**\r\n * Utility to validate code_challenge and code_challenge_method\r\n * @param codeChallenge\r\n * @param codeChallengeMethod\r\n */\r\n RequestValidator.validateCodeChallengeParams = function (codeChallenge, codeChallengeMethod) {\r\n if (StringUtils.isEmpty(codeChallenge) || StringUtils.isEmpty(codeChallengeMethod)) {\r\n throw ClientConfigurationError.createInvalidCodeChallengeParamsError();\r\n }\r\n else {\r\n this.validateCodeChallengeMethod(codeChallengeMethod);\r\n }\r\n };\r\n /**\r\n * Utility to validate code_challenge_method\r\n * @param codeChallengeMethod\r\n */\r\n RequestValidator.validateCodeChallengeMethod = function (codeChallengeMethod) {\r\n if ([\r\n CodeChallengeMethodValues.PLAIN,\r\n CodeChallengeMethodValues.S256\r\n ].indexOf(codeChallengeMethod) < 0) {\r\n throw ClientConfigurationError.createInvalidCodeChallengeMethodError();\r\n }\r\n };\r\n /**\r\n * Removes unnecessary or duplicate query parameters from extraQueryParameters\r\n * @param request\r\n */\r\n RequestValidator.sanitizeEQParams = function (eQParams, queryParams) {\r\n if (!eQParams) {\r\n return null;\r\n }\r\n // Remove any query parameters already included in SSO params\r\n queryParams.forEach(function (value, key) {\r\n if (eQParams[key]) {\r\n delete eQParams[key];\r\n }\r\n });\r\n return eQParams;\r\n };\r\n return RequestValidator;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nvar RequestParameterBuilder = /** @class */ (function () {\r\n function RequestParameterBuilder() {\r\n this.parameters = new Map();\r\n }\r\n /**\r\n * add response_type = code\r\n */\r\n RequestParameterBuilder.prototype.addResponseTypeCode = function () {\r\n this.parameters.set(AADServerParamKeys.RESPONSE_TYPE, encodeURIComponent(Constants.CODE_RESPONSE_TYPE));\r\n };\r\n /**\r\n * add response_mode. defaults to query.\r\n * @param responseMode\r\n */\r\n RequestParameterBuilder.prototype.addResponseMode = function (responseMode) {\r\n this.parameters.set(AADServerParamKeys.RESPONSE_MODE, encodeURIComponent((responseMode) ? responseMode : ResponseMode.QUERY));\r\n };\r\n /**\r\n * add scopes. set addOidcScopes to false to prevent default scopes in non-user scenarios\r\n * @param scopeSet\r\n * @param addOidcScopes\r\n */\r\n RequestParameterBuilder.prototype.addScopes = function (scopes, addOidcScopes) {\r\n if (addOidcScopes === void 0) { addOidcScopes = true; }\r\n var requestScopes = addOidcScopes ? __spreadArrays$1(scopes || [], [Constants.OPENID_SCOPE, Constants.PROFILE_SCOPE]) : scopes || [];\r\n var scopeSet = new ScopeSet(requestScopes);\r\n this.parameters.set(AADServerParamKeys.SCOPE, encodeURIComponent(scopeSet.printScopes()));\r\n };\r\n /**\r\n * add clientId\r\n * @param clientId\r\n */\r\n RequestParameterBuilder.prototype.addClientId = function (clientId) {\r\n this.parameters.set(AADServerParamKeys.CLIENT_ID, encodeURIComponent(clientId));\r\n };\r\n /**\r\n * add redirect_uri\r\n * @param redirectUri\r\n */\r\n RequestParameterBuilder.prototype.addRedirectUri = function (redirectUri) {\r\n RequestValidator.validateRedirectUri(redirectUri);\r\n this.parameters.set(AADServerParamKeys.REDIRECT_URI, encodeURIComponent(redirectUri));\r\n };\r\n /**\r\n * add domain_hint\r\n * @param domainHint\r\n */\r\n RequestParameterBuilder.prototype.addDomainHint = function (domainHint) {\r\n this.parameters.set(SSOTypes.DOMAIN_HINT, encodeURIComponent(domainHint));\r\n };\r\n /**\r\n * add login_hint\r\n * @param loginHint\r\n */\r\n RequestParameterBuilder.prototype.addLoginHint = function (loginHint) {\r\n this.parameters.set(SSOTypes.LOGIN_HINT, encodeURIComponent(loginHint));\r\n };\r\n /**\r\n * add sid\r\n * @param sid\r\n */\r\n RequestParameterBuilder.prototype.addSid = function (sid) {\r\n this.parameters.set(SSOTypes.SID, encodeURIComponent(sid));\r\n };\r\n /**\r\n * add claims\r\n * @param claims\r\n */\r\n RequestParameterBuilder.prototype.addClaims = function (claims, clientCapabilities) {\r\n var mergedClaims = this.addClientCapabilitiesToClaims(claims, clientCapabilities);\r\n RequestValidator.validateClaims(mergedClaims);\r\n this.parameters.set(AADServerParamKeys.CLAIMS, encodeURIComponent(mergedClaims));\r\n };\r\n /**\r\n * add correlationId\r\n * @param correlationId\r\n */\r\n RequestParameterBuilder.prototype.addCorrelationId = function (correlationId) {\r\n this.parameters.set(AADServerParamKeys.CLIENT_REQUEST_ID, encodeURIComponent(correlationId));\r\n };\r\n /**\r\n * add library info query params\r\n * @param libraryInfo\r\n */\r\n RequestParameterBuilder.prototype.addLibraryInfo = function (libraryInfo) {\r\n // Telemetry Info\r\n this.parameters.set(AADServerParamKeys.X_CLIENT_SKU, libraryInfo.sku);\r\n this.parameters.set(AADServerParamKeys.X_CLIENT_VER, libraryInfo.version);\r\n this.parameters.set(AADServerParamKeys.X_CLIENT_OS, libraryInfo.os);\r\n this.parameters.set(AADServerParamKeys.X_CLIENT_CPU, libraryInfo.cpu);\r\n };\r\n /**\r\n * add prompt\r\n * @param prompt\r\n */\r\n RequestParameterBuilder.prototype.addPrompt = function (prompt) {\r\n RequestValidator.validatePrompt(prompt);\r\n this.parameters.set(\"\" + AADServerParamKeys.PROMPT, encodeURIComponent(prompt));\r\n };\r\n /**\r\n * add state\r\n * @param state\r\n */\r\n RequestParameterBuilder.prototype.addState = function (state) {\r\n if (!StringUtils.isEmpty(state)) {\r\n this.parameters.set(AADServerParamKeys.STATE, encodeURIComponent(state));\r\n }\r\n };\r\n /**\r\n * add nonce\r\n * @param nonce\r\n */\r\n RequestParameterBuilder.prototype.addNonce = function (nonce) {\r\n this.parameters.set(AADServerParamKeys.NONCE, encodeURIComponent(nonce));\r\n };\r\n /**\r\n * add code_challenge and code_challenge_method\r\n * - throw if either of them are not passed\r\n * @param codeChallenge\r\n * @param codeChallengeMethod\r\n */\r\n RequestParameterBuilder.prototype.addCodeChallengeParams = function (codeChallenge, codeChallengeMethod) {\r\n RequestValidator.validateCodeChallengeParams(codeChallenge, codeChallengeMethod);\r\n if (codeChallenge && codeChallengeMethod) {\r\n this.parameters.set(AADServerParamKeys.CODE_CHALLENGE, encodeURIComponent(codeChallenge));\r\n this.parameters.set(AADServerParamKeys.CODE_CHALLENGE_METHOD, encodeURIComponent(codeChallengeMethod));\r\n }\r\n else {\r\n throw ClientConfigurationError.createInvalidCodeChallengeParamsError();\r\n }\r\n };\r\n /**\r\n * add the `authorization_code` passed by the user to exchange for a token\r\n * @param code\r\n */\r\n RequestParameterBuilder.prototype.addAuthorizationCode = function (code) {\r\n this.parameters.set(AADServerParamKeys.CODE, encodeURIComponent(code));\r\n };\r\n /**\r\n * add the `authorization_code` passed by the user to exchange for a token\r\n * @param code\r\n */\r\n RequestParameterBuilder.prototype.addDeviceCode = function (code) {\r\n this.parameters.set(AADServerParamKeys.DEVICE_CODE, encodeURIComponent(code));\r\n };\r\n /**\r\n * add the `refreshToken` passed by the user\r\n * @param refreshToken\r\n */\r\n RequestParameterBuilder.prototype.addRefreshToken = function (refreshToken) {\r\n this.parameters.set(AADServerParamKeys.REFRESH_TOKEN, encodeURIComponent(refreshToken));\r\n };\r\n /**\r\n * add the `code_verifier` passed by the user to exchange for a token\r\n * @param codeVerifier\r\n */\r\n RequestParameterBuilder.prototype.addCodeVerifier = function (codeVerifier) {\r\n this.parameters.set(AADServerParamKeys.CODE_VERIFIER, encodeURIComponent(codeVerifier));\r\n };\r\n /**\r\n * add client_secret\r\n * @param clientSecret\r\n */\r\n RequestParameterBuilder.prototype.addClientSecret = function (clientSecret) {\r\n this.parameters.set(AADServerParamKeys.CLIENT_SECRET, encodeURIComponent(clientSecret));\r\n };\r\n /**\r\n * add clientAssertion for confidential client flows\r\n * @param clientAssertion\r\n */\r\n RequestParameterBuilder.prototype.addClientAssertion = function (clientAssertion) {\r\n this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION, encodeURIComponent(clientAssertion));\r\n };\r\n /**\r\n * add clientAssertionType for confidential client flows\r\n * @param clientAssertionType\r\n */\r\n RequestParameterBuilder.prototype.addClientAssertionType = function (clientAssertionType) {\r\n this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION_TYPE, encodeURIComponent(clientAssertionType));\r\n };\r\n /**\r\n * add OBO assertion for confidential client flows\r\n * @param clientAssertion\r\n */\r\n RequestParameterBuilder.prototype.addOboAssertion = function (oboAssertion) {\r\n this.parameters.set(AADServerParamKeys.OBO_ASSERTION, encodeURIComponent(oboAssertion));\r\n };\r\n /**\r\n * add grant type\r\n * @param grantType\r\n */\r\n RequestParameterBuilder.prototype.addRequestTokenUse = function (tokenUse) {\r\n this.parameters.set(AADServerParamKeys.REQUESTED_TOKEN_USE, encodeURIComponent(tokenUse));\r\n };\r\n /**\r\n * add grant type\r\n * @param grantType\r\n */\r\n RequestParameterBuilder.prototype.addGrantType = function (grantType) {\r\n this.parameters.set(AADServerParamKeys.GRANT_TYPE, encodeURIComponent(grantType));\r\n };\r\n /**\r\n * add client info\r\n *\r\n */\r\n RequestParameterBuilder.prototype.addClientInfo = function () {\r\n this.parameters.set(ClientInfo, \"1\");\r\n };\r\n /**\r\n * add extraQueryParams\r\n * @param eQparams\r\n */\r\n RequestParameterBuilder.prototype.addExtraQueryParameters = function (eQparams) {\r\n var _this = this;\r\n RequestValidator.sanitizeEQParams(eQparams, this.parameters);\r\n Object.keys(eQparams).forEach(function (key) {\r\n _this.parameters.set(key, eQparams[key]);\r\n });\r\n };\r\n RequestParameterBuilder.prototype.addClientCapabilitiesToClaims = function (claims, clientCapabilities) {\r\n var mergedClaims;\r\n // Parse provided claims into JSON object or initialize empty object\r\n if (StringUtils.isEmpty(claims)) {\r\n mergedClaims = {};\r\n }\r\n else {\r\n try {\r\n mergedClaims = JSON.parse(claims);\r\n }\r\n catch (e) {\r\n throw ClientConfigurationError.createInvalidClaimsRequestError();\r\n }\r\n }\r\n if (clientCapabilities && clientCapabilities.length > 0) {\r\n if (!mergedClaims.hasOwnProperty(ClaimsRequestKeys.ACCESS_TOKEN)) {\r\n // Add access_token key to claims object\r\n mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN] = {};\r\n }\r\n // Add xms_cc claim with provided clientCapabilities to access_token key\r\n mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN][ClaimsRequestKeys.XMS_CC] = {\r\n values: clientCapabilities\r\n };\r\n }\r\n return JSON.stringify(mergedClaims);\r\n };\r\n /**\r\n * Utility to create a URL from the params map\r\n */\r\n RequestParameterBuilder.prototype.createQueryString = function () {\r\n var queryParameterArray = new Array();\r\n this.parameters.forEach(function (value, key) {\r\n queryParameterArray.push(key + \"=\" + value);\r\n });\r\n return queryParameterArray.join(\"&\");\r\n };\r\n return RequestParameterBuilder;\r\n}());\n\n/**\r\n * Id Token representation class. Parses id token string and generates claims object.\r\n */\r\nvar IdToken = /** @class */ (function () {\r\n function IdToken(rawIdToken, crypto) {\r\n if (StringUtils.isEmpty(rawIdToken)) {\r\n throw ClientAuthError.createIdTokenNullOrEmptyError(rawIdToken);\r\n }\r\n this.rawIdToken = rawIdToken;\r\n this.claims = IdToken.extractIdToken(rawIdToken, crypto);\r\n }\r\n /**\r\n * Extract IdToken by decoding the RAWIdToken\r\n *\r\n * @param encodedIdToken\r\n */\r\n IdToken.extractIdToken = function (encodedIdToken, crypto) {\r\n // id token will be decoded to get the username\r\n var decodedToken = StringUtils.decodeJwt(encodedIdToken);\r\n if (!decodedToken) {\r\n return null;\r\n }\r\n try {\r\n var base64IdTokenPayload = decodedToken.JWSPayload;\r\n // base64Decode() should throw an error if there is an issue\r\n var base64Decoded = crypto.base64Decode(base64IdTokenPayload);\r\n return JSON.parse(base64Decoded);\r\n }\r\n catch (err) {\r\n throw ClientAuthError.createIdTokenParsingError(err);\r\n }\r\n };\r\n return IdToken;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Utility class which exposes functions for managing date and time operations.\r\n */\r\nvar TimeUtils = /** @class */ (function () {\r\n function TimeUtils() {\r\n }\r\n /**\r\n * return the current time in Unix time (seconds).\r\n */\r\n TimeUtils.nowSeconds = function () {\r\n // Date.getTime() returns in milliseconds.\r\n return Math.round(new Date().getTime() / 1000.0);\r\n };\r\n /**\r\n * check if a token is expired based on given UTC time in seconds.\r\n * @param expiresOn\r\n */\r\n TimeUtils.isTokenExpired = function (expiresOn, offset) {\r\n // check for access token expiry\r\n var expirationSec = Number(expiresOn) || 0;\r\n var offsetCurrentTimeSec = TimeUtils.nowSeconds() + offset;\r\n // If current time + offset is greater than token expiration time, then token is expired.\r\n return (offsetCurrentTimeSec > expirationSec);\r\n };\r\n return TimeUtils;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * ID_TOKEN Cache\r\n *\r\n * Key:Value Schema:\r\n *\r\n * Key Example: uid.utid-login.microsoftonline.com-idtoken-clientId-contoso.com-\r\n *\r\n * Value Schema:\r\n * {\r\n * homeAccountId: home account identifier for the auth scheme,\r\n * environment: entity that issued the token, represented as a full host\r\n * credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other\r\n * clientId: client ID of the application\r\n * secret: Actual credential as a string\r\n * realm: Full tenant or organizational identifier that the account belongs to\r\n * }\r\n */\r\nvar IdTokenEntity = /** @class */ (function (_super) {\r\n __extends$1(IdTokenEntity, _super);\r\n function IdTokenEntity() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n /**\r\n * Create IdTokenEntity\r\n * @param homeAccountId\r\n * @param authenticationResult\r\n * @param clientId\r\n * @param authority\r\n */\r\n IdTokenEntity.createIdTokenEntity = function (homeAccountId, environment, idToken, clientId, tenantId, oboAssertion) {\r\n var idTokenEntity = new IdTokenEntity();\r\n idTokenEntity.credentialType = CredentialType.ID_TOKEN;\r\n idTokenEntity.homeAccountId = homeAccountId;\r\n idTokenEntity.environment = environment;\r\n idTokenEntity.clientId = clientId;\r\n idTokenEntity.secret = idToken;\r\n idTokenEntity.realm = tenantId;\r\n idTokenEntity.oboAssertion = oboAssertion;\r\n return idTokenEntity;\r\n };\r\n /**\r\n * Validates an entity: checks for all expected params\r\n * @param entity\r\n */\r\n IdTokenEntity.isIdTokenEntity = function (entity) {\r\n return (entity.hasOwnProperty(\"homeAccountId\") &&\r\n entity.hasOwnProperty(\"environment\") &&\r\n entity.hasOwnProperty(\"credentialType\") &&\r\n entity.hasOwnProperty(\"realm\") &&\r\n entity.hasOwnProperty(\"clientId\") &&\r\n entity.hasOwnProperty(\"secret\") &&\r\n entity[\"credentialType\"] === CredentialType.ID_TOKEN);\r\n };\r\n return IdTokenEntity;\r\n}(CredentialEntity));\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * ACCESS_TOKEN Credential Type\r\n *\r\n * Key:Value Schema:\r\n *\r\n * Key Example: uid.utid-login.microsoftonline.com-accesstoken-clientId-contoso.com-user.read\r\n *\r\n * Value Schema:\r\n * {\r\n * homeAccountId: home account identifier for the auth scheme,\r\n * environment: entity that issued the token, represented as a full host\r\n * credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other\r\n * clientId: client ID of the application\r\n * secret: Actual credential as a string\r\n * familyId: Family ID identifier, usually only used for refresh tokens\r\n * realm: Full tenant or organizational identifier that the account belongs to\r\n * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.\r\n * cachedAt: Absolute device time when entry was created in the cache.\r\n * expiresOn: Token expiry time, calculated based on current UTC time in seconds. Represented as a string.\r\n * extendedExpiresOn: Additional extended expiry time until when token is valid in case of server-side outage. Represented as string in UTC seconds.\r\n * keyId: used for POP and SSH tokenTypes\r\n * tokenType: Type of the token issued. Usually \"Bearer\"\r\n * }\r\n */\r\nvar AccessTokenEntity = /** @class */ (function (_super) {\r\n __extends$1(AccessTokenEntity, _super);\r\n function AccessTokenEntity() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n /**\r\n * Create AccessTokenEntity\r\n * @param homeAccountId\r\n * @param environment\r\n * @param accessToken\r\n * @param clientId\r\n * @param tenantId\r\n * @param scopes\r\n * @param expiresOn\r\n * @param extExpiresOn\r\n */\r\n AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, oboAssertion) {\r\n var atEntity = new AccessTokenEntity();\r\n atEntity.homeAccountId = homeAccountId;\r\n atEntity.credentialType = CredentialType.ACCESS_TOKEN;\r\n atEntity.secret = accessToken;\r\n var currentTime = TimeUtils.nowSeconds();\r\n atEntity.cachedAt = currentTime.toString();\r\n /*\r\n * Token expiry time.\r\n * This value should be  calculated based on the current UTC time measured locally and the value  expires_in Represented as a string in JSON.\r\n */\r\n atEntity.expiresOn = expiresOn.toString();\r\n atEntity.extendedExpiresOn = extExpiresOn.toString();\r\n atEntity.environment = environment;\r\n atEntity.clientId = clientId;\r\n atEntity.realm = tenantId;\r\n atEntity.target = scopes;\r\n atEntity.oboAssertion = oboAssertion;\r\n return atEntity;\r\n };\r\n /**\r\n * Validates an entity: checks for all expected params\r\n * @param entity\r\n */\r\n AccessTokenEntity.isAccessTokenEntity = function (entity) {\r\n return (entity.hasOwnProperty(\"homeAccountId\") &&\r\n entity.hasOwnProperty(\"environment\") &&\r\n entity.hasOwnProperty(\"credentialType\") &&\r\n entity.hasOwnProperty(\"realm\") &&\r\n entity.hasOwnProperty(\"clientId\") &&\r\n entity.hasOwnProperty(\"secret\") &&\r\n entity.hasOwnProperty(\"target\") &&\r\n entity[\"credentialType\"] === CredentialType.ACCESS_TOKEN);\r\n };\r\n return AccessTokenEntity;\r\n}(CredentialEntity));\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * REFRESH_TOKEN Cache\r\n *\r\n * Key:Value Schema:\r\n *\r\n * Key Example: uid.utid-login.microsoftonline.com-refreshtoken-clientId--\r\n *\r\n * Value:\r\n * {\r\n * homeAccountId: home account identifier for the auth scheme,\r\n * environment: entity that issued the token, represented as a full host\r\n * credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other\r\n * clientId: client ID of the application\r\n * secret: Actual credential as a string\r\n * familyId: Family ID identifier, '1' represents Microsoft Family\r\n * realm: Full tenant or organizational identifier that the account belongs to\r\n * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.\r\n * }\r\n */\r\nvar RefreshTokenEntity = /** @class */ (function (_super) {\r\n __extends$1(RefreshTokenEntity, _super);\r\n function RefreshTokenEntity() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n /**\r\n * Create RefreshTokenEntity\r\n * @param homeAccountId\r\n * @param authenticationResult\r\n * @param clientId\r\n * @param authority\r\n */\r\n RefreshTokenEntity.createRefreshTokenEntity = function (homeAccountId, environment, refreshToken, clientId, familyId, oboAssertion) {\r\n var rtEntity = new RefreshTokenEntity();\r\n rtEntity.clientId = clientId;\r\n rtEntity.credentialType = CredentialType.REFRESH_TOKEN;\r\n rtEntity.environment = environment;\r\n rtEntity.homeAccountId = homeAccountId;\r\n rtEntity.secret = refreshToken;\r\n rtEntity.oboAssertion = oboAssertion;\r\n if (familyId)\r\n rtEntity.familyId = familyId;\r\n return rtEntity;\r\n };\r\n /**\r\n * Validates an entity: checks for all expected params\r\n * @param entity\r\n */\r\n RefreshTokenEntity.isRefreshTokenEntity = function (entity) {\r\n return (entity.hasOwnProperty(\"homeAccountId\") &&\r\n entity.hasOwnProperty(\"environment\") &&\r\n entity.hasOwnProperty(\"credentialType\") &&\r\n entity.hasOwnProperty(\"clientId\") &&\r\n entity.hasOwnProperty(\"secret\") &&\r\n entity[\"credentialType\"] === CredentialType.REFRESH_TOKEN);\r\n };\r\n return RefreshTokenEntity;\r\n}(CredentialEntity));\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * InteractionRequiredAuthErrorMessage class containing string constants used by error codes and messages.\r\n */\r\nvar InteractionRequiredAuthErrorMessage = [\r\n \"interaction_required\",\r\n \"consent_required\",\r\n \"login_required\"\r\n];\r\nvar InteractionRequiredAuthSubErrorMessage = [\r\n \"message_only\",\r\n \"additional_action\",\r\n \"basic_action\",\r\n \"user_password_expired\",\r\n \"consent_required\"\r\n];\r\n/**\r\n * Error thrown when user interaction is required at the auth server.\r\n */\r\nvar InteractionRequiredAuthError = /** @class */ (function (_super) {\r\n __extends$1(InteractionRequiredAuthError, _super);\r\n function InteractionRequiredAuthError(errorCode, errorMessage, subError) {\r\n var _this = _super.call(this, errorCode, errorMessage, subError) || this;\r\n _this.name = \"InteractionRequiredAuthError\";\r\n Object.setPrototypeOf(_this, InteractionRequiredAuthError.prototype);\r\n return _this;\r\n }\r\n InteractionRequiredAuthError.isInteractionRequiredError = function (errorCode, errorString, subError) {\r\n var isInteractionRequiredErrorCode = !StringUtils.isEmpty(errorCode) && InteractionRequiredAuthErrorMessage.indexOf(errorCode) > -1;\r\n var isInteractionRequiredSubError = !StringUtils.isEmpty(subError) && InteractionRequiredAuthSubErrorMessage.indexOf(subError) > -1;\r\n var isInteractionRequiredErrorDesc = !StringUtils.isEmpty(errorString) && InteractionRequiredAuthErrorMessage.some(function (irErrorCode) {\r\n return errorString.indexOf(irErrorCode) > -1;\r\n });\r\n return isInteractionRequiredErrorCode || isInteractionRequiredErrorDesc || isInteractionRequiredSubError;\r\n };\r\n return InteractionRequiredAuthError;\r\n}(ServerError));\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nvar CacheRecord = /** @class */ (function () {\r\n function CacheRecord(accountEntity, idTokenEntity, accessTokenEntity, refreshTokenEntity, appMetadataEntity) {\r\n this.account = accountEntity;\r\n this.idToken = idTokenEntity;\r\n this.accessToken = accessTokenEntity;\r\n this.refreshToken = refreshTokenEntity;\r\n this.appMetadata = appMetadataEntity;\r\n }\r\n return CacheRecord;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Class which provides helpers for OAuth 2.0 protocol specific values\r\n */\r\nvar ProtocolUtils = /** @class */ (function () {\r\n function ProtocolUtils() {\r\n }\r\n /**\r\n * Appends user state with random guid, or returns random guid.\r\n * @param userState\r\n * @param randomGuid\r\n */\r\n ProtocolUtils.setRequestState = function (cryptoObj, userState, meta) {\r\n var libraryState = ProtocolUtils.generateLibraryState(cryptoObj, meta);\r\n return !StringUtils.isEmpty(userState) ? \"\" + libraryState + Constants.RESOURCE_DELIM + userState : libraryState;\r\n };\r\n /**\r\n * Generates the state value used by the common library.\r\n * @param randomGuid\r\n * @param cryptoObj\r\n */\r\n ProtocolUtils.generateLibraryState = function (cryptoObj, meta) {\r\n if (!cryptoObj) {\r\n throw ClientAuthError.createNoCryptoObjectError(\"generateLibraryState\");\r\n }\r\n // Create a state object containing a unique id and the timestamp of the request creation\r\n var stateObj = {\r\n id: cryptoObj.createNewGuid(),\r\n ts: TimeUtils.nowSeconds()\r\n };\r\n if (meta) {\r\n stateObj.meta = meta;\r\n }\r\n var stateString = JSON.stringify(stateObj);\r\n return cryptoObj.base64Encode(stateString);\r\n };\r\n /**\r\n * Parses the state into the RequestStateObject, which contains the LibraryState info and the state passed by the user.\r\n * @param state\r\n * @param cryptoObj\r\n */\r\n ProtocolUtils.parseRequestState = function (cryptoObj, state) {\r\n if (!cryptoObj) {\r\n throw ClientAuthError.createNoCryptoObjectError(\"parseRequestState\");\r\n }\r\n if (StringUtils.isEmpty(state)) {\r\n throw ClientAuthError.createInvalidStateError(state, \"Null, undefined or empty state\");\r\n }\r\n try {\r\n // Split the state between library state and user passed state and decode them separately\r\n var splitState = decodeURIComponent(state).split(Constants.RESOURCE_DELIM);\r\n var libraryState = splitState[0];\r\n var userState = splitState.length > 1 ? splitState.slice(1).join(Constants.RESOURCE_DELIM) : \"\";\r\n var libraryStateString = cryptoObj.base64Decode(libraryState);\r\n var libraryStateObj = JSON.parse(libraryStateString);\r\n return {\r\n userRequestState: !StringUtils.isEmpty(userState) ? userState : \"\",\r\n libraryState: libraryStateObj\r\n };\r\n }\r\n catch (e) {\r\n throw ClientAuthError.createInvalidStateError(state, e);\r\n }\r\n };\r\n return ProtocolUtils;\r\n}());\n\n/**\r\n * Class that handles response parsing.\r\n */\r\nvar ResponseHandler = /** @class */ (function () {\r\n function ResponseHandler(clientId, cacheStorage, cryptoObj, logger) {\r\n this.clientId = clientId;\r\n this.cacheStorage = cacheStorage;\r\n this.cryptoObj = cryptoObj;\r\n this.logger = logger;\r\n }\r\n /**\r\n * Function which validates server authorization code response.\r\n * @param serverResponseHash\r\n * @param cachedState\r\n * @param cryptoObj\r\n */\r\n ResponseHandler.prototype.validateServerAuthorizationCodeResponse = function (serverResponseHash, cachedState, cryptoObj) {\r\n if (decodeURIComponent(serverResponseHash.state) !== decodeURIComponent(cachedState)) {\r\n throw ClientAuthError.createStateMismatchError();\r\n }\r\n // Check for error\r\n if (serverResponseHash.error || serverResponseHash.error_description || serverResponseHash.suberror) {\r\n if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponseHash.error, serverResponseHash.error_description, serverResponseHash.suberror)) {\r\n throw new InteractionRequiredAuthError(serverResponseHash.error, serverResponseHash.error_description, serverResponseHash.suberror);\r\n }\r\n throw new ServerError(serverResponseHash.error, serverResponseHash.error_description, serverResponseHash.suberror);\r\n }\r\n if (serverResponseHash.client_info) {\r\n buildClientInfo(serverResponseHash.client_info, cryptoObj);\r\n }\r\n };\r\n /**\r\n * Function which validates server authorization token response.\r\n * @param serverResponse\r\n */\r\n ResponseHandler.prototype.validateTokenResponse = function (serverResponse) {\r\n // Check for error\r\n if (serverResponse.error || serverResponse.error_description || serverResponse.suberror) {\r\n if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponse.error, serverResponse.error_description, serverResponse.suberror)) {\r\n throw new InteractionRequiredAuthError(serverResponse.error, serverResponse.error_description, serverResponse.suberror);\r\n }\r\n var errString = serverResponse.error_codes + \" - [\" + serverResponse.timestamp + \"]: \" + serverResponse.error_description + \" - Correlation ID: \" + serverResponse.correlation_id + \" - Trace ID: \" + serverResponse.trace_id;\r\n throw new ServerError(serverResponse.error, errString);\r\n }\r\n };\r\n /**\r\n * Returns a constructed token response based on given string. Also manages the cache updates and cleanups.\r\n * @param serverTokenResponse\r\n * @param authority\r\n */\r\n ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, cachedNonce, cachedState, requestScopes, oboAssertion) {\r\n // generate homeAccountId\r\n if (serverTokenResponse.client_info) {\r\n this.clientInfo = buildClientInfo(serverTokenResponse.client_info, this.cryptoObj);\r\n if (!StringUtils.isEmpty(this.clientInfo.uid) && !StringUtils.isEmpty(this.clientInfo.utid)) {\r\n this.homeAccountIdentifier = this.clientInfo.uid + \".\" + this.clientInfo.utid;\r\n }\r\n }\r\n else {\r\n this.homeAccountIdentifier = \"\";\r\n }\r\n var idTokenObj = null;\r\n if (!StringUtils.isEmpty(serverTokenResponse.id_token)) {\r\n // create an idToken object (not entity)\r\n idTokenObj = new IdToken(serverTokenResponse.id_token, this.cryptoObj);\r\n // token nonce check (TODO: Add a warning if no nonce is given?)\r\n if (!StringUtils.isEmpty(cachedNonce)) {\r\n if (idTokenObj.claims.nonce !== cachedNonce) {\r\n throw ClientAuthError.createNonceMismatchError();\r\n }\r\n }\r\n }\r\n // save the response tokens\r\n var requestStateObj = null;\r\n if (!StringUtils.isEmpty(cachedState)) {\r\n requestStateObj = ProtocolUtils.parseRequestState(this.cryptoObj, cachedState);\r\n }\r\n var cacheRecord = this.generateCacheRecord(serverTokenResponse, idTokenObj, authority, requestStateObj && requestStateObj.libraryState, requestScopes, oboAssertion);\r\n this.cacheStorage.saveCacheRecord(cacheRecord);\r\n return ResponseHandler.generateAuthenticationResult(cacheRecord, idTokenObj, false, requestStateObj);\r\n };\r\n /**\r\n * Generates CacheRecord\r\n * @param serverTokenResponse\r\n * @param idTokenObj\r\n * @param authority\r\n */\r\n ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, idTokenObj, authority, libraryState, requestScopes, oboAssertion) {\r\n var env = Authority.generateEnvironmentFromAuthority(authority);\r\n if (StringUtils.isEmpty(env)) {\r\n throw ClientAuthError.createInvalidCacheEnvironmentError();\r\n }\r\n // IdToken: non AAD scenarios can have empty realm\r\n var cachedIdToken = null;\r\n var cachedAccount = null;\r\n if (!StringUtils.isEmpty(serverTokenResponse.id_token)) {\r\n cachedIdToken = IdTokenEntity.createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token, this.clientId, idTokenObj.claims.tid || \"\", oboAssertion);\r\n cachedAccount = this.generateAccountEntity(serverTokenResponse, idTokenObj, authority, oboAssertion);\r\n }\r\n // AccessToken\r\n var cachedAccessToken = null;\r\n if (!StringUtils.isEmpty(serverTokenResponse.access_token)) {\r\n // If scopes not returned in server response, use request scopes\r\n var responseScopes = serverTokenResponse.scope ? ScopeSet.fromString(serverTokenResponse.scope) : new ScopeSet(requestScopes || []);\r\n // Expiration calculation\r\n var currentTime = TimeUtils.nowSeconds();\r\n // If the request timestamp was sent in the library state, use that timestamp to calculate expiration. Otherwise, use current time.\r\n var timestamp = libraryState ? libraryState.ts : currentTime;\r\n var tokenExpirationSeconds = timestamp + serverTokenResponse.expires_in;\r\n var extendedTokenExpirationSeconds = tokenExpirationSeconds + serverTokenResponse.ext_expires_in;\r\n // non AAD scenarios can have empty realm\r\n cachedAccessToken = AccessTokenEntity.createAccessTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.access_token, this.clientId, idTokenObj ? idTokenObj.claims.tid || \"\" : authority.tenant, responseScopes.printScopes(), tokenExpirationSeconds, extendedTokenExpirationSeconds, oboAssertion);\r\n }\r\n // refreshToken\r\n var cachedRefreshToken = null;\r\n if (!StringUtils.isEmpty(serverTokenResponse.refresh_token)) {\r\n cachedRefreshToken = RefreshTokenEntity.createRefreshTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.refresh_token, this.clientId, serverTokenResponse.foci, oboAssertion);\r\n }\r\n // appMetadata\r\n var cachedAppMetadata = null;\r\n if (!StringUtils.isEmpty(serverTokenResponse.foci)) {\r\n cachedAppMetadata = AppMetadataEntity.createAppMetadataEntity(this.clientId, env, serverTokenResponse.foci);\r\n }\r\n return new CacheRecord(cachedAccount, cachedIdToken, cachedAccessToken, cachedRefreshToken, cachedAppMetadata);\r\n };\r\n /**\r\n * Generate Account\r\n * @param serverTokenResponse\r\n * @param idToken\r\n * @param authority\r\n */\r\n ResponseHandler.prototype.generateAccountEntity = function (serverTokenResponse, idToken, authority, oboAssertion) {\r\n var authorityType = authority.authorityType;\r\n // ADFS does not require client_info in the response\r\n if (authorityType === AuthorityType.Adfs) {\r\n return AccountEntity.createADFSAccount(authority, idToken, oboAssertion);\r\n }\r\n if (StringUtils.isEmpty(serverTokenResponse.client_info)) {\r\n throw ClientAuthError.createClientInfoEmptyError(serverTokenResponse.client_info);\r\n }\r\n return AccountEntity.createAccount(serverTokenResponse.client_info, authority, idToken, this.cryptoObj, oboAssertion);\r\n };\r\n /**\r\n * Creates an @AuthenticationResult from @CacheRecord , @IdToken , and a boolean that states whether or not the result is from cache.\r\n *\r\n * Optionally takes a state string that is set as-is in the response.\r\n *\r\n * @param cacheRecord\r\n * @param idTokenObj\r\n * @param fromTokenCache\r\n * @param stateString\r\n */\r\n ResponseHandler.generateAuthenticationResult = function (cacheRecord, idTokenObj, fromTokenCache, requestState) {\r\n var accessToken = \"\";\r\n var responseScopes = [];\r\n var expiresOn = null;\r\n var extExpiresOn = null;\r\n var familyId = null;\r\n if (cacheRecord.accessToken) {\r\n accessToken = cacheRecord.accessToken.secret;\r\n responseScopes = ScopeSet.fromString(cacheRecord.accessToken.target).asArray();\r\n expiresOn = new Date(Number(cacheRecord.accessToken.expiresOn) * 1000);\r\n extExpiresOn = new Date(Number(cacheRecord.accessToken.extendedExpiresOn) * 1000);\r\n }\r\n if (cacheRecord.appMetadata) {\r\n familyId = cacheRecord.appMetadata.familyId || null;\r\n }\r\n var uid = idTokenObj ? idTokenObj.claims.oid || idTokenObj.claims.sub : \"\";\r\n var tid = idTokenObj ? idTokenObj.claims.tid : \"\";\r\n return {\r\n uniqueId: uid,\r\n tenantId: tid,\r\n scopes: responseScopes,\r\n account: cacheRecord.account ? cacheRecord.account.getAccountInfo() : null,\r\n idToken: idTokenObj ? idTokenObj.rawIdToken : \"\",\r\n idTokenClaims: idTokenObj ? idTokenObj.claims : null,\r\n accessToken: accessToken,\r\n fromCache: fromTokenCache,\r\n expiresOn: expiresOn,\r\n extExpiresOn: extExpiresOn,\r\n familyId: familyId,\r\n state: requestState ? requestState.userRequestState : \"\"\r\n };\r\n };\r\n return ResponseHandler;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Oauth2.0 Authorization Code client\r\n */\r\nvar AuthorizationCodeClient = /** @class */ (function (_super) {\r\n __extends$1(AuthorizationCodeClient, _super);\r\n function AuthorizationCodeClient(configuration) {\r\n return _super.call(this, configuration) || this;\r\n }\r\n /**\r\n * Creates the URL of the authorization request letting the user input credentials and consent to the\r\n * application. The URL target the /authorize endpoint of the authority configured in the\r\n * application object.\r\n *\r\n * Once the user inputs their credentials and consents, the authority will send a response to the redirect URI\r\n * sent in the request and should contain an authorization code, which can then be used to acquire tokens via\r\n * acquireToken(AuthorizationCodeRequest)\r\n * @param request\r\n */\r\n AuthorizationCodeClient.prototype.getAuthCodeUrl = function (request) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var queryString;\r\n return __generator$1(this, function (_a) {\r\n queryString = this.createAuthCodeUrlQueryString(request);\r\n return [2 /*return*/, this.authority.authorizationEndpoint + \"?\" + queryString];\r\n });\r\n });\r\n };\r\n /**\r\n * API to acquire a token in exchange of 'authorization_code` acquired by the user in the first leg of the\r\n * authorization_code_grant\r\n * @param request\r\n */\r\n AuthorizationCodeClient.prototype.acquireToken = function (request, cachedNonce, cachedState) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var response, responseHandler, tokenResponse;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n this.logger.info(\"in acquireToken call\");\r\n if (!request || StringUtils.isEmpty(request.code)) {\r\n throw ClientAuthError.createTokenRequestCannotBeMadeError();\r\n }\r\n return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];\r\n case 1:\r\n response = _a.sent();\r\n responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger);\r\n // Validate response. This function throws a server error if an error is returned by the server.\r\n responseHandler.validateTokenResponse(response.body);\r\n tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, cachedNonce, cachedState);\r\n return [2 /*return*/, tokenResponse];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Handles the hash fragment response from public client code request. Returns a code response used by\r\n * the client to exchange for a token in acquireToken.\r\n * @param hashFragment\r\n */\r\n AuthorizationCodeClient.prototype.handleFragmentResponse = function (hashFragment, cachedState) {\r\n // Handle responses.\r\n var responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger);\r\n // Create UrlString object to remove leading # using getHash()\r\n var hashUrlString = new UrlString(hashFragment);\r\n // Deserialize hash fragment response parameters.\r\n var serverParams = UrlString.getDeserializedHash(hashUrlString.getHash());\r\n // Get code response\r\n responseHandler.validateServerAuthorizationCodeResponse(serverParams, cachedState, this.cryptoUtils);\r\n return serverParams.code;\r\n };\r\n /**\r\n * Use to log out the current user, and redirect the user to the postLogoutRedirectUri.\r\n * Default behaviour is to redirect the user to `window.location.href`.\r\n * @param authorityUri\r\n */\r\n AuthorizationCodeClient.prototype.getLogoutUri = function (logoutRequest) {\r\n // Throw error if logoutRequest is null/undefined\r\n if (!logoutRequest) {\r\n throw ClientConfigurationError.createEmptyLogoutRequestError();\r\n }\r\n if (logoutRequest.account) {\r\n // Clear given account.\r\n this.cacheManager.removeAccount(AccountEntity.generateAccountCacheKey(logoutRequest.account));\r\n }\r\n else {\r\n // Clear all accounts and tokens\r\n this.cacheManager.clear();\r\n }\r\n // Get postLogoutRedirectUri.\r\n var postLogoutUriParam = logoutRequest.postLogoutRedirectUri ?\r\n \"?\" + AADServerParamKeys.POST_LOGOUT_URI + \"=\" + encodeURIComponent(logoutRequest.postLogoutRedirectUri) : \"\";\r\n var correlationIdParam = logoutRequest.correlationId ?\r\n \"&\" + AADServerParamKeys.CLIENT_REQUEST_ID + \"=\" + encodeURIComponent(logoutRequest.correlationId) : \"\";\r\n // Construct logout URI.\r\n var logoutUri = \"\" + this.authority.endSessionEndpoint + postLogoutUriParam + correlationIdParam;\r\n return logoutUri;\r\n };\r\n /**\r\n * Executes POST request to token endpoint\r\n * @param authority\r\n * @param request\r\n */\r\n AuthorizationCodeClient.prototype.executeTokenRequest = function (authority, request) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var thumbprint, requestBody, headers;\r\n return __generator$1(this, function (_a) {\r\n thumbprint = {\r\n clientId: this.config.authOptions.clientId,\r\n authority: authority.canonicalAuthority,\r\n scopes: request.scopes\r\n };\r\n requestBody = this.createTokenRequestBody(request);\r\n headers = this.createDefaultTokenRequestHeaders();\r\n return [2 /*return*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];\r\n });\r\n });\r\n };\r\n /**\r\n * Generates a map for all the params to be sent to the service\r\n * @param request\r\n */\r\n AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {\r\n var parameterBuilder = new RequestParameterBuilder();\r\n parameterBuilder.addClientId(this.config.authOptions.clientId);\r\n // validate the redirectUri (to be a non null value)\r\n parameterBuilder.addRedirectUri(request.redirectUri);\r\n // Add scope array, parameter builder will add default scopes and dedupe\r\n parameterBuilder.addScopes(request.scopes);\r\n // add code: user set, not validated\r\n parameterBuilder.addAuthorizationCode(request.code);\r\n // add code_verifier if passed\r\n if (request.codeVerifier) {\r\n parameterBuilder.addCodeVerifier(request.codeVerifier);\r\n }\r\n if (this.config.clientCredentials.clientSecret) {\r\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\r\n }\r\n if (this.config.clientCredentials.clientAssertion) {\r\n var clientAssertion = this.config.clientCredentials.clientAssertion;\r\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\r\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\r\n }\r\n parameterBuilder.addGrantType(GrantType.AUTHORIZATION_CODE_GRANT);\r\n parameterBuilder.addClientInfo();\r\n var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\r\n parameterBuilder.addCorrelationId(correlationId);\r\n if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\r\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\r\n }\r\n return parameterBuilder.createQueryString();\r\n };\r\n /**\r\n * This API validates the `AuthorizationCodeUrlRequest` and creates a URL\r\n * @param request\r\n */\r\n AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {\r\n var parameterBuilder = new RequestParameterBuilder();\r\n parameterBuilder.addClientId(this.config.authOptions.clientId);\r\n var requestScopes = __spreadArrays$1(request.scopes || [], request.extraScopesToConsent || []);\r\n parameterBuilder.addScopes(requestScopes);\r\n // validate the redirectUri (to be a non null value)\r\n parameterBuilder.addRedirectUri(request.redirectUri);\r\n // generate the correlationId if not set by the user and add\r\n var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\r\n parameterBuilder.addCorrelationId(correlationId);\r\n // add response_mode. If not passed in it defaults to query.\r\n parameterBuilder.addResponseMode(request.responseMode);\r\n // add response_type = code\r\n parameterBuilder.addResponseTypeCode();\r\n // add library info parameters\r\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\r\n // add client_info=1\r\n parameterBuilder.addClientInfo();\r\n if (request.codeChallenge) {\r\n parameterBuilder.addCodeChallengeParams(request.codeChallenge, request.codeChallengeMethod);\r\n }\r\n if (request.prompt) {\r\n parameterBuilder.addPrompt(request.prompt);\r\n }\r\n if (request.domainHint) {\r\n parameterBuilder.addDomainHint(request.domainHint);\r\n }\r\n // Add sid or loginHint with preference for sid -> loginHint -> username of AccountInfo object\r\n if (request.sid) {\r\n parameterBuilder.addSid(request.sid);\r\n }\r\n else if (request.loginHint) {\r\n parameterBuilder.addLoginHint(request.loginHint);\r\n }\r\n else if (request.account && request.account.username) {\r\n parameterBuilder.addLoginHint(request.account.username);\r\n }\r\n if (request.nonce) {\r\n parameterBuilder.addNonce(request.nonce);\r\n }\r\n if (request.state) {\r\n parameterBuilder.addState(request.state);\r\n }\r\n if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\r\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\r\n }\r\n if (request.extraQueryParameters) {\r\n parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);\r\n }\r\n return parameterBuilder.createQueryString();\r\n };\r\n return AuthorizationCodeClient;\r\n}(BaseClient));\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * OAuth2.0 Device code client\r\n */\r\nvar DeviceCodeClient = /** @class */ (function (_super) {\r\n __extends$1(DeviceCodeClient, _super);\r\n function DeviceCodeClient(configuration) {\r\n return _super.call(this, configuration) || this;\r\n }\r\n /**\r\n * Gets device code from device code endpoint, calls back to with device code response, and\r\n * polls token endpoint to exchange device code for tokens\r\n * @param request\r\n */\r\n DeviceCodeClient.prototype.acquireToken = function (request) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var deviceCodeResponse, response, responseHandler, tokenResponse;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, this.getDeviceCode(request)];\r\n case 1:\r\n deviceCodeResponse = _a.sent();\r\n request.deviceCodeCallback(deviceCodeResponse);\r\n return [4 /*yield*/, this.acquireTokenWithDeviceCode(request, deviceCodeResponse)];\r\n case 2:\r\n response = _a.sent();\r\n responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger);\r\n // Validate response. This function throws a server error if an error is returned by the server.\r\n responseHandler.validateTokenResponse(response);\r\n tokenResponse = responseHandler.handleServerTokenResponse(response, this.authority);\r\n return [2 /*return*/, tokenResponse];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Creates device code request and executes http GET\r\n * @param request\r\n */\r\n DeviceCodeClient.prototype.getDeviceCode = function (request) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var queryString, headers, thumbprint;\r\n return __generator$1(this, function (_a) {\r\n queryString = this.createQueryString(request);\r\n headers = this.createDefaultLibraryHeaders();\r\n thumbprint = {\r\n clientId: this.config.authOptions.clientId,\r\n authority: request.authority,\r\n scopes: request.scopes\r\n };\r\n return [2 /*return*/, this.executePostRequestToDeviceCodeEndpoint(this.authority.deviceCodeEndpoint, queryString, headers, thumbprint)];\r\n });\r\n });\r\n };\r\n /**\r\n * Executes POST request to device code endpoint\r\n * @param deviceCodeEndpoint\r\n * @param queryString\r\n * @param headers\r\n */\r\n DeviceCodeClient.prototype.executePostRequestToDeviceCodeEndpoint = function (deviceCodeEndpoint, queryString, headers, thumbprint) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var _a, userCode, deviceCode, verificationUri, expiresIn, interval, message;\r\n return __generator$1(this, function (_b) {\r\n switch (_b.label) {\r\n case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, deviceCodeEndpoint, {\r\n body: queryString,\r\n headers: headers\r\n })];\r\n case 1:\r\n _a = (_b.sent()).body, userCode = _a.user_code, deviceCode = _a.device_code, verificationUri = _a.verification_uri, expiresIn = _a.expires_in, interval = _a.interval, message = _a.message;\r\n return [2 /*return*/, {\r\n userCode: userCode,\r\n deviceCode: deviceCode,\r\n verificationUri: verificationUri,\r\n expiresIn: expiresIn,\r\n interval: interval,\r\n message: message\r\n }];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Create device code endpoint query parameters and returns string\r\n */\r\n DeviceCodeClient.prototype.createQueryString = function (request) {\r\n var parameterBuilder = new RequestParameterBuilder();\r\n parameterBuilder.addScopes(request.scopes);\r\n parameterBuilder.addClientId(this.config.authOptions.clientId);\r\n if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\r\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\r\n }\r\n return parameterBuilder.createQueryString();\r\n };\r\n /**\r\n * Creates token request with device code response and polls token endpoint at interval set by the device code\r\n * response\r\n * @param request\r\n * @param deviceCodeResponse\r\n */\r\n DeviceCodeClient.prototype.acquireTokenWithDeviceCode = function (request, deviceCodeResponse) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var requestBody, headers, deviceCodeExpirationTime, pollingIntervalMilli;\r\n var _this = this;\r\n return __generator$1(this, function (_a) {\r\n requestBody = this.createTokenRequestBody(request, deviceCodeResponse);\r\n headers = this.createDefaultTokenRequestHeaders();\r\n deviceCodeExpirationTime = TimeUtils.nowSeconds() + deviceCodeResponse.expiresIn;\r\n pollingIntervalMilli = deviceCodeResponse.interval * 1000;\r\n /*\r\n * Poll token endpoint while (device code is not expired AND operation has not been cancelled by\r\n * setting CancellationToken.cancel = true). POST request is sent at interval set by pollingIntervalMilli\r\n */\r\n return [2 /*return*/, new Promise(function (resolve, reject) {\r\n var intervalId = setInterval(function () { return __awaiter$1(_this, void 0, void 0, function () {\r\n var thumbprint, response, error_1;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n _a.trys.push([0, 5, , 6]);\r\n if (!request.cancel) return [3 /*break*/, 1];\r\n this.logger.error(\"Token request cancelled by setting DeviceCodeRequest.cancel = true\");\r\n clearInterval(intervalId);\r\n reject(ClientAuthError.createDeviceCodeCancelledError());\r\n return [3 /*break*/, 4];\r\n case 1:\r\n if (!(TimeUtils.nowSeconds() > deviceCodeExpirationTime)) return [3 /*break*/, 2];\r\n this.logger.error(\"Device code expired. Expiration time of device code was \" + deviceCodeExpirationTime);\r\n clearInterval(intervalId);\r\n reject(ClientAuthError.createDeviceCodeExpiredError());\r\n return [3 /*break*/, 4];\r\n case 2:\r\n thumbprint = {\r\n clientId: this.config.authOptions.clientId,\r\n authority: request.authority,\r\n scopes: request.scopes\r\n };\r\n return [4 /*yield*/, this.executePostToTokenEndpoint(this.authority.tokenEndpoint, requestBody, headers, thumbprint)];\r\n case 3:\r\n response = _a.sent();\r\n if (response.body && response.body.error == Constants.AUTHORIZATION_PENDING) {\r\n // user authorization is pending. Sleep for polling interval and try again\r\n this.logger.info(response.body.error_description);\r\n }\r\n else {\r\n clearInterval(intervalId);\r\n resolve(response.body);\r\n }\r\n _a.label = 4;\r\n case 4: return [3 /*break*/, 6];\r\n case 5:\r\n error_1 = _a.sent();\r\n clearInterval(intervalId);\r\n reject(error_1);\r\n return [3 /*break*/, 6];\r\n case 6: return [2 /*return*/];\r\n }\r\n });\r\n }); }, pollingIntervalMilli);\r\n })];\r\n });\r\n });\r\n };\r\n /**\r\n * Creates query parameters and converts to string.\r\n * @param request\r\n * @param deviceCodeResponse\r\n */\r\n DeviceCodeClient.prototype.createTokenRequestBody = function (request, deviceCodeResponse) {\r\n var requestParameters = new RequestParameterBuilder();\r\n requestParameters.addScopes(request.scopes);\r\n requestParameters.addClientId(this.config.authOptions.clientId);\r\n requestParameters.addGrantType(GrantType.DEVICE_CODE_GRANT);\r\n requestParameters.addDeviceCode(deviceCodeResponse.deviceCode);\r\n var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\r\n requestParameters.addCorrelationId(correlationId);\r\n requestParameters.addClientInfo();\r\n if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\r\n requestParameters.addClaims(request.claims, this.config.authOptions.clientCapabilities);\r\n }\r\n return requestParameters.createQueryString();\r\n };\r\n return DeviceCodeClient;\r\n}(BaseClient));\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * OAuth2.0 refresh token client\r\n */\r\nvar RefreshTokenClient = /** @class */ (function (_super) {\r\n __extends$1(RefreshTokenClient, _super);\r\n function RefreshTokenClient(configuration) {\r\n return _super.call(this, configuration) || this;\r\n }\r\n RefreshTokenClient.prototype.acquireToken = function (request) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var response, responseHandler, tokenResponse;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];\r\n case 1:\r\n response = _a.sent();\r\n responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger);\r\n responseHandler.validateTokenResponse(response.body);\r\n tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority);\r\n return [2 /*return*/, tokenResponse];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Gets cached refresh token and attaches to request, then calls acquireToken API\r\n * @param request\r\n */\r\n RefreshTokenClient.prototype.acquireTokenByRefreshToken = function (request) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var isFOCI, noFamilyRTInCache, clientMismatchErrorWithFamilyRT;\r\n return __generator$1(this, function (_a) {\r\n // Cannot renew token if no request object is given.\r\n if (!request) {\r\n throw ClientConfigurationError.createEmptyTokenRequestError();\r\n }\r\n // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases\r\n if (!request.account) {\r\n throw ClientAuthError.createNoAccountInSilentRequestError();\r\n }\r\n isFOCI = this.cacheManager.isAppMetadataFOCI(request.account.environment, this.config.authOptions.clientId);\r\n // if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest\r\n if (isFOCI) {\r\n try {\r\n return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, true)];\r\n }\r\n catch (e) {\r\n noFamilyRTInCache = e instanceof ClientAuthError && e.errorCode === ClientAuthErrorMessage.noTokensFoundError.code;\r\n clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;\r\n // if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)\r\n if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {\r\n return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, false)];\r\n // throw in all other cases\r\n }\r\n else {\r\n throw e;\r\n }\r\n }\r\n }\r\n // fall back to application refresh token acquisition\r\n return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, false)];\r\n });\r\n });\r\n };\r\n /**\r\n * makes a network call to acquire tokens by exchanging RefreshToken available in userCache; throws if refresh token is not cached\r\n * @param request\r\n */\r\n RefreshTokenClient.prototype.acquireTokenWithCachedRefreshToken = function (request, foci) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var refreshToken, refreshTokenRequest;\r\n return __generator$1(this, function (_a) {\r\n refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);\r\n // no refresh Token\r\n if (!refreshToken) {\r\n throw ClientAuthError.createNoTokensFoundError();\r\n }\r\n refreshTokenRequest = __assign$1(__assign$1({}, request), { refreshToken: refreshToken.secret });\r\n return [2 /*return*/, this.acquireToken(refreshTokenRequest)];\r\n });\r\n });\r\n };\r\n /**\r\n * Constructs the network message and makes a NW call to the underlying secure token service\r\n * @param request\r\n * @param authority\r\n */\r\n RefreshTokenClient.prototype.executeTokenRequest = function (request, authority) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var requestBody, headers, thumbprint;\r\n return __generator$1(this, function (_a) {\r\n requestBody = this.createTokenRequestBody(request);\r\n headers = this.createDefaultTokenRequestHeaders();\r\n thumbprint = {\r\n clientId: this.config.authOptions.clientId,\r\n authority: authority.canonicalAuthority,\r\n scopes: request.scopes\r\n };\r\n return [2 /*return*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];\r\n });\r\n });\r\n };\r\n /**\r\n * Helper function to create the token request body\r\n * @param request\r\n */\r\n RefreshTokenClient.prototype.createTokenRequestBody = function (request) {\r\n var parameterBuilder = new RequestParameterBuilder();\r\n parameterBuilder.addClientId(this.config.authOptions.clientId);\r\n parameterBuilder.addScopes(request.scopes);\r\n parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);\r\n parameterBuilder.addClientInfo();\r\n var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\r\n parameterBuilder.addCorrelationId(correlationId);\r\n parameterBuilder.addRefreshToken(request.refreshToken);\r\n if (this.config.clientCredentials.clientSecret) {\r\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\r\n }\r\n if (this.config.clientCredentials.clientAssertion) {\r\n var clientAssertion = this.config.clientCredentials.clientAssertion;\r\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\r\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\r\n }\r\n if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\r\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\r\n }\r\n return parameterBuilder.createQueryString();\r\n };\r\n return RefreshTokenClient;\r\n}(BaseClient));\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * OAuth2.0 client credential grant\r\n */\r\nvar ClientCredentialClient = /** @class */ (function (_super) {\r\n __extends$1(ClientCredentialClient, _super);\r\n function ClientCredentialClient(configuration) {\r\n return _super.call(this, configuration) || this;\r\n }\r\n ClientCredentialClient.prototype.acquireToken = function (request) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var cachedAuthenticationResult;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n this.scopeSet = new ScopeSet(request.scopes || []);\r\n if (!request.skipCache) return [3 /*break*/, 2];\r\n return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];\r\n case 1: return [2 /*return*/, _a.sent()];\r\n case 2:\r\n cachedAuthenticationResult = this.getCachedAuthenticationResult();\r\n if (!(cachedAuthenticationResult != null)) return [3 /*break*/, 3];\r\n return [2 /*return*/, cachedAuthenticationResult];\r\n case 3: return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];\r\n case 4: return [2 /*return*/, _a.sent()];\r\n }\r\n });\r\n });\r\n };\r\n ClientCredentialClient.prototype.getCachedAuthenticationResult = function () {\r\n var cachedAccessToken = this.readAccessTokenFromCache();\r\n if (!cachedAccessToken ||\r\n TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {\r\n return null;\r\n }\r\n return ResponseHandler.generateAuthenticationResult({\r\n account: null,\r\n accessToken: cachedAccessToken,\r\n idToken: null,\r\n refreshToken: null,\r\n appMetadata: null\r\n }, null, true);\r\n };\r\n ClientCredentialClient.prototype.readAccessTokenFromCache = function () {\r\n var accessTokenFilter = {\r\n homeAccountId: \"\",\r\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\r\n credentialType: CredentialType.ACCESS_TOKEN,\r\n clientId: this.config.authOptions.clientId,\r\n realm: this.authority.tenant,\r\n target: this.scopeSet.printScopesLowerCase()\r\n };\r\n var credentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);\r\n var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });\r\n if (accessTokens.length < 1) {\r\n return null;\r\n }\r\n else if (accessTokens.length > 1) {\r\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\r\n }\r\n return accessTokens[0];\r\n };\r\n ClientCredentialClient.prototype.executeTokenRequest = function (request, authority) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var requestBody, headers, thumbprint, response, responseHandler, tokenResponse;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n requestBody = this.createTokenRequestBody(request);\r\n headers = this.createDefaultTokenRequestHeaders();\r\n thumbprint = {\r\n clientId: this.config.authOptions.clientId,\r\n authority: request.authority,\r\n scopes: request.scopes\r\n };\r\n return [4 /*yield*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];\r\n case 1:\r\n response = _a.sent();\r\n responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger);\r\n responseHandler.validateTokenResponse(response.body);\r\n tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, null, null, request.scopes);\r\n return [2 /*return*/, tokenResponse];\r\n }\r\n });\r\n });\r\n };\r\n ClientCredentialClient.prototype.createTokenRequestBody = function (request) {\r\n var parameterBuilder = new RequestParameterBuilder();\r\n parameterBuilder.addClientId(this.config.authOptions.clientId);\r\n parameterBuilder.addScopes(request.scopes, false);\r\n parameterBuilder.addGrantType(GrantType.CLIENT_CREDENTIALS_GRANT);\r\n var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\r\n parameterBuilder.addCorrelationId(correlationId);\r\n if (this.config.clientCredentials.clientSecret) {\r\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\r\n }\r\n if (this.config.clientCredentials.clientAssertion) {\r\n var clientAssertion = this.config.clientCredentials.clientAssertion;\r\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\r\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\r\n }\r\n if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\r\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\r\n }\r\n return parameterBuilder.createQueryString();\r\n };\r\n return ClientCredentialClient;\r\n}(BaseClient));\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * On-Behalf-Of client\r\n */\r\nvar OnBehalfOfClient = /** @class */ (function (_super) {\r\n __extends$1(OnBehalfOfClient, _super);\r\n function OnBehalfOfClient(configuration) {\r\n return _super.call(this, configuration) || this;\r\n }\r\n OnBehalfOfClient.prototype.acquireToken = function (request) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var cachedAuthenticationResult;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n this.scopeSet = new ScopeSet(request.scopes || []);\r\n if (!request.skipCache) return [3 /*break*/, 2];\r\n return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];\r\n case 1: return [2 /*return*/, _a.sent()];\r\n case 2:\r\n cachedAuthenticationResult = this.getCachedAuthenticationResult(request);\r\n if (!(cachedAuthenticationResult != null)) return [3 /*break*/, 3];\r\n return [2 /*return*/, cachedAuthenticationResult];\r\n case 3: return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];\r\n case 4: return [2 /*return*/, _a.sent()];\r\n }\r\n });\r\n });\r\n };\r\n OnBehalfOfClient.prototype.getCachedAuthenticationResult = function (request) {\r\n var cachedAccessToken = this.readAccessTokenFromCache(request);\r\n if (!cachedAccessToken ||\r\n TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {\r\n return null;\r\n }\r\n var cachedIdToken = this.readIdTokenFromCache(request);\r\n var idTokenObject = null;\r\n var cachedAccount = null;\r\n if (cachedIdToken) {\r\n idTokenObject = new IdToken(cachedIdToken.secret, this.config.cryptoInterface);\r\n var accountKey = AccountEntity.generateAccountCacheKey({\r\n homeAccountId: cachedIdToken.homeAccountId,\r\n environment: cachedIdToken.environment,\r\n tenantId: cachedIdToken.realm,\r\n username: null\r\n });\r\n cachedAccount = this.cacheManager.getAccount(accountKey);\r\n }\r\n return ResponseHandler.generateAuthenticationResult({\r\n account: cachedAccount,\r\n accessToken: cachedAccessToken,\r\n idToken: cachedIdToken,\r\n refreshToken: null,\r\n appMetadata: null,\r\n }, idTokenObject, true);\r\n };\r\n OnBehalfOfClient.prototype.readAccessTokenFromCache = function (request) {\r\n var accessTokenFilter = {\r\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\r\n credentialType: CredentialType.ACCESS_TOKEN,\r\n clientId: this.config.authOptions.clientId,\r\n realm: this.authority.tenant,\r\n target: this.scopeSet.printScopesLowerCase(),\r\n oboAssertion: request.oboAssertion\r\n };\r\n var credentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);\r\n var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });\r\n var numAccessTokens = accessTokens.length;\r\n if (numAccessTokens < 1) {\r\n return null;\r\n }\r\n else if (numAccessTokens > 1) {\r\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\r\n }\r\n return accessTokens[0];\r\n };\r\n OnBehalfOfClient.prototype.readIdTokenFromCache = function (request) {\r\n var idTokenFilter = {\r\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\r\n credentialType: CredentialType.ID_TOKEN,\r\n clientId: this.config.authOptions.clientId,\r\n realm: this.authority.tenant,\r\n oboAssertion: request.oboAssertion\r\n };\r\n var credentialCache = this.cacheManager.getCredentialsFilteredBy(idTokenFilter);\r\n var idTokens = Object.keys(credentialCache.idTokens).map(function (key) { return credentialCache.idTokens[key]; });\r\n // When acquiring a token on behalf of an application, there might not be an id token in the cache\r\n if (idTokens.length < 1) {\r\n return null;\r\n }\r\n return idTokens[0];\r\n };\r\n OnBehalfOfClient.prototype.executeTokenRequest = function (request, authority) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var requestBody, headers, thumbprint, response, responseHandler, tokenResponse;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n requestBody = this.createTokenRequestBody(request);\r\n headers = this.createDefaultTokenRequestHeaders();\r\n thumbprint = {\r\n clientId: this.config.authOptions.clientId,\r\n authority: request.authority,\r\n scopes: request.scopes\r\n };\r\n return [4 /*yield*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];\r\n case 1:\r\n response = _a.sent();\r\n responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger);\r\n responseHandler.validateTokenResponse(response.body);\r\n tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, null, null, request.scopes, request.oboAssertion);\r\n return [2 /*return*/, tokenResponse];\r\n }\r\n });\r\n });\r\n };\r\n OnBehalfOfClient.prototype.createTokenRequestBody = function (request) {\r\n var parameterBuilder = new RequestParameterBuilder();\r\n parameterBuilder.addClientId(this.config.authOptions.clientId);\r\n parameterBuilder.addScopes(request.scopes);\r\n parameterBuilder.addGrantType(GrantType.JWT_BEARER);\r\n parameterBuilder.addClientInfo();\r\n var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\r\n parameterBuilder.addCorrelationId(correlationId);\r\n parameterBuilder.addRequestTokenUse(AADServerParamKeys.ON_BEHALF_OF);\r\n parameterBuilder.addOboAssertion(request.oboAssertion);\r\n if (this.config.clientCredentials.clientSecret) {\r\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\r\n }\r\n if (this.config.clientCredentials.clientAssertion) {\r\n var clientAssertion = this.config.clientCredentials.clientAssertion;\r\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\r\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\r\n }\r\n return parameterBuilder.createQueryString();\r\n };\r\n return OnBehalfOfClient;\r\n}(BaseClient));\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nvar SilentFlowClient = /** @class */ (function (_super) {\r\n __extends$1(SilentFlowClient, _super);\r\n function SilentFlowClient(configuration) {\r\n return _super.call(this, configuration) || this;\r\n }\r\n /**\r\n * Retrieves a token from cache if it is still valid, or uses the cached refresh token to renew\r\n * the given token and returns the renewed token\r\n * @param request\r\n */\r\n SilentFlowClient.prototype.acquireToken = function (request) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var refreshTokenClient;\r\n return __generator$1(this, function (_a) {\r\n try {\r\n return [2 /*return*/, this.acquireCachedToken(request)];\r\n }\r\n catch (e) {\r\n if (e instanceof ClientAuthError && e.errorCode === ClientAuthErrorMessage.tokenRefreshRequired.code) {\r\n refreshTokenClient = new RefreshTokenClient(this.config);\r\n return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(request)];\r\n }\r\n else {\r\n throw e;\r\n }\r\n }\r\n return [2 /*return*/];\r\n });\r\n });\r\n };\r\n /**\r\n * Retrieves token from cache or throws an error if it must be refreshed.\r\n * @param request\r\n */\r\n SilentFlowClient.prototype.acquireCachedToken = function (request) {\r\n // Cannot renew token if no request object is given.\r\n if (!request) {\r\n throw ClientConfigurationError.createEmptyTokenRequestError();\r\n }\r\n // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases\r\n if (!request.account) {\r\n throw ClientAuthError.createNoAccountInSilentRequestError();\r\n }\r\n var requestScopes = new ScopeSet(request.scopes || []);\r\n var environment = request.authority || Authority.generateEnvironmentFromAuthority(this.authority);\r\n var cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment);\r\n if (this.isRefreshRequired(request, cacheRecord.accessToken)) {\r\n throw ClientAuthError.createRefreshRequiredError();\r\n }\r\n else {\r\n if (this.config.serverTelemetryManager) {\r\n this.config.serverTelemetryManager.incrementCacheHits();\r\n }\r\n return this.generateResultFromCacheRecord(cacheRecord);\r\n }\r\n };\r\n /**\r\n * Helper function to build response object from the CacheRecord\r\n * @param cacheRecord\r\n */\r\n SilentFlowClient.prototype.generateResultFromCacheRecord = function (cacheRecord) {\r\n var idTokenObj = new IdToken(cacheRecord.idToken.secret, this.config.cryptoInterface);\r\n return ResponseHandler.generateAuthenticationResult(cacheRecord, idTokenObj, true);\r\n };\r\n /**\r\n * Given a request object and an accessTokenEntity determine if the accessToken needs to be refreshed\r\n * @param request\r\n * @param cachedAccessToken\r\n */\r\n SilentFlowClient.prototype.isRefreshRequired = function (request, cachedAccessToken) {\r\n if (request.forceRefresh || request.claims) {\r\n // Must refresh due to request parameters\r\n return true;\r\n }\r\n else if (!cachedAccessToken || TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {\r\n // Must refresh due to expired or non-existent access_token\r\n return true;\r\n }\r\n return false;\r\n };\r\n return SilentFlowClient;\r\n}(BaseClient));\n\nvar AuthorityFactory = /** @class */ (function () {\r\n function AuthorityFactory() {\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 (i.e. aad, b2c, adfs)\r\n *\r\n * Also performs endpoint discovery.\r\n *\r\n * @param authorityUri\r\n * @param networkClient\r\n */\r\n AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient) {\r\n return __awaiter$1(this, void 0, void 0, function () {\r\n var acquireTokenAuthority, e_1;\r\n return __generator$1(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient);\r\n if (acquireTokenAuthority.discoveryComplete()) {\r\n return [2 /*return*/, acquireTokenAuthority];\r\n }\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 3, , 4]);\r\n return [4 /*yield*/, acquireTokenAuthority.resolveEndpointsAsync()];\r\n case 2:\r\n _a.sent();\r\n return [2 /*return*/, acquireTokenAuthority];\r\n case 3:\r\n e_1 = _a.sent();\r\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(e_1);\r\n case 4: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Create an authority object of the correct type based on the url\r\n * Performs basic authority validation - checks to see if the authority is of a valid type (i.e. aad, b2c, adfs)\r\n *\r\n * Does not perform endpoint discovery.\r\n *\r\n * @param authorityUrl\r\n * @param networkInterface\r\n */\r\n AuthorityFactory.createInstance = function (authorityUrl, networkInterface) {\r\n // Throw error if authority url is empty\r\n if (StringUtils.isEmpty(authorityUrl)) {\r\n throw ClientConfigurationError.createUrlEmptyError();\r\n }\r\n return new Authority(authorityUrl, networkInterface);\r\n };\r\n return AuthorityFactory;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nvar ServerTelemetryManager = /** @class */ (function () {\r\n function ServerTelemetryManager(telemetryRequest, cacheManager) {\r\n this.cacheManager = cacheManager;\r\n this.apiId = telemetryRequest.apiId;\r\n this.correlationId = telemetryRequest.correlationId;\r\n this.forceRefresh = telemetryRequest.forceRefresh || false;\r\n this.telemetryCacheKey = SERVER_TELEM_CONSTANTS.CACHE_KEY + Separators.CACHE_KEY_SEPARATOR + telemetryRequest.clientId;\r\n }\r\n // API to add MSER Telemetry to request\r\n ServerTelemetryManager.prototype.generateCurrentRequestHeaderValue = function () {\r\n var forceRefreshInt = this.forceRefresh ? 1 : 0;\r\n var request = \"\" + this.apiId + SERVER_TELEM_CONSTANTS.VALUE_SEPARATOR + forceRefreshInt;\r\n var platformFields = \"\"; // TODO: Determine what we want to include\r\n return [SERVER_TELEM_CONSTANTS.SCHEMA_VERSION, request, platformFields].join(SERVER_TELEM_CONSTANTS.CATEGORY_SEPARATOR);\r\n };\r\n // API to add MSER Telemetry for the last failed request\r\n ServerTelemetryManager.prototype.generateLastRequestHeaderValue = function () {\r\n var lastRequests = this.getLastRequests();\r\n var failedRequests = lastRequests.failedRequests.join(SERVER_TELEM_CONSTANTS.VALUE_SEPARATOR);\r\n var errors = lastRequests.errors.join(SERVER_TELEM_CONSTANTS.VALUE_SEPARATOR);\r\n var platformFields = lastRequests.errorCount;\r\n return [SERVER_TELEM_CONSTANTS.SCHEMA_VERSION, lastRequests.cacheHits, failedRequests, errors, platformFields].join(SERVER_TELEM_CONSTANTS.CATEGORY_SEPARATOR);\r\n };\r\n // API to cache token failures for MSER data capture\r\n ServerTelemetryManager.prototype.cacheFailedRequest = function (error) {\r\n var lastRequests = this.getLastRequests();\r\n lastRequests.failedRequests.push(this.apiId, this.correlationId);\r\n lastRequests.errors.push(StringUtils.isEmpty(error.suberror) ? error.errorCode : error.suberror);\r\n lastRequests.errorCount += 1;\r\n if (lastRequests.errors.length > SERVER_TELEM_CONSTANTS.FAILURE_LIMIT) {\r\n // Prevent request headers from becoming too large due to excessive failures\r\n lastRequests.failedRequests.shift(); // Remove apiId\r\n lastRequests.failedRequests.shift(); // Remove correlationId\r\n lastRequests.errors.shift();\r\n }\r\n this.cacheManager.setItem(this.telemetryCacheKey, lastRequests, CacheSchemaType.TELEMETRY);\r\n return;\r\n };\r\n ServerTelemetryManager.prototype.incrementCacheHits = function () {\r\n var lastRequests = this.getLastRequests();\r\n lastRequests.cacheHits += 1;\r\n this.cacheManager.setItem(this.telemetryCacheKey, lastRequests, CacheSchemaType.TELEMETRY);\r\n return lastRequests.cacheHits;\r\n };\r\n ServerTelemetryManager.prototype.getLastRequests = function () {\r\n var initialValue = {\r\n failedRequests: [],\r\n errors: [],\r\n errorCount: 0,\r\n cacheHits: 0\r\n };\r\n var lastRequests = this.cacheManager.getItem(this.telemetryCacheKey, CacheSchemaType.TELEMETRY);\r\n return lastRequests || initialValue;\r\n };\r\n ServerTelemetryManager.prototype.clearTelemetryCache = function () {\r\n this.cacheManager.removeItem(this.telemetryCacheKey);\r\n };\r\n return ServerTelemetryManager;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Constants\r\n */\r\nvar BrowserConstants = {\r\n // Local storage constant string\r\n CACHE_LOCATION_LOCAL: \"localStorage\",\r\n // Session storage constant string\r\n CACHE_LOCATION_SESSION: \"sessionStorage\",\r\n // Interaction status key (only used for browsers)\r\n INTERACTION_STATUS_KEY: \"interaction.status\",\r\n // Interaction in progress cache value\r\n INTERACTION_IN_PROGRESS_VALUE: \"interaction_in_progress\",\r\n // Invalid grant error code\r\n INVALID_GRANT_ERROR: \"invalid_grant\",\r\n // Default popup window width\r\n POPUP_WIDTH: 483,\r\n // Default popup window height\r\n POPUP_HEIGHT: 600,\r\n // Default popup monitor poll interval in milliseconds\r\n POLL_INTERVAL_MS: 50,\r\n // msal-browser SKU\r\n MSAL_SKU: \"msal.js.browser\",\r\n};\r\n/**\r\n * HTTP Request types supported by MSAL.\r\n */\r\nvar HTTP_REQUEST_TYPE;\r\n(function (HTTP_REQUEST_TYPE) {\r\n HTTP_REQUEST_TYPE[\"GET\"] = \"GET\";\r\n HTTP_REQUEST_TYPE[\"POST\"] = \"POST\";\r\n})(HTTP_REQUEST_TYPE || (HTTP_REQUEST_TYPE = {}));\r\n/**\r\n * Temporary cache keys for MSAL, deleted after any request.\r\n */\r\nvar TemporaryCacheKeys;\r\n(function (TemporaryCacheKeys) {\r\n TemporaryCacheKeys[\"AUTHORITY\"] = \"authority\";\r\n TemporaryCacheKeys[\"ACQUIRE_TOKEN_ACCOUNT\"] = \"acquireToken.account\";\r\n TemporaryCacheKeys[\"SESSION_STATE\"] = \"session.state\";\r\n TemporaryCacheKeys[\"REQUEST_STATE\"] = \"request.state\";\r\n TemporaryCacheKeys[\"NONCE_IDTOKEN\"] = \"nonce.id_token\";\r\n TemporaryCacheKeys[\"ORIGIN_URI\"] = \"request.origin\";\r\n TemporaryCacheKeys[\"RENEW_STATUS\"] = \"token.renew.status\";\r\n TemporaryCacheKeys[\"URL_HASH\"] = \"urlHash\";\r\n TemporaryCacheKeys[\"REQUEST_PARAMS\"] = \"request.params\";\r\n TemporaryCacheKeys[\"SCOPES\"] = \"scopes\";\r\n})(TemporaryCacheKeys || (TemporaryCacheKeys = {}));\r\n/**\r\n * API Codes for Telemetry purposes.\r\n * Before adding a new code you must claim it in the MSAL Telemetry tracker as these number spaces are shared across all MSALs\r\n * 0-99 Silent Flow\r\n * 800-899 Auth Code Flow\r\n */\r\nvar ApiId;\r\n(function (ApiId) {\r\n ApiId[ApiId[\"acquireTokenRedirect\"] = 861] = \"acquireTokenRedirect\";\r\n ApiId[ApiId[\"acquireTokenPopup\"] = 862] = \"acquireTokenPopup\";\r\n ApiId[ApiId[\"ssoSilent\"] = 863] = \"ssoSilent\";\r\n ApiId[ApiId[\"acquireTokenSilent_authCode\"] = 864] = \"acquireTokenSilent_authCode\";\r\n ApiId[ApiId[\"handleRedirectPromise\"] = 865] = \"handleRedirectPromise\";\r\n ApiId[ApiId[\"acquireTokenSilent_silentFlow\"] = 61] = \"acquireTokenSilent_silentFlow\";\r\n})(ApiId || (ApiId = {}));\r\n/*\r\n * Interaction type of the API - used for state and telemetry\r\n */\r\nvar InteractionType;\r\n(function (InteractionType) {\r\n InteractionType[\"REDIRECT\"] = \"redirect\";\r\n InteractionType[\"POPUP\"] = \"popup\";\r\n InteractionType[\"SILENT\"] = \"silent\";\r\n})(InteractionType || (InteractionType = {}));\r\nvar DEFAULT_REQUEST = {\r\n scopes: [Constants.OPENID_SCOPE, Constants.PROFILE_SCOPE]\r\n};\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Utility class for math specific functions in browser.\r\n */\r\nvar MathUtils = /** @class */ (function () {\r\n function MathUtils() {\r\n }\r\n /**\r\n * Decimal to Hex\r\n *\r\n * @param num\r\n */\r\n MathUtils.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 return MathUtils;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nvar GuidGenerator = /** @class */ (function () {\r\n function GuidGenerator(cryptoObj) {\r\n this.cryptoObj = cryptoObj;\r\n }\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 GuidGenerator.prototype.generateGuid = function () {\r\n try {\r\n var buffer = new Uint8Array(16);\r\n this.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 MathUtils.decimalToHex(buffer[0]) + MathUtils.decimalToHex(buffer[1])\r\n + MathUtils.decimalToHex(buffer[2]) + MathUtils.decimalToHex(buffer[3])\r\n + \"-\" + MathUtils.decimalToHex(buffer[4]) + MathUtils.decimalToHex(buffer[5])\r\n + \"-\" + MathUtils.decimalToHex(buffer[6]) + MathUtils.decimalToHex(buffer[7])\r\n + \"-\" + MathUtils.decimalToHex(buffer[8]) + MathUtils.decimalToHex(buffer[9])\r\n + \"-\" + MathUtils.decimalToHex(buffer[10]) + MathUtils.decimalToHex(buffer[11])\r\n + MathUtils.decimalToHex(buffer[12]) + MathUtils.decimalToHex(buffer[13])\r\n + MathUtils.decimalToHex(buffer[14]) + MathUtils.decimalToHex(buffer[15]);\r\n }\r\n catch (err) {\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 GuidGenerator.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 return GuidGenerator;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Utility functions for strings in a browser. See here for implementation details:\r\n * https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_2_%E2%80%93_JavaScript's_UTF-16_%3E_UTF-8_%3E_base64\r\n */\r\nvar BrowserStringUtils = /** @class */ (function () {\r\n function BrowserStringUtils() {\r\n }\r\n /**\r\n * Converts string to Uint8Array\r\n * @param sDOMStr\r\n */\r\n BrowserStringUtils.stringToUtf8Arr = function (sDOMStr) {\r\n var nChr;\r\n var nArrLen = 0;\r\n var nStrLen = sDOMStr.length;\r\n /* mapping... */\r\n for (var nMapIdx = 0; nMapIdx < nStrLen; nMapIdx++) {\r\n nChr = sDOMStr.charCodeAt(nMapIdx);\r\n nArrLen += nChr < 0x80 ? 1 : nChr < 0x800 ? 2 : nChr < 0x10000 ? 3 : nChr < 0x200000 ? 4 : nChr < 0x4000000 ? 5 : 6;\r\n }\r\n var aBytes = new Uint8Array(nArrLen);\r\n /* transcription... */\r\n for (var nIdx = 0, nChrIdx = 0; nIdx < nArrLen; nChrIdx++) {\r\n nChr = sDOMStr.charCodeAt(nChrIdx);\r\n if (nChr < 128) {\r\n /* one byte */\r\n aBytes[nIdx++] = nChr;\r\n }\r\n else if (nChr < 0x800) {\r\n /* two bytes */\r\n aBytes[nIdx++] = 192 + (nChr >>> 6);\r\n aBytes[nIdx++] = 128 + (nChr & 63);\r\n }\r\n else if (nChr < 0x10000) {\r\n /* three bytes */\r\n aBytes[nIdx++] = 224 + (nChr >>> 12);\r\n aBytes[nIdx++] = 128 + (nChr >>> 6 & 63);\r\n aBytes[nIdx++] = 128 + (nChr & 63);\r\n }\r\n else if (nChr < 0x200000) {\r\n /* four bytes */\r\n aBytes[nIdx++] = 240 + (nChr >>> 18);\r\n aBytes[nIdx++] = 128 + (nChr >>> 12 & 63);\r\n aBytes[nIdx++] = 128 + (nChr >>> 6 & 63);\r\n aBytes[nIdx++] = 128 + (nChr & 63);\r\n }\r\n else if (nChr < 0x4000000) {\r\n /* five bytes */\r\n aBytes[nIdx++] = 248 + (nChr >>> 24);\r\n aBytes[nIdx++] = 128 + (nChr >>> 18 & 63);\r\n aBytes[nIdx++] = 128 + (nChr >>> 12 & 63);\r\n aBytes[nIdx++] = 128 + (nChr >>> 6 & 63);\r\n aBytes[nIdx++] = 128 + (nChr & 63);\r\n }\r\n else /* if (nChr <= 0x7fffffff) */ {\r\n /* six bytes */\r\n aBytes[nIdx++] = 252 + (nChr >>> 30);\r\n aBytes[nIdx++] = 128 + (nChr >>> 24 & 63);\r\n aBytes[nIdx++] = 128 + (nChr >>> 18 & 63);\r\n aBytes[nIdx++] = 128 + (nChr >>> 12 & 63);\r\n aBytes[nIdx++] = 128 + (nChr >>> 6 & 63);\r\n aBytes[nIdx++] = 128 + (nChr & 63);\r\n }\r\n }\r\n return aBytes;\r\n };\r\n /**\r\n * Converts Uint8Array to a string\r\n * @param aBytes\r\n */\r\n BrowserStringUtils.utf8ArrToString = function (aBytes) {\r\n var sView = \"\";\r\n for (var nPart = void 0, nLen = aBytes.length, nIdx = 0; nIdx < nLen; nIdx++) {\r\n nPart = aBytes[nIdx];\r\n sView += String.fromCharCode(nPart > 251 && nPart < 254 && nIdx + 5 < nLen ? /* six bytes */\r\n /* (nPart - 252 << 30) may be not so safe in ECMAScript! So...: */\r\n (nPart - 252) * 1073741824 + (aBytes[++nIdx] - 128 << 24) + (aBytes[++nIdx] - 128 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128\r\n : nPart > 247 && nPart < 252 && nIdx + 4 < nLen ? /* five bytes */\r\n (nPart - 248 << 24) + (aBytes[++nIdx] - 128 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128\r\n : nPart > 239 && nPart < 248 && nIdx + 3 < nLen ? /* four bytes */\r\n (nPart - 240 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128\r\n : nPart > 223 && nPart < 240 && nIdx + 2 < nLen ? /* three bytes */\r\n (nPart - 224 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128\r\n : nPart > 191 && nPart < 224 && nIdx + 1 < nLen ? /* two bytes */\r\n (nPart - 192 << 6) + aBytes[++nIdx] - 128\r\n : /* nPart < 127 ? */ /* one byte */\r\n nPart);\r\n }\r\n return sView;\r\n };\r\n return BrowserStringUtils;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Class which exposes APIs to encode plaintext to base64 encoded string. See here for implementation details:\r\n * https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_2_%E2%80%93_JavaScript's_UTF-16_%3E_UTF-8_%3E_base64\r\n */\r\nvar Base64Encode = /** @class */ (function () {\r\n function Base64Encode() {\r\n }\r\n /**\r\n * Returns URL Safe b64 encoded string from a plaintext string.\r\n * @param input\r\n */\r\n Base64Encode.prototype.urlEncode = function (input) {\r\n return encodeURIComponent(this.encode(input)\r\n .replace(/=/g, \"\")\r\n .replace(/\\+/g, \"-\")\r\n .replace(/\\//g, \"_\"));\r\n };\r\n /**\r\n * Returns URL Safe b64 encoded string from an int8Array.\r\n * @param inputArr\r\n */\r\n Base64Encode.prototype.urlEncodeArr = function (inputArr) {\r\n return this.base64EncArr(inputArr)\r\n .replace(/=/g, \"\")\r\n .replace(/\\+/g, \"-\")\r\n .replace(/\\//g, \"_\");\r\n };\r\n /**\r\n * Returns b64 encoded string from plaintext string.\r\n * @param input\r\n */\r\n Base64Encode.prototype.encode = function (input) {\r\n var inputUtf8Arr = BrowserStringUtils.stringToUtf8Arr(input);\r\n return this.base64EncArr(inputUtf8Arr);\r\n };\r\n /**\r\n * Base64 encode byte array\r\n * @param aBytes\r\n */\r\n Base64Encode.prototype.base64EncArr = function (aBytes) {\r\n var eqLen = (3 - (aBytes.length % 3)) % 3;\r\n var sB64Enc = \"\";\r\n for (var nMod3 = void 0, nLen = aBytes.length, nUint24 = 0, nIdx = 0; nIdx < nLen; nIdx++) {\r\n nMod3 = nIdx % 3;\r\n /* Uncomment the following line in order to split the output in lines 76-character long: */\r\n /*\r\n *if (nIdx > 0 && (nIdx * 4 / 3) % 76 === 0) { sB64Enc += \"\\r\\n\"; }\r\n */\r\n nUint24 |= aBytes[nIdx] << (16 >>> nMod3 & 24);\r\n if (nMod3 === 2 || aBytes.length - nIdx === 1) {\r\n sB64Enc += String.fromCharCode(this.uint6ToB64(nUint24 >>> 18 & 63), this.uint6ToB64(nUint24 >>> 12 & 63), this.uint6ToB64(nUint24 >>> 6 & 63), this.uint6ToB64(nUint24 & 63));\r\n nUint24 = 0;\r\n }\r\n }\r\n return eqLen === 0 ? sB64Enc : sB64Enc.substring(0, sB64Enc.length - eqLen) + (eqLen === 1 ? \"=\" : \"==\");\r\n };\r\n /**\r\n * Base64 string to array encoding helper\r\n * @param nUint6\r\n */\r\n Base64Encode.prototype.uint6ToB64 = function (nUint6) {\r\n return nUint6 < 26 ?\r\n nUint6 + 65\r\n : nUint6 < 52 ?\r\n nUint6 + 71\r\n : nUint6 < 62 ?\r\n nUint6 - 4\r\n : nUint6 === 62 ?\r\n 43\r\n : nUint6 === 63 ?\r\n 47\r\n :\r\n 65;\r\n };\r\n return Base64Encode;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Class which exposes APIs to decode base64 strings to plaintext. See here for implementation details:\r\n * https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_2_%E2%80%93_JavaScript's_UTF-16_%3E_UTF-8_%3E_base64\r\n */\r\nvar Base64Decode = /** @class */ (function () {\r\n function Base64Decode() {\r\n }\r\n /**\r\n * Returns a URL-safe plaintext decoded string from b64 encoded input.\r\n * @param input\r\n */\r\n Base64Decode.prototype.decode = 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 var inputUtf8Arr = this.base64DecToArr(encodedString);\r\n return BrowserStringUtils.utf8ArrToString(inputUtf8Arr);\r\n };\r\n /**\r\n * Decodes base64 into Uint8Array\r\n * @param base64String\r\n * @param nBlockSize\r\n */\r\n Base64Decode.prototype.base64DecToArr = function (base64String, nBlockSize) {\r\n var sB64Enc = base64String.replace(/[^A-Za-z0-9\\+\\/]/g, \"\");\r\n var nInLen = sB64Enc.length;\r\n var nOutLen = nBlockSize ? Math.ceil((nInLen * 3 + 1 >>> 2) / nBlockSize) * nBlockSize : nInLen * 3 + 1 >>> 2;\r\n var aBytes = new Uint8Array(nOutLen);\r\n for (var nMod3 = void 0, nMod4 = void 0, nUint24 = 0, nOutIdx = 0, nInIdx = 0; nInIdx < nInLen; nInIdx++) {\r\n nMod4 = nInIdx & 3;\r\n nUint24 |= this.b64ToUint6(sB64Enc.charCodeAt(nInIdx)) << 18 - 6 * nMod4;\r\n if (nMod4 === 3 || nInLen - nInIdx === 1) {\r\n for (nMod3 = 0; nMod3 < 3 && nOutIdx < nOutLen; nMod3++, nOutIdx++) {\r\n aBytes[nOutIdx] = nUint24 >>> (16 >>> nMod3 & 24) & 255;\r\n }\r\n nUint24 = 0;\r\n }\r\n }\r\n return aBytes;\r\n };\r\n /**\r\n * Base64 string to array decoding helper\r\n * @param charNum\r\n */\r\n Base64Decode.prototype.b64ToUint6 = function (charNum) {\r\n return charNum > 64 && charNum < 91 ?\r\n charNum - 65\r\n : charNum > 96 && charNum < 123 ?\r\n charNum - 71\r\n : charNum > 47 && charNum < 58 ?\r\n charNum + 4\r\n : charNum === 43 ?\r\n 62\r\n : charNum === 47 ?\r\n 63\r\n :\r\n 0;\r\n };\r\n return Base64Decode;\r\n}());\n\n/**\r\n * BrowserAuthErrorMessage class containing string constants used by error codes and messages.\r\n */\r\nvar BrowserAuthErrorMessage = {\r\n pkceNotGenerated: {\r\n code: \"pkce_not_created\",\r\n desc: \"The PKCE code challenge and verifier could not be generated.\"\r\n },\r\n cryptoDoesNotExist: {\r\n code: \"crypto_nonexistent\",\r\n desc: \"The crypto object or function is not available.\"\r\n },\r\n httpMethodNotImplementedError: {\r\n code: \"http_method_not_implemented\",\r\n desc: \"The HTTP method given has not been implemented in this library.\"\r\n },\r\n emptyNavigateUriError: {\r\n code: \"empty_navigate_uri\",\r\n desc: \"Navigation URI is empty. Please check stack trace for more info.\"\r\n },\r\n hashEmptyError: {\r\n code: \"hash_empty_error\",\r\n desc: \"Hash value cannot be processed because it is empty.\"\r\n },\r\n interactionInProgress: {\r\n code: \"interaction_in_progress\",\r\n desc: \"Interaction is currently in progress. Please ensure that this interaction has been completed before calling an interactive API.\"\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 emptyWindowError: {\r\n code: \"empty_window_error\",\r\n desc: \"window.open returned null or undefined window object.\"\r\n },\r\n userCancelledError: {\r\n code: \"user_cancelled\",\r\n desc: \"User cancelled the flow.\"\r\n },\r\n monitorWindowTimeoutError: {\r\n code: \"monitor_window_timeout\",\r\n desc: \"Token acquisition in popup failed due to timeout.\"\r\n },\r\n redirectInIframeError: {\r\n code: \"redirect_in_iframe\",\r\n desc: \"Code flow is not supported inside an iframe. Please ensure you are using MSAL.js in a top frame of the window if using the redirect APIs, or use the popup APIs.\"\r\n },\r\n blockTokenRequestsInHiddenIframeError: {\r\n code: \"block_iframe_reload\",\r\n desc: \"Request was blocked inside an iframe because MSAL detected an authentication response. Please ensure monitorWindowForHash was called.\"\r\n },\r\n iframeClosedPrematurelyError: {\r\n code: \"iframe_closed_prematurely\",\r\n desc: \"The iframe being monitored was closed prematurely.\"\r\n },\r\n silentSSOInsufficientInfoError: {\r\n code: \"silent_sso_error\",\r\n desc: \"Silent SSO could not be completed - insufficient information was provided. Please provide either a loginHint or sid.\"\r\n },\r\n silentPromptValueError: {\r\n code: \"silent_prompt_value_error\",\r\n desc: \"The value given for the prompt value is not valid for silent requests - must be set to 'none'.\"\r\n },\r\n tokenRequestCacheError: {\r\n code: \"token_request_cache_error\",\r\n desc: \"The token request could not be fetched from the cache correctly.\"\r\n },\r\n invalidCacheType: {\r\n code: \"invalid_cache_type\",\r\n desc: \"Invalid cache type\"\r\n },\r\n notInBrowserEnvironment: {\r\n code: \"non_browser_environment\",\r\n desc: \"Login and token requests are not supported in non-browser environments.\"\r\n }\r\n};\r\n/**\r\n * Browser library error class thrown by the MSAL.js library for SPAs\r\n */\r\nvar BrowserAuthError = /** @class */ (function (_super) {\r\n __extends(BrowserAuthError, _super);\r\n function BrowserAuthError(errorCode, errorMessage) {\r\n var _this = _super.call(this, errorCode, errorMessage) || this;\r\n Object.setPrototypeOf(_this, BrowserAuthError.prototype);\r\n _this.name = \"BrowserAuthError\";\r\n return _this;\r\n }\r\n /**\r\n * Creates an error thrown when PKCE is not implemented.\r\n * @param errDetail\r\n */\r\n BrowserAuthError.createPkceNotGeneratedError = function (errDetail) {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.pkceNotGenerated.code, BrowserAuthErrorMessage.pkceNotGenerated.desc + \" Detail:\" + errDetail);\r\n };\r\n /**\r\n * Creates an error thrown when the crypto object is unavailable.\r\n * @param errDetail\r\n */\r\n BrowserAuthError.createCryptoNotAvailableError = function (errDetail) {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.cryptoDoesNotExist.code, BrowserAuthErrorMessage.cryptoDoesNotExist.desc + \" Detail:\" + errDetail);\r\n };\r\n /**\r\n * Creates an error thrown when an HTTP method hasn't been implemented by the browser class.\r\n * @param method\r\n */\r\n BrowserAuthError.createHttpMethodNotImplementedError = function (method) {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.httpMethodNotImplementedError.code, BrowserAuthErrorMessage.httpMethodNotImplementedError.desc + \" Given Method: \" + method);\r\n };\r\n /**\r\n * Creates an error thrown when the navigation URI is empty.\r\n */\r\n BrowserAuthError.createEmptyNavigationUriError = function () {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.emptyNavigateUriError.code, BrowserAuthErrorMessage.emptyNavigateUriError.desc);\r\n };\r\n /**\r\n * Creates an error thrown when the hash string value is unexpectedly empty.\r\n * @param hashValue\r\n */\r\n BrowserAuthError.createEmptyHashError = function (hashValue) {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.hashEmptyError.code, BrowserAuthErrorMessage.hashEmptyError.desc + \" Given Url: \" + hashValue);\r\n };\r\n /**\r\n * Creates an error thrown when a browser interaction (redirect or popup) is in progress.\r\n */\r\n BrowserAuthError.createInteractionInProgressError = function () {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.interactionInProgress.code, BrowserAuthErrorMessage.interactionInProgress.desc);\r\n };\r\n /**\r\n * Creates an error thrown when the popup window could not be opened.\r\n * @param errDetail\r\n */\r\n BrowserAuthError.createPopupWindowError = function (errDetail) {\r\n var errorMessage = BrowserAuthErrorMessage.popUpWindowError.desc;\r\n errorMessage = !StringUtils.isEmpty(errDetail) ? errorMessage + \" Details: \" + errDetail : errorMessage;\r\n return new BrowserAuthError(BrowserAuthErrorMessage.popUpWindowError.code, errorMessage);\r\n };\r\n /**\r\n * Creates an error thrown when window.open returns an empty window object.\r\n * @param errDetail\r\n */\r\n BrowserAuthError.createEmptyWindowCreatedError = function () {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.emptyWindowError.code, BrowserAuthErrorMessage.emptyWindowError.desc);\r\n };\r\n /**\r\n * Creates an error thrown when the user closes a popup.\r\n */\r\n BrowserAuthError.createUserCancelledError = function () {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.userCancelledError.code, BrowserAuthErrorMessage.userCancelledError.desc);\r\n };\r\n /**\r\n * Creates an error thrown when monitorWindowFromHash times out for a given popup.\r\n * @param urlNavigate\r\n */\r\n BrowserAuthError.createMonitorWindowTimeoutError = function () {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.monitorWindowTimeoutError.code, BrowserAuthErrorMessage.monitorWindowTimeoutError.desc);\r\n };\r\n /**\r\n * Creates an error thrown when navigateWindow is called inside an iframe.\r\n * @param windowParentCheck\r\n */\r\n BrowserAuthError.createRedirectInIframeError = function (windowParentCheck) {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.redirectInIframeError.code, BrowserAuthErrorMessage.redirectInIframeError.desc + \" (window.parent !== window) => \" + windowParentCheck);\r\n };\r\n /**\r\n * Creates an error thrown when an auth reload is done inside an iframe.\r\n */\r\n BrowserAuthError.createBlockReloadInHiddenIframeError = function () {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.blockTokenRequestsInHiddenIframeError.code, BrowserAuthErrorMessage.blockTokenRequestsInHiddenIframeError.desc);\r\n };\r\n /**\r\n * Creates an error thrown when an iframe is found to be closed before the timeout is reached.\r\n */\r\n BrowserAuthError.createIframeClosedPrematurelyError = function () {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.iframeClosedPrematurelyError.code, BrowserAuthErrorMessage.iframeClosedPrematurelyError.desc);\r\n };\r\n /**\r\n * Creates an error thrown when the login_hint, sid or account object is not provided in the ssoSilent API.\r\n */\r\n BrowserAuthError.createSilentSSOInsufficientInfoError = function () {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.silentSSOInsufficientInfoError.code, BrowserAuthErrorMessage.silentSSOInsufficientInfoError.desc);\r\n };\r\n /**\r\n * Creates an error thrown when a given prompt value is invalid for silent requests.\r\n */\r\n BrowserAuthError.createSilentPromptValueError = function (givenPrompt) {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.silentPromptValueError.code, BrowserAuthErrorMessage.silentPromptValueError.desc + \" Given value: \" + givenPrompt);\r\n };\r\n /**\r\n * Creates an error thrown when the token request could not be retrieved from the cache\r\n * @param errDetail\r\n */\r\n BrowserAuthError.createTokenRequestCacheError = function (errDetail) {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.tokenRequestCacheError.code, BrowserAuthErrorMessage.tokenRequestCacheError.desc + \" Error Detail: \" + errDetail);\r\n };\r\n /**\r\n * Creates an error thrown if cache type is invalid.\r\n */\r\n BrowserAuthError.createInvalidCacheTypeError = function () {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.invalidCacheType.code, \"\" + BrowserAuthErrorMessage.invalidCacheType.desc);\r\n };\r\n /**\r\n * Create an error thrown when login and token requests are made from a non-browser environment\r\n */\r\n BrowserAuthError.createNonBrowserEnvironmentError = function () {\r\n return new BrowserAuthError(BrowserAuthErrorMessage.notInBrowserEnvironment.code, BrowserAuthErrorMessage.notInBrowserEnvironment.desc);\r\n };\r\n return BrowserAuthError;\r\n}(AuthError));\n\n// Constant byte array length\r\nvar RANDOM_BYTE_ARR_LENGTH = 32;\r\n/**\r\n * Class which exposes APIs to generate PKCE codes and code verifiers.\r\n */\r\nvar PkceGenerator = /** @class */ (function () {\r\n function PkceGenerator(cryptoObj) {\r\n this.base64Encode = new Base64Encode();\r\n this.cryptoObj = cryptoObj;\r\n }\r\n /**\r\n * Generates PKCE Codes. See the RFC for more information: https://tools.ietf.org/html/rfc7636\r\n */\r\n PkceGenerator.prototype.generateCodes = function () {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var codeVerifier, codeChallenge;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n codeVerifier = this.generateCodeVerifier();\r\n return [4 /*yield*/, this.generateCodeChallengeFromVerifier(codeVerifier)];\r\n case 1:\r\n codeChallenge = _a.sent();\r\n return [2 /*return*/, {\r\n verifier: codeVerifier,\r\n challenge: codeChallenge\r\n }];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Generates a random 32 byte buffer and returns the base64\r\n * encoded string to be used as a PKCE Code Verifier\r\n */\r\n PkceGenerator.prototype.generateCodeVerifier = function () {\r\n try {\r\n // Generate random values as utf-8\r\n var buffer = new Uint8Array(RANDOM_BYTE_ARR_LENGTH);\r\n this.cryptoObj.getRandomValues(buffer);\r\n // encode verifier as base64\r\n var pkceCodeVerifierB64 = this.base64Encode.urlEncodeArr(buffer);\r\n return pkceCodeVerifierB64;\r\n }\r\n catch (e) {\r\n throw BrowserAuthError.createPkceNotGeneratedError(e);\r\n }\r\n };\r\n /**\r\n * Creates a base64 encoded PKCE Code Challenge string from the\r\n * hash created from the PKCE Code Verifier supplied\r\n */\r\n PkceGenerator.prototype.generateCodeChallengeFromVerifier = function (pkceCodeVerifier) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var pkceHashedCodeVerifier, e_1;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n _a.trys.push([0, 2, , 3]);\r\n return [4 /*yield*/, this.cryptoObj.sha256Digest(pkceCodeVerifier)];\r\n case 1:\r\n pkceHashedCodeVerifier = _a.sent();\r\n // encode hash as base64\r\n return [2 /*return*/, this.base64Encode.urlEncodeArr(new Uint8Array(pkceHashedCodeVerifier))];\r\n case 2:\r\n e_1 = _a.sent();\r\n throw BrowserAuthError.createPkceNotGeneratedError(e_1);\r\n case 3: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n return PkceGenerator;\r\n}());\n\n// SHA-256 hashing algorithm\r\nvar HASH_ALG = \"SHA-256\";\r\n/**\r\n * This class implements functions used by the browser library to perform cryptography operations such as\r\n * hashing and encoding. It also has helper functions to validate the availability of specific APIs.\r\n */\r\nvar BrowserCrypto = /** @class */ (function () {\r\n function BrowserCrypto() {\r\n if (!(this.hasCryptoAPI())) {\r\n throw BrowserAuthError.createCryptoNotAvailableError(\"Browser crypto or msCrypto object not available.\");\r\n }\r\n }\r\n /**\r\n * Returns a sha-256 hash of the given dataString as an ArrayBuffer.\r\n * @param dataString\r\n */\r\n BrowserCrypto.prototype.sha256Digest = function (dataString) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var data;\r\n return __generator(this, function (_a) {\r\n data = BrowserStringUtils.stringToUtf8Arr(dataString);\r\n return [2 /*return*/, this.hasIECrypto() ? this.getMSCryptoDigest(HASH_ALG, data) : this.getSubtleCryptoDigest(HASH_ALG, data)];\r\n });\r\n });\r\n };\r\n /**\r\n * Populates buffer with cryptographically random values.\r\n * @param dataBuffer\r\n */\r\n BrowserCrypto.prototype.getRandomValues = function (dataBuffer) {\r\n var cryptoObj = window[\"msCrypto\"] || window.crypto;\r\n if (!cryptoObj.getRandomValues) {\r\n throw BrowserAuthError.createCryptoNotAvailableError(\"getRandomValues does not exist.\");\r\n }\r\n cryptoObj.getRandomValues(dataBuffer);\r\n };\r\n /**\r\n * Checks whether IE crypto (AKA msCrypto) is available.\r\n */\r\n BrowserCrypto.prototype.hasIECrypto = function () {\r\n return !!window[\"msCrypto\"];\r\n };\r\n /**\r\n * Check whether browser crypto is available.\r\n */\r\n BrowserCrypto.prototype.hasBrowserCrypto = function () {\r\n return !!window.crypto;\r\n };\r\n /**\r\n * Check whether IE crypto or other browser cryptography is available.\r\n */\r\n BrowserCrypto.prototype.hasCryptoAPI = function () {\r\n return this.hasIECrypto() || this.hasBrowserCrypto();\r\n };\r\n /**\r\n * Helper function for SHA digest.\r\n * @param algorithm\r\n * @param data\r\n */\r\n BrowserCrypto.prototype.getSubtleCryptoDigest = function (algorithm, data) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n return [2 /*return*/, window.crypto.subtle.digest(algorithm, data)];\r\n });\r\n });\r\n };\r\n /**\r\n * Helper function for SHA digest.\r\n * @param algorithm\r\n * @param data\r\n */\r\n BrowserCrypto.prototype.getMSCryptoDigest = function (algorithm, data) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n return [2 /*return*/, new Promise(function (resolve, reject) {\r\n var digestOperation = window[\"msCrypto\"].subtle.digest(algorithm, data.buffer);\r\n digestOperation.addEventListener(\"complete\", function (e) {\r\n resolve(e.target.result);\r\n });\r\n digestOperation.addEventListener(\"error\", function (error) {\r\n reject(error);\r\n });\r\n })];\r\n });\r\n });\r\n };\r\n return BrowserCrypto;\r\n}());\n\n/**\r\n * This class implements MSAL's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and\r\n * implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).\r\n */\r\nvar CryptoOps = /** @class */ (function () {\r\n function CryptoOps() {\r\n // Browser crypto needs to be validated first before any other classes can be set.\r\n this.browserCrypto = new BrowserCrypto();\r\n this.b64Encode = new Base64Encode();\r\n this.b64Decode = new Base64Decode();\r\n this.guidGenerator = new GuidGenerator(this.browserCrypto);\r\n this.pkceGenerator = new PkceGenerator(this.browserCrypto);\r\n }\r\n /**\r\n * Creates a new random GUID - used to populate state and nonce.\r\n * @returns string (GUID)\r\n */\r\n CryptoOps.prototype.createNewGuid = function () {\r\n return this.guidGenerator.generateGuid();\r\n };\r\n /**\r\n * Encodes input string to base64.\r\n * @param input\r\n */\r\n CryptoOps.prototype.base64Encode = function (input) {\r\n return this.b64Encode.encode(input);\r\n };\r\n /**\r\n * Decodes input string from base64.\r\n * @param input\r\n */\r\n CryptoOps.prototype.base64Decode = function (input) {\r\n return this.b64Decode.decode(input);\r\n };\r\n /**\r\n * Generates PKCE codes used in Authorization Code Flow.\r\n */\r\n CryptoOps.prototype.generatePkceCodes = function () {\r\n return __awaiter(this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n return [2 /*return*/, this.pkceGenerator.generateCodes()];\r\n });\r\n });\r\n };\r\n return CryptoOps;\r\n}());\n\n/**\r\n * BrowserAuthErrorMessage class containing string constants used by error codes and messages.\r\n */\r\nvar BrowserConfigurationAuthErrorMessage = {\r\n redirectUriNotSet: {\r\n code: \"redirect_uri_empty\",\r\n desc: \"A redirect URI is required for all calls, and none has been set.\"\r\n },\r\n postLogoutUriNotSet: {\r\n code: \"post_logout_uri_empty\",\r\n desc: \"A post logout redirect has not been set.\"\r\n },\r\n storageNotSupportedError: {\r\n code: \"storage_not_supported\",\r\n desc: \"Given storage configuration option was not supported.\"\r\n },\r\n noRedirectCallbacksSet: {\r\n code: \"no_redirect_callbacks\",\r\n desc: \"No redirect callbacks have been set. Please call setRedirectCallbacks() 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};\r\n/**\r\n * Browser library error class thrown by the MSAL.js library for SPAs\r\n */\r\nvar BrowserConfigurationAuthError = /** @class */ (function (_super) {\r\n __extends(BrowserConfigurationAuthError, _super);\r\n function BrowserConfigurationAuthError(errorCode, errorMessage) {\r\n var _this = _super.call(this, errorCode, errorMessage) || this;\r\n _this.name = \"BrowserConfigurationAuthError\";\r\n Object.setPrototypeOf(_this, BrowserConfigurationAuthError.prototype);\r\n return _this;\r\n }\r\n /**\r\n * Creates an error thrown when the redirect uri is empty (not set by caller)\r\n */\r\n BrowserConfigurationAuthError.createRedirectUriEmptyError = function () {\r\n return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.redirectUriNotSet.code, BrowserConfigurationAuthErrorMessage.redirectUriNotSet.desc);\r\n };\r\n /**\r\n * Creates an error thrown when the post-logout redirect uri is empty (not set by caller)\r\n */\r\n BrowserConfigurationAuthError.createPostLogoutRedirectUriEmptyError = function () {\r\n return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.postLogoutUriNotSet.code, BrowserConfigurationAuthErrorMessage.postLogoutUriNotSet.desc);\r\n };\r\n /**\r\n * Creates error thrown when given storage location is not supported.\r\n * @param givenStorageLocation\r\n */\r\n BrowserConfigurationAuthError.createStorageNotSupportedError = function (givenStorageLocation) {\r\n return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.storageNotSupportedError.code, BrowserConfigurationAuthErrorMessage.storageNotSupportedError.desc + \" Given Location: \" + givenStorageLocation);\r\n };\r\n /**\r\n * Creates error thrown when callback object is invalid.\r\n * @param callbackObject\r\n */\r\n BrowserConfigurationAuthError.createInvalidCallbackObjectError = function (callbackObject) {\r\n return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.invalidCallbackObject.code, BrowserConfigurationAuthErrorMessage.invalidCallbackObject.desc + \" Given value for callback function: \" + callbackObject);\r\n };\r\n /**\r\n * Creates error thrown when redirect callbacks are not set before calling loginRedirect() or acquireTokenRedirect().\r\n */\r\n BrowserConfigurationAuthError.createRedirectCallbacksNotSetError = function () {\r\n return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.noRedirectCallbacksSet.code, BrowserConfigurationAuthErrorMessage.noRedirectCallbacksSet.desc);\r\n };\r\n return BrowserConfigurationAuthError;\r\n}(AuthError));\n\n// Cookie life calculation (hours * minutes * seconds * ms)\r\nvar COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;\r\n/**\r\n * This class implements the cache storage interface for MSAL through browser local or session storage.\r\n * Cookies are only used if storeAuthStateInCookie is true, and are only used for\r\n * parameters such as state and nonce, generally.\r\n */\r\nvar BrowserStorage = /** @class */ (function (_super) {\r\n __extends(BrowserStorage, _super);\r\n function BrowserStorage(clientId, cacheConfig, cryptoImpl) {\r\n var _this = _super.call(this) || this;\r\n // Validate cache location\r\n _this.validateWindowStorage(cacheConfig.cacheLocation);\r\n _this.cacheConfig = cacheConfig;\r\n _this.windowStorage = window[_this.cacheConfig.cacheLocation];\r\n _this.clientId = clientId;\r\n _this.cryptoImpl = cryptoImpl;\r\n // Migrate any cache entries from older versions of MSAL.\r\n _this.migrateCacheEntries();\r\n return _this;\r\n }\r\n /**\r\n * Validates the the given cache location string is an expected value:\r\n * - localStorage\r\n * - sessionStorage (default)\r\n * Also validates if given cacheLocation is supported on the browser.\r\n * @param cacheLocation\r\n */\r\n BrowserStorage.prototype.validateWindowStorage = function (cacheLocation) {\r\n if (cacheLocation !== BrowserConstants.CACHE_LOCATION_LOCAL && cacheLocation !== BrowserConstants.CACHE_LOCATION_SESSION) {\r\n throw BrowserConfigurationAuthError.createStorageNotSupportedError(cacheLocation);\r\n }\r\n var storageSupported = !!window[cacheLocation];\r\n if (!storageSupported) {\r\n throw BrowserConfigurationAuthError.createStorageNotSupportedError(cacheLocation);\r\n }\r\n };\r\n /**\r\n * Migrate all old cache entries to new schema. No rollback supported.\r\n * @param storeAuthStateInCookie\r\n */\r\n BrowserStorage.prototype.migrateCacheEntries = function () {\r\n var _this = this;\r\n var idTokenKey = Constants.CACHE_PREFIX + \".\" + PersistentCacheKeys.ID_TOKEN;\r\n var clientInfoKey = Constants.CACHE_PREFIX + \".\" + PersistentCacheKeys.CLIENT_INFO;\r\n var errorKey = Constants.CACHE_PREFIX + \".\" + PersistentCacheKeys.ERROR;\r\n var errorDescKey = Constants.CACHE_PREFIX + \".\" + PersistentCacheKeys.ERROR_DESC;\r\n var idTokenValue = this.windowStorage.getItem(idTokenKey);\r\n var clientInfoValue = this.windowStorage.getItem(clientInfoKey);\r\n var errorValue = this.windowStorage.getItem(errorKey);\r\n var errorDescValue = this.windowStorage.getItem(errorDescKey);\r\n var values = [idTokenValue, clientInfoValue, errorValue, errorDescValue];\r\n var keysToMigrate = [PersistentCacheKeys.ID_TOKEN, PersistentCacheKeys.CLIENT_INFO, PersistentCacheKeys.ERROR, PersistentCacheKeys.ERROR_DESC];\r\n keysToMigrate.forEach(function (cacheKey, index) { return _this.migrateCacheEntry(cacheKey, values[index]); });\r\n };\r\n /**\r\n * Utility function to help with migration.\r\n * @param newKey\r\n * @param value\r\n * @param storeAuthStateInCookie\r\n */\r\n BrowserStorage.prototype.migrateCacheEntry = function (newKey, value) {\r\n if (value) {\r\n this.setItem(this.generateCacheKey(newKey), value, CacheSchemaType.TEMPORARY);\r\n }\r\n };\r\n /**\r\n * Parses key as JSON object, JSON.parse() will throw an error.\r\n * @param key\r\n */\r\n BrowserStorage.prototype.validateObjectKey = function (key) {\r\n JSON.parse(key);\r\n };\r\n /**\r\n * Sets the cache item with the key and value given.\r\n * Stores in cookie if storeAuthStateInCookie is set to true.\r\n * This can cause cookie overflow if used incorrectly.\r\n * @param key\r\n * @param value\r\n */\r\n BrowserStorage.prototype.setItem = function (key, value, type) {\r\n // save the cacheItem\r\n switch (type) {\r\n case CacheSchemaType.ACCOUNT:\r\n case CacheSchemaType.CREDENTIAL:\r\n case CacheSchemaType.APP_METADATA:\r\n case CacheSchemaType.THROTTLING:\r\n this.windowStorage.setItem(key, JSON.stringify(value));\r\n break;\r\n case CacheSchemaType.TEMPORARY: {\r\n var stringVal = value;\r\n this.windowStorage.setItem(key, stringVal);\r\n if (this.cacheConfig.storeAuthStateInCookie) {\r\n this.setItemCookie(key, stringVal);\r\n }\r\n break;\r\n }\r\n case CacheSchemaType.TELEMETRY: {\r\n this.windowStorage.setItem(key, JSON.stringify(value));\r\n break;\r\n }\r\n default: {\r\n throw BrowserAuthError.createInvalidCacheTypeError();\r\n }\r\n }\r\n };\r\n /**\r\n * Gets cache item with given key.\r\n * Will retrieve frm cookies if storeAuthStateInCookie is set to true.\r\n * @param key\r\n */\r\n BrowserStorage.prototype.getItem = function (key, type) {\r\n var value = this.windowStorage.getItem(key);\r\n if (StringUtils.isEmpty(value)) {\r\n return null;\r\n }\r\n switch (type) {\r\n case CacheSchemaType.ACCOUNT: {\r\n var account = new AccountEntity();\r\n return CacheManager.toObject(account, JSON.parse(value));\r\n }\r\n case CacheSchemaType.CREDENTIAL: {\r\n var credentialType = CredentialEntity.getCredentialType(key);\r\n switch (credentialType) {\r\n case CredentialType.ID_TOKEN: {\r\n var idTokenEntity = new IdTokenEntity();\r\n return CacheManager.toObject(idTokenEntity, JSON.parse(value));\r\n }\r\n case CredentialType.ACCESS_TOKEN: {\r\n var accessTokenEntity = new AccessTokenEntity();\r\n return CacheManager.toObject(accessTokenEntity, JSON.parse(value));\r\n }\r\n case CredentialType.REFRESH_TOKEN: {\r\n var refreshTokenEntity = new RefreshTokenEntity();\r\n return CacheManager.toObject(refreshTokenEntity, JSON.parse(value));\r\n }\r\n }\r\n }\r\n case CacheSchemaType.APP_METADATA: {\r\n return JSON.parse(value);\r\n }\r\n case CacheSchemaType.THROTTLING: {\r\n return JSON.parse(value);\r\n }\r\n case CacheSchemaType.TEMPORARY: {\r\n var itemCookie = this.getItemCookie(key);\r\n if (this.cacheConfig.storeAuthStateInCookie) {\r\n return itemCookie;\r\n }\r\n return value;\r\n }\r\n case CacheSchemaType.TELEMETRY: {\r\n return JSON.parse(value);\r\n }\r\n default: {\r\n throw BrowserAuthError.createInvalidCacheTypeError();\r\n }\r\n }\r\n };\r\n /**\r\n * Removes the cache item with the given key.\r\n * Will also clear the cookie item if storeAuthStateInCookie is set to true.\r\n * @param key\r\n */\r\n BrowserStorage.prototype.removeItem = function (key) {\r\n this.windowStorage.removeItem(key);\r\n if (this.cacheConfig.storeAuthStateInCookie) {\r\n this.clearItemCookie(key);\r\n }\r\n return true;\r\n };\r\n /**\r\n * Checks whether key is in cache.\r\n * @param key\r\n */\r\n BrowserStorage.prototype.containsKey = function (key) {\r\n return this.windowStorage.hasOwnProperty(key);\r\n };\r\n /**\r\n * Gets all keys in window.\r\n */\r\n BrowserStorage.prototype.getKeys = function () {\r\n return Object.keys(this.windowStorage);\r\n };\r\n /**\r\n * Clears all cache entries created by MSAL (except tokens).\r\n */\r\n BrowserStorage.prototype.clear = function () {\r\n this.removeAllAccounts();\r\n this.removeAppMetadata();\r\n var key;\r\n for (key in this.windowStorage) {\r\n // Check if key contains msal prefix; For now, we are clearing all the cache items created by MSAL.js\r\n if (this.windowStorage.hasOwnProperty(key) && ((key.indexOf(Constants.CACHE_PREFIX) !== -1) || (key.indexOf(this.clientId) !== -1))) {\r\n this.removeItem(key);\r\n }\r\n }\r\n };\r\n /**\r\n * Add value to cookies\r\n * @param cookieName\r\n * @param cookieValue\r\n * @param expires\r\n */\r\n BrowserStorage.prototype.setItemCookie = function (cookieName, cookieValue, expires) {\r\n var cookieStr = encodeURIComponent(cookieName) + \"=\" + encodeURIComponent(cookieValue) + \";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 cookieName\r\n */\r\n BrowserStorage.prototype.getItemCookie = function (cookieName) {\r\n var name = encodeURIComponent(cookieName) + \"=\";\r\n var cookieList = document.cookie.split(\";\");\r\n for (var i = 0; i < cookieList.length; i++) {\r\n var cookie = cookieList[i];\r\n while (cookie.charAt(0) === \" \") {\r\n cookie = cookie.substring(1);\r\n }\r\n if (cookie.indexOf(name) === 0) {\r\n return decodeURIComponent(cookie.substring(name.length, cookie.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 cookieName\r\n */\r\n BrowserStorage.prototype.clearItemCookie = function (cookieName) {\r\n this.setItemCookie(cookieName, \"\", -1);\r\n };\r\n /**\r\n * Clear all msal cookies\r\n */\r\n BrowserStorage.prototype.clearMsalCookie = function (stateString) {\r\n var nonceKey = stateString ? this.generateNonceKey(stateString) : this.generateStateKey(TemporaryCacheKeys.NONCE_IDTOKEN);\r\n this.clearItemCookie(this.generateStateKey(stateString));\r\n this.clearItemCookie(nonceKey);\r\n this.clearItemCookie(this.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI));\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 * COOKIE_LIFE_MULTIPLIER);\r\n return expr.toUTCString();\r\n };\r\n /**\r\n * Gets the cache object referenced by the browser\r\n */\r\n BrowserStorage.prototype.getCache = function () {\r\n return this.windowStorage;\r\n };\r\n /**\r\n * interface compat, we cannot overwrite browser cache; Functionality is supported by individual entities in browser\r\n */\r\n BrowserStorage.prototype.setCache = function () {\r\n // sets nothing\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 BrowserStorage.prototype.generateCacheKey = function (key) {\r\n try {\r\n // Defined schemas do not need the key migrated\r\n this.validateObjectKey(key);\r\n return key;\r\n }\r\n catch (e) {\r\n if (StringUtils.startsWith(key, Constants.CACHE_PREFIX) || StringUtils.startsWith(key, PersistentCacheKeys.ADAL_ID_TOKEN)) {\r\n return key;\r\n }\r\n return Constants.CACHE_PREFIX + \".\" + this.clientId + \".\" + key;\r\n }\r\n };\r\n /**\r\n * Create authorityKey to cache authority\r\n * @param state\r\n */\r\n BrowserStorage.prototype.generateAuthorityKey = function (stateString) {\r\n var stateId = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString).libraryState.id;\r\n return this.generateCacheKey(TemporaryCacheKeys.AUTHORITY + \".\" + stateId);\r\n };\r\n /**\r\n * Create Nonce key to cache nonce\r\n * @param state\r\n */\r\n BrowserStorage.prototype.generateNonceKey = function (stateString) {\r\n var stateId = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString).libraryState.id;\r\n return this.generateCacheKey(TemporaryCacheKeys.NONCE_IDTOKEN + \".\" + stateId);\r\n };\r\n /**\r\n * Creates full cache key for the request state\r\n * @param stateString State string for the request\r\n */\r\n BrowserStorage.prototype.generateStateKey = function (stateString) {\r\n // Use the library state id to key temp storage for uniqueness for multiple concurrent requests\r\n var stateId = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString).libraryState.id;\r\n return this.generateCacheKey(TemporaryCacheKeys.REQUEST_STATE + \".\" + stateId);\r\n };\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 */\r\n BrowserStorage.prototype.setAuthorityCache = function (authority, state) {\r\n // Cache authorityKey\r\n this.setItem(this.generateAuthorityKey(state), authority, CacheSchemaType.TEMPORARY);\r\n };\r\n /**\r\n * Gets the cached authority based on the cached state. Returns empty if no cached state found.\r\n */\r\n BrowserStorage.prototype.getCachedAuthority = function (cachedState) {\r\n var state = this.getItem(this.generateStateKey(cachedState), CacheSchemaType.TEMPORARY);\r\n if (!state) {\r\n return null;\r\n }\r\n return this.getItem(this.generateAuthorityKey(state), CacheSchemaType.TEMPORARY);\r\n };\r\n /**\r\n * Updates account, authority, and state in cache\r\n * @param serverAuthenticationRequest\r\n * @param account\r\n */\r\n BrowserStorage.prototype.updateCacheEntries = function (state, nonce, authorityInstance) {\r\n // Cache the request state\r\n this.setItem(this.generateStateKey(state), state, CacheSchemaType.TEMPORARY);\r\n // Cache the nonce\r\n this.setItem(this.generateNonceKey(state), nonce, CacheSchemaType.TEMPORARY);\r\n // Cache authorityKey\r\n this.setAuthorityCache(authorityInstance, state);\r\n };\r\n /**\r\n * Reset all temporary cache items\r\n * @param state\r\n */\r\n BrowserStorage.prototype.resetRequestCache = function (state) {\r\n var _this = this;\r\n // check state and remove associated cache items\r\n this.getKeys().forEach(function (key) {\r\n if (!StringUtils.isEmpty(state) && key.indexOf(state) !== -1) {\r\n _this.removeItem(key);\r\n }\r\n });\r\n // delete generic interactive request parameters\r\n if (state) {\r\n this.removeItem(this.generateStateKey(state));\r\n this.removeItem(this.generateNonceKey(state));\r\n this.removeItem(this.generateAuthorityKey(state));\r\n }\r\n this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));\r\n this.removeItem(this.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI));\r\n this.removeItem(this.generateCacheKey(TemporaryCacheKeys.URL_HASH));\r\n };\r\n BrowserStorage.prototype.cleanRequest = function (stateString) {\r\n // Interaction is completed - remove interaction status.\r\n this.removeItem(this.generateCacheKey(BrowserConstants.INTERACTION_STATUS_KEY));\r\n if (stateString) {\r\n var cachedState = this.getItem(this.generateStateKey(stateString), CacheSchemaType.TEMPORARY);\r\n this.resetRequestCache(cachedState || \"\");\r\n }\r\n };\r\n BrowserStorage.prototype.cacheCodeRequest = function (authCodeRequest, browserCrypto) {\r\n this.setItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS), browserCrypto.base64Encode(JSON.stringify(authCodeRequest)), CacheSchemaType.TEMPORARY);\r\n };\r\n /**\r\n * Gets the token exchange parameters from the cache. Throws an error if nothing is found.\r\n */\r\n BrowserStorage.prototype.getCachedRequest = function (state, browserCrypto) {\r\n try {\r\n // Get token request from cache and parse as TokenExchangeParameters.\r\n var encodedTokenRequest = this.getItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS), CacheSchemaType.TEMPORARY);\r\n var parsedRequest = JSON.parse(browserCrypto.base64Decode(encodedTokenRequest));\r\n this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));\r\n // Get cached authority and use if no authority is cached with request.\r\n if (StringUtils.isEmpty(parsedRequest.authority)) {\r\n var cachedAuthority = this.getItem(this.generateAuthorityKey(state), CacheSchemaType.TEMPORARY);\r\n parsedRequest.authority = cachedAuthority;\r\n }\r\n return parsedRequest;\r\n }\r\n catch (err) {\r\n throw BrowserAuthError.createTokenRequestCacheError(err);\r\n }\r\n };\r\n return BrowserStorage;\r\n}(CacheManager));\n\n/**\r\n * This class implements the Fetch API for GET and POST requests. See more here: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API\r\n */\r\nvar FetchClient = /** @class */ (function () {\r\n function FetchClient() {\r\n }\r\n /**\r\n * Fetch Client for REST endpoints - Get request\r\n * @param url\r\n * @param headers\r\n * @param body\r\n */\r\n FetchClient.prototype.sendGetRequestAsync = function (url, options) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var response, _a;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0: return [4 /*yield*/, fetch(url, {\r\n method: HTTP_REQUEST_TYPE.GET,\r\n headers: this.getFetchHeaders(options)\r\n })];\r\n case 1:\r\n response = _b.sent();\r\n _a = {\r\n headers: this.getHeaderDict(response.headers)\r\n };\r\n return [4 /*yield*/, response.json()];\r\n case 2: return [2 /*return*/, (_a.body = (_b.sent()),\r\n _a.status = response.status,\r\n _a)];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Fetch Client for REST endpoints - Post request\r\n * @param url\r\n * @param headers\r\n * @param body\r\n */\r\n FetchClient.prototype.sendPostRequestAsync = function (url, options) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var reqBody, response, _a;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n reqBody = (options && options.body) || \"\";\r\n return [4 /*yield*/, fetch(url, {\r\n method: HTTP_REQUEST_TYPE.POST,\r\n headers: this.getFetchHeaders(options),\r\n body: reqBody\r\n })];\r\n case 1:\r\n response = _b.sent();\r\n _a = {\r\n headers: this.getHeaderDict(response.headers)\r\n };\r\n return [4 /*yield*/, response.json()];\r\n case 2: return [2 /*return*/, (_a.body = (_b.sent()),\r\n _a.status = response.status,\r\n _a)];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Get Fetch API Headers object from string map\r\n * @param inputHeaders\r\n */\r\n FetchClient.prototype.getFetchHeaders = function (options) {\r\n var headers = new Headers();\r\n if (!(options && options.headers)) {\r\n return headers;\r\n }\r\n Object.keys(options.headers).forEach(function (key) {\r\n headers.append(key, options.headers[key]);\r\n });\r\n return headers;\r\n };\r\n FetchClient.prototype.getHeaderDict = function (headers) {\r\n var headerDict = {};\r\n headers.forEach(function (value, key) {\r\n headerDict[key] = value;\r\n });\r\n return headerDict;\r\n };\r\n return FetchClient;\r\n}());\n\n/**\r\n * This client implements the XMLHttpRequest class to send GET and POST requests.\r\n */\r\nvar XhrClient = /** @class */ (function () {\r\n function XhrClient() {\r\n }\r\n /**\r\n * XhrClient for REST endpoints - Get request\r\n * @param url\r\n * @param headers\r\n * @param body\r\n */\r\n XhrClient.prototype.sendGetRequestAsync = function (url, options) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n return [2 /*return*/, this.sendRequestAsync(url, HTTP_REQUEST_TYPE.GET, options)];\r\n });\r\n });\r\n };\r\n /**\r\n * XhrClient for REST endpoints - Post request\r\n * @param url\r\n * @param headers\r\n * @param body\r\n */\r\n XhrClient.prototype.sendPostRequestAsync = function (url, options) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n return [2 /*return*/, this.sendRequestAsync(url, HTTP_REQUEST_TYPE.POST, options)];\r\n });\r\n });\r\n };\r\n /**\r\n * Helper for XhrClient requests.\r\n * @param url\r\n * @param method\r\n * @param options\r\n */\r\n XhrClient.prototype.sendRequestAsync = function (url, method, options) {\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 _this.setXhrHeaders(xhr, options);\r\n xhr.onload = function () {\r\n if (xhr.status < 200 || xhr.status >= 300) {\r\n reject(xhr.responseText);\r\n }\r\n try {\r\n var jsonResponse = JSON.parse(xhr.responseText);\r\n var networkResponse = {\r\n headers: _this.getHeaderDict(xhr),\r\n body: jsonResponse,\r\n status: xhr.status\r\n };\r\n resolve(networkResponse);\r\n }\r\n catch (e) {\r\n reject(xhr.responseText);\r\n }\r\n };\r\n xhr.onerror = function () {\r\n reject(xhr.status);\r\n };\r\n if (method === \"POST\" && options.body) {\r\n xhr.send(options.body);\r\n }\r\n else if (method === \"GET\") {\r\n xhr.send();\r\n }\r\n else {\r\n throw BrowserAuthError.createHttpMethodNotImplementedError(method);\r\n }\r\n });\r\n };\r\n /**\r\n * Helper to set XHR headers for request.\r\n * @param xhr\r\n * @param options\r\n */\r\n XhrClient.prototype.setXhrHeaders = function (xhr, options) {\r\n if (options && options.headers) {\r\n Object.keys(options.headers).forEach(function (key) {\r\n xhr.setRequestHeader(key, options.headers[key]);\r\n });\r\n }\r\n };\r\n /**\r\n * Gets a string map of the headers received in the response.\r\n *\r\n * Algorithm comes from https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders\r\n * @param xhr\r\n */\r\n XhrClient.prototype.getHeaderDict = function (xhr) {\r\n var headerString = xhr.getAllResponseHeaders();\r\n var headerArr = headerString.trim().split(/[\\r\\n]+/);\r\n var headerDict = {};\r\n headerArr.forEach(function (value) {\r\n var parts = value.split(\": \");\r\n var headerName = parts.shift();\r\n var headerVal = parts.join(\": \");\r\n headerDict[headerName] = headerVal;\r\n });\r\n return headerDict;\r\n };\r\n return XhrClient;\r\n}());\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n/**\r\n * Utility class for browser specific functions\r\n */\r\nvar BrowserUtils = /** @class */ (function () {\r\n function BrowserUtils() {\r\n }\r\n // #region Window Navigation and URL management\r\n /**\r\n * Used to redirect the browser to the STS authorization endpoint\r\n * @param {string} urlNavigate - URL of the authorization endpoint\r\n * @param {boolean} noHistory - boolean flag, uses .replace() instead of .assign() if true\r\n */\r\n BrowserUtils.navigateWindow = function (urlNavigate, noHistory) {\r\n if (noHistory) {\r\n window.location.replace(urlNavigate);\r\n }\r\n else {\r\n window.location.assign(urlNavigate);\r\n }\r\n };\r\n /**\r\n * Clears hash from window url.\r\n */\r\n BrowserUtils.clearHash = function () {\r\n window.location.hash = \"\";\r\n };\r\n /**\r\n * Replaces current hash with hash from provided url\r\n */\r\n BrowserUtils.replaceHash = function (url) {\r\n var urlParts = url.split(\"#\");\r\n urlParts.shift(); // Remove part before the hash\r\n window.location.hash = urlParts.length > 0 ? urlParts.join(\"#\") : \"\";\r\n };\r\n /**\r\n * Returns boolean of whether the current window is in an iframe or not.\r\n */\r\n BrowserUtils.isInIframe = function () {\r\n return window.parent !== window;\r\n };\r\n // #endregion\r\n /**\r\n * Returns current window URL as redirect uri\r\n */\r\n BrowserUtils.getCurrentUri = function () {\r\n return window.location.href.split(\"?\")[0].split(\"#\")[0];\r\n };\r\n /**\r\n * Gets the homepage url for the current window location.\r\n */\r\n BrowserUtils.getHomepage = function () {\r\n var currentUrl = new UrlString(window.location.href);\r\n var urlComponents = currentUrl.getUrlComponents();\r\n return urlComponents.Protocol + \"//\" + urlComponents.HostNameAndPort + \"/\";\r\n };\r\n /**\r\n * Returns best compatible network client object.\r\n */\r\n BrowserUtils.getBrowserNetworkClient = function () {\r\n if (window.fetch) {\r\n return new FetchClient();\r\n }\r\n else {\r\n return new XhrClient();\r\n }\r\n };\r\n /**\r\n * Throws error if we have completed an auth and are\r\n * attempting another auth request inside an iframe.\r\n */\r\n BrowserUtils.blockReloadInHiddenIframes = function () {\r\n var isResponseHash = UrlString.hashContainsKnownProperties(window.location.hash);\r\n // return an error if called from the hidden iframe created by the msal js silent calls\r\n if (isResponseHash && BrowserUtils.isInIframe()) {\r\n throw BrowserAuthError.createBlockReloadInHiddenIframeError();\r\n }\r\n };\r\n /**\r\n * Throws error if token requests are made in non-browser environment\r\n * @param isBrowserEnvironment Flag indicating if environment is a browser.\r\n */\r\n BrowserUtils.blockNonBrowserEnvironment = function (isBrowserEnvironment) {\r\n if (!isBrowserEnvironment) {\r\n throw BrowserAuthError.createNonBrowserEnvironmentError();\r\n }\r\n };\r\n /**\r\n * Returns boolean of whether current browser is an Internet Explorer or Edge browser.\r\n */\r\n BrowserUtils.detectIEOrEdge = function () {\r\n var ua = window.navigator.userAgent;\r\n var msie = ua.indexOf(\"MSIE \");\r\n var msie11 = ua.indexOf(\"Trident/\");\r\n var msedge = ua.indexOf(\"Edge/\");\r\n var isIE = msie > 0 || msie11 > 0;\r\n var isEdge = msedge > 0;\r\n return isIE || isEdge;\r\n };\r\n return BrowserUtils;\r\n}());\n\n// Default timeout for popup windows and iframes in milliseconds\r\nvar DEFAULT_POPUP_TIMEOUT_MS = 60000;\r\nvar DEFAULT_IFRAME_TIMEOUT_MS = 6000;\r\n/**\r\n * MSAL function that sets the default options when not explicitly configured from app developer\r\n *\r\n * @param auth\r\n * @param cache\r\n * @param system\r\n *\r\n * @returns Configuration object\r\n */\r\nfunction buildConfiguration(_a) {\r\n var userInputAuth = _a.auth, userInputCache = _a.cache, userInputSystem = _a.system;\r\n // Default auth options for browser\r\n var DEFAULT_AUTH_OPTIONS = {\r\n clientId: \"\",\r\n authority: \"\" + Constants.DEFAULT_AUTHORITY,\r\n knownAuthorities: [],\r\n cloudDiscoveryMetadata: \"\",\r\n redirectUri: \"\",\r\n postLogoutRedirectUri: \"\",\r\n navigateToLoginRequestUrl: true,\r\n clientCapabilities: []\r\n };\r\n // Default cache options for browser\r\n var DEFAULT_CACHE_OPTIONS = {\r\n cacheLocation: BrowserConstants.CACHE_LOCATION_SESSION,\r\n storeAuthStateInCookie: false\r\n };\r\n // Default logger options for browser\r\n var DEFAULT_LOGGER_OPTIONS = {\r\n loggerCallback: function () { },\r\n piiLoggingEnabled: false\r\n };\r\n // Default system options for browser\r\n var DEFAULT_BROWSER_SYSTEM_OPTIONS = __assign(__assign({}, DEFAULT_SYSTEM_OPTIONS), { loggerOptions: DEFAULT_LOGGER_OPTIONS, networkClient: BrowserUtils.getBrowserNetworkClient(), windowHashTimeout: DEFAULT_POPUP_TIMEOUT_MS, iframeHashTimeout: DEFAULT_IFRAME_TIMEOUT_MS, loadFrameTimeout: BrowserUtils.detectIEOrEdge() ? 500 : 0, asyncPopups: false });\r\n var overlayedConfig = {\r\n auth: __assign(__assign({}, DEFAULT_AUTH_OPTIONS), userInputAuth),\r\n cache: __assign(__assign({}, DEFAULT_CACHE_OPTIONS), userInputCache),\r\n system: __assign(__assign({}, DEFAULT_BROWSER_SYSTEM_OPTIONS), userInputSystem)\r\n };\r\n return overlayedConfig;\r\n}\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nvar BrowserProtocolUtils = /** @class */ (function () {\r\n function BrowserProtocolUtils() {\r\n }\r\n /**\r\n * Extracts the BrowserStateObject from the state string.\r\n * @param browserCrypto\r\n * @param state\r\n */\r\n BrowserProtocolUtils.extractBrowserRequestState = function (browserCrypto, state) {\r\n if (StringUtils.isEmpty(state)) {\r\n return null;\r\n }\r\n try {\r\n var requestStateObj = ProtocolUtils.parseRequestState(browserCrypto, state);\r\n return requestStateObj.libraryState.meta;\r\n }\r\n catch (e) {\r\n throw ClientAuthError.createInvalidStateError(state, e);\r\n }\r\n };\r\n /**\r\n * Parses properties of server response from url hash\r\n * @param locationHash Hash from url\r\n */\r\n BrowserProtocolUtils.parseServerResponseFromHash = function (locationHash) {\r\n if (!locationHash) {\r\n return {};\r\n }\r\n var hashUrlString = new UrlString(locationHash);\r\n return UrlString.getDeserializedHash(hashUrlString.getHash());\r\n };\r\n return BrowserProtocolUtils;\r\n}());\n\n/**\r\n * Abstract class which defines operations for a browser interaction handling class.\r\n */\r\nvar InteractionHandler = /** @class */ (function () {\r\n function InteractionHandler(authCodeModule, storageImpl) {\r\n this.authModule = authCodeModule;\r\n this.browserStorage = storageImpl;\r\n }\r\n /**\r\n * Function to handle response parameters from hash.\r\n * @param locationHash\r\n */\r\n InteractionHandler.prototype.handleCodeResponse = function (locationHash) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var serverParams, requestState, authCode, cachedNonce, tokenResponse;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n // Check that location hash isn't empty.\r\n if (StringUtils.isEmpty(locationHash)) {\r\n throw BrowserAuthError.createEmptyHashError(locationHash);\r\n }\r\n serverParams = BrowserProtocolUtils.parseServerResponseFromHash(locationHash);\r\n requestState = this.browserStorage.getItem(this.browserStorage.generateStateKey(serverParams.state), CacheSchemaType.TEMPORARY);\r\n authCode = this.authModule.handleFragmentResponse(locationHash, requestState);\r\n cachedNonce = this.browserStorage.getItem(this.browserStorage.generateNonceKey(requestState), CacheSchemaType.TEMPORARY);\r\n // Assign code to request\r\n this.authCodeRequest.code = authCode;\r\n return [4 /*yield*/, this.authModule.acquireToken(this.authCodeRequest, cachedNonce, requestState)];\r\n case 1:\r\n tokenResponse = _a.sent();\r\n this.browserStorage.cleanRequest(serverParams.state);\r\n return [2 /*return*/, tokenResponse];\r\n }\r\n });\r\n });\r\n };\r\n return InteractionHandler;\r\n}());\n\nvar RedirectHandler = /** @class */ (function (_super) {\r\n __extends(RedirectHandler, _super);\r\n function RedirectHandler() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n /**\r\n * Redirects window to given URL.\r\n * @param urlNavigate\r\n */\r\n RedirectHandler.prototype.initiateAuthRequest = function (requestUrl, authCodeRequest, redirectStartPage, browserCrypto) {\r\n // Navigate if valid URL\r\n if (!StringUtils.isEmpty(requestUrl)) {\r\n // Cache start page, returns to this page after redirectUri if navigateToLoginRequestUrl is true\r\n if (redirectStartPage) {\r\n this.browserStorage.setItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI), redirectStartPage, CacheSchemaType.TEMPORARY);\r\n }\r\n // Set interaction status in the library.\r\n this.browserStorage.setItem(this.browserStorage.generateCacheKey(BrowserConstants.INTERACTION_STATUS_KEY), BrowserConstants.INTERACTION_IN_PROGRESS_VALUE, CacheSchemaType.TEMPORARY);\r\n this.browserStorage.cacheCodeRequest(authCodeRequest, browserCrypto);\r\n this.authModule.logger.infoPii(\"Navigate to:\" + requestUrl);\r\n var isIframedApp = BrowserUtils.isInIframe();\r\n if (isIframedApp) {\r\n // If we are not in top frame, we shouldn't redirect. This is also handled by the service.\r\n throw BrowserAuthError.createRedirectInIframeError(isIframedApp);\r\n }\r\n // Navigate window to request URL\r\n BrowserUtils.navigateWindow(requestUrl);\r\n }\r\n else {\r\n // Throw error if request URL is empty.\r\n this.authModule.logger.info(\"Navigate url is empty\");\r\n throw BrowserAuthError.createEmptyNavigationUriError();\r\n }\r\n // Return this window handle. Not used for redirect, but needed for API definition.\r\n return window;\r\n };\r\n /**\r\n * Handle authorization code response in the window.\r\n * @param hash\r\n */\r\n RedirectHandler.prototype.handleCodeResponse = function (locationHash, browserCrypto, clientId) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var serverParams, requestState, authCode, cachedNonce, tokenResponse;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n // Check that location hash isn't empty.\r\n if (StringUtils.isEmpty(locationHash)) {\r\n throw BrowserAuthError.createEmptyHashError(locationHash);\r\n }\r\n // Interaction is completed - remove interaction status.\r\n this.browserStorage.removeItem(this.browserStorage.generateCacheKey(BrowserConstants.INTERACTION_STATUS_KEY));\r\n serverParams = BrowserProtocolUtils.parseServerResponseFromHash(locationHash);\r\n requestState = this.browserStorage.getItem(this.browserStorage.generateStateKey(serverParams.state), CacheSchemaType.TEMPORARY);\r\n authCode = this.authModule.handleFragmentResponse(locationHash, requestState);\r\n cachedNonce = this.browserStorage.getItem(this.browserStorage.generateNonceKey(requestState), CacheSchemaType.TEMPORARY);\r\n this.authCodeRequest = this.browserStorage.getCachedRequest(requestState, browserCrypto);\r\n this.authCodeRequest.code = authCode;\r\n // Remove throttle if it exists\r\n if (clientId) {\r\n ThrottlingUtils.removeThrottle(this.browserStorage, clientId, this.authCodeRequest.authority, this.authCodeRequest.scopes);\r\n }\r\n return [4 /*yield*/, this.authModule.acquireToken(this.authCodeRequest, cachedNonce, requestState)];\r\n case 1:\r\n tokenResponse = _a.sent();\r\n this.browserStorage.cleanRequest(serverParams.state);\r\n return [2 /*return*/, tokenResponse];\r\n }\r\n });\r\n });\r\n };\r\n return RedirectHandler;\r\n}(InteractionHandler));\n\n/**\r\n * This class implements the interaction handler base class for browsers. It is written specifically for handling\r\n * popup window scenarios. It includes functions for monitoring the popup window for a hash.\r\n */\r\nvar PopupHandler = /** @class */ (function (_super) {\r\n __extends(PopupHandler, _super);\r\n function PopupHandler(authCodeModule, storageImpl) {\r\n var _this = _super.call(this, authCodeModule, storageImpl) || this;\r\n // Properly sets this reference for the unload event.\r\n _this.unloadWindow = _this.unloadWindow.bind(_this);\r\n return _this;\r\n }\r\n /**\r\n * Opens a popup window with given request Url.\r\n * @param requestUrl\r\n */\r\n PopupHandler.prototype.initiateAuthRequest = function (requestUrl, authCodeRequest, popup) {\r\n // Check that request url is not empty.\r\n if (!StringUtils.isEmpty(requestUrl)) {\r\n // Save auth code request\r\n this.authCodeRequest = authCodeRequest;\r\n // Set interaction status in the library.\r\n this.browserStorage.setItem(this.browserStorage.generateCacheKey(BrowserConstants.INTERACTION_STATUS_KEY), BrowserConstants.INTERACTION_IN_PROGRESS_VALUE, CacheSchemaType.TEMPORARY);\r\n this.authModule.logger.infoPii(\"Navigate to:\" + requestUrl);\r\n // Open the popup window to requestUrl.\r\n return this.openPopup(requestUrl, popup);\r\n }\r\n else {\r\n // Throw error if request URL is empty.\r\n this.authModule.logger.error(\"Navigate url is empty\");\r\n throw BrowserAuthError.createEmptyNavigationUriError();\r\n }\r\n };\r\n /**\r\n * Monitors a window until it loads a url with a known hash, or hits a specified timeout.\r\n * @param popupWindow - window that is being monitored\r\n * @param timeout - milliseconds until timeout\r\n * @param urlNavigate - url that was navigated to\r\n */\r\n PopupHandler.prototype.monitorPopupForHash = function (popupWindow, timeout) {\r\n var _this = this;\r\n return new Promise(function (resolve, reject) {\r\n var maxTicks = timeout / BrowserConstants.POLL_INTERVAL_MS;\r\n var ticks = 0;\r\n var intervalId = setInterval(function () {\r\n if (popupWindow.closed) {\r\n // Window is closed\r\n _this.cleanPopup();\r\n clearInterval(intervalId);\r\n reject(BrowserAuthError.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 = popupWindow.location.href;\r\n }\r\n catch (e) { }\r\n // Don't process blank pages or cross domain\r\n if (StringUtils.isEmpty(href) || href === \"about:blank\") {\r\n return;\r\n }\r\n // Only run clock when we are on same domain\r\n ticks++;\r\n var contentHash = popupWindow.location.hash;\r\n if (UrlString.hashContainsKnownProperties(contentHash)) {\r\n // Success case\r\n _this.cleanPopup(popupWindow);\r\n clearInterval(intervalId);\r\n resolve(contentHash);\r\n return;\r\n }\r\n else if (ticks > maxTicks) {\r\n // Timeout error\r\n _this.cleanPopup(popupWindow);\r\n clearInterval(intervalId);\r\n reject(BrowserAuthError.createMonitorWindowTimeoutError());\r\n return;\r\n }\r\n }, BrowserConstants.POLL_INTERVAL_MS);\r\n });\r\n };\r\n /**\r\n * @hidden\r\n *\r\n * Configures popup window for login.\r\n *\r\n * @param urlNavigate\r\n * @param title\r\n * @param popUpWidth\r\n * @param popUpHeight\r\n * @ignore\r\n * @hidden\r\n */\r\n PopupHandler.prototype.openPopup = function (urlNavigate, popup) {\r\n try {\r\n var popupWindow = void 0;\r\n // Popup window passed in, setting url to navigate to\r\n if (popup) {\r\n popupWindow = popup;\r\n popupWindow.location.assign(urlNavigate);\r\n }\r\n else if (typeof popup === \"undefined\") {\r\n // Popup will be undefined if it was not passed in\r\n popupWindow = PopupHandler.openSizedPopup(urlNavigate);\r\n }\r\n // Popup will be null if popups are blocked\r\n if (!popupWindow) {\r\n throw BrowserAuthError.createEmptyWindowCreatedError();\r\n }\r\n if (popupWindow.focus) {\r\n popupWindow.focus();\r\n }\r\n this.currentWindow = popupWindow;\r\n window.addEventListener(\"beforeunload\", this.unloadWindow);\r\n return popupWindow;\r\n }\r\n catch (e) {\r\n this.authModule.logger.error(\"error opening popup \" + e.message);\r\n this.browserStorage.removeItem(this.browserStorage.generateCacheKey(BrowserConstants.INTERACTION_STATUS_KEY));\r\n throw BrowserAuthError.createPopupWindowError(e.toString());\r\n }\r\n };\r\n PopupHandler.openSizedPopup = function (urlNavigate) {\r\n if (urlNavigate === void 0) { urlNavigate = \"about:blank\"; }\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 = Math.max(0, ((width / 2) - (BrowserConstants.POPUP_WIDTH / 2)) + winLeft);\r\n var top = Math.max(0, ((height / 2) - (BrowserConstants.POPUP_HEIGHT / 2)) + winTop);\r\n return window.open(urlNavigate, Constants.LIBRARY_NAME, \"width=\" + BrowserConstants.POPUP_WIDTH + \", height=\" + BrowserConstants.POPUP_HEIGHT + \", top=\" + top + \", left=\" + left);\r\n };\r\n /**\r\n * Event callback to unload main window.\r\n */\r\n PopupHandler.prototype.unloadWindow = function (e) {\r\n this.browserStorage.cleanRequest();\r\n this.currentWindow.close();\r\n // Guarantees browser unload will happen, so no other errors will be thrown.\r\n delete e[\"returnValue\"];\r\n };\r\n /**\r\n * Closes popup, removes any state vars created during popup calls.\r\n * @param popupWindow\r\n */\r\n PopupHandler.prototype.cleanPopup = function (popupWindow) {\r\n if (popupWindow) {\r\n // Close window.\r\n popupWindow.close();\r\n }\r\n // Remove window unload function\r\n window.removeEventListener(\"beforeunload\", this.unloadWindow);\r\n // Interaction is completed - remove interaction status.\r\n this.browserStorage.removeItem(this.browserStorage.generateCacheKey(BrowserConstants.INTERACTION_STATUS_KEY));\r\n };\r\n return PopupHandler;\r\n}(InteractionHandler));\n\nvar SilentHandler = /** @class */ (function (_super) {\r\n __extends(SilentHandler, _super);\r\n function SilentHandler(authCodeModule, storageImpl, configuredLoadFrameTimeout) {\r\n var _this = _super.call(this, authCodeModule, storageImpl) || this;\r\n _this.loadFrameTimeout = configuredLoadFrameTimeout;\r\n return _this;\r\n }\r\n /**\r\n * Creates a hidden iframe to given URL using user-requested scopes as an id.\r\n * @param urlNavigate\r\n * @param userRequestScopes\r\n */\r\n SilentHandler.prototype.initiateAuthRequest = function (requestUrl, authCodeRequest) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var _a;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n if (StringUtils.isEmpty(requestUrl)) {\r\n // Throw error if request URL is empty.\r\n this.authModule.logger.info(\"Navigate url is empty\");\r\n throw BrowserAuthError.createEmptyNavigationUriError();\r\n }\r\n // Save auth code request\r\n this.authCodeRequest = authCodeRequest;\r\n if (!this.loadFrameTimeout) return [3 /*break*/, 2];\r\n return [4 /*yield*/, this.loadFrame(requestUrl)];\r\n case 1:\r\n _a = _b.sent();\r\n return [3 /*break*/, 3];\r\n case 2:\r\n _a = this.loadFrameSync(requestUrl);\r\n _b.label = 3;\r\n case 3: return [2 /*return*/, _a];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Monitors an iframe content window until it loads a url with a known hash, or hits a specified timeout.\r\n * @param iframe\r\n * @param timeout\r\n */\r\n SilentHandler.prototype.monitorIframeForHash = function (iframe, timeout) {\r\n var _this = this;\r\n return new Promise(function (resolve, reject) {\r\n /*\r\n * Polling for iframes can be purely timing based,\r\n * since we don't need to account for interaction.\r\n */\r\n var nowMark = window.performance.now();\r\n var timeoutMark = nowMark + timeout;\r\n var intervalId = setInterval(function () {\r\n if (window.performance.now() > timeoutMark) {\r\n _this.removeHiddenIframe(iframe);\r\n clearInterval(intervalId);\r\n reject(BrowserAuthError.createMonitorWindowTimeoutError());\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 = iframe.contentWindow.location.href;\r\n }\r\n catch (e) { }\r\n if (StringUtils.isEmpty(href)) {\r\n return;\r\n }\r\n var contentHash = iframe.contentWindow.location.hash;\r\n if (UrlString.hashContainsKnownProperties(contentHash)) {\r\n // Success case\r\n _this.removeHiddenIframe(iframe);\r\n clearInterval(intervalId);\r\n resolve(contentHash);\r\n return;\r\n }\r\n }, BrowserConstants.POLL_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 SilentHandler.prototype.loadFrame = function (urlNavigate) {\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 var _this = this;\r\n return new Promise(function (resolve, reject) {\r\n setTimeout(function () {\r\n var frameHandle = _this.loadFrameSync(urlNavigate);\r\n if (!frameHandle) {\r\n reject(\"Unable to load iframe\");\r\n return;\r\n }\r\n resolve(frameHandle);\r\n }, _this.loadFrameTimeout);\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 SilentHandler.prototype.loadFrameSync = function (urlNavigate) {\r\n var frameHandle = this.createHiddenIframe();\r\n frameHandle.src = urlNavigate;\r\n return frameHandle;\r\n };\r\n /**\r\n * @hidden\r\n * Creates a new hidden iframe or gets an existing one for silent token renewal.\r\n * @ignore\r\n */\r\n SilentHandler.prototype.createHiddenIframe = function () {\r\n var authFrame = document.createElement(\"iframe\");\r\n authFrame.style.visibility = \"hidden\";\r\n authFrame.style.position = \"absolute\";\r\n authFrame.style.width = authFrame.style.height = \"0\";\r\n authFrame.style.border = \"0\";\r\n authFrame.setAttribute(\"sandbox\", \"allow-scripts allow-same-origin allow-forms\");\r\n document.getElementsByTagName(\"body\")[0].appendChild(authFrame);\r\n return authFrame;\r\n };\r\n /**\r\n * @hidden\r\n * Removes a hidden iframe from the page.\r\n * @ignore\r\n */\r\n SilentHandler.prototype.removeHiddenIframe = function (iframe) {\r\n if (document.body === iframe.parentNode) {\r\n document.body.removeChild(iframe);\r\n }\r\n };\r\n return SilentHandler;\r\n}(InteractionHandler));\n\nvar version$1 = \"2.2.1\";\n\n/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\nvar ClientApplication = /** @class */ (function () {\r\n /**\r\n * @constructor\r\n * Constructor for the PublicClientApplication used to instantiate the PublicClientApplication object\r\n *\r\n * Important attributes in the Configuration object for auth are:\r\n * - clientID: the application ID of your application. 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 * - redirect_uri: the uri of your application registered in the portal.\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 * In Azure B2C, authority is of the form https://{instance}/tfp/{tenant}/{policyName}/\r\n * Full B2C functionality will be available in this library in future versions.\r\n *\r\n * @param {@link (Configuration:type)} configuration object for the MSAL PublicClientApplication instance\r\n */\r\n function ClientApplication(configuration) {\r\n /*\r\n * If loaded in an environment where window is not available,\r\n * set internal flag to false so that further requests fail.\r\n * This is to support server-side rendering environments.\r\n */\r\n this.isBrowserEnvironment = typeof window !== \"undefined\";\r\n if (!this.isBrowserEnvironment) {\r\n return;\r\n }\r\n // Set the configuration.\r\n this.config = buildConfiguration(configuration);\r\n // Initialize the crypto class.\r\n this.browserCrypto = new CryptoOps();\r\n // Initialize the network module class.\r\n this.networkClient = this.config.system.networkClient;\r\n // Initialize the browser storage class.\r\n this.browserStorage = new BrowserStorage(this.config.auth.clientId, this.config.cache, this.browserCrypto);\r\n // Initialize logger\r\n this.logger = new Logger(this.config.system.loggerOptions);\r\n // Initialize default authority instance\r\n TrustedAuthority.setTrustedAuthoritiesFromConfig(this.config.auth.knownAuthorities, this.config.auth.cloudDiscoveryMetadata);\r\n this.defaultAuthority = null;\r\n }\r\n // #region Redirect Flow\r\n /**\r\n * Event handler function which allows users to fire events after the PublicClientApplication object\r\n * has loaded during redirect flows. This should be invoked on all page loads involved in redirect\r\n * auth flows.\r\n * @returns {Promise.} token response or null. If the return value is null, then no auth redirect was detected.\r\n */\r\n ClientApplication.prototype.handleRedirectPromise = function () {\r\n return __awaiter(this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n return [2 /*return*/, this.isBrowserEnvironment ? this.handleRedirectResponse() : null];\r\n });\r\n });\r\n };\r\n /**\r\n * Checks if navigateToLoginRequestUrl is set, and:\r\n * - if true, performs logic to cache and navigate\r\n * - if false, handles hash string and parses response\r\n */\r\n ClientApplication.prototype.handleRedirectResponse = function () {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var responseHash, loginRequestUrl, loginRequestUrlNormalized, currentUrlNormalized, hashKey, homepage;\r\n return __generator(this, function (_a) {\r\n if (!this.interactionInProgress()) {\r\n this.logger.info(\"handleRedirectPromise called but there is no interaction in progress, returning null.\");\r\n return [2 /*return*/, null];\r\n }\r\n responseHash = this.getRedirectResponseHash();\r\n if (StringUtils.isEmpty(responseHash)) {\r\n // Not a recognized server response hash or hash not associated with a redirect request\r\n return [2 /*return*/, null];\r\n }\r\n loginRequestUrl = this.browserStorage.getItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI), CacheSchemaType.TEMPORARY);\r\n loginRequestUrlNormalized = UrlString.removeHashFromUrl(loginRequestUrl || \"\");\r\n currentUrlNormalized = UrlString.removeHashFromUrl(window.location.href);\r\n if (loginRequestUrlNormalized === currentUrlNormalized && this.config.auth.navigateToLoginRequestUrl) {\r\n if (loginRequestUrl.indexOf(\"#\") > -1) {\r\n // Replace current hash with non-msal hash, if present\r\n BrowserUtils.replaceHash(loginRequestUrl);\r\n }\r\n // We are on the page we need to navigate to - handle hash\r\n return [2 /*return*/, this.handleHash(responseHash)];\r\n }\r\n else if (!this.config.auth.navigateToLoginRequestUrl) {\r\n return [2 /*return*/, this.handleHash(responseHash)];\r\n }\r\n else if (!BrowserUtils.isInIframe()) {\r\n hashKey = this.browserStorage.generateCacheKey(TemporaryCacheKeys.URL_HASH);\r\n this.browserStorage.setItem(hashKey, responseHash, CacheSchemaType.TEMPORARY);\r\n if (!loginRequestUrl || loginRequestUrl === \"null\") {\r\n homepage = BrowserUtils.getHomepage();\r\n // Cache the homepage under ORIGIN_URI to ensure cached hash is processed on homepage\r\n this.browserStorage.setItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI), homepage, CacheSchemaType.TEMPORARY);\r\n this.logger.warning(\"Unable to get valid login request url from cache, redirecting to home page\");\r\n BrowserUtils.navigateWindow(homepage, true);\r\n }\r\n else {\r\n // Navigate to page that initiated the redirect request\r\n BrowserUtils.navigateWindow(loginRequestUrl, true);\r\n }\r\n }\r\n return [2 /*return*/, null];\r\n });\r\n });\r\n };\r\n /**\r\n * Gets the response hash for a redirect request\r\n * Returns null if interactionType in the state value is not \"redirect\" or the hash does not contain known properties\r\n * @returns {string}\r\n */\r\n ClientApplication.prototype.getRedirectResponseHash = function () {\r\n // Get current location hash from window or cache.\r\n var hash = window.location.hash;\r\n var isResponseHash = UrlString.hashContainsKnownProperties(hash);\r\n var cachedHash = this.browserStorage.getItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.URL_HASH), CacheSchemaType.TEMPORARY);\r\n this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.URL_HASH));\r\n var responseHash = isResponseHash ? hash : cachedHash;\r\n if (responseHash) {\r\n // Deserialize hash fragment response parameters.\r\n var serverParams_1 = UrlString.getDeserializedHash(responseHash);\r\n var platformStateObj = BrowserProtocolUtils.extractBrowserRequestState(this.browserCrypto, serverParams_1.state);\r\n if (platformStateObj.interactionType !== InteractionType.REDIRECT) {\r\n return null;\r\n }\r\n else {\r\n BrowserUtils.clearHash();\r\n return responseHash;\r\n }\r\n }\r\n // Deserialize hash fragment response parameters.\r\n var serverParams = BrowserProtocolUtils.parseServerResponseFromHash(hash);\r\n this.browserStorage.cleanRequest(serverParams.state);\r\n return null;\r\n };\r\n /**\r\n * Checks if hash exists and handles in window.\r\n * @param responseHash\r\n * @param interactionHandler\r\n */\r\n ClientApplication.prototype.handleHash = function (responseHash) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var encodedTokenRequest, cachedRequest, serverTelemetryManager, hashUrlString, serverParams, currentAuthority, authClient, interactionHandler, e_1;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n encodedTokenRequest = this.browserStorage.getItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS), CacheSchemaType.TEMPORARY);\r\n cachedRequest = JSON.parse(this.browserCrypto.base64Decode(encodedTokenRequest));\r\n serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.handleRedirectPromise, cachedRequest.correlationId);\r\n hashUrlString = new UrlString(responseHash);\r\n serverParams = BrowserProtocolUtils.parseServerResponseFromHash(responseHash);\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 4, , 5]);\r\n currentAuthority = this.browserStorage.getCachedAuthority(serverParams.state);\r\n return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, currentAuthority)];\r\n case 2:\r\n authClient = _a.sent();\r\n interactionHandler = new RedirectHandler(authClient, this.browserStorage);\r\n return [4 /*yield*/, interactionHandler.handleCodeResponse(responseHash, this.browserCrypto, this.config.auth.clientId)];\r\n case 3: return [2 /*return*/, _a.sent()];\r\n case 4:\r\n e_1 = _a.sent();\r\n serverTelemetryManager.cacheFailedRequest(e_1);\r\n this.browserStorage.cleanRequest(serverParams.state);\r\n throw e_1;\r\n case 5: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Use when you want to obtain an access_token for your API by redirecting the user's browser window to the authorization endpoint. This function redirects\r\n * the page, so any code that follows this function will not execute.\r\n *\r\n * IMPORTANT: It is NOT recommended to have code that is dependent on the resolution of the Promise. This function will navigate away from the current\r\n * browser window. It currently returns a Promise in order to reflect the asynchronous nature of the code running in this function.\r\n *\r\n * @param {@link (RedirectRequest:type)}\r\n */\r\n ClientApplication.prototype.acquireTokenRedirect = function (request) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var validRequest, serverTelemetryManager, authCodeRequest, authClient, interactionHandler, navigateUrl, redirectStartPage, e_2;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n this.preflightBrowserEnvironmentCheck();\r\n validRequest = this.preflightInteractiveRequest(request, InteractionType.REDIRECT);\r\n serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenRedirect, validRequest.correlationId);\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 5, , 6]);\r\n return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];\r\n case 2:\r\n authCodeRequest = _a.sent();\r\n return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority)];\r\n case 3:\r\n authClient = _a.sent();\r\n interactionHandler = new RedirectHandler(authClient, this.browserStorage);\r\n return [4 /*yield*/, authClient.getAuthCodeUrl(validRequest)];\r\n case 4:\r\n navigateUrl = _a.sent();\r\n redirectStartPage = (request && request.redirectStartPage) || window.location.href;\r\n // Show the UI once the url has been created. Response will come back in the hash, which will be handled in the handleRedirectCallback function.\r\n interactionHandler.initiateAuthRequest(navigateUrl, authCodeRequest, redirectStartPage, this.browserCrypto);\r\n return [3 /*break*/, 6];\r\n case 5:\r\n e_2 = _a.sent();\r\n serverTelemetryManager.cacheFailedRequest(e_2);\r\n this.browserStorage.cleanRequest(validRequest.state);\r\n throw e_2;\r\n case 6: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n // #endregion\r\n // #region Popup Flow\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 (PopupRequest: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 ClientApplication.prototype.acquireTokenPopup = function (request) {\r\n try {\r\n this.preflightBrowserEnvironmentCheck();\r\n }\r\n catch (e) {\r\n // Since this function is syncronous we need to reject\r\n return Promise.reject(e);\r\n }\r\n // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.\r\n if (this.config.system.asyncPopups) {\r\n return this.acquireTokenPopupAsync(request);\r\n }\r\n else {\r\n // asyncPopups flag is set to false. Opens popup before acquiring token.\r\n var popup = PopupHandler.openSizedPopup();\r\n return this.acquireTokenPopupAsync(request, popup);\r\n }\r\n };\r\n /**\r\n * Helper which obtains an access_token for your API via opening a popup window in the user's browser\r\n * @param {@link (PopupRequest: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 ClientApplication.prototype.acquireTokenPopupAsync = function (request, popup) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var validRequest, serverTelemetryManager, authCodeRequest, authClient, navigateUrl, interactionHandler, popupWindow, hash, e_3;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n validRequest = this.preflightInteractiveRequest(request, InteractionType.POPUP);\r\n serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenPopup, validRequest.correlationId);\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 7, , 8]);\r\n return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];\r\n case 2:\r\n authCodeRequest = _a.sent();\r\n return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority)];\r\n case 3:\r\n authClient = _a.sent();\r\n return [4 /*yield*/, authClient.getAuthCodeUrl(validRequest)];\r\n case 4:\r\n navigateUrl = _a.sent();\r\n interactionHandler = new PopupHandler(authClient, this.browserStorage);\r\n popupWindow = interactionHandler.initiateAuthRequest(navigateUrl, authCodeRequest, popup);\r\n return [4 /*yield*/, interactionHandler.monitorPopupForHash(popupWindow, this.config.system.windowHashTimeout)];\r\n case 5:\r\n hash = _a.sent();\r\n // Remove throttle if it exists\r\n ThrottlingUtils.removeThrottle(this.browserStorage, this.config.auth.clientId, authCodeRequest.authority, authCodeRequest.scopes);\r\n return [4 /*yield*/, interactionHandler.handleCodeResponse(hash)];\r\n case 6: \r\n // Handle response from hash string.\r\n return [2 /*return*/, _a.sent()];\r\n case 7:\r\n e_3 = _a.sent();\r\n serverTelemetryManager.cacheFailedRequest(e_3);\r\n this.browserStorage.cleanRequest(validRequest.state);\r\n throw e_3;\r\n case 8: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n // #endregion\r\n // #region Silent Flow\r\n /**\r\n * This function uses a hidden iframe to fetch an authorization code from the eSTS. There are cases where this may not work:\r\n * - Any browser using a form of Intelligent Tracking Prevention\r\n * - If there is not an established session with the service\r\n *\r\n * In these cases, the request must be done inside a popup or full frame redirect.\r\n *\r\n * For the cases where interaction is required, you cannot send a request with prompt=none.\r\n *\r\n * If your refresh token has expired, you can use this function to fetch a new set of tokens silently as long as\r\n * you session on the server still exists.\r\n * @param {@link AuthorizationUrlRequest}\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 ClientApplication.prototype.ssoSilent = function (request) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var silentRequest, serverTelemetryManager, authCodeRequest, authClient, navigateUrl, e_4;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n this.preflightBrowserEnvironmentCheck();\r\n // Check that we have some SSO data\r\n if (StringUtils.isEmpty(request.loginHint) && StringUtils.isEmpty(request.sid) && (!request.account || StringUtils.isEmpty(request.account.username))) {\r\n throw BrowserAuthError.createSilentSSOInsufficientInfoError();\r\n }\r\n // Check that prompt is set to none, throw error if it is set to anything else.\r\n if (request.prompt && request.prompt !== PromptValue.NONE) {\r\n throw BrowserAuthError.createSilentPromptValueError(request.prompt);\r\n }\r\n silentRequest = this.initializeAuthorizationRequest(__assign(__assign({}, request), { prompt: PromptValue.NONE }), InteractionType.SILENT);\r\n serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.ssoSilent, silentRequest.correlationId);\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 6, , 7]);\r\n return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];\r\n case 2:\r\n authCodeRequest = _a.sent();\r\n return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority)];\r\n case 3:\r\n authClient = _a.sent();\r\n return [4 /*yield*/, authClient.getAuthCodeUrl(silentRequest)];\r\n case 4:\r\n navigateUrl = _a.sent();\r\n return [4 /*yield*/, this.silentTokenHelper(navigateUrl, authCodeRequest, authClient)];\r\n case 5: return [2 /*return*/, _a.sent()];\r\n case 6:\r\n e_4 = _a.sent();\r\n serverTelemetryManager.cacheFailedRequest(e_4);\r\n this.browserStorage.cleanRequest(silentRequest.state);\r\n throw e_4;\r\n case 7: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Use this function to obtain a token before every call to the API / resource provider\r\n *\r\n * MSAL return's a cached token when available\r\n * Or it send's a request to the STS to obtain a new token using a refresh token.\r\n *\r\n * @param {@link (SilentRequest:type)}\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 ClientApplication.prototype.acquireTokenByRefreshToken = function (request) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var silentRequest, serverTelemetryManager, refreshTokenClient, e_5, isServerError, isInteractionRequiredError, isInvalidGrantError;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n // block the reload if it occurred inside a hidden iframe\r\n BrowserUtils.blockReloadInHiddenIframes();\r\n silentRequest = __assign(__assign({}, request), this.initializeBaseRequest(request));\r\n serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow, silentRequest.correlationId);\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 4, , 7]);\r\n return [4 /*yield*/, this.createRefreshTokenClient(serverTelemetryManager, silentRequest.authority)];\r\n case 2:\r\n refreshTokenClient = _a.sent();\r\n return [4 /*yield*/, refreshTokenClient.acquireTokenByRefreshToken(silentRequest)];\r\n case 3: \r\n // Send request to renew token. Auth module will throw errors if token cannot be renewed.\r\n return [2 /*return*/, _a.sent()];\r\n case 4:\r\n e_5 = _a.sent();\r\n serverTelemetryManager.cacheFailedRequest(e_5);\r\n isServerError = e_5 instanceof ServerError;\r\n isInteractionRequiredError = e_5 instanceof InteractionRequiredAuthError;\r\n isInvalidGrantError = (e_5.errorCode === BrowserConstants.INVALID_GRANT_ERROR);\r\n if (!(isServerError && isInvalidGrantError && !isInteractionRequiredError)) return [3 /*break*/, 6];\r\n return [4 /*yield*/, this.ssoSilent(request)];\r\n case 5: return [2 /*return*/, _a.sent()];\r\n case 6: throw e_5;\r\n case 7: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Helper which acquires an authorization code silently using a hidden iframe from given url\r\n * using the scopes requested as part of the id, and exchanges the code for a set of OAuth tokens.\r\n * @param navigateUrl\r\n * @param userRequestScopes\r\n */\r\n ClientApplication.prototype.silentTokenHelper = function (navigateUrl, authCodeRequest, authClient) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var silentHandler, msalFrame, hash;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n silentHandler = new SilentHandler(authClient, this.browserStorage, this.config.system.loadFrameTimeout);\r\n return [4 /*yield*/, silentHandler.initiateAuthRequest(navigateUrl, authCodeRequest)];\r\n case 1:\r\n msalFrame = _a.sent();\r\n return [4 /*yield*/, silentHandler.monitorIframeForHash(msalFrame, this.config.system.iframeHashTimeout)];\r\n case 2:\r\n hash = _a.sent();\r\n // Handle response from hash string\r\n return [2 /*return*/, silentHandler.handleCodeResponse(hash)];\r\n }\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 * @param {@link (EndSessionRequest:type)}\r\n */\r\n ClientApplication.prototype.logout = function (logoutRequest) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var validLogoutRequest, authClient, logoutUri;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n this.preflightBrowserEnvironmentCheck();\r\n validLogoutRequest = this.initializeLogoutRequest(logoutRequest);\r\n return [4 /*yield*/, this.createAuthCodeClient(null, validLogoutRequest && validLogoutRequest.authority)];\r\n case 1:\r\n authClient = _a.sent();\r\n logoutUri = authClient.getLogoutUri(validLogoutRequest);\r\n BrowserUtils.navigateWindow(logoutUri);\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n // #endregion\r\n // #region Account APIs\r\n /**\r\n * Returns all accounts that MSAL currently has data for.\r\n * (the account object is created at the time of successful login)\r\n * or empty array when no accounts are found\r\n * @returns {@link AccountInfo[]} - Array of account objects in cache\r\n */\r\n ClientApplication.prototype.getAllAccounts = function () {\r\n return this.isBrowserEnvironment ? this.browserStorage.getAllAccounts() : [];\r\n };\r\n /**\r\n * Returns the signed in account matching username.\r\n * (the account object is created at the time of successful login)\r\n * or null when no matching account is found.\r\n * This API is provided for convenience but getAccountById should be used for best reliability\r\n * @returns {@link AccountInfo} - the account object stored in MSAL\r\n */\r\n ClientApplication.prototype.getAccountByUsername = function (userName) {\r\n var allAccounts = this.getAllAccounts();\r\n if (!StringUtils.isEmpty(userName) && allAccounts && allAccounts.length) {\r\n return allAccounts.filter(function (accountObj) { return accountObj.username.toLowerCase() === userName.toLowerCase(); })[0] || null;\r\n }\r\n else {\r\n return null;\r\n }\r\n };\r\n /**\r\n * Returns the signed in account matching homeAccountId.\r\n * (the account object is created at the time of successful login)\r\n * or null when no matching account is found\r\n * @returns {@link AccountInfo} - the account object stored in MSAL\r\n */\r\n ClientApplication.prototype.getAccountByHomeId = function (homeAccountId) {\r\n var allAccounts = this.getAllAccounts();\r\n if (!StringUtils.isEmpty(homeAccountId) && allAccounts && allAccounts.length) {\r\n return allAccounts.filter(function (accountObj) { return accountObj.homeAccountId === homeAccountId; })[0] || null;\r\n }\r\n else {\r\n return null;\r\n }\r\n };\r\n // #endregion\r\n // #region Helpers\r\n /**\r\n *\r\n * Use to get the redirect uri configured in MSAL or null.\r\n * @returns {string} redirect URL\r\n *\r\n */\r\n ClientApplication.prototype.getRedirectUri = function (requestRedirectUri) {\r\n return requestRedirectUri || this.config.auth.redirectUri || BrowserUtils.getCurrentUri();\r\n };\r\n /**\r\n * Use to get the post logout redirect uri configured in MSAL or null.\r\n *\r\n * @returns {string} post logout redirect URL\r\n */\r\n ClientApplication.prototype.getPostLogoutRedirectUri = function (requestPostLogoutRedirectUri) {\r\n return requestPostLogoutRedirectUri || this.config.auth.postLogoutRedirectUri || BrowserUtils.getCurrentUri();\r\n };\r\n /**\r\n * Used to get a discovered version of the default authority.\r\n */\r\n ClientApplication.prototype.getDiscoveredDefaultAuthority = function () {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var _a;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n if (!!this.defaultAuthority) return [3 /*break*/, 2];\r\n _a = this;\r\n return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(this.config.auth.authority, this.config.system.networkClient)];\r\n case 1:\r\n _a.defaultAuthority = _b.sent();\r\n _b.label = 2;\r\n case 2: return [2 /*return*/, this.defaultAuthority];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Helper to check whether interaction is in progress.\r\n */\r\n ClientApplication.prototype.interactionInProgress = function () {\r\n // Check whether value in cache is present and equal to expected value\r\n return this.browserStorage.getItem(this.browserStorage.generateCacheKey(BrowserConstants.INTERACTION_STATUS_KEY), CacheSchemaType.TEMPORARY) === BrowserConstants.INTERACTION_IN_PROGRESS_VALUE;\r\n };\r\n /**\r\n * Creates an Authorization Code Client with the given authority, or the default authority.\r\n * @param authorityUrl\r\n */\r\n ClientApplication.prototype.createAuthCodeClient = function (serverTelemetryManager, authorityUrl) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var clientConfig;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl)];\r\n case 1:\r\n clientConfig = _a.sent();\r\n return [2 /*return*/, new AuthorizationCodeClient(clientConfig)];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Creates an Silent Flow Client with the given authority, or the default authority.\r\n * @param authorityUrl\r\n */\r\n ClientApplication.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var clientConfig;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl)];\r\n case 1:\r\n clientConfig = _a.sent();\r\n return [2 /*return*/, new SilentFlowClient(clientConfig)];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Creates a Refresh Client with the given authority, or the default authority.\r\n * @param authorityUrl\r\n */\r\n ClientApplication.prototype.createRefreshTokenClient = function (serverTelemetryManager, authorityUrl) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var clientConfig;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl)];\r\n case 1:\r\n clientConfig = _a.sent();\r\n return [2 /*return*/, new RefreshTokenClient(clientConfig)];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Creates a Client Configuration object with the given request authority, or the default authority.\r\n * @param requestAuthority\r\n */\r\n ClientApplication.prototype.getClientConfiguration = function (serverTelemetryManager, requestAuthority) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var discoveredAuthority, _a;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n if (!(!StringUtils.isEmpty(requestAuthority) && requestAuthority !== this.config.auth.authority)) return [3 /*break*/, 2];\r\n return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(requestAuthority, this.config.system.networkClient)];\r\n case 1:\r\n _a = _b.sent();\r\n return [3 /*break*/, 4];\r\n case 2: return [4 /*yield*/, this.getDiscoveredDefaultAuthority()];\r\n case 3:\r\n _a = _b.sent();\r\n _b.label = 4;\r\n case 4:\r\n discoveredAuthority = _a;\r\n return [2 /*return*/, {\r\n authOptions: {\r\n clientId: this.config.auth.clientId,\r\n authority: discoveredAuthority,\r\n knownAuthorities: this.config.auth.knownAuthorities,\r\n cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,\r\n clientCapabilities: this.config.auth.clientCapabilities\r\n },\r\n systemOptions: {\r\n tokenRenewalOffsetSeconds: this.config.system.tokenRenewalOffsetSeconds\r\n },\r\n loggerOptions: {\r\n loggerCallback: this.config.system.loggerOptions.loggerCallback,\r\n piiLoggingEnabled: this.config.system.loggerOptions.piiLoggingEnabled\r\n },\r\n cryptoInterface: this.browserCrypto,\r\n networkInterface: this.networkClient,\r\n storageInterface: this.browserStorage,\r\n serverTelemetryManager: serverTelemetryManager,\r\n libraryInfo: {\r\n sku: BrowserConstants.MSAL_SKU,\r\n version: version$1,\r\n cpu: \"\",\r\n os: \"\"\r\n }\r\n }];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Helper to validate app environment before making a request.\r\n */\r\n ClientApplication.prototype.preflightInteractiveRequest = function (request, interactionType) {\r\n // block the reload if it occurred inside a hidden iframe\r\n BrowserUtils.blockReloadInHiddenIframes();\r\n // Check if interaction is in progress. Throw error if true.\r\n if (this.interactionInProgress()) {\r\n throw BrowserAuthError.createInteractionInProgressError();\r\n }\r\n return this.initializeAuthorizationRequest(request, interactionType);\r\n };\r\n /**\r\n * Helper to validate app environment before making a silent request\r\n * * @param request\r\n */\r\n ClientApplication.prototype.preflightBrowserEnvironmentCheck = function () {\r\n // Block request if not in browser environment\r\n BrowserUtils.blockNonBrowserEnvironment(this.isBrowserEnvironment);\r\n // block the reload if it occurred inside a hidden iframe\r\n BrowserUtils.blockReloadInHiddenIframes();\r\n };\r\n /**\r\n * Initializer function for all request APIs\r\n * @param request\r\n */\r\n ClientApplication.prototype.initializeBaseRequest = function (request) {\r\n var validatedRequest = __assign({}, request);\r\n if (StringUtils.isEmpty(validatedRequest.authority)) {\r\n validatedRequest.authority = this.config.auth.authority;\r\n }\r\n validatedRequest.correlationId = (request && request.correlationId) || this.browserCrypto.createNewGuid();\r\n return validatedRequest;\r\n };\r\n ClientApplication.prototype.initializeServerTelemetryManager = function (apiId, correlationId, forceRefresh) {\r\n var telemetryPayload = {\r\n clientId: this.config.auth.clientId,\r\n correlationId: correlationId,\r\n apiId: apiId,\r\n forceRefresh: forceRefresh || false\r\n };\r\n return new ServerTelemetryManager(telemetryPayload, this.browserStorage);\r\n };\r\n /**\r\n * Generates a request that will contain the openid and profile scopes.\r\n * @param request\r\n */\r\n ClientApplication.prototype.setDefaultScopes = function (request) {\r\n return __assign(__assign({}, request), { scopes: __spreadArrays(((request && request.scopes) || [])) });\r\n };\r\n /**\r\n * Helper to initialize required request parameters for interactive APIs and ssoSilent()\r\n * @param request\r\n */\r\n ClientApplication.prototype.initializeAuthorizationRequest = function (request, interactionType) {\r\n var validatedRequest = __assign(__assign({}, request), this.setDefaultScopes(request));\r\n validatedRequest.redirectUri = this.getRedirectUri(validatedRequest.redirectUri);\r\n // Check for ADAL SSO\r\n if (StringUtils.isEmpty(validatedRequest.loginHint)) {\r\n // Only check for adal token if no SSO params are being used\r\n var adalIdTokenString = this.browserStorage.getItem(PersistentCacheKeys.ADAL_ID_TOKEN, CacheSchemaType.TEMPORARY);\r\n if (!StringUtils.isEmpty(adalIdTokenString)) {\r\n var adalIdToken = new IdToken(adalIdTokenString, this.browserCrypto);\r\n this.browserStorage.removeItem(PersistentCacheKeys.ADAL_ID_TOKEN);\r\n if (adalIdToken.claims && adalIdToken.claims.upn) {\r\n validatedRequest.loginHint = adalIdToken.claims.upn;\r\n }\r\n }\r\n }\r\n var browserState = {\r\n interactionType: interactionType\r\n };\r\n validatedRequest.state = ProtocolUtils.setRequestState(this.browserCrypto, (request && request.state) || \"\", browserState);\r\n if (StringUtils.isEmpty(validatedRequest.nonce)) {\r\n validatedRequest.nonce = this.browserCrypto.createNewGuid();\r\n }\r\n validatedRequest.responseMode = ResponseMode.FRAGMENT;\r\n validatedRequest = __assign(__assign({}, validatedRequest), this.initializeBaseRequest(validatedRequest));\r\n this.browserStorage.updateCacheEntries(validatedRequest.state, validatedRequest.nonce, validatedRequest.authority);\r\n return validatedRequest;\r\n };\r\n /**\r\n * Generates an auth code request tied to the url request.\r\n * @param request\r\n */\r\n ClientApplication.prototype.initializeAuthorizationCodeRequest = function (request) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var generatedPkceParams, authCodeRequest;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, this.browserCrypto.generatePkceCodes()];\r\n case 1:\r\n generatedPkceParams = _a.sent();\r\n authCodeRequest = __assign(__assign({}, request), { redirectUri: request.redirectUri, code: \"\", codeVerifier: generatedPkceParams.verifier });\r\n request.codeChallenge = generatedPkceParams.challenge;\r\n request.codeChallengeMethod = Constants.S256_CODE_CHALLENGE_METHOD;\r\n return [2 /*return*/, authCodeRequest];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Initializer for the logout request.\r\n * @param logoutRequest\r\n */\r\n ClientApplication.prototype.initializeLogoutRequest = function (logoutRequest) {\r\n var validLogoutRequest = __assign({}, logoutRequest);\r\n if (StringUtils.isEmpty(validLogoutRequest.authority)) {\r\n validLogoutRequest.authority = this.config.auth.authority;\r\n }\r\n validLogoutRequest.correlationId = (validLogoutRequest && validLogoutRequest.correlationId) || this.browserCrypto.createNewGuid();\r\n validLogoutRequest.postLogoutRedirectUri = this.getPostLogoutRedirectUri(logoutRequest ? logoutRequest.postLogoutRedirectUri : \"\");\r\n return validLogoutRequest;\r\n };\r\n return ClientApplication;\r\n}());\n\n/**\r\n * The PublicClientApplication class is the object exposed by the library to perform authentication and authorization functions in Single Page Applications\r\n * to obtain JWT tokens as described in the OAuth 2.0 Authorization Code Flow with PKCE specification.\r\n */\r\nvar PublicClientApplication = /** @class */ (function (_super) {\r\n __extends(PublicClientApplication, _super);\r\n /**\r\n * @constructor\r\n * Constructor for the PublicClientApplication used to instantiate the PublicClientApplication object\r\n *\r\n * Important attributes in the Configuration object for auth are:\r\n * - clientID: the application ID of your application. 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 * - redirect_uri: the uri of your application registered in the portal.\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 * In Azure B2C, authority is of the form https://{instance}/tfp/{tenant}/{policyName}/\r\n * Full B2C functionality will be available in this library in future versions.\r\n *\r\n * @param {@link (Configuration:type)} configuration object for the MSAL PublicClientApplication instance\r\n */\r\n function PublicClientApplication(configuration) {\r\n return _super.call(this, configuration) || this;\r\n }\r\n /**\r\n * Use when initiating the login process by redirecting the user's browser to the authorization endpoint. This function redirects the page, so\r\n * any code that follows this function will not execute.\r\n *\r\n * IMPORTANT: It is NOT recommended to have code that is dependent on the resolution of the Promise. This function will navigate away from the current\r\n * browser window. It currently returns a Promise in order to reflect the asynchronous nature of the code running in this function.\r\n *\r\n * @param {@link (RedirectRequest:type)}\r\n */\r\n PublicClientApplication.prototype.loginRedirect = function (request) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n return [2 /*return*/, this.acquireTokenRedirect(request || DEFAULT_REQUEST)];\r\n });\r\n });\r\n };\r\n /**\r\n * Use when initiating the login process via opening a popup window in the user's browser\r\n *\r\n * @param {@link (PopupRequest: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 PublicClientApplication.prototype.loginPopup = function (request) {\r\n return this.acquireTokenPopup(request || DEFAULT_REQUEST);\r\n };\r\n PublicClientApplication.prototype.acquireTokenSilent = function (request) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var silentRequest, serverTelemetryManager, silentAuthClient, e_1;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n this.preflightBrowserEnvironmentCheck();\r\n silentRequest = __assign(__assign({}, request), this.initializeBaseRequest(request));\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 3, , 4]);\r\n serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow, silentRequest.correlationId);\r\n return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority)];\r\n case 2:\r\n silentAuthClient = _a.sent();\r\n return [2 /*return*/, silentAuthClient.acquireCachedToken(silentRequest)];\r\n case 3:\r\n e_1 = _a.sent();\r\n return [2 /*return*/, this.acquireTokenByRefreshToken(request)];\r\n case 4: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n return PublicClientApplication;\r\n}(ClientApplication));\n\nexport { AuthError, AuthErrorMessage, BrowserAuthError, BrowserAuthErrorMessage, BrowserConfigurationAuthError, BrowserConfigurationAuthErrorMessage, InteractionRequiredAuthError, LogLevel, Logger, PublicClientApplication };\n//# sourceMappingURL=index.es.js.map\n"],"sourceRoot":""}