????
Current Path : C:/Windows/SystemApps/Microsoft.Windows.CloudExperienceHost_cw5n1h2txyewy/js/ |
Current File : C:/Windows/SystemApps/Microsoft.Windows.CloudExperienceHost_cw5n1h2txyewy/js/autoPilot.js |
// // Copyright (C) Microsoft. All rights reserved. // "use strict"; var CloudExperienceHost; (function (CloudExperienceHost) { var AutoPilot; (function (AutoPilot) { var PlugAndForget; (function (PlugAndForget) { function getShouldSkipAsync() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { try { EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotUtilStatics.getOobeSettingsOverrideAsync(EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotOobeSetting.aadAuthUsingDeviceTicket).then(function (useDeviceTicketForAadAuth) { // True - Skip the pages for the Autopilot Plug and Forget flow // False - Show the pages completeDispatch(useDeviceTicketForAadAuth); }, errorDispatch); } catch (err) { // If an exception is thrown, skip the Plug and Forget flow and resume through the Consumer OOBE flow CloudExperienceHost.Telemetry.logEvent("Autopilot_PlugAndForget_GetShouldSkipAsyncFailed", JSON.stringify({ error: err })); completeDispatch(true); } }); } PlugAndForget.getShouldSkipAsync = getShouldSkipAsync; })(PlugAndForget = AutoPilot.PlugAndForget || (AutoPilot.PlugAndForget = {})); var ShouldUseRefactoredEsp; (function (ShouldUseRefactoredEsp) { function getShouldSkipAsync() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { try { EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotUtilStatics.getSettingAsync("UseRefactoredEsp").then(function (result) { if ("" === result) { // Don't use refactored ESP. completeDispatch(false); } else { // Use refactored ESP. completeDispatch(true); } }, errorDispatch); } catch (err) { // If an exception is thrown, don't use the refactored ESP. CloudExperienceHost.Telemetry.logEvent("AutoPilot_ShouldUseRefactoredEsp_GetShouldSkipAsyncFailed", JSON.stringify({ error: err })); completeDispatch(false); } }); } ShouldUseRefactoredEsp.getShouldSkipAsync = getShouldSkipAsync; })(ShouldUseRefactoredEsp = AutoPilot.ShouldUseRefactoredEsp || (AutoPilot.ShouldUseRefactoredEsp = {})); var ShouldUseRefactoredEspAndShouldShowEsp; (function (ShouldUseRefactoredEspAndShouldShowEsp) { function getShouldSkipAsync() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { try { EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotUtilStatics.getSettingAsync("UseRefactoredEsp").then(function (result) { if ("" === result) { // Don't use refactored ESP. let context = CloudExperienceHost.getContext(); let isOOBE = (context.host.toLowerCase() !== "nthentormdm" && context.host.toLowerCase() !== "nthaadormdm"); let enterpriseManagementWorker = new EnterpriseDeviceManagement.Enrollment.ReflectedEnroller(); return enterpriseManagementWorker.showMdmSyncStatusPageAsync(isOOBE).then(function (results) { CloudExperienceHost.Telemetry.logEvent("Show ESP page?", results); if (1 === results) { completeDispatch(false); } else { completeDispatch(true); } }, errorDispatch); } else { // Use refactored ESP. completeDispatch(true); } }, errorDispatch); } catch (err) { // If an exception is thrown, don't use the refactored ESP. CloudExperienceHost.Telemetry.logEvent("AutoPilot_ShouldUseRefactoredEspAndShouldShowEsp_GetShouldSkipAsyncFailed", JSON.stringify({ error: err })); completeDispatch(false); } }); } ShouldUseRefactoredEspAndShouldShowEsp.getShouldSkipAsync = getShouldSkipAsync; })(ShouldUseRefactoredEspAndShouldShowEsp = AutoPilot.ShouldUseRefactoredEspAndShouldShowEsp || (AutoPilot.ShouldUseRefactoredEspAndShouldShowEsp = {})); var ShouldSkipAutoPilotUpdate; (function (ShouldSkipAutoPilotUpdate) { function getShouldSkipAsync() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { try { EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotUtilStatics.isLocalProfileAvailableAsync().then(function (result) { // If we have a profile, check if update is enabled (absence of this policy means enabled by default) if (result) { EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotUtilStatics.getDwordPolicyAsync("CloudAssignedAutopilotUpdateDisabled").then(function (isDisabledResult) { CloudExperienceHost.Telemetry.logEvent(isDisabledResult !== 0 ? "AutoPilot_ShouldSkipAutoPilotUpdate_SkippingBecauseDisabled" : "AutoPilot_ShouldSkipAutoPilotUpdate_NoSkippingBecauseEnabled"); completeDispatch(isDisabledResult !== 0); // return we should skip if update is explicitly disabled }, function (err) { CloudExperienceHost.Telemetry.logEvent("Autopilot_AutoPilotUpdatePage_GetShouldSkipOptOutAsyncFailed", JSON.stringify({ error: err })); completeDispatch(true); }); } else { CloudExperienceHost.Telemetry.logEvent("AutoPilot_ShouldSkipAutoPilotUpdate_Skipping"); completeDispatch(true); // return we should skip if we don't have AP profile } }, errorDispatch); } catch (err) { // If an exception is thrown, skip the update page and resume through the Consumer OOBE flow CloudExperienceHost.Telemetry.logEvent("Autopilot_AutoPilotUpdatePage_GetShouldSkipAsyncFailed", JSON.stringify({ error: err })); completeDispatch(true); } }); } ShouldSkipAutoPilotUpdate.getShouldSkipAsync = getShouldSkipAsync; })(ShouldSkipAutoPilotUpdate = AutoPilot.ShouldSkipAutoPilotUpdate || (AutoPilot.ShouldSkipAutoPilotUpdate = {})); var ShouldSkipDeviceRename; (function (ShouldSkipDeviceRename) { function getShouldSkipAsync() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { checkIfShouldSkipAsync().then(completeDispatch, errorDispatch); }); } async function checkIfShouldSkipAsync() { try { // Get the CloudAssignedDeviceName policy let deviceName = await EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotUtilStatics.getStringPolicyAsync("CloudAssignedDeviceName"); // If policy is empty or null, skip device rename if ((deviceName === null) || (deviceName === "")) { CloudExperienceHost.Telemetry.logEvent("ShouldSkipDeviceRename.checkIfShouldSkipAsync: Info: No device name specified. Skipping Autopilot device rename."); return true; } else { let deviceNameLastProcessed = await EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotUtilStatics.getStringPolicyAsync("CloudAssignedDeviceNameLastProcessed"); if (deviceName === deviceNameLastProcessed) { CloudExperienceHost.Telemetry.logEvent("ShouldSkipDeviceRename.checkIfShouldSkipAsync: Info: Autopilot device rename has already been set. Skipping device rename."); return true; } return false; } } catch (err) { // If an exception is thrown, skip the rename page and resume through the Consumer OOBE flow CloudExperienceHost.Telemetry.logEvent("ShouldSkipDeviceRename.checkIfShouldSkipAsync: Failure: AutoPilotDeviceRename preload check failed. Skipping Autopilot device rename.", JSON.stringify(err)); return true; } } ShouldSkipDeviceRename.getShouldSkipAsync = getShouldSkipAsync; })(ShouldSkipDeviceRename = AutoPilot.ShouldSkipDeviceRename || (AutoPilot.ShouldSkipDeviceRename = {})); var Activation; (function (Activation) { function getShouldSkipAsync() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { try { CloudExperienceHostAPI.UtilStaticsCore.isNetworkRequiredAsync().then(function (result) { CloudExperienceHost.Telemetry.logEvent(result ? "AutoPilot_ActivationPage_PreLoadCheckCompleted_NoSkipping" : "AutoPilot_ActivationPage_PreLoadCheckCompleted_Skipping"); completeDispatch(!result); }, errorDispatch); } catch (err) { CloudExperienceHost.Telemetry.logEvent("AutoPilot_ActivationPage_PreLoadCheckFailed", JSON.stringify(err)); completeDispatch(true); } }); } Activation.getShouldSkipAsync = getShouldSkipAsync; })(Activation = AutoPilot.Activation || (AutoPilot.Activation = {})); var AutopilotWrapper; (function (AutopilotWrapper) { function GetCurrentNode() { return CloudExperienceHost.getCurrentNode(); } AutopilotWrapper.GetCurrentNode = GetCurrentNode; })(AutopilotWrapper = AutoPilot.AutopilotWrapper || (AutoPilot.AutopilotWrapper = {})); var EnrollmentStatusPage; (function (EnrollmentStatusPage) { function showMdmSyncStatusPageAsync() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { var context = CloudExperienceHost.getContext(); var host = context.host.toLowerCase(); if (host === "mosetmdmconnecttoworkprogress" || host === "mosetmdmconnecttoworkprovisioningprogress") { completeDispatch(1); } if ((CloudExperienceHost.getCurrentNode().cxid === "ManagementProgress") || (CloudExperienceHost.getCurrentNode().cxid === "MDMProgressForPlugAndForget") || (CloudExperienceHost.getCurrentNode().cxid === "AutopilotEnrollmentStatus")){ completeDispatch(1); } // For Autopilot WG DJ++ scenario, we want to always show ESP let autopilotManager = new EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotServer(); autopilotManager.getDeviceAutopilotModeAsync().then(function (result) { CloudExperienceHost.Telemetry.logEvent("Autopilot_EnrollmentStatusPage_showMdmSyncStatusPageAsync_getDeviceAutopilotModeAsync", result); if (result === EnterpriseDeviceManagement.Service.AutoPilot.AutopilotMode.whiteGloveDJPP) { completeDispatch(1); } }); var enterpriseManagementWorker = new EnterpriseDeviceManagement.Enrollment.ReflectedEnroller(); if (host === "mosetmamconnecttowork" || host === "mosetmdmconnecttowork" || host === "mosetconnecttowork" || host === "nthaadormdm" || host === "nthentormdm") { enterpriseManagementWorker.showMdmSyncStatusPageAsync(false).then(completeDispatch, errorDispatch); } else { enterpriseManagementWorker.showMdmSyncStatusPageAsync(true).then(completeDispatch, errorDispatch); } }); } AutoPilot.EnrollmentStatusPage.showMdmSyncStatusPageAsync = showMdmSyncStatusPageAsync; function runProvisioningInStatusPageAsync() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { var platform = CloudExperienceHost.Environment.getPlatform(); if (platform === CloudExperienceHost.TargetPlatform.DESKTOP) { // This will fail on WCOS devices as provisioning is only available on desktop let pluginManager = new CloudExperienceHostAPI.Provisioning.PluginManager(); let isAutopilotReset = pluginManager.isPostPowerwash(); // Run provisioning after Autopilot Reset or for Plug and Forget (self-deploying) modes if ((isAutopilotReset) || (CloudExperienceHost.getCurrentNode().cxid === "MDMProgressForPlugAndForget")) { completeDispatch(1); } else { completeDispatch(0); } } else { completeDispatch(0); } }); } AutoPilot.EnrollmentStatusPage.runProvisioningInStatusPageAsync = runProvisioningInStatusPageAsync; function restoreMDMSyncTasks() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { var platform = CloudExperienceHost.Environment.getPlatform(); if (platform === CloudExperienceHost.TargetPlatform.DESKTOP) { // This will fail on WCOS devices as provisioning is only available on desktop let pluginManager = new CloudExperienceHostAPI.Provisioning.PluginManager(); let isAutopilotReset = pluginManager.isPostPowerwash(); // Restore MDM sync tasks after Autopilot Reset if (isAutopilotReset) { completeDispatch(1); } else { completeDispatch(0); } } else { completeDispatch(0); } }); } AutoPilot.EnrollmentStatusPage.restoreMDMSyncTasks = restoreMDMSyncTasks; function forceInclusiveCSS(appRoot) { return new WinJS.Promise(function (completeDispatch, errorDispatch) { var context = CloudExperienceHost.getContext(); context.host = "frx"; context.experienceName = "FRXINCLUSIVE"; context.personality = CloudExperienceHost.TargetPersonality.InclusiveBlue; var cssList = CloudExperienceHost.GetCssList(appRoot, context); completeDispatch(cssList); }); } AutoPilot.EnrollmentStatusPage.forceInclusiveCSS = forceInclusiveCSS; function getShouldSkipAsync() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { let context = CloudExperienceHost.getContext(); let isRunInOOBE = (context.host.toLowerCase() !== "nthentormdm" && context.host.toLowerCase() !== "nthaadormdm"); let enterpriseManagementWorker = new EnterpriseDeviceManagement.Enrollment.ReflectedEnroller(); return enterpriseManagementWorker.showMdmSyncStatusPageAsync(isRunInOOBE).then(function (results) { CloudExperienceHost.Telemetry.logEvent("Autopilot_EnrollmentStatusPage_getShouldSkipAsync_Info:SkippedMDMPage", isRunInOOBE); // For Autopilot WG DJ++ scenario, we want to always show ESP let autopilotServer = new EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotServer(); autopilotServer.getDeviceAutopilotModeAsync().then(function (autopilotMode) { let isWhiteGloveDJPP = (autopilotMode === EnterpriseDeviceManagement.Service.AutoPilot.AutopilotMode.whiteGloveDJPP); if (1 === results || isWhiteGloveDJPP) { completeDispatch(false); } else { completeDispatch(true); } }); }, errorDispatch); }); } AutoPilot.EnrollmentStatusPage.getShouldSkipAsync = getShouldSkipAsync; function setStatusPageReboot() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { var pageName = CloudExperienceHost.getCurrentNode().cxid; var cxidToMatch = CloudExperienceHost.Storage.SharableData.getValue("MDMRebootPossible"); CloudExperienceHost.Telemetry.logEvent(`Autopilot_EnrollmentStatusPage_setStatusPageReboot: Initializing persistent reboot settings. Current CXID: ${pageName}`); if ((pageName === cxidToMatch) && (pageName !== "MDMProgressForPlugAndForget") && (pageName !== "AutopilotEnrollmentStatus") && pageName !== ("MDMProgressForPlugAndForgetRefactored")) { // If we've seen this page before, we are rebooting, so we need to clear AutoLogin information. Best effort. try { CloudExperienceHost.Telemetry.logEvent("Autopilot_EnrollmentStatusPage_setStatusPageReboot: Clearing Autologon credentials"); var enterpriseManagementWorker = new EnterpriseDeviceManagement.Enrollment.ReflectedEnroller(); enterpriseManagementWorker.clearAutoLoginData(); } catch (e) { CloudExperienceHost.Telemetry.logEvent("Autopilot_EnrollmentStatusPage_setStatusPageReboot: Error occured while clearing Autologon credentials", JSON.stringify({ error: e })); } } CloudExperienceHost.setRebootForOOBE(pageName); CloudExperienceHost.Storage.SharableData.addValue("OOBEResumeEnabled", true); CloudExperienceHost.Storage.SharableData.addValue("MDMRebootPossible", pageName); completeDispatch(true); }); } AutoPilot.EnrollmentStatusPage.setStatusPageReboot = setStatusPageReboot; })(EnrollmentStatusPage = AutoPilot.EnrollmentStatusPage || (AutoPilot.EnrollmentStatusPage = {})); var Veto; (function (Veto) { function getShouldSkipAsync() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { try { EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotUtilStatics.getOobeSettingsOverrideAsync(EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotOobeSetting.aadAuthUsingDeviceTicket).then(function (useDeviceTicketForAadAuth) { // True - Show the Autopilot Veto page // False - Skip the Autopilot Veto page completeDispatch(!useDeviceTicketForAadAuth); }, errorDispatch); } catch (err) { // If an exception is thrown, skip the Plug and Forget flow and resume through the Consumer OOBE flow CloudExperienceHost.Telemetry.logEvent("Autopilot_Veto_GetShouldSkipAsyncFailed", JSON.stringify({ error: err })); completeDispatch(true); } }); } Veto.getShouldSkipAsync = getShouldSkipAsync; })(Veto = AutoPilot.Veto || (AutoPilot.Veto = {})); function isDevicePlugAndForgetAsync() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotUtilStatics.getOobeSettingsOverrideAsync(EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotOobeSetting.aadAuthUsingDeviceTicket).then(function (result) { // If result is true, proceed with the Plug and Forget Scenario. Else, proceed with the normal flow. completeDispatch(result); }, function (e) { // Default to normal flow completeDispatch(false); }); }); } AutoPilot.isDevicePlugAndForgetAsync = isDevicePlugAndForgetAsync; function disableAutoPilotAsync() { return new WinJS.Promise(function (completeDispatch, errorDispatch) { EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotUtilStatics.disableAsync().then(function () { CloudExperienceHost.setRebootForOOBE(); completeDispatch(true); }); }); } AutoPilot.disableAutoPilotAsync = disableAutoPilotAsync; function getDwordPolicyAsync(policyName) { return new WinJS.Promise(function (completeDispatch, errorDispatch) { EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotUtilStatics.getDwordPolicyAsync(policyName).done(completeDispatch, errorDispatch); }); } AutoPilot.getDwordPolicyAsync = getDwordPolicyAsync; function getStringPolicyAsync(policyName) { return new WinJS.Promise(function (completeDispatch, errorDispatch) { EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotUtilStatics.getStringPolicyAsync(policyName).done(completeDispatch, errorDispatch); }); } AutoPilot.getStringPolicyAsync = getStringPolicyAsync; // This function creates the query string part of the URL to pass-in the ZTD tenant name to eSTS. // This is required to be passed-in up front as opposed to using the CXH bridge since the branding elements are burned into the page upon generation. function getZTDQueryStringAsync() { return EnterpriseDeviceManagement.Service.AutoPilot.AutoPilotUtilStatics.getStringPolicyAsync("CloudAssignedTenantDomain").then(function (result) { let ztdQueryString = ""; if (result) { ztdQueryString += "ztd_tenant=" + encodeURIComponent(result); } return ztdQueryString; }); } AutoPilot.getZTDQueryStringAsync = getZTDQueryStringAsync; // Resource creation function for just Autopilot OOBE pages function makeAutopilotResourceObject() { var resources = {}; // Load and resolve all resources for this file let context = Windows.ApplicationModel.Resources.Core.ResourceContext; let resourceContext = context.getForCurrentView(); let apResourceMap = ModernDeployment.Autopilot.Core.AutopilotLocalizationResourcesHelper.getAutopilotResourceMap(); let resourceMap = apResourceMap.getSubtree("ModernDeployment.Autopilot.Core.AutopilotSystemResources\\Autopilot"); let iter = resourceMap.first(); while (iter.hasCurrent) { resources[iter.current.key] = iter.current.value.resolve(resourceContext).valueAsString; iter.moveNext(); } return JSON.stringify(resources); } AutoPilot.makeAutopilotResourceObject = makeAutopilotResourceObject; function internalLogEvent(eventName, errorCode, eventMessage, eventMetadata) { var c_message = "message"; var c_errorCode = "errorCode"; if ((eventMetadata === null) || (eventMetadata === undefined) || (typeof(eventMetadata) !== "object")) { eventMetadata = {}; } if ((eventMessage === null) || (eventMessage === undefined) || (typeof(eventMessage) !== "string")) { eventMetadata[c_message] = ""; } else { eventMetadata[c_message] = eventMessage; } if ((errorCode === null) || (errorCode === undefined)) { eventMetadata[c_errorCode] = 0; } else { if (typeof(errorCode) === "number") { eventMetadata[c_errorCode] = errorCode; } else { throw Error("The errorCode parameter must be an integer."); } } CloudExperienceHost.Telemetry.safeLogEvent(eventName, eventMetadata); } AutoPilot.internalLogEvent = internalLogEvent; function logInfoEvent(eventName, eventMessage) { internalLogEvent(eventName, null, eventMessage, null); } AutoPilot.logInfoEvent = logInfoEvent; function logHresultEvent(eventName, eventMessage, hresult) { internalLogEvent(eventName, hresult, eventMessage, null); } AutoPilot.logHresultEvent = logHresultEvent; // Log event values. Event names must remain in sync with ETWProcessingData.json AutoPilot.EventName_CommercialOOBE_AutopilotRegion_SettingApplication_Start = "CommercialOOBE_AutopilotRegion_SettingApplication_Start"; AutoPilot.EventName_CommercialOOBE_AutopilotRegion_SettingApplication_Succeeded = "CommercialOOBE_AutopilotRegion_SettingApplication_Succeeded"; AutoPilot.EventName_CommercialOOBE_AutopilotRegion_SettingApplication_Failed = "CommercialOOBE_AutopilotRegion_SettingApplication_Failed"; AutoPilot.EventName_CommercialOOBE_AutopilotRegion_SettingRetrieval_Start = "CommercialOOBE_AutopilotRegion_SettingRetrieval_Start"; AutoPilot.EventName_CommercialOOBE_AutopilotRegion_SettingRetrieval_Succeeded = "CommercialOOBE_AutopilotRegion_SettingRetrieval_Succeeded"; AutoPilot.EventName_CommercialOOBE_AutopilotRegion_SettingRetrieval_Failed = "CommercialOOBE_AutopilotRegion_SettingRetrieval_Failed"; })(AutoPilot = CloudExperienceHost.AutoPilot || (CloudExperienceHost.AutoPilot = {})); })(CloudExperienceHost || (CloudExperienceHost = {}));