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AAGpC,EAAgBsB,KAAK,MAAK,kBAC1C,YAAetB,EAAgBqC,OAC/B,YAAe,SACf,OAAU,WACV,QAAW/B,K,oCAMjB,C","sources":["/./Common/AuthenticationTypes.ts","/./Common/Helpers.ts","/./Common/Strings.ts","/./Common/Auth/AuthHelpers.ts","/./SmbDownload/SmbDownload.ts","/./SmbDownload/SmbDownload.Main.ts"],"sourcesContent":["// Copyright (C) Microsoft Corporation. All rights reserved.\r\n\r\nexport enum DataBoundary {\r\n\tNone = 'None',\r\n\tEU = 'EU'\r\n}\r\n\r\nexport enum UserAgeGroup {\r\n\tUndefined,\r\n\tMinorWithoutParentalConsent,\r\n\tMinorWithParentalConsent,\r\n\tAdult,\r\n\tNotAdult,\r\n\tMinorNoParentalConsentRequired,\r\n}\r\n\r\nexport interface MeControlAccount {\r\n\ttype: string,\r\n\ttenantId: string,\r\n\tmemberName: string,\r\n\tdisplayName: string,\r\n\tfirstName: string,\r\n\tlastName: string,\r\n\tauthenticatedState: string\r\n}\r\n\r\nexport interface SilentSignInProperties {\r\n\taccount: MeControlAccount,\r\n\tuserIsChild?: boolean,\r\n\tlocalTelemetryId: string,\r\n\ttelemetryAuthType: string,\r\n\tpuid: string,\r\n\tauthType: string,\r\n\tdataBoundary: string,\r\n\tageGroup?: UserAgeGroup\r\n}\r\n\r\nexport type MsShellObj = {\r\n\tmeControlOptions: { currentAccount: MeControlAccount }\r\n}\r\n\r\nexport interface IMsCommonShell {\r\n\tload: (msShellCurrentAccount: MsShellObj) => Promise;\r\n\tmeControlOptions: () => { currentAccount: MeControlAccount };\r\n}\r\n\r\n// Value Guidance Types\r\nexport interface ISignInCompletionObj {\r\n\teventType: string,\r\n\tauthType?: string,\r\n\tdataBoundary?: DataBoundary,\r\n\tmeControlAccount?: MeControlAccount\r\n}\r\n","// Copyright (C) Microsoft Corporation. All rights reserved.\r\nimport { MeControlAccount, DataBoundary } from '../Common/AuthenticationTypes';\r\n\r\n/*\r\n * @param {string} authType - authentication type from user auth object\r\n * @returns {boolean} - true if user is authenticated, false otherwise\r\n */\r\nexport const isUserAuthenticated = (authType: string): boolean => (authType && (authType != '') ? authType.toLowerCase() != 'none' : false);\r\n\r\n/*\r\n * @returns {MeControlAccount} - returns current user account information if available\r\n */\r\nexport const getCurrUser = (): MeControlAccount => (window?.msCommonShell?.meControlOptions()?.currentAccount);\r\n\r\n/*\r\n * @param {string} authType - authentication type from user auth object\r\n * @returns {boolean} - true if user is AAD user, false otherwise\r\n */\r\nexport const isAadUser = (authType): boolean => !!authType && (authType.toLowerCase() === \"aad\");\r\n\r\n/*\r\n * @param {window} window - window to close\r\n */\r\nexport const closeWindow = (window: Window | undefined | null): void => window?.close();\r\n\r\n/*\r\n * Returns valid data source\r\n * @param {string} dataBoundary - data boundary from user auth object\r\n */\r\nexport const parseDataBoundary = (dataBoundary: string): DataBoundary => (dataBoundary === DataBoundary.EU ? DataBoundary.EU : DataBoundary.None);\r\n\r\n/*\r\n * @param {string} url - URL to open in pop up window\r\n * @param {string} width - width of the window\r\n * @param {string} height - height of the window\r\n * @returns {Window} - returns the window created\r\n */\r\nexport const createPopUpWindow = (url: string, width: number, height: number) : Window | null => {\r\n\tif (window) {\r\n\t\tconst wLeft = window.screenLeft ? window.screenLeft : window.screenX;\r\n\t\tconst wTop = window.screenTop ? window.screenTop : window.screenY;\r\n\r\n\t\tconst left = wLeft + (window.innerWidth / 2) - (width / 2);\r\n\t\tconst top = wTop + (window.innerHeight / 2) - (height / 2);\r\n\t\treturn window.open(url, '_blank', `popup=yes, width=${width}, height=${height}, top=${top}, left=${left}`);\r\n\t}\r\n\treturn null;\r\n}\r\n\r\n/*\r\n * @param {MeControlAccount} userAccount - sets MeControlAccount in msCommonShell\r\n * @param {window} win - window to set MeControlAccount in\r\n */\r\nexport const SetMeControlAccount = (userAccount: MeControlAccount, window: any): void => {\r\n\t// ToDo: pattri, #7729785 set type for window\r\n\twindow?.MeControl?.API?.setActiveAccount(userAccount);\r\n}\r\n","// Copyright (C) Microsoft Corporation. All rights reserved.\r\n\r\n// Silent Sign In\r\nexport const eventNameSilentSignInComplete = \"silentSignInComplete\";\r\n\r\n// Popup Sign In\r\nexport const eventNamePopupSignInComplete = \"popupSignInComplete\";\r\n\r\n// Value Guidance strings\r\nexport const eventNameVgSignInSuccess = \"vg.signin.success\";\r\nexport const eventNameVgSignInFailed = \"vg.signin.failed\";\r\n\r\nexport const vgComponentNames = {\r\n\tvgHero: 'vg-hero',\r\n\tvgExplore: 'vg-explore'\r\n}\r\n\r\nexport const HvcComponentType = {\r\n\t[vgComponentNames.vgHero]: 'ValueGuidanceV2HvcHero',\r\n\t[vgComponentNames.vgExplore]: 'ValueGuidanceV2HvcExplore'\r\n}\r\n\r\nexport const TenantAdminPoliciesElementId = \"TAP__SETTINGS\";\r\n","// Copyright (C) Microsoft Corporation. All rights reserved.\r\n\r\nimport { SilentSignInProperties } from \"../AuthenticationTypes\";\r\nimport { getMetaTagValue } from \"../MetaTagHelpers\";\r\nimport { eventNameSilentSignInComplete } from \"../Strings\";\r\n\r\n//todo: move some of the auth helpers from Helpers.ts to here\r\n\r\n/**\r\n * Checks if the user is authenticated by looking at the \r\n * current me control account, as well as the meta tag values for auth type and tenant id\r\n * @returns true if the user is authenticated, false otherwise\r\n */\r\nexport function isUserAuthenticated(): boolean {\r\n return (!!getMetaTagValue(\"awa-authtype\") || !!getMetaTagValue(\"awa-tenantid\") || !!window.msCommonShell?.meControlOptions()?.currentAccount);\r\n}\r\n\r\n/**\r\n * Checks to see if the silent auth event will fire by looking\r\n * at the silentSigninProgress global variable first and then\r\n * checking to see if the silent auth iframe is on the page\r\n * @returns true if the silent auth event will fire, false otherwise\r\n */\r\nexport function willSilentAuthEventFire(): boolean {\r\n if (typeof window.silentSigninProgress !== 'undefined') {\r\n return window.silentSigninProgress;\r\n }\r\n\r\n return !!document.getElementById(\"iframeOP\");\r\n}\r\n\r\n/**\r\n * Adds an event listener for the silent auth event and takes an option timeout parameter\r\n * for how long to wait for the event to fire. If the event does not fire within the timeout period \r\n * the listener will be removed and the callback will be called when the timeout expires.\r\n * @param listener the callback to be called when the silent auth event fires or the timeout expires\r\n * @param timeout the amount of time (in milliseconds) to wait for the silent auth event to fire\r\n */\r\nexport function addSilentAuthEventListener(listener: (event: CustomEvent) => any, timeout?: number, options?: boolean | AddEventListenerOptions): void {\r\n \r\n if(!timeout){\r\n window.addEventListener(eventNameSilentSignInComplete, listener, options);\r\n return;\r\n }\r\n \r\n //handles silent auth event by removing the timeout and calling the listener callback\r\n function silentAuthEventCallbackWrapper(event: CustomEvent){\r\n clearTimeout(timeoutHandler);\r\n listener(event);\r\n }\r\n\r\n //handles the timeout by removing the silent auth listener and calling the listener callback with error\r\n function timeoutCallback(){\r\n window.removeEventListener(eventNameSilentSignInComplete, silentAuthEventCallbackWrapper);\r\n listener(new CustomEvent(eventNameSilentSignInComplete, { detail: new Error(`Silent auth did not complete before allowed timeout of ${timeout}`) }));\r\n }\r\n\r\n let timeoutHandler = setTimeout(timeoutCallback, timeout);\r\n window.addEventListener(eventNameSilentSignInComplete, silentAuthEventCallbackWrapper, options);\r\n}","// Copyright (C) Microsoft Corporation. All rights reserved.\r\n\r\nimport { isAadUser, isUserAuthenticated } from \"../Common/Helpers\";\r\nimport { addSilentAuthEventListener } from \"../Common/Auth/AuthHelpers\";\r\nimport { SilentSignInProperties } from '../Common/AuthenticationTypes';\r\n\r\nlet $downloadButton = $('#smbOfficeDownload');\r\n\r\nexport function LoadSmbDownload() {\r\n\tconst analytics = window.analytics;\r\n\r\n\t$downloadButton.on('click', async function () {\r\n\t\tif ($downloadButton.attr('href') === '#') {\r\n\t\t\tconst { productId, url } = await getOfficeDownload();\r\n\t\t\tif (url) {\r\n\t\t\t\twindow.location.href = url;\r\n\t\t\t}\r\n\r\n\t\t\tif (analytics) {\r\n\t\t\t\tanalytics.captureContentUpdate(null, {\r\n\t\t\t\t\tisAuto: false,\r\n\t\t\t\t\tbehavior: window.oneDS.Behavior.OTHER,\r\n\t\t\t\t\tcontent: {\r\n\t\t\t\t\t\t'contentId': `${$downloadButton.attr('id')}_productDetail`,\r\n\t\t\t\t\t\t'contentName': $downloadButton.text(),\r\n\t\t\t\t\t\t'contentType': 'anchor',\r\n\t\t\t\t\t\t'compnm': 'cta-link',\r\n\t\t\t\t\t\t'product': productId\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t});\r\n}\r\n\r\nasync function getOfficeDownload(): Promise<{ productId: string, url: string }> {\r\n\tlet result: Response;\r\n\ttry {\r\n\t\tresult = await fetch('/officedownload', {\r\n\t\t\tmethod: 'GET',\r\n\t\t});\r\n\t\tconst data = await result.json();\r\n\t\treturn { productId: data.ProductId, url: data.Url };\r\n\t} catch (error) {\r\n\t\tconsole.error('Get installer download link failed, error: ' + error);\r\n\t\treturn { url: '', productId: '' };\r\n\t}\r\n}\r\n\r\naddSilentAuthEventListener((props: CustomEvent) => {\r\n\tif (props.detail instanceof Error) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst authProperties = props.detail as SilentSignInProperties;\r\n\tconst isUserAuthed = isUserAuthenticated(authProperties.authType);\r\n\tconst isUserAad = isAadUser(authProperties.authType);\r\n\r\n\tif (isUserAuthed && isUserAad) {\r\n\t\t$(\"#smbOfficeDownload\").attr(\"href\", \"#\");\r\n\t}\r\n})\r\n","// Copyright (C) Microsoft Corporation. All rights reserved.\r\n\r\nimport { LoadSmbDownload } from './SmbDownload';\r\n\r\n(window).loadSmbDownload = LoadSmbDownload;\r\n"],"names":["UserAgeGroup","DataBoundary","eventNameSilentSignInComplete","listener","options","$downloadButton","$","getOfficeDownload","fetch","method","json","productId","data","ProductId","url","Url","console","error","props","detail","Error","authType","authProperties","isUserAuthed","toLowerCase","isUserAad","isAadUser","attr","window","addEventListener","loadSmbDownload","analytics","on","location","href","captureContentUpdate","isAuto","behavior","oneDS","Behavior","OTHER","content","text"],"sourceRoot":""}