(target, urlOrChannel, options)
| 92 | |
| 93 | export default class RFB extends EventTargetMixin { |
| 94 | constructor(target, urlOrChannel, options) { |
| 95 | if (!target) { |
| 96 | throw new Error("Must specify target"); |
| 97 | } |
| 98 | if (!urlOrChannel) { |
| 99 | throw new Error("Must specify URL, WebSocket or RTCDataChannel"); |
| 100 | } |
| 101 | |
| 102 | // We rely on modern APIs which might not be available in an |
| 103 | // insecure context |
| 104 | if (!window.isSecureContext) { |
| 105 | Log.Error("noVNC requires a secure context (TLS). Expect crashes!"); |
| 106 | } |
| 107 | |
| 108 | super(); |
| 109 | |
| 110 | this._target = target; |
| 111 | |
| 112 | if (typeof urlOrChannel === "string") { |
| 113 | this._url = urlOrChannel; |
| 114 | } else { |
| 115 | this._url = null; |
| 116 | this._rawChannel = urlOrChannel; |
| 117 | } |
| 118 | |
| 119 | // Connection details |
| 120 | options = options || {}; |
| 121 | this._rfbCredentials = options.credentials || {}; |
| 122 | this._shared = 'shared' in options ? !!options.shared : true; |
| 123 | this._repeaterID = options.repeaterID || ''; |
| 124 | this._language = options.language || ''; |
| 125 | this._wsProtocols = ['binary']; |
| 126 | |
| 127 | // Keymaps |
| 128 | this._scancodes = {}; |
| 129 | if (this._language === "jp") { |
| 130 | this._scancodes = SCANCODES_JP; |
| 131 | } else if (this._language === "es-latam") { |
| 132 | this._scancodes = SCANCODES_ES_LATAM; |
| 133 | } |
| 134 | |
| 135 | // Internal state |
| 136 | this._rfbConnectionState = ''; |
| 137 | this._rfbInitState = ''; |
| 138 | this._rfbAuthScheme = -1; |
| 139 | this._rfbCleanDisconnect = true; |
| 140 | this._rfbRSAAESAuthenticationState = null; |
| 141 | |
| 142 | // Server capabilities |
| 143 | this._rfbVersion = 0; |
| 144 | this._rfbMaxVersion = 3.8; |
| 145 | this._rfbTightVNC = false; |
| 146 | this._rfbVeNCryptState = 0; |
| 147 | this._rfbXvpVer = 0; |
| 148 | |
| 149 | this._fbWidth = 0; |
| 150 | this._fbHeight = 0; |
| 151 |
no test coverage detected