| Server IP : 123.56.80.60 / Your IP : 216.73.216.78 Web Server : Apache/2.4.54 (Win32) OpenSSL/1.1.1s PHP/7.4.33 mod_fcgid/2.3.10-dev System : Windows NT iZhx3sob14hnz7Z 10.0 build 14393 (Windows Server 2016) i586 User : SYSTEM ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Windows/SystemApps/Microsoft.Windows.CloudExperienceHost_cw5n1h2txyewy/js/ |
Upload File : |
"use strict";
var CloudExperienceHost;
(function (CloudExperienceHost) {
var MSAError = (function () {
function MSAError() {
}
return MSAError;
})();
CloudExperienceHost.MSAError = MSAError;
var MSATokenProviderManager = (function () {
function MSATokenProviderManager(appView) {
this._isInitialPageLoaded = false;
this._platform = null;
var isWAMActivity = false;
if (!CloudExperienceHost.Telemetry.WebAppTelemetry.getInstance().isStarted()) {
CloudExperienceHost.Telemetry.WebAppTelemetry.getInstance().start("msa-wam");
isWAMActivity = true;
}
this._platform = null;
this._appView = appView;
this._msaUIHandler = new CloudExperienceHost.MSAUIHandlerInternal(appView, new MicrosoftAccount.TokenProvider.Core.TokenBrokerOperation());
this._msaUIHandler.setIsWAMActivity(isWAMActivity);
this._msaExtension = new MicrosoftAccount.Extension.ExtensionWorker();
WinJS.Namespace.define("CloudExperienceHost", {
getContext: this._getContext.bind(this)
});
if (typeof (CloudExperienceHost.getCurrentNode) === 'undefined') {
WinJS.Namespace.define("CloudExperienceHost", {
getCurrentNode: this._getINavigable.bind(this)
});
}
}
MSATokenProviderManager.prototype.start = function (args) {
var webAccountProviderOperation;
if (args.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.webAccountProvider) {
webAccountProviderOperation = args.detail.operation;
}
else {
throw new Error(CloudExperienceHost.ErrorNames.ActivationNotSupported);
}
if (webAccountProviderOperation == null) {
throw new CloudExperienceHost.InvalidArgumentError();
}
this._platform = CloudExperienceHost.Environment.getPlatform();
this._appView.loadCss();
this._appView.showProgress().then(function () {
this._initializeWebView().then(function () {
var tokenOperation = this._msaUIHandler.getTokenOperation();
tokenOperation.webAccountProviderOperation = webAccountProviderOperation;
tokenOperation.loadUrlInWebView = this._loadURLInWebView.bind(this);
tokenOperation.stopListeningForVerificationCode = this._stopListeningForVerificationCode.bind(this);
var msaTokenProvider;
msaTokenProvider = new MicrosoftAccount.TokenProvider.Core.TokenProviderExecutor(tokenOperation);
msaTokenProvider.execute();
}.bind(this));
}.bind(this));
};
MSATokenProviderManager.prototype.resume = function (args) {
this.start(args);
};
MSATokenProviderManager.prototype.checkpoint = function () {
};
MSATokenProviderManager.prototype.restart = function (uri) {
};
MSATokenProviderManager.prototype.onUnhandledException = function (e) {
CloudExperienceHost.Telemetry.WebAppTelemetry.getInstance().logEvent("onUnhandledException", e.detail.errorMessage);
this._msaUIHandler.saveAuthStateAndCompleteWebFlow(CloudExperienceHost.AppResult.fail, null , null , null , null , null , null , null , null , "0xc0000144", "0xc0000144", null );
return null;
};
MSATokenProviderManager.prototype._loadURLInWebView = function (url, contextParams, method, value) {
this._isInitialPageLoaded = false;
this._startListeningForVerificationCode();
this._redirectToURL(url, contextParams, method, value);
CloudExperienceHost.Telemetry.WebAppTelemetry.getInstance().logEvent("_loadURLInWebView");
};
MSATokenProviderManager.prototype._startListeningForVerificationCode = function () {
var tokenOperation = this._msaUIHandler.getTokenOperation();
this._msaExtension.getVerificationCodeAsync().then(function (verificationCode) {
if (verificationCode) {
tokenOperation.receivedVerificationCode = verificationCode;
}
else {
tokenOperation.receivedVerificationCode = "-1";
}
this._stopListeningForVerificationCode();
}.bind(this), function (e) {
tokenOperation.receivedVerificationCode = "-1";
this._stopListeningForVerificationCode();
}.bind(this));
};
MSATokenProviderManager.prototype._stopListeningForVerificationCode = function () {
if (this._msaExtension) {
this._msaExtension.cancelVerificationCodeWait();
}
};
MSATokenProviderManager.prototype._initializeWebView = function () {
return new WinJS.Promise(function (completeDispatch, errorDispatch ) {
this._webView = this._appView.createWebView();
this._appView.cleanView();
this._appView.getView().appendChild(this._webView);
this._webView.focus();
this._webView.addEventListener("MSWebViewNavigationCompleted", this._onNavigationCompleted.bind(this));
var discovery = new CloudExperienceHost.Discovery();
discovery.getApiRules().then(function (rules) {
var contractHandler = new CloudExperienceHost.ContractHandler(rules);
this._bridge = new CloudExperienceHost.Bridge(this._webView, contractHandler);
this._bridge.addEventListener(CloudExperienceHost.Events.done, this._onDone.bind(this));
this._bridge.addEventListener(CloudExperienceHost.Events.postDeviceTicketToUrl, this._onPostDeviceTicketToUrl.bind(this));
this._bridge.addEventListener(CloudExperienceHost.Events.registerNGCForUser, this._onRegisterNGCForUser.bind(this));
completeDispatch();
}.bind(this), errorDispatch);
}.bind(this));
};
MSATokenProviderManager.prototype._onTicketRequestComplete = function (targetUrl, result) {
if (targetUrl) {
this._loadURLInWebView(targetUrl, null, result ? "POST" : "GET", result);
}
else {
this._onTicketError(targetUrl, result, -2147012891 );
}
};
MSATokenProviderManager.prototype._onPostDeviceTicketToUrl = function (data) {
var targetUrl = data.targetUrl;
var policy = data.policy;
var guid = "D9AB8D3D-41EF-49AD-86CB-F036516A662D";
this._appView.showProgress().then(function () {
var msaExtension = new MicrosoftAccount.Extension.ExtensionWorker();
msaExtension.getDeviceTicketForWebFlowAsync(targetUrl, policy, guid).done(function (result) {
this._onTicketRequestComplete(result.ResultUrl, result.Ticket);
}.bind(this), function (error) {
this._onTicketError(targetUrl, error.message, error.number);
}.bind(this));
}.bind(this));
};
MSATokenProviderManager.prototype._onTicketError = function (targetUrl, errorMsg, errorCode) {
var logData = new Object;
logData["errorCode"] = errorCode || null;
logData["message"] = errorMsg || null;
logData["targetUrl"] = targetUrl;
CloudExperienceHost.Telemetry.WebAppTelemetry.getInstance().logEvent("TicketRequestError", JSON.stringify(logData));
var hr = this._numToHexString(errorCode, 4);
var msaError = new CloudExperienceHost.MSAError();
msaError.hr = hr;
msaError.hrInternal = hr;
msaError.msaUIHandler = this._msaUIHandler;
msaError.hasInternetAccess = CloudExperienceHost.Environment.hasInternetAccess();
this._appView.cleanView();
this._appView.showProgress().then(function () {
WinJS.UI.Pages.render("views/tokenManagerErrorHandler.html", this._appView.getView(), msaError).done(function () {
this._appView.showView().done(function () {
}.bind(this));
}.bind(this));
}.bind(this));
};
MSATokenProviderManager.prototype._onRegisterNGCForUser = function (data) {
this._msaUIHandler.registerNGCForUser(data, this._loadURLInWebView.bind(this)).done(this._onTicketRequestComplete.bind(this), function (error) {
var destinationUrl = data.returnUrl;
var hexString = this._numToHexString(error.number, 4);
destinationUrl += (destinationUrl.indexOf('?') > 0 ? '&' : '?') + "errorCode=" + encodeURIComponent(hexString);
this._loadURLInWebView(destinationUrl);
}.bind(this));
};
MSATokenProviderManager.prototype._numToHexString = function (errorCode, integerByteLength) {
var integerBitLength = 8 * integerByteLength;
var hexString = "undefined";
if (errorCode < Math.pow(2, integerBitLength) && errorCode > -Math.pow(2, integerBitLength)) {
if (errorCode > 0) {
hexString = "0x" + errorCode.toString(16);
}
else {
hexString = "0x" + (errorCode + Math.pow(2, integerBitLength)).toString(16);
}
}
return hexString;
};
MSATokenProviderManager.prototype._redirectToURL = function (url, contextParams, method, value) {
var httpRequestMessage;
var httpMethod = (!(typeof (method) === 'undefined') && method.toUpperCase() === "POST") ? Windows.Web.Http.HttpMethod.post : Windows.Web.Http.HttpMethod.get;
var uri = new Windows.Foundation.Uri(url);
httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(httpMethod, uri);
if (!(typeof (value) === 'undefined')) {
this._addDataToRequest(httpRequestMessage, null, value);
}
this._appendCustomHeaders(httpRequestMessage, contextParams);
if (CloudExperienceHost.Environment.hasInternetAccess()) {
this._webView.navigateWithHttpRequestMessage(httpRequestMessage);
}
else {
this._onNavigationFailed(null);
}
};
MSATokenProviderManager.prototype._appendCustomHeaders = function (httpRequestMessage, contextHeaders) {
var context = CloudExperienceHost.getContext();
httpRequestMessage.headers.append("hostApp", "CloudExperienceHost");
httpRequestMessage.headers.append("cxh-correlationId", CloudExperienceHost.Telemetry.WebAppTelemetry.getInstance().getId());
httpRequestMessage.headers.append("cxh-cxid", "TokenBroker");
for (var key in context) {
httpRequestMessage.headers.append("cxh-" + key, context[key]);
}
if (typeof (contextHeaders) !== 'undefined' && contextHeaders !== null) {
for (var iterator = contextHeaders.first(); iterator.hasCurrent; iterator.moveNext()) {
httpRequestMessage.headers.append(iterator.current.key, iterator.current.value);
}
}
};
MSATokenProviderManager.prototype._addDataToRequest = function (httpRequestMessage, key, value) {
if (httpRequestMessage.method === Windows.Web.Http.HttpMethod.get) {
if (!key) {
throw new CloudExperienceHost.InvalidArgumentError("key cannot be empty for GET request");
}
httpRequestMessage.headers.append(key, value);
}
else {
var content = !!key ? (key + "=" + value) : value;
var contentType = "application/x-www-form-urlencoded";
httpRequestMessage.content = new Windows.Web.Http.HttpStringContent(content, Windows.Storage.Streams.UnicodeEncoding.utf8, contentType);
}
};
MSATokenProviderManager.prototype._onNavigationCompleted = function (eventInfo) {
if (eventInfo.isSuccess === true) {
if (!this._isInitialPageLoaded) {
this._appView.showView();
this._isInitialPageLoaded = true;
}
}
else {
this._onNavigationFailed(eventInfo);
}
CloudExperienceHost.Telemetry.WebAppTelemetry.getInstance().logEvent("_onNavigationCompleted");
};
MSATokenProviderManager.prototype._getContext = function () {
var context = new CloudExperienceHost.Context();
context.host = "TokenBroker";
context.protocol = "TokenBroker";
context.source = "TokenBroker";
context.platform = this._platform;
context.capabilities = JSON.stringify({ "PrivatePropertyBag": 1 });
return context;
};
MSATokenProviderManager.prototype._onDone = function (result) {
var hr = null;
var hrInternal = null;
if (result == CloudExperienceHost.AppResult.fail) {
hr = "0x801901f4";
hrInternal = "0x80190005";
}
else {
hr = "0x8000ffff";
hrInternal = "0x80000008";
}
CloudExperienceHost.Telemetry.WebAppTelemetry.getInstance().logEvent("_onDone", JSON.stringify(result));
this._stopListeningForVerificationCode();
this._handleNavigationError(hr, hrInternal);
};
MSATokenProviderManager.prototype._onNavigationFailed = function (eventInfo) {
var hr = "0x80048842";
var hrInternal = "0x800713AB";
if (eventInfo) {
hrInternal = this._onTranslateWebErrorStatus(eventInfo.webErrorStatus);
CloudExperienceHost.Telemetry.WebAppTelemetry.getInstance().logEvent("_onNavigationFailed_WebError", JSON.stringify(eventInfo.webErrorStatus));
}
this._handleNavigationError(hr, hrInternal);
CloudExperienceHost.Telemetry.WebAppTelemetry.getInstance().logEvent("_onNavigationFailed", hrInternal);
};
MSATokenProviderManager.prototype._handleNavigationError = function (hr, hrInternal) {
var msaError = new CloudExperienceHost.MSAError();
msaError.hr = hr;
msaError.hrInternal = hrInternal;
msaError.msaUIHandler = this._msaUIHandler;
msaError.hasInternetAccess = CloudExperienceHost.Environment.hasInternetAccess();
if (hrInternal === "0x800704CF") {
msaError.hasInternetAccess = false;
}
this._appView.cleanView();
this._appView.showProgress().then(function () {
WinJS.UI.Pages.render("views/tokenManagerErrorHandler.html", this._appView.getView(), msaError).done(function () {
this._appView.showView();
}.bind(this));
}.bind(this));
};
MSATokenProviderManager.prototype._onTranslateWebErrorStatus = function (navigationError) {
var hrInternal = null;
switch (navigationError) {
case Windows.Web.WebErrorStatus.certificateCommonNameIsIncorrect:
case Windows.Web.WebErrorStatus.certificateExpired:
case Windows.Web.WebErrorStatus.certificateContainsErrors:
case Windows.Web.WebErrorStatus.certificateRevoked:
case Windows.Web.WebErrorStatus.certificateIsInvalid:
hrInternal = "0x80072F17";
break;
case Windows.Web.WebErrorStatus.serverUnreachable:
case Windows.Web.WebErrorStatus.timeout:
case Windows.Web.WebErrorStatus.cannotConnect:
case Windows.Web.WebErrorStatus.requestTimeout:
case Windows.Web.WebErrorStatus.badGateway:
case Windows.Web.WebErrorStatus.serviceUnavailable:
case Windows.Web.WebErrorStatus.gatewayTimeout:
hrInternal = "0x800704CF";
break;
case Windows.Web.WebErrorStatus.connectionAborted:
case Windows.Web.WebErrorStatus.connectionReset:
case Windows.Web.WebErrorStatus.disconnected:
case Windows.Web.WebErrorStatus.operationCanceled:
hrInternal = "0x800704D4";
break;
case Windows.Web.WebErrorStatus.httpToHttpsOnRedirection:
hrInternal = "0x80072f08";
break;
case Windows.Web.WebErrorStatus.httpsToHttpOnRedirection:
hrInternal = "0x80072f07";
break;
case Windows.Web.WebErrorStatus.hostNameNotResolved:
hrInternal = "0x800704D0";
break;
case Windows.Web.WebErrorStatus.unexpectedStatusCode:
case Windows.Web.WebErrorStatus.unexpectedRedirection:
case Windows.Web.WebErrorStatus.unexpectedClientError:
case Windows.Web.WebErrorStatus.unexpectedServerError:
hrInternal = "0x8007043B";
break;
default:
hrInternal = "0x80190001";
}
return hrInternal;
};
MSATokenProviderManager.prototype._getINavigable = function () {
return {
cxid: "TokenBroker",
url: "",
urlPathParam: "",
visibility: false,
successID: "",
failID: "",
cancelID: "",
backID: "",
offlineID: "",
abortID: "",
action1ID: "",
action2ID: "",
action3ID: "",
initialize: undefined,
queryStringBuilder: "",
httpMethod: "",
contentType: "",
encoding: "",
showAccountErrorPageOnFailure: false,
showErrorPageOnFailure: false,
timeout: 0,
ignoreResult: false
};
};
return MSATokenProviderManager;
})();
CloudExperienceHost.MSATokenProviderManager = MSATokenProviderManager;
})(CloudExperienceHost || (CloudExperienceHost = {}));