/** * appstream_embed.js * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Provided as AWS Content and subject to the AWS Customer agreement and any other agreement with AWS governing your use of AWS services. */ !function e(t,n,r){function i(o,E){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!E&&a)return a(o,!0);if(s)return s(o,!0);var _=new Error("Cannot find module '"+o+"'");throw _.code="MODULE_NOT_FOUND",_}var u=n[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,n,r)}return n[o].exports}for(var s="function"==typeof require&&require,o=0;o0||window.navigator.userAgent.indexOf("Trident")>0||window.navigator.userAgent.indexOf("Edge")>0},this._bridgeReady=function(e){var t;n._eventEmitter.emit(r.Events.EVENT_API_BRIDGE,((t={})[r.Events.EVENT_PARAM_STATUS]="success",t))},this._bridgeError=function(e){n._waiting_for_new_ie_frame=!1;var t={errorCode:500,errorMessage:r.ErrorMessages.INTERNAL_SERVER_ERROR};n.reportError(t)},this.updateUserInterfaceState=function(e){n._userInterfaceState||(n._userInterfaceState=new i.EmbedUserInterfaceState),n._eventEmitter.emit(r.Events.EVENT_USER_INTERFACE_STATE_CHANGED,n._userInterfaceState.updateState(e))},this.updateSessionState=function(e){n._sessionState||(n._sessionState=new i.EmbedSessionState),n._eventEmitter.emit(r.Events.EVENT_SESSION_STATE_CHANGED,n._sessionState.updateState(e)),e.sessionStatus==r.SessionStatus.Disconnected&&n._disconnectingSession&&n.destroy()},this._options=this.sanitize(t),this._eventEmitter=new s.EventEmitter,this._options){this._onBridgeReady=this._getBridgeReady(e);var o=this._createSessionIframe(this._options);this._isIE_or_Edge()&&(o.style.display="none"),this._iframe=o,this._iframe.onload=function(){this._clientOrigin=this._urlOrigin(this._iframe.src)}.bind(this),e.appendChild(this._iframe),this._client=this._iframe.contentWindow,this._clientOrigin=this._urlOrigin(this._options.sessionURL),this._origin=document.location.origin}}return e.prototype.sanitize=function(e){var t;return e.sessionURL||(console.error("Expected AppStream streaming URL to embed."),t={errorCode:400,errorMessage:r.ErrorMessages.MISSING_PARAMETER},this.reportError(t)),e.userInterfaceConfig&&(e.userInterfaceConfig.hiddenElements&&(e.userInterfaceConfig.hiddenElements.length>r.MAX_HIDDEN_ELEMENTS_LENGTH&&(t={errorCode:400,errorMessage:r.ErrorMessages.VALIDATION_ERROR},console.error("Exceeded the number of hidden elements allowed : "+r.MAX_HIDDEN_ELEMENTS_LENGTH),this.reportError(t)),Array.isArray(e.userInterfaceConfig.hiddenElements)||(t={errorCode:400,errorMessage:r.ErrorMessages.VALIDATION_ERROR},console.error("Hidden elements must be of type Array"),this.reportError(t))),e.userInterfaceConfig.disabledInput&&(Array.isArray(e.userInterfaceConfig.disabledInput)||(t={errorCode:400,errorMessage:r.ErrorMessages.VALIDATION_ERROR},console.error("Disabled input must be of type Array"),this.reportError(t)))),e},e.prototype.serializeKeyboardEvent=function(e){return null!=e&&e instanceof KeyboardEvent?{type:e.type,eventInit:{key:e.key,location:e.location,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:e.code,repeat:e.repeat}}:null},e.prototype._getSessionState=function(){if(!this._sessionState)return null;var e={};return null!==this._sessionState.sessionStatus&&void 0!==this._sessionState.sessionStatus&&(e[i.EmbedSessionState.SESSION_STATUS_KEY]=this._sessionState.sessionStatus),null!==this._sessionState.sessionTerminationReason&&void 0!==this._sessionState.sessionTerminationReason&&(e[i.EmbedSessionState.SESSION_TERMINATION_REASON_KEY]=this._sessionState.sessionTerminationReason),null!==this._sessionState.sessionDisconnectionReason&&void 0!==this._sessionState.sessionDisconnectionReason&&(e[i.EmbedSessionState.SESSION_DISCONNECTION_REASON_KEY]=this._sessionState.sessionDisconnectionReason),e},e.prototype._getUserInterfaceState=function(){return this._userInterfaceState?{hidden:this._userInterfaceState.hidden,isFullscreen:this._userInterfaceState.isFullscreen,isSoftKeyboardVisible:this._userInterfaceState.isSoftKeyboardVisible}:null},e.prototype.callSessionMethod=function(e,t){this._sendMessage_v1(e,t)},e.prototype.disconnect=function(){var e=this;this._disconnectingSession=!0,this._sendMessage_v1(r.METHOD_DISCONNECT_SESSION),setTimeout((function(){return e.destroy()}),r.DISCONNECT_WAIT_TIMEOUT)},e.prototype.destroy=function(){this._iframe.parentNode.removeChild(this._iframe),this._waiting_for_new_ie_frame=!1,window.removeEventListener("message",this),delete this._iframe,delete this._client},e.prototype._createSessionIframe=function(e){var t=document.createElement("iframe");return t.setAttribute("frameBorder","0"),void 0!==e.iframeConfig&&null!==e.iframeConfig&&this.setElementAttributes(t,e.iframeConfig),t.setAttribute("src",e.sessionURL),t.setAttribute("id","appstream-streaming-session"),t.setAttribute("allow","fullscreen *; microphone *;"),t.setAttribute("allowfullscreen",""),t.setAttribute("scrolling","no"),t.style.height="1px",t.style.width="1px",t.style.minHeight="100%",t.style.minWidth="100%",t},e.prototype.setElementAttributes=function(e,t){if(null!=e&&e instanceof HTMLElement)for(var n in t)n.length>0&&null!==t[n]&&void 0!==t[n]&&e.setAttribute(n,t[n])},e.prototype._getBridgeReady=function(e){var t=this;return new Promise((function(n,i){var s;s=t._isIE_or_Edge()?function(n){if(t._isClientMessage(n)&&n.data.method===r.METHOD_EMBED_CLIENT_INTERFACE_READY)try{var i=t._clientOrigin.split("https://")[1].split(":")[0],s=n.data.args[0];if(!t._waiting_for_new_ie_frame&&s.embedOrigin.indexOf(i)>-1){t._clientOrigin=s.embedOrigin;var E=t._options.sessionURL.split("/authenticate?")[1],a=t._clientOrigin+"/authenticate?"+E;t._options.sessionURL=a,1==s.recreateIFrame&&(t.destroy(),t._iframe=t._createSessionIframe(t._options),t._iframe.onload=function(){t._clientOrigin=t._urlOrigin(a)}.bind(t),e.appendChild(t._iframe),t._client=t._iframe.contentWindow,t._clientOrigin=t._urlOrigin(t._options.sessionURL),t._origin=document.location.origin,t._waiting_for_new_ie_frame=!0)}else window.addEventListener("message",o),t._sendEmbedOptions(),t._waiting_for_new_ie_frame=!1}catch(e){var _={errorCode:500,errorMessage:r.ErrorMessages.INTERNAL_SERVER_ERROR};console.error("Error during the IE/Edge Specific multi session flow"),console.error(e),t.reportError(_)}}.bind(t):function(e){if(t._isClientMessage(e)&&e.data.method===r.METHOD_EMBED_CLIENT_INTERFACE_READY){var n=e.data.args[0].embedOrigin;null!=n&&(t._clientOrigin=n,t._iframe.setAttribute("allow","fullscreen "+t._clientOrigin+"; microphone "+t._clientOrigin)),window.addEventListener("message",o),t._sendEmbedOptions()}}.bind(t);var o=function(e){if(t._isClientMessage(e)&&e.data.method===r.METHOD_SEND_INITIAL_STATE){window.removeEventListener("message",o),window.addEventListener("message",t);var i=e.data.args[0];t.updateUserInterfaceState(i.userInterfaceState),t.updateSessionState(i.sessionState),n()}}.bind(t);window.addEventListener("message",s),setTimeout(i,r.HOST_WAIT_TIMEOUT)})).then(t._bridgeReady,t._bridgeError)},e.prototype._sendEmbedOptions=function(){var e={embedOptions:{origin:this._origin,sessionURL:this._options.sessionURL,clientVersion:r.ClientVersions.V1,userInterfaceConfig:this._options.userInterfaceConfig}};this._sendMessage_v1(r.METHOD_EMBED_OPTIONS,e)},e.prototype._sendMessage_v1=function(e,t){var n={namespace:r.BRIDGE_HOST_NAMESPACE,messageVersion:r.MessageVersions.V1,method:e,args:[t]};this._client.postMessage(n,this._clientOrigin)},e.prototype._isClientMessage=function(e){return!!this._iframe&&(this._isIE_or_Edge()?Boolean(e.data)&&e.data.namespace===r.BRIDGE_CLIENT_NAMESPACE:Boolean(e.data)&&e.data.namespace===r.BRIDGE_CLIENT_NAMESPACE&&e.source===this._client)},e.prototype.addEventListener=function(e,t){Object.values=Object.values||function(e){return Object.keys(e).map((function(t){return e[t]}))},Array.prototype.includes?Object.values(r.Events).includes(e)&&this._eventEmitter.on(e,t):Object.values(r.Events).indexOf(e)>=0&&this._eventEmitter.on(e,t)},e.prototype.removeEventListener=function(e,t){this._eventEmitter.removeListener(e,t)},e.prototype.handleEvent=function(e){if(e.data.version)switch(e.data.version){case r.MessageVersions.V1:this._handleEventV1(e)}},e.prototype._handleEventV1=function(e){if(this._isClientMessage(e)){var t=e.data.args[0];switch(e.data.method){case r.METHOD_UPDATE_USER_INTERFACE_STATE:this.updateUserInterfaceState(t.userInterfaceState);break;case r.METHOD_UPDATE_SESSION_STATE:this.updateSessionState(t.sessionState);break;case r.METHOD_REPORT_ERROR:this.reportError(t.error)}}},e.prototype._urlOrigin=function(e){var t=document.createElement("a");return t.href=e,void 0!==t.origin&&null!==t.origin&&t.origin.length>0?t.origin:void 0!==t.host&&null!==t.host&&t.host.length>0?"https://"+t.host:void 0!==t.hostname&&null!==t.hostname&&t.hostname.length>0?"https://"+t.hostname:"*"},e}();t.exports={};var E,a=Object.freeze({STREAMING_URL:r.OPTION_STREAMING_URL,HIDDEN_ELEMENTS:r.OPTION_HIDDEN_ELEMENTS,DISABLED_INPUT:r.OPTION_DISABLED_INPUT}),_=Object.freeze({TOOLBAR:r.ELEMENT_TOOLBAR,CATALOG_BUTTON:r.ELEMENT_TOOLBAR_CATALOG,WINDOW_SWITCHER_BUTTON:r.ELEMENT_TOOLBAR__WINDOW_SWITCHER,FILES_BUTTON:r.ELEMENT_TOOLBAR_FILES,CLIPBOARD_BUTTON:r.ELEMENT_TOOLBAR_CLIPBOARD,COPY_LOCAL_BUTTON:r.ELEMENT_TOOLBAR_COPY_LOCAL,PASTE_REMOTE_BUTTON:r.ELEMENT_TOOLBAR_PASTE_REMOTE,SETTINGS_BUTTON:r.ELEMENT_TOOLBAR_SETTINGS,ENABLE_MICROPHONE_BUTTON:r.ELEMENT_TOOLBAR_MICROPHONE,STREAMING_MODE_BUTTON:r.ELEMENT_TOOLBAR_STREAMING_MODE,SCREEN_RESOLUTION_BUTTON:r.ELEMENT_TOOLBAR_SCREEN_RESOLUTION,REGIONAL_SETTINGS_BUTTON:r.ELEMENT_TOOLBAR_REGIONAL_SETTINGS,FULLSCREEN_BUTTON:r.ELEMENT_TOOLBAR_FULLSCREEN,END_SESSION_BUTTON:r.ELEMENT_TOOLBAR_END_SESSION}),u=Object.freeze({KEY_DOWN:r.InputListeners.KEY_DOWN,KEY_UP:r.InputListeners.KEY_UP,KEY_PRESS:r.InputListeners.KEY_PRESS,MOUSE_MOVE:r.InputListeners.MOUSE_MOVE,MOUSE_DOWN:r.InputListeners.MOUSE_DOWN,MOUSE_UP:r.InputListeners.MOUSE_UP,MOUSE_LEAVE:r.InputListeners.MOUSE_LEAVE,WHEEL:r.InputListeners.WHEEL,TOUCH_START:r.InputListeners.TOUCH_START,TOUCH_MOVE:r.InputListeners.TOUCH_MOVE,TOUCH_END:r.InputListeners.TOUCH_END,TOUCH_CANCEL:r.InputListeners.TOUCH_CANCEL}),c=Object.freeze({SESSION_STATE_CHANGE:r.Events.EVENT_SESSION_STATE_CHANGED,SESSION_INTERFACE_STATE_CHANGE:r.Events.EVENT_USER_INTERFACE_STATE_CHANGED,SESSION_RESIZE:r.Events.EVENT_SESSION_RESIZE,SESSION_ERROR:r.Events.EVENT_SESSION_ERROR}),f=Object.freeze({STATUS:r.Events.EVENT_PARAM_SESSION_STATUS,ERROR:r.Events.EVENT_PARAM_ERROR}),l=Object.freeze(r.SessionStatus),S=Object.freeze(r.EmbedKeyboardLocation),d=Object.freeze({END_SESSION:r.METHOD_END_SESSION,SEND_KEYS:r.METHOD_SEND_KEYS,SEND_KEYBOARD_EVENT:r.METHOD_SEND_KEYBOARD_EVENT,ENTER_FULLSCREEN:r.METHOD_ENTER_FULLSCREEN,EXIT_FULLSCREEN:r.METHOD_EXIT_FULLSCREEN,SHOW_SOFTKEYBOARD:r.METHOD_SHOW_SOFTKEYBOARD,HIDE_SOFTKEYBOARD:r.METHOD_HIDE_SOFTKEYBOARD,LAUNCH_APP:r.METHOD_LAUNCH_APP,LAUNCH_APP_SWITCHER:r.METHOD_LAUNCH_APP_SWITCHER}),h=function(){function e(e,t){this._bridge=new o(function(e){if(T(e))return document.getElementById(e);return e}(e),t)}return e.prototype.endSession=function(){this._bridge.callSessionMethod(d.END_SESSION)},e.prototype.enterFullscreen=function(){this._bridge.callSessionMethod(d.ENTER_FULLSCREEN)},e.prototype.exitFullscreen=function(){this._bridge.callSessionMethod(d.EXIT_FULLSCREEN)},e.prototype.launchAppSwitcher=function(){this._bridge.callSessionMethod(d.LAUNCH_APP_SWITCHER)},e.prototype.launchApp=function(e){T(e)&&this._bridge.callSessionMethod(d.LAUNCH_APP,{appId:e})},e.prototype.sendKeys=function(e){e.length>0&&this._bridge.callSessionMethod(d.SEND_KEYS,{keys:e})},e.prototype.sendKeyboardEvent=function(e){var t=this._bridge.serializeKeyboardEvent(e);t&&this._bridge.callSessionMethod(d.SEND_KEYBOARD_EVENT,{keyboardEvent:t})},e.prototype.getSessionState=function(){return this._bridge._getSessionState()},e.prototype.getUserInterfaceState=function(){return this._bridge._getUserInterfaceState()},e.prototype.addEventListener=function(e,t){this._bridge.addEventListener(e,t)},e.prototype.removeEventListener=function(e,t){this._bridge.removeEventListener(e,t)},e.prototype.destroy=function(){this._bridge&&this._bridge.disconnect()},e}();function T(e){return"string"==typeof e}t.exports={AppStreamEmbed:h,EMBED_OPTIONS:a,EMBED_ELEMENTS:_,EMBED_EVENTS:c,EMBED_INPUT_LISTENERS:u,EMBED_EVENT_PARAMS:f,EMBED_SESSION_STATUS:l,EMBED_METHODS:d,EMBED_KEYBOARD_LOCATION:S},function(e){var t=function(){};e.EmbedError=t}(E||(E={}))},{"es6-promise/auto":3,events:5}],3:[function(e,t,n){"use strict";t.exports=e("./").polyfill()},{"./":4}],4:[function(e,t,n){(function(r,i){ /*! * @overview es6-promise - a tiny implementation of Promises/A+. * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) * @license Licensed under MIT license * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE * @version v4.2.8+1e68dce6 */ !function(e,r){"object"==typeof n&&void 0!==t?t.exports=r():"function"==typeof define&&define.amd?define(r):e.ES6Promise=r()}(this,(function(){"use strict";function t(e){return"function"==typeof e}var n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},s=0,o=void 0,E=void 0,a=function(e,t){d[s]=e,d[s+1]=t,2===(s+=2)&&(E?E(h):A())};var _="undefined"!=typeof window?window:void 0,u=_||{},c=u.MutationObserver||u.WebKitMutationObserver,f="undefined"==typeof self&&void 0!==r&&"[object process]"==={}.toString.call(r),l="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function S(){var e=setTimeout;return function(){return e(h,1)}}var d=new Array(1e3);function h(){for(var e=0;e0&&E.length>s){E.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+E.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=E.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",a.name,a.message)}}else E=o[t]=n,++e._eventsCount;return e}function T(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t1&&(t=arguments[1]),t instanceof Error)throw t;var a=new Error('Unhandled "error" event. ('+t+")");throw a.context=t,a}if(!(n=o[e]))return!1;var _="function"==typeof n;switch(r=arguments.length){case 1:c(n,_,this);break;case 2:f(n,_,this,arguments[1]);break;case 3:l(n,_,this,arguments[1],arguments[2]);break;case 4:S(n,_,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),s=1;s=0;o--)if(n[o]===t||n[o].listener===t){E=n[o].listener,s=o;break}if(s<0)return this;0===s?n.shift():function(e,t){for(var n=t,r=n+1,i=e.length;r=0;s--)this.removeListener(e,t[s]);return this},o.prototype.listeners=function(e){return p(this,e,!0)},o.prototype.rawListeners=function(e){return p(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):N.call(e,t)},o.prototype.listenerCount=N,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],6:[function(e,t,n){var r,i,s=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{i="function"==typeof clearTimeout?clearTimeout:E}catch(e){i=E}}();var _,u=[],c=!1,f=-1;function l(){c&&_&&(c=!1,_.length?u=_.concat(u):f=-1,u.length&&S())}function S(){if(!c){var e=a(l);c=!0;for(var t=u.length;t;){for(_=u,u=[];++f1)for(var n=1;n