@novnc/novnc 1.2.0-test → 1.3.0-g1075cd8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +0 -6
- package/README.md +16 -6
- package/core/decoders/copyrect.js +5 -0
- package/core/decoders/hextile.js +57 -3
- package/core/decoders/jpeg.js +141 -0
- package/core/decoders/raw.js +12 -2
- package/core/decoders/tight.js +24 -8
- package/core/decoders/zrle.js +185 -0
- package/core/display.js +9 -151
- package/core/encodings.js +4 -0
- package/core/input/domkeytable.js +25 -21
- package/core/input/keyboard.js +12 -127
- package/core/input/util.js +18 -35
- package/core/input/vkeys.js +0 -1
- package/core/input/xtscancodes.js +5 -3
- package/core/ra2.js +567 -0
- package/core/rfb.js +332 -114
- package/core/util/browser.js +0 -17
- package/core/util/cursor.js +1 -11
- package/core/util/events.js +0 -4
- package/core/util/md5.js +79 -0
- package/core/websock.js +76 -17
- package/docs/API.md +46 -6
- package/docs/LIBRARY.md +3 -7
- package/lib/base64.js +5 -5
- package/lib/decoders/copyrect.js +8 -3
- package/lib/decoders/hextile.js +65 -9
- package/lib/decoders/jpeg.js +188 -0
- package/lib/decoders/raw.js +14 -5
- package/lib/decoders/rre.js +3 -3
- package/lib/decoders/tight.js +40 -22
- package/lib/decoders/tightpng.js +10 -10
- package/lib/decoders/zrle.js +234 -0
- package/lib/deflator.js +5 -5
- package/lib/des.js +3 -3
- package/lib/display.js +47 -214
- package/lib/encodings.js +8 -0
- package/lib/inflator.js +5 -5
- package/lib/input/domkeytable.js +197 -194
- package/lib/input/fixedkeys.js +2 -2
- package/lib/input/gesturehandler.js +3 -3
- package/lib/input/keyboard.js +40 -160
- package/lib/input/keysym.js +2 -2
- package/lib/input/keysymdef.js +2 -2
- package/lib/input/util.js +35 -80
- package/lib/input/vkeys.js +2 -4
- package/lib/input/xtscancodes.js +11 -5
- package/lib/ra2.js +1257 -0
- package/lib/rfb.js +656 -306
- package/lib/util/browser.js +9 -27
- package/lib/util/cursor.js +5 -17
- package/lib/util/events.js +3 -5
- package/lib/util/eventtarget.js +4 -4
- package/lib/util/int.js +1 -1
- package/lib/util/logging.js +2 -2
- package/lib/util/md5.js +103 -0
- package/lib/vendor/pako/lib/utils/common.js +2 -2
- package/lib/vendor/pako/lib/zlib/adler32.js +1 -1
- package/lib/vendor/pako/lib/zlib/constants.js +2 -2
- package/lib/vendor/pako/lib/zlib/crc32.js +1 -1
- package/lib/vendor/pako/lib/zlib/deflate.js +114 -113
- package/lib/vendor/pako/lib/zlib/gzheader.js +1 -1
- package/lib/vendor/pako/lib/zlib/inffast.js +5 -5
- package/lib/vendor/pako/lib/zlib/inflate.js +51 -49
- package/lib/vendor/pako/lib/zlib/inftrees.js +4 -4
- package/lib/vendor/pako/lib/zlib/messages.js +2 -2
- package/lib/vendor/pako/lib/zlib/trees.js +5 -5
- package/lib/vendor/pako/lib/zlib/zstream.js +1 -1
- package/lib/websock.js +107 -46
- package/package.json +2 -10
- package/core/util/polyfill.js +0 -61
- package/lib/util/polyfill.js +0 -72
- package/lib/vendor/promise.js +0 -255
package/lib/rfb.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports
|
|
8
|
+
exports["default"] = void 0;
|
|
7
9
|
|
|
8
10
|
var _int = require("./util/int.js");
|
|
9
11
|
|
|
@@ -41,7 +43,9 @@ var _xtscancodes = _interopRequireDefault(require("./input/xtscancodes.js"));
|
|
|
41
43
|
|
|
42
44
|
var _encodings = require("./encodings.js");
|
|
43
45
|
|
|
44
|
-
require("./
|
|
46
|
+
var _ra = _interopRequireDefault(require("./ra2.js"));
|
|
47
|
+
|
|
48
|
+
var _md = require("./util/md5.js");
|
|
45
49
|
|
|
46
50
|
var _raw = _interopRequireDefault(require("./decoders/raw.js"));
|
|
47
51
|
|
|
@@ -55,31 +59,49 @@ var _tight = _interopRequireDefault(require("./decoders/tight.js"));
|
|
|
55
59
|
|
|
56
60
|
var _tightpng = _interopRequireDefault(require("./decoders/tightpng.js"));
|
|
57
61
|
|
|
58
|
-
|
|
62
|
+
var _zrle = _interopRequireDefault(require("./decoders/zrle.js"));
|
|
63
|
+
|
|
64
|
+
var _jpeg = _interopRequireDefault(require("./decoders/jpeg.js"));
|
|
65
|
+
|
|
66
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
67
|
+
|
|
68
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
69
|
+
|
|
70
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
71
|
+
|
|
72
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
73
|
+
|
|
74
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
59
75
|
|
|
60
|
-
function
|
|
76
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
61
77
|
|
|
62
|
-
function
|
|
78
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
63
79
|
|
|
64
|
-
function
|
|
80
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
81
|
+
|
|
82
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
83
|
+
|
|
84
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
85
|
+
|
|
86
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
65
87
|
|
|
66
88
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
67
89
|
|
|
68
90
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
69
91
|
|
|
70
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
92
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
71
93
|
|
|
72
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
94
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
73
95
|
|
|
74
96
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
75
97
|
|
|
76
98
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
77
99
|
|
|
78
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
100
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
79
101
|
|
|
80
102
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
81
103
|
|
|
82
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
104
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
83
105
|
|
|
84
106
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
85
107
|
|
|
@@ -120,7 +142,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
120
142
|
|
|
121
143
|
var _super = _createSuper(RFB);
|
|
122
144
|
|
|
123
|
-
function RFB(target,
|
|
145
|
+
function RFB(target, urlOrChannel, options) {
|
|
124
146
|
var _this;
|
|
125
147
|
|
|
126
148
|
_classCallCheck(this, RFB);
|
|
@@ -129,13 +151,20 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
129
151
|
throw new Error("Must specify target");
|
|
130
152
|
}
|
|
131
153
|
|
|
132
|
-
if (!
|
|
133
|
-
throw new Error("Must specify URL");
|
|
154
|
+
if (!urlOrChannel) {
|
|
155
|
+
throw new Error("Must specify URL, WebSocket or RTCDataChannel");
|
|
134
156
|
}
|
|
135
157
|
|
|
136
158
|
_this = _super.call(this);
|
|
137
159
|
_this._target = target;
|
|
138
|
-
|
|
160
|
+
|
|
161
|
+
if (typeof urlOrChannel === "string") {
|
|
162
|
+
_this._url = urlOrChannel;
|
|
163
|
+
} else {
|
|
164
|
+
_this._url = null;
|
|
165
|
+
_this._rawChannel = urlOrChannel;
|
|
166
|
+
} // Connection details
|
|
167
|
+
|
|
139
168
|
|
|
140
169
|
options = options || {};
|
|
141
170
|
_this._rfbCredentials = options.credentials || {};
|
|
@@ -146,7 +175,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
146
175
|
_this._rfbConnectionState = '';
|
|
147
176
|
_this._rfbInitState = '';
|
|
148
177
|
_this._rfbAuthScheme = -1;
|
|
149
|
-
_this._rfbCleanDisconnect = true;
|
|
178
|
+
_this._rfbCleanDisconnect = true;
|
|
179
|
+
_this._rfbRSAAESAuthenticationState = null; // Server capabilities
|
|
150
180
|
|
|
151
181
|
_this._rfbVersion = 0;
|
|
152
182
|
_this._rfbMaxVersion = 3.8;
|
|
@@ -179,6 +209,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
179
209
|
_this._keyboard = null; // Keyboard input handler object
|
|
180
210
|
|
|
181
211
|
_this._gestures = null; // Gesture input handler object
|
|
212
|
+
|
|
213
|
+
_this._resizeObserver = null; // Resize observer object
|
|
182
214
|
// Timers
|
|
183
215
|
|
|
184
216
|
_this._disconnTimer = null; // disconnection timer
|
|
@@ -213,10 +245,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
213
245
|
|
|
214
246
|
_this._eventHandlers = {
|
|
215
247
|
focusCanvas: _this._focusCanvas.bind(_assertThisInitialized(_this)),
|
|
216
|
-
|
|
248
|
+
handleResize: _this._handleResize.bind(_assertThisInitialized(_this)),
|
|
217
249
|
handleMouse: _this._handleMouse.bind(_assertThisInitialized(_this)),
|
|
218
250
|
handleWheel: _this._handleWheel.bind(_assertThisInitialized(_this)),
|
|
219
|
-
handleGesture: _this._handleGesture.bind(_assertThisInitialized(_this))
|
|
251
|
+
handleGesture: _this._handleGesture.bind(_assertThisInitialized(_this)),
|
|
252
|
+
handleRSAAESCredentialsRequired: _this._handleRSAAESCredentialsRequired.bind(_assertThisInitialized(_this)),
|
|
253
|
+
handleRSAAESServerVerification: _this._handleRSAAESServerVerification.bind(_assertThisInitialized(_this))
|
|
220
254
|
}; // main setup
|
|
221
255
|
|
|
222
256
|
Log.Debug(">> RFB.constructor"); // Create DOM elements
|
|
@@ -230,9 +264,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
230
264
|
_this._canvas = document.createElement('canvas');
|
|
231
265
|
_this._canvas.style.margin = 'auto'; // Some browsers add an outline on focus
|
|
232
266
|
|
|
233
|
-
_this._canvas.style.outline = 'none';
|
|
234
|
-
|
|
235
|
-
_this._canvas.style.flexShrink = '0';
|
|
267
|
+
_this._canvas.style.outline = 'none';
|
|
236
268
|
_this._canvas.width = 0;
|
|
237
269
|
_this._canvas.height = 0;
|
|
238
270
|
_this._canvas.tabIndex = -1;
|
|
@@ -240,7 +272,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
240
272
|
_this._screen.appendChild(_this._canvas); // Cursor
|
|
241
273
|
|
|
242
274
|
|
|
243
|
-
_this._cursor = new _cursor
|
|
275
|
+
_this._cursor = new _cursor["default"](); // XXX: TightVNC 2.8.11 sends no cursor at all until Windows changes
|
|
244
276
|
// it. Result: no cursor at all until a window border or an edit field
|
|
245
277
|
// is hit blindly. But there are also VNC servers that draw the cursor
|
|
246
278
|
// in the framebuffer and don't send the empty local cursor. There is
|
|
@@ -252,95 +284,43 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
252
284
|
|
|
253
285
|
_this._cursorImage = RFB.cursors.none; // populate decoder array with objects
|
|
254
286
|
|
|
255
|
-
_this._decoders[_encodings.encodings.encodingRaw] = new _raw
|
|
256
|
-
_this._decoders[_encodings.encodings.encodingCopyRect] = new _copyrect
|
|
257
|
-
_this._decoders[_encodings.encodings.encodingRRE] = new _rre
|
|
258
|
-
_this._decoders[_encodings.encodings.encodingHextile] = new _hextile
|
|
259
|
-
_this._decoders[_encodings.encodings.encodingTight] = new _tight
|
|
260
|
-
_this._decoders[_encodings.encodings.encodingTightPNG] = new _tightpng
|
|
287
|
+
_this._decoders[_encodings.encodings.encodingRaw] = new _raw["default"]();
|
|
288
|
+
_this._decoders[_encodings.encodings.encodingCopyRect] = new _copyrect["default"]();
|
|
289
|
+
_this._decoders[_encodings.encodings.encodingRRE] = new _rre["default"]();
|
|
290
|
+
_this._decoders[_encodings.encodings.encodingHextile] = new _hextile["default"]();
|
|
291
|
+
_this._decoders[_encodings.encodings.encodingTight] = new _tight["default"]();
|
|
292
|
+
_this._decoders[_encodings.encodings.encodingTightPNG] = new _tightpng["default"]();
|
|
293
|
+
_this._decoders[_encodings.encodings.encodingZRLE] = new _zrle["default"]();
|
|
294
|
+
_this._decoders[_encodings.encodings.encodingJPEG] = new _jpeg["default"](); // NB: nothing that needs explicit teardown should be done
|
|
261
295
|
// before this point, since this can throw an exception
|
|
262
296
|
|
|
263
297
|
try {
|
|
264
|
-
_this._display = new _display
|
|
298
|
+
_this._display = new _display["default"](_this._canvas);
|
|
265
299
|
} catch (exc) {
|
|
266
300
|
Log.Error("Display exception: " + exc);
|
|
267
301
|
throw exc;
|
|
268
302
|
}
|
|
269
303
|
|
|
270
304
|
_this._display.onflush = _this._onFlush.bind(_assertThisInitialized(_this));
|
|
271
|
-
_this._keyboard = new _keyboard
|
|
305
|
+
_this._keyboard = new _keyboard["default"](_this._canvas);
|
|
272
306
|
_this._keyboard.onkeyevent = _this._handleKeyEvent.bind(_assertThisInitialized(_this));
|
|
273
|
-
_this._gestures = new _gesturehandler
|
|
274
|
-
_this._sock = new _websock
|
|
307
|
+
_this._gestures = new _gesturehandler["default"]();
|
|
308
|
+
_this._sock = new _websock["default"]();
|
|
275
309
|
|
|
276
|
-
_this._sock.on('
|
|
277
|
-
_this._handleMessage();
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
_this._sock.on('open', function () {
|
|
281
|
-
if (_this._rfbConnectionState === 'connecting' && _this._rfbInitState === '') {
|
|
282
|
-
_this._rfbInitState = 'ProtocolVersion';
|
|
283
|
-
Log.Debug("Starting VNC handshake");
|
|
284
|
-
} else {
|
|
285
|
-
_this._fail("Unexpected server connection while " + _this._rfbConnectionState);
|
|
286
|
-
}
|
|
287
|
-
});
|
|
310
|
+
_this._sock.on('open', _this._socketOpen.bind(_assertThisInitialized(_this)));
|
|
288
311
|
|
|
289
|
-
_this._sock.on('close',
|
|
290
|
-
Log.Debug("WebSocket on-close event");
|
|
291
|
-
var msg = "";
|
|
312
|
+
_this._sock.on('close', _this._socketClose.bind(_assertThisInitialized(_this)));
|
|
292
313
|
|
|
293
|
-
|
|
294
|
-
msg = "(code: " + e.code;
|
|
314
|
+
_this._sock.on('message', _this._handleMessage.bind(_assertThisInitialized(_this)));
|
|
295
315
|
|
|
296
|
-
|
|
297
|
-
msg += ", reason: " + e.reason;
|
|
298
|
-
}
|
|
316
|
+
_this._sock.on('error', _this._socketError.bind(_assertThisInitialized(_this)));
|
|
299
317
|
|
|
300
|
-
|
|
301
|
-
|
|
318
|
+
_this._expectedClientWidth = null;
|
|
319
|
+
_this._expectedClientHeight = null;
|
|
320
|
+
_this._resizeObserver = new ResizeObserver(_this._eventHandlers.handleResize); // All prepared, kick off the connection
|
|
302
321
|
|
|
303
|
-
|
|
304
|
-
case 'connecting':
|
|
305
|
-
_this._fail("Connection closed " + msg);
|
|
322
|
+
_this._updateConnectionState('connecting');
|
|
306
323
|
|
|
307
|
-
break;
|
|
308
|
-
|
|
309
|
-
case 'connected':
|
|
310
|
-
// Handle disconnects that were initiated server-side
|
|
311
|
-
_this._updateConnectionState('disconnecting');
|
|
312
|
-
|
|
313
|
-
_this._updateConnectionState('disconnected');
|
|
314
|
-
|
|
315
|
-
break;
|
|
316
|
-
|
|
317
|
-
case 'disconnecting':
|
|
318
|
-
// Normal disconnection path
|
|
319
|
-
_this._updateConnectionState('disconnected');
|
|
320
|
-
|
|
321
|
-
break;
|
|
322
|
-
|
|
323
|
-
case 'disconnected':
|
|
324
|
-
_this._fail("Unexpected server disconnect " + "when already disconnected " + msg);
|
|
325
|
-
|
|
326
|
-
break;
|
|
327
|
-
|
|
328
|
-
default:
|
|
329
|
-
_this._fail("Unexpected server disconnect before connecting " + msg);
|
|
330
|
-
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
_this._sock.off('close');
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
_this._sock.on('error', function (e) {
|
|
338
|
-
return Log.Warn("WebSocket on-error event");
|
|
339
|
-
}); // Slight delay of the actual connection so that the caller has
|
|
340
|
-
// time to set up callbacks
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
setTimeout(_this._updateConnectionState.bind(_assertThisInitialized(_this), 'connecting'));
|
|
344
324
|
Log.Debug("<< RFB.constructor"); // ===== PROPERTIES =====
|
|
345
325
|
|
|
346
326
|
_this.dragViewport = false;
|
|
@@ -363,8 +343,138 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
363
343
|
|
|
364
344
|
|
|
365
345
|
_createClass(RFB, [{
|
|
346
|
+
key: "viewOnly",
|
|
347
|
+
get: function get() {
|
|
348
|
+
return this._viewOnly;
|
|
349
|
+
},
|
|
350
|
+
set: function set(viewOnly) {
|
|
351
|
+
this._viewOnly = viewOnly;
|
|
352
|
+
|
|
353
|
+
if (this._rfbConnectionState === "connecting" || this._rfbConnectionState === "connected") {
|
|
354
|
+
if (viewOnly) {
|
|
355
|
+
this._keyboard.ungrab();
|
|
356
|
+
} else {
|
|
357
|
+
this._keyboard.grab();
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}, {
|
|
362
|
+
key: "capabilities",
|
|
363
|
+
get: function get() {
|
|
364
|
+
return this._capabilities;
|
|
365
|
+
}
|
|
366
|
+
}, {
|
|
367
|
+
key: "touchButton",
|
|
368
|
+
get: function get() {
|
|
369
|
+
return 0;
|
|
370
|
+
},
|
|
371
|
+
set: function set(button) {
|
|
372
|
+
Log.Warn("Using old API!");
|
|
373
|
+
}
|
|
374
|
+
}, {
|
|
375
|
+
key: "clipViewport",
|
|
376
|
+
get: function get() {
|
|
377
|
+
return this._clipViewport;
|
|
378
|
+
},
|
|
379
|
+
set: function set(viewport) {
|
|
380
|
+
this._clipViewport = viewport;
|
|
381
|
+
|
|
382
|
+
this._updateClip();
|
|
383
|
+
}
|
|
384
|
+
}, {
|
|
385
|
+
key: "scaleViewport",
|
|
386
|
+
get: function get() {
|
|
387
|
+
return this._scaleViewport;
|
|
388
|
+
},
|
|
389
|
+
set: function set(scale) {
|
|
390
|
+
this._scaleViewport = scale; // Scaling trumps clipping, so we may need to adjust
|
|
391
|
+
// clipping when enabling or disabling scaling
|
|
392
|
+
|
|
393
|
+
if (scale && this._clipViewport) {
|
|
394
|
+
this._updateClip();
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
this._updateScale();
|
|
398
|
+
|
|
399
|
+
if (!scale && this._clipViewport) {
|
|
400
|
+
this._updateClip();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}, {
|
|
404
|
+
key: "resizeSession",
|
|
405
|
+
get: function get() {
|
|
406
|
+
return this._resizeSession;
|
|
407
|
+
},
|
|
408
|
+
set: function set(resize) {
|
|
409
|
+
this._resizeSession = resize;
|
|
410
|
+
|
|
411
|
+
if (resize) {
|
|
412
|
+
this._requestRemoteResize();
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}, {
|
|
416
|
+
key: "showDotCursor",
|
|
417
|
+
get: function get() {
|
|
418
|
+
return this._showDotCursor;
|
|
419
|
+
},
|
|
420
|
+
set: function set(show) {
|
|
421
|
+
this._showDotCursor = show;
|
|
422
|
+
|
|
423
|
+
this._refreshCursor();
|
|
424
|
+
}
|
|
425
|
+
}, {
|
|
426
|
+
key: "background",
|
|
427
|
+
get: function get() {
|
|
428
|
+
return this._screen.style.background;
|
|
429
|
+
},
|
|
430
|
+
set: function set(cssValue) {
|
|
431
|
+
this._screen.style.background = cssValue;
|
|
432
|
+
}
|
|
433
|
+
}, {
|
|
434
|
+
key: "qualityLevel",
|
|
435
|
+
get: function get() {
|
|
436
|
+
return this._qualityLevel;
|
|
437
|
+
},
|
|
438
|
+
set: function set(qualityLevel) {
|
|
439
|
+
if (!Number.isInteger(qualityLevel) || qualityLevel < 0 || qualityLevel > 9) {
|
|
440
|
+
Log.Error("qualityLevel must be an integer between 0 and 9");
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
if (this._qualityLevel === qualityLevel) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
this._qualityLevel = qualityLevel;
|
|
449
|
+
|
|
450
|
+
if (this._rfbConnectionState === 'connected') {
|
|
451
|
+
this._sendEncodings();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}, {
|
|
455
|
+
key: "compressionLevel",
|
|
456
|
+
get: function get() {
|
|
457
|
+
return this._compressionLevel;
|
|
458
|
+
},
|
|
459
|
+
set: function set(compressionLevel) {
|
|
460
|
+
if (!Number.isInteger(compressionLevel) || compressionLevel < 0 || compressionLevel > 9) {
|
|
461
|
+
Log.Error("compressionLevel must be an integer between 0 and 9");
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if (this._compressionLevel === compressionLevel) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
this._compressionLevel = compressionLevel;
|
|
470
|
+
|
|
471
|
+
if (this._rfbConnectionState === 'connected') {
|
|
472
|
+
this._sendEncodings();
|
|
473
|
+
}
|
|
474
|
+
} // ===== PUBLIC METHODS =====
|
|
475
|
+
|
|
476
|
+
}, {
|
|
366
477
|
key: "disconnect",
|
|
367
|
-
// ===== PUBLIC METHODS =====
|
|
368
478
|
value: function disconnect() {
|
|
369
479
|
this._updateConnectionState('disconnecting');
|
|
370
480
|
|
|
@@ -373,6 +483,17 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
373
483
|
this._sock.off('message');
|
|
374
484
|
|
|
375
485
|
this._sock.off('open');
|
|
486
|
+
|
|
487
|
+
if (this._rfbRSAAESAuthenticationState !== null) {
|
|
488
|
+
this._rfbRSAAESAuthenticationState.disconnect();
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}, {
|
|
492
|
+
key: "approveServer",
|
|
493
|
+
value: function approveServer() {
|
|
494
|
+
if (this._rfbRSAAESAuthenticationState !== null) {
|
|
495
|
+
this._rfbRSAAESAuthenticationState.approveServer();
|
|
496
|
+
}
|
|
376
497
|
}
|
|
377
498
|
}, {
|
|
378
499
|
key: "sendCredentials",
|
|
@@ -388,12 +509,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
388
509
|
}
|
|
389
510
|
|
|
390
511
|
Log.Info("Sending Ctrl-Alt-Del");
|
|
391
|
-
this.sendKey(_keysym
|
|
392
|
-
this.sendKey(_keysym
|
|
393
|
-
this.sendKey(_keysym
|
|
394
|
-
this.sendKey(_keysym
|
|
395
|
-
this.sendKey(_keysym
|
|
396
|
-
this.sendKey(_keysym
|
|
512
|
+
this.sendKey(_keysym["default"].XK_Control_L, "ControlLeft", true);
|
|
513
|
+
this.sendKey(_keysym["default"].XK_Alt_L, "AltLeft", true);
|
|
514
|
+
this.sendKey(_keysym["default"].XK_Delete, "Delete", true);
|
|
515
|
+
this.sendKey(_keysym["default"].XK_Delete, "Delete", false);
|
|
516
|
+
this.sendKey(_keysym["default"].XK_Alt_L, "AltLeft", false);
|
|
517
|
+
this.sendKey(_keysym["default"].XK_Control_L, "ControlLeft", false);
|
|
397
518
|
}
|
|
398
519
|
}, {
|
|
399
520
|
key: "machineShutdown",
|
|
@@ -425,7 +546,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
425
546
|
return;
|
|
426
547
|
}
|
|
427
548
|
|
|
428
|
-
var scancode = _xtscancodes
|
|
549
|
+
var scancode = _xtscancodes["default"][code];
|
|
429
550
|
|
|
430
551
|
if (this._qemuExtKeyEventSupported && scancode) {
|
|
431
552
|
// 0 is NoSymbol
|
|
@@ -443,8 +564,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
443
564
|
}
|
|
444
565
|
}, {
|
|
445
566
|
key: "focus",
|
|
446
|
-
value: function focus() {
|
|
447
|
-
this._canvas.focus();
|
|
567
|
+
value: function focus(options) {
|
|
568
|
+
this._canvas.focus(options);
|
|
448
569
|
}
|
|
449
570
|
}, {
|
|
450
571
|
key: "blur",
|
|
@@ -477,16 +598,25 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
477
598
|
key: "_connect",
|
|
478
599
|
value: function _connect() {
|
|
479
600
|
Log.Debug(">> RFB.connect");
|
|
480
|
-
Log.Info("connecting to " + this._url);
|
|
481
601
|
|
|
482
|
-
|
|
483
|
-
|
|
602
|
+
if (this._url) {
|
|
603
|
+
Log.Info("connecting to ".concat(this._url));
|
|
604
|
+
|
|
484
605
|
this._sock.open(this._url, this._wsProtocols);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
606
|
+
} else {
|
|
607
|
+
Log.Info("attaching ".concat(this._rawChannel, " to Websock"));
|
|
608
|
+
|
|
609
|
+
this._sock.attach(this._rawChannel);
|
|
610
|
+
|
|
611
|
+
if (this._sock.readyState === 'closed') {
|
|
612
|
+
throw Error("Cannot use already closed WebSocket/RTCDataChannel");
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
if (this._sock.readyState === 'open') {
|
|
616
|
+
// FIXME: _socketOpen() can in theory call _fail(), which
|
|
617
|
+
// isn't allowed this early, but I'm not sure that can
|
|
618
|
+
// happen without a bug messing up our state variables
|
|
619
|
+
this._socketOpen();
|
|
490
620
|
}
|
|
491
621
|
} // Make our elements part of the page
|
|
492
622
|
|
|
@@ -497,11 +627,11 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
497
627
|
|
|
498
628
|
this._cursor.attach(this._canvas);
|
|
499
629
|
|
|
500
|
-
this._refreshCursor(); // Monitor size changes of the screen
|
|
501
|
-
|
|
630
|
+
this._refreshCursor(); // Monitor size changes of the screen element
|
|
631
|
+
|
|
502
632
|
|
|
633
|
+
this._resizeObserver.observe(this._screen); // Always grab focus on some kind of click event
|
|
503
634
|
|
|
504
|
-
window.addEventListener('resize', this._eventHandlers.windowResize); // Always grab focus on some kind of click event
|
|
505
635
|
|
|
506
636
|
this._canvas.addEventListener("mousedown", this._eventHandlers.focusCanvas);
|
|
507
637
|
|
|
@@ -562,7 +692,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
562
692
|
|
|
563
693
|
this._canvas.removeEventListener("touchstart", this._eventHandlers.focusCanvas);
|
|
564
694
|
|
|
565
|
-
|
|
695
|
+
this._resizeObserver.disconnect();
|
|
566
696
|
|
|
567
697
|
this._keyboard.ungrab();
|
|
568
698
|
|
|
@@ -584,6 +714,73 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
584
714
|
clearTimeout(this._mouseMoveTimer);
|
|
585
715
|
Log.Debug("<< RFB.disconnect");
|
|
586
716
|
}
|
|
717
|
+
}, {
|
|
718
|
+
key: "_socketOpen",
|
|
719
|
+
value: function _socketOpen() {
|
|
720
|
+
if (this._rfbConnectionState === 'connecting' && this._rfbInitState === '') {
|
|
721
|
+
this._rfbInitState = 'ProtocolVersion';
|
|
722
|
+
Log.Debug("Starting VNC handshake");
|
|
723
|
+
} else {
|
|
724
|
+
this._fail("Unexpected server connection while " + this._rfbConnectionState);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}, {
|
|
728
|
+
key: "_socketClose",
|
|
729
|
+
value: function _socketClose(e) {
|
|
730
|
+
Log.Debug("WebSocket on-close event");
|
|
731
|
+
var msg = "";
|
|
732
|
+
|
|
733
|
+
if (e.code) {
|
|
734
|
+
msg = "(code: " + e.code;
|
|
735
|
+
|
|
736
|
+
if (e.reason) {
|
|
737
|
+
msg += ", reason: " + e.reason;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
msg += ")";
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
switch (this._rfbConnectionState) {
|
|
744
|
+
case 'connecting':
|
|
745
|
+
this._fail("Connection closed " + msg);
|
|
746
|
+
|
|
747
|
+
break;
|
|
748
|
+
|
|
749
|
+
case 'connected':
|
|
750
|
+
// Handle disconnects that were initiated server-side
|
|
751
|
+
this._updateConnectionState('disconnecting');
|
|
752
|
+
|
|
753
|
+
this._updateConnectionState('disconnected');
|
|
754
|
+
|
|
755
|
+
break;
|
|
756
|
+
|
|
757
|
+
case 'disconnecting':
|
|
758
|
+
// Normal disconnection path
|
|
759
|
+
this._updateConnectionState('disconnected');
|
|
760
|
+
|
|
761
|
+
break;
|
|
762
|
+
|
|
763
|
+
case 'disconnected':
|
|
764
|
+
this._fail("Unexpected server disconnect " + "when already disconnected " + msg);
|
|
765
|
+
|
|
766
|
+
break;
|
|
767
|
+
|
|
768
|
+
default:
|
|
769
|
+
this._fail("Unexpected server disconnect before connecting " + msg);
|
|
770
|
+
|
|
771
|
+
break;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
this._sock.off('close'); // Delete reference to raw channel to allow cleanup.
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
this._rawChannel = null;
|
|
778
|
+
}
|
|
779
|
+
}, {
|
|
780
|
+
key: "_socketError",
|
|
781
|
+
value: function _socketError(e) {
|
|
782
|
+
Log.Warn("WebSocket on-error event");
|
|
783
|
+
}
|
|
587
784
|
}, {
|
|
588
785
|
key: "_focusCanvas",
|
|
589
786
|
value: function _focusCanvas(event) {
|
|
@@ -591,7 +788,9 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
591
788
|
return;
|
|
592
789
|
}
|
|
593
790
|
|
|
594
|
-
this.focus(
|
|
791
|
+
this.focus({
|
|
792
|
+
preventScroll: true
|
|
793
|
+
});
|
|
595
794
|
}
|
|
596
795
|
}, {
|
|
597
796
|
key: "_setDesktopName",
|
|
@@ -604,12 +803,38 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
604
803
|
}));
|
|
605
804
|
}
|
|
606
805
|
}, {
|
|
607
|
-
key: "
|
|
608
|
-
value: function
|
|
806
|
+
key: "_saveExpectedClientSize",
|
|
807
|
+
value: function _saveExpectedClientSize() {
|
|
808
|
+
this._expectedClientWidth = this._screen.clientWidth;
|
|
809
|
+
this._expectedClientHeight = this._screen.clientHeight;
|
|
810
|
+
}
|
|
811
|
+
}, {
|
|
812
|
+
key: "_currentClientSize",
|
|
813
|
+
value: function _currentClientSize() {
|
|
814
|
+
return [this._screen.clientWidth, this._screen.clientHeight];
|
|
815
|
+
}
|
|
816
|
+
}, {
|
|
817
|
+
key: "_clientHasExpectedSize",
|
|
818
|
+
value: function _clientHasExpectedSize() {
|
|
819
|
+
var _this$_currentClientS = this._currentClientSize(),
|
|
820
|
+
_this$_currentClientS2 = _slicedToArray(_this$_currentClientS, 2),
|
|
821
|
+
currentWidth = _this$_currentClientS2[0],
|
|
822
|
+
currentHeight = _this$_currentClientS2[1];
|
|
823
|
+
|
|
824
|
+
return currentWidth == this._expectedClientWidth && currentHeight == this._expectedClientHeight;
|
|
825
|
+
}
|
|
826
|
+
}, {
|
|
827
|
+
key: "_handleResize",
|
|
828
|
+
value: function _handleResize() {
|
|
609
829
|
var _this2 = this;
|
|
610
830
|
|
|
611
|
-
//
|
|
831
|
+
// Don't change anything if the client size is already as expected
|
|
832
|
+
if (this._clientHasExpectedSize()) {
|
|
833
|
+
return;
|
|
834
|
+
} // If the window resized then our screen element might have
|
|
612
835
|
// as well. Update the viewport dimensions.
|
|
836
|
+
|
|
837
|
+
|
|
613
838
|
window.requestAnimationFrame(function () {
|
|
614
839
|
_this2._updateClip();
|
|
615
840
|
|
|
@@ -650,6 +875,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
650
875
|
this._display.viewportChangeSize(size.w, size.h);
|
|
651
876
|
|
|
652
877
|
this._fixScrollbars();
|
|
878
|
+
} // When changing clipping we might show or hide scrollbars.
|
|
879
|
+
// This causes the expected client dimensions to change.
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
if (curClip !== newClip) {
|
|
883
|
+
this._saveExpectedClientSize();
|
|
653
884
|
}
|
|
654
885
|
}
|
|
655
886
|
}, {
|
|
@@ -696,11 +927,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
696
927
|
}, {
|
|
697
928
|
key: "_fixScrollbars",
|
|
698
929
|
value: function _fixScrollbars() {
|
|
699
|
-
// This is a hack because
|
|
700
|
-
// for when scrollbars are needed.
|
|
701
|
-
//
|
|
930
|
+
// This is a hack because Safari on macOS screws up the calculation
|
|
931
|
+
// for when scrollbars are needed. We get scrollbars when making the
|
|
932
|
+
// browser smaller, despite remote resize being enabled. So to fix it
|
|
933
|
+
// we temporarily toggle them off and on.
|
|
702
934
|
var orig = this._screen.style.overflow;
|
|
703
|
-
this._screen.style.overflow = 'hidden'; // Force
|
|
935
|
+
this._screen.style.overflow = 'hidden'; // Force Safari to recalculate the layout by asking for
|
|
704
936
|
// an element's dimensions
|
|
705
937
|
|
|
706
938
|
this._screen.getBoundingClientRect();
|
|
@@ -1275,7 +1507,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1275
1507
|
magnitude = Math.hypot(ev.detail.magnitudeX, ev.detail.magnitudeY);
|
|
1276
1508
|
|
|
1277
1509
|
if (Math.abs(magnitude - this._gestureLastMagnitudeX) > GESTURE_ZOOMSENS) {
|
|
1278
|
-
this._handleKeyEvent(_keysym
|
|
1510
|
+
this._handleKeyEvent(_keysym["default"].XK_Control_L, "ControlLeft", true);
|
|
1279
1511
|
|
|
1280
1512
|
while (magnitude - this._gestureLastMagnitudeX > GESTURE_ZOOMSENS) {
|
|
1281
1513
|
this._handleMouseButton(pos.x, pos.y, true, 0x8);
|
|
@@ -1294,7 +1526,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1294
1526
|
}
|
|
1295
1527
|
}
|
|
1296
1528
|
|
|
1297
|
-
this._handleKeyEvent(_keysym
|
|
1529
|
+
this._handleKeyEvent(_keysym["default"].XK_Control_L, "ControlLeft", false);
|
|
1298
1530
|
|
|
1299
1531
|
break;
|
|
1300
1532
|
}
|
|
@@ -1348,10 +1580,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1348
1580
|
break;
|
|
1349
1581
|
|
|
1350
1582
|
case "003.003":
|
|
1351
|
-
case "003.006":
|
|
1352
|
-
|
|
1353
|
-
case "003.889":
|
|
1354
|
-
// Apple Remote Desktop
|
|
1583
|
+
case "003.006":
|
|
1584
|
+
// UltraVNC
|
|
1355
1585
|
this._rfbVersion = 3.3;
|
|
1356
1586
|
break;
|
|
1357
1587
|
|
|
@@ -1360,6 +1590,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1360
1590
|
break;
|
|
1361
1591
|
|
|
1362
1592
|
case "003.008":
|
|
1593
|
+
case "003.889": // Apple Remote Desktop
|
|
1594
|
+
|
|
1363
1595
|
case "004.000": // Intel AMT KVM
|
|
1364
1596
|
|
|
1365
1597
|
case "004.001": // RealVNC 4.6
|
|
@@ -1399,18 +1631,6 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1399
1631
|
}, {
|
|
1400
1632
|
key: "_negotiateSecurity",
|
|
1401
1633
|
value: function _negotiateSecurity() {
|
|
1402
|
-
// Polyfill since IE and PhantomJS doesn't have
|
|
1403
|
-
// TypedArray.includes()
|
|
1404
|
-
function includes(item, array) {
|
|
1405
|
-
for (var i = 0; i < array.length; i++) {
|
|
1406
|
-
if (array[i] === item) {
|
|
1407
|
-
return true;
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
return false;
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
1634
|
if (this._rfbVersion >= 3.7) {
|
|
1415
1635
|
// Server sends supported list, client decides
|
|
1416
1636
|
var numTypes = this._sock.rQshift8();
|
|
@@ -1430,15 +1650,19 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1430
1650
|
|
|
1431
1651
|
Log.Debug("Server security types: " + types); // Look for each auth in preferred order
|
|
1432
1652
|
|
|
1433
|
-
if (includes(1
|
|
1653
|
+
if (types.includes(1)) {
|
|
1434
1654
|
this._rfbAuthScheme = 1; // None
|
|
1435
|
-
} else if (includes(22
|
|
1655
|
+
} else if (types.includes(22)) {
|
|
1436
1656
|
this._rfbAuthScheme = 22; // XVP
|
|
1437
|
-
} else if (includes(16
|
|
1657
|
+
} else if (types.includes(16)) {
|
|
1438
1658
|
this._rfbAuthScheme = 16; // Tight
|
|
1439
|
-
} else if (includes(
|
|
1659
|
+
} else if (types.includes(6)) {
|
|
1660
|
+
this._rfbAuthScheme = 6; // RA2ne Auth
|
|
1661
|
+
} else if (types.includes(2)) {
|
|
1440
1662
|
this._rfbAuthScheme = 2; // VNC Auth
|
|
1441
|
-
} else if (includes(
|
|
1663
|
+
} else if (types.includes(30)) {
|
|
1664
|
+
this._rfbAuthScheme = 30; // ARD Auth
|
|
1665
|
+
} else if (types.includes(19)) {
|
|
1442
1666
|
this._rfbAuthScheme = 19; // VeNCrypt Auth
|
|
1443
1667
|
} else {
|
|
1444
1668
|
return this._fail("Unsupported security types (types: " + types + ")");
|
|
@@ -1602,7 +1826,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1602
1826
|
|
|
1603
1827
|
|
|
1604
1828
|
if (this._rfbVeNCryptState == 4) {
|
|
1605
|
-
if (
|
|
1829
|
+
if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
|
|
1606
1830
|
this.dispatchEvent(new CustomEvent("credentialsrequired", {
|
|
1607
1831
|
detail: {
|
|
1608
1832
|
types: ["username", "password"]
|
|
@@ -1612,11 +1836,11 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1612
1836
|
}
|
|
1613
1837
|
|
|
1614
1838
|
var user = (0, _strings.encodeUTF8)(this._rfbCredentials.username);
|
|
1615
|
-
var pass = (0, _strings.encodeUTF8)(this._rfbCredentials.password);
|
|
1839
|
+
var pass = (0, _strings.encodeUTF8)(this._rfbCredentials.password);
|
|
1616
1840
|
|
|
1617
|
-
this._sock.send([
|
|
1841
|
+
this._sock.send([user.length >> 24 & 0xFF, user.length >> 16 & 0xFF, user.length >> 8 & 0xFF, user.length & 0xFF]);
|
|
1618
1842
|
|
|
1619
|
-
this._sock.send([
|
|
1843
|
+
this._sock.send([pass.length >> 24 & 0xFF, pass.length >> 16 & 0xFF, pass.length >> 8 & 0xFF, pass.length & 0xFF]);
|
|
1620
1844
|
|
|
1621
1845
|
this._sock.sendString(user);
|
|
1622
1846
|
|
|
@@ -1651,6 +1875,209 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1651
1875
|
this._rfbInitState = "SecurityResult";
|
|
1652
1876
|
return true;
|
|
1653
1877
|
}
|
|
1878
|
+
}, {
|
|
1879
|
+
key: "_negotiateARDAuth",
|
|
1880
|
+
value: function _negotiateARDAuth() {
|
|
1881
|
+
if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
|
|
1882
|
+
this.dispatchEvent(new CustomEvent("credentialsrequired", {
|
|
1883
|
+
detail: {
|
|
1884
|
+
types: ["username", "password"]
|
|
1885
|
+
}
|
|
1886
|
+
}));
|
|
1887
|
+
return false;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
if (this._rfbCredentials.ardPublicKey != undefined && this._rfbCredentials.ardCredentials != undefined) {
|
|
1891
|
+
// if the async web crypto is done return the results
|
|
1892
|
+
this._sock.send(this._rfbCredentials.ardCredentials);
|
|
1893
|
+
|
|
1894
|
+
this._sock.send(this._rfbCredentials.ardPublicKey);
|
|
1895
|
+
|
|
1896
|
+
this._rfbCredentials.ardCredentials = null;
|
|
1897
|
+
this._rfbCredentials.ardPublicKey = null;
|
|
1898
|
+
this._rfbInitState = "SecurityResult";
|
|
1899
|
+
return true;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
if (this._sock.rQwait("read ard", 4)) {
|
|
1903
|
+
return false;
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
var generator = this._sock.rQshiftBytes(2); // DH base generator value
|
|
1907
|
+
|
|
1908
|
+
|
|
1909
|
+
var keyLength = this._sock.rQshift16();
|
|
1910
|
+
|
|
1911
|
+
if (this._sock.rQwait("read ard keylength", keyLength * 2, 4)) {
|
|
1912
|
+
return false;
|
|
1913
|
+
} // read the server values
|
|
1914
|
+
|
|
1915
|
+
|
|
1916
|
+
var prime = this._sock.rQshiftBytes(keyLength); // predetermined prime modulus
|
|
1917
|
+
|
|
1918
|
+
|
|
1919
|
+
var serverPublicKey = this._sock.rQshiftBytes(keyLength); // other party's public key
|
|
1920
|
+
|
|
1921
|
+
|
|
1922
|
+
var clientPrivateKey = window.crypto.getRandomValues(new Uint8Array(keyLength));
|
|
1923
|
+
var padding = Array.from(window.crypto.getRandomValues(new Uint8Array(64)), function (_byte) {
|
|
1924
|
+
return String.fromCharCode(65 + _byte % 26);
|
|
1925
|
+
}).join('');
|
|
1926
|
+
|
|
1927
|
+
this._negotiateARDAuthAsync(generator, keyLength, prime, serverPublicKey, clientPrivateKey, padding);
|
|
1928
|
+
|
|
1929
|
+
return false;
|
|
1930
|
+
}
|
|
1931
|
+
}, {
|
|
1932
|
+
key: "_modPow",
|
|
1933
|
+
value: function _modPow(base, exponent, modulus) {
|
|
1934
|
+
var baseHex = "0x" + Array.from(base, function (_byte2) {
|
|
1935
|
+
return ('0' + (_byte2 & 0xFF).toString(16)).slice(-2);
|
|
1936
|
+
}).join('');
|
|
1937
|
+
var exponentHex = "0x" + Array.from(exponent, function (_byte3) {
|
|
1938
|
+
return ('0' + (_byte3 & 0xFF).toString(16)).slice(-2);
|
|
1939
|
+
}).join('');
|
|
1940
|
+
var modulusHex = "0x" + Array.from(modulus, function (_byte4) {
|
|
1941
|
+
return ('0' + (_byte4 & 0xFF).toString(16)).slice(-2);
|
|
1942
|
+
}).join('');
|
|
1943
|
+
var b = BigInt(baseHex);
|
|
1944
|
+
var e = BigInt(exponentHex);
|
|
1945
|
+
var m = BigInt(modulusHex);
|
|
1946
|
+
var r = 1n;
|
|
1947
|
+
b = b % m;
|
|
1948
|
+
|
|
1949
|
+
while (e > 0) {
|
|
1950
|
+
if (e % 2n === 1n) {
|
|
1951
|
+
r = r * b % m;
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
e = e / 2n;
|
|
1955
|
+
b = b * b % m;
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
var hexResult = r.toString(16);
|
|
1959
|
+
|
|
1960
|
+
while (hexResult.length / 2 < exponent.length || hexResult.length % 2 != 0) {
|
|
1961
|
+
hexResult = "0" + hexResult;
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
var bytesResult = [];
|
|
1965
|
+
|
|
1966
|
+
for (var c = 0; c < hexResult.length; c += 2) {
|
|
1967
|
+
bytesResult.push(parseInt(hexResult.substr(c, 2), 16));
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
return bytesResult;
|
|
1971
|
+
}
|
|
1972
|
+
}, {
|
|
1973
|
+
key: "_aesEcbEncrypt",
|
|
1974
|
+
value: function () {
|
|
1975
|
+
var _aesEcbEncrypt2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(string, key) {
|
|
1976
|
+
var keyString, aesKey, data, i, encrypted, _i2, block, encryptedBlock;
|
|
1977
|
+
|
|
1978
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1979
|
+
while (1) {
|
|
1980
|
+
switch (_context.prev = _context.next) {
|
|
1981
|
+
case 0:
|
|
1982
|
+
// perform AES-ECB blocks
|
|
1983
|
+
keyString = Array.from(key, function (_byte5) {
|
|
1984
|
+
return String.fromCharCode(_byte5);
|
|
1985
|
+
}).join('');
|
|
1986
|
+
_context.next = 3;
|
|
1987
|
+
return window.crypto.subtle.importKey("raw", (0, _md.MD5)(keyString), {
|
|
1988
|
+
name: "AES-CBC"
|
|
1989
|
+
}, false, ["encrypt"]);
|
|
1990
|
+
|
|
1991
|
+
case 3:
|
|
1992
|
+
aesKey = _context.sent;
|
|
1993
|
+
data = new Uint8Array(string.length);
|
|
1994
|
+
|
|
1995
|
+
for (i = 0; i < string.length; ++i) {
|
|
1996
|
+
data[i] = string.charCodeAt(i);
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
encrypted = new Uint8Array(data.length);
|
|
2000
|
+
_i2 = 0;
|
|
2001
|
+
|
|
2002
|
+
case 8:
|
|
2003
|
+
if (!(_i2 < data.length)) {
|
|
2004
|
+
_context.next = 17;
|
|
2005
|
+
break;
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
block = data.slice(_i2, _i2 + 16);
|
|
2009
|
+
_context.next = 12;
|
|
2010
|
+
return window.crypto.subtle.encrypt({
|
|
2011
|
+
name: "AES-CBC",
|
|
2012
|
+
iv: block
|
|
2013
|
+
}, aesKey, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]));
|
|
2014
|
+
|
|
2015
|
+
case 12:
|
|
2016
|
+
encryptedBlock = _context.sent;
|
|
2017
|
+
encrypted.set(new Uint8Array(encryptedBlock).slice(0, 16), _i2);
|
|
2018
|
+
|
|
2019
|
+
case 14:
|
|
2020
|
+
_i2 += 16;
|
|
2021
|
+
_context.next = 8;
|
|
2022
|
+
break;
|
|
2023
|
+
|
|
2024
|
+
case 17:
|
|
2025
|
+
return _context.abrupt("return", encrypted);
|
|
2026
|
+
|
|
2027
|
+
case 18:
|
|
2028
|
+
case "end":
|
|
2029
|
+
return _context.stop();
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
}, _callee);
|
|
2033
|
+
}));
|
|
2034
|
+
|
|
2035
|
+
function _aesEcbEncrypt(_x, _x2) {
|
|
2036
|
+
return _aesEcbEncrypt2.apply(this, arguments);
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
return _aesEcbEncrypt;
|
|
2040
|
+
}()
|
|
2041
|
+
}, {
|
|
2042
|
+
key: "_negotiateARDAuthAsync",
|
|
2043
|
+
value: function () {
|
|
2044
|
+
var _negotiateARDAuthAsync2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(generator, keyLength, prime, serverPublicKey, clientPrivateKey, padding) {
|
|
2045
|
+
var clientPublicKey, sharedKey, username, password, paddedUsername, paddedPassword, credentials, encrypted;
|
|
2046
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
2047
|
+
while (1) {
|
|
2048
|
+
switch (_context2.prev = _context2.next) {
|
|
2049
|
+
case 0:
|
|
2050
|
+
// calculate the DH keys
|
|
2051
|
+
clientPublicKey = this._modPow(generator, clientPrivateKey, prime);
|
|
2052
|
+
sharedKey = this._modPow(serverPublicKey, clientPrivateKey, prime);
|
|
2053
|
+
username = (0, _strings.encodeUTF8)(this._rfbCredentials.username).substring(0, 63);
|
|
2054
|
+
password = (0, _strings.encodeUTF8)(this._rfbCredentials.password).substring(0, 63);
|
|
2055
|
+
paddedUsername = username + '\0' + padding.substring(0, 63);
|
|
2056
|
+
paddedPassword = password + '\0' + padding.substring(0, 63);
|
|
2057
|
+
credentials = paddedUsername.substring(0, 64) + paddedPassword.substring(0, 64);
|
|
2058
|
+
_context2.next = 9;
|
|
2059
|
+
return this._aesEcbEncrypt(credentials, sharedKey);
|
|
2060
|
+
|
|
2061
|
+
case 9:
|
|
2062
|
+
encrypted = _context2.sent;
|
|
2063
|
+
this._rfbCredentials.ardCredentials = encrypted;
|
|
2064
|
+
this._rfbCredentials.ardPublicKey = clientPublicKey;
|
|
2065
|
+
setTimeout(this._initMsg.bind(this), 0);
|
|
2066
|
+
|
|
2067
|
+
case 13:
|
|
2068
|
+
case "end":
|
|
2069
|
+
return _context2.stop();
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
}, _callee2, this);
|
|
2073
|
+
}));
|
|
2074
|
+
|
|
2075
|
+
function _negotiateARDAuthAsync(_x3, _x4, _x5, _x6, _x7, _x8) {
|
|
2076
|
+
return _negotiateARDAuthAsync2.apply(this, arguments);
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
return _negotiateARDAuthAsync;
|
|
2080
|
+
}()
|
|
1654
2081
|
}, {
|
|
1655
2082
|
key: "_negotiateTightUnixAuth",
|
|
1656
2083
|
value: function _negotiateTightUnixAuth() {
|
|
@@ -1815,6 +2242,55 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1815
2242
|
|
|
1816
2243
|
return this._fail("No supported sub-auth types!");
|
|
1817
2244
|
}
|
|
2245
|
+
}, {
|
|
2246
|
+
key: "_handleRSAAESCredentialsRequired",
|
|
2247
|
+
value: function _handleRSAAESCredentialsRequired(event) {
|
|
2248
|
+
this.dispatchEvent(event);
|
|
2249
|
+
}
|
|
2250
|
+
}, {
|
|
2251
|
+
key: "_handleRSAAESServerVerification",
|
|
2252
|
+
value: function _handleRSAAESServerVerification(event) {
|
|
2253
|
+
this.dispatchEvent(event);
|
|
2254
|
+
}
|
|
2255
|
+
}, {
|
|
2256
|
+
key: "_negotiateRA2neAuth",
|
|
2257
|
+
value: function _negotiateRA2neAuth() {
|
|
2258
|
+
var _this5 = this;
|
|
2259
|
+
|
|
2260
|
+
if (this._rfbRSAAESAuthenticationState === null) {
|
|
2261
|
+
this._rfbRSAAESAuthenticationState = new _ra["default"](this._sock, function () {
|
|
2262
|
+
return _this5._rfbCredentials;
|
|
2263
|
+
});
|
|
2264
|
+
|
|
2265
|
+
this._rfbRSAAESAuthenticationState.addEventListener("serververification", this._eventHandlers.handleRSAAESServerVerification);
|
|
2266
|
+
|
|
2267
|
+
this._rfbRSAAESAuthenticationState.addEventListener("credentialsrequired", this._eventHandlers.handleRSAAESCredentialsRequired);
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
this._rfbRSAAESAuthenticationState.checkInternalEvents();
|
|
2271
|
+
|
|
2272
|
+
if (!this._rfbRSAAESAuthenticationState.hasStarted) {
|
|
2273
|
+
this._rfbRSAAESAuthenticationState.negotiateRA2neAuthAsync()["catch"](function (e) {
|
|
2274
|
+
if (e.message !== "disconnect normally") {
|
|
2275
|
+
_this5._fail(e.message);
|
|
2276
|
+
}
|
|
2277
|
+
}).then(function () {
|
|
2278
|
+
_this5.dispatchEvent(new CustomEvent('securityresult'));
|
|
2279
|
+
|
|
2280
|
+
_this5._rfbInitState = "SecurityResult";
|
|
2281
|
+
|
|
2282
|
+
_this5._initMsg();
|
|
2283
|
+
})["finally"](function () {
|
|
2284
|
+
_this5._rfbRSAAESAuthenticationState.removeEventListener("serververification", _this5._eventHandlers.handleRSAAESServerVerification);
|
|
2285
|
+
|
|
2286
|
+
_this5._rfbRSAAESAuthenticationState.removeEventListener("credentialsrequired", _this5._eventHandlers.handleRSAAESCredentialsRequired);
|
|
2287
|
+
|
|
2288
|
+
_this5._rfbRSAAESAuthenticationState = null;
|
|
2289
|
+
});
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
return false;
|
|
2293
|
+
}
|
|
1818
2294
|
}, {
|
|
1819
2295
|
key: "_negotiateAuthentication",
|
|
1820
2296
|
value: function _negotiateAuthentication() {
|
|
@@ -1833,6 +2309,10 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1833
2309
|
// XVP auth
|
|
1834
2310
|
return this._negotiateXvpAuth();
|
|
1835
2311
|
|
|
2312
|
+
case 30:
|
|
2313
|
+
// ARD auth
|
|
2314
|
+
return this._negotiateARDAuth();
|
|
2315
|
+
|
|
1836
2316
|
case 2:
|
|
1837
2317
|
// VNC authentication
|
|
1838
2318
|
return this._negotiateStdVNCAuth();
|
|
@@ -1849,6 +2329,10 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1849
2329
|
// TightVNC UNIX Security Type
|
|
1850
2330
|
return this._negotiateTightUnixAuth();
|
|
1851
2331
|
|
|
2332
|
+
case 6:
|
|
2333
|
+
// RA2ne Security Type
|
|
2334
|
+
return this._negotiateRA2neAuth();
|
|
2335
|
+
|
|
1852
2336
|
default:
|
|
1853
2337
|
return this._fail("Unsupported auth scheme (scheme: " + this._rfbAuthScheme + ")");
|
|
1854
2338
|
}
|
|
@@ -2007,6 +2491,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2007
2491
|
if (this._fbDepth == 24) {
|
|
2008
2492
|
encs.push(_encodings.encodings.encodingTight);
|
|
2009
2493
|
encs.push(_encodings.encodings.encodingTightPNG);
|
|
2494
|
+
encs.push(_encodings.encodings.encodingZRLE);
|
|
2495
|
+
encs.push(_encodings.encodings.encodingJPEG);
|
|
2010
2496
|
encs.push(_encodings.encodings.encodingHextile);
|
|
2011
2497
|
encs.push(_encodings.encodings.encodingRRE);
|
|
2012
2498
|
}
|
|
@@ -2139,8 +2625,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2139
2625
|
} // Update our server capabilities for Actions
|
|
2140
2626
|
|
|
2141
2627
|
|
|
2142
|
-
for (var
|
|
2143
|
-
var _index = 1 <<
|
|
2628
|
+
for (var _i3 = 24; _i3 <= 31; _i3++) {
|
|
2629
|
+
var _index = 1 << _i3;
|
|
2144
2630
|
|
|
2145
2631
|
this._clipboardServerCapabilitiesActions[_index] = !!(actions & _index);
|
|
2146
2632
|
}
|
|
@@ -2199,12 +2685,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2199
2685
|
|
|
2200
2686
|
var zlibStream = this._sock.rQshiftBytes(length - 4);
|
|
2201
2687
|
|
|
2202
|
-
var streamInflator = new _inflator
|
|
2688
|
+
var streamInflator = new _inflator["default"]();
|
|
2203
2689
|
var textData = null;
|
|
2204
2690
|
streamInflator.setInput(zlibStream);
|
|
2205
2691
|
|
|
2206
|
-
for (var
|
|
2207
|
-
var format = 1 <<
|
|
2692
|
+
for (var _i4 = 0; _i4 <= 15; _i4++) {
|
|
2693
|
+
var format = 1 << _i4;
|
|
2208
2694
|
|
|
2209
2695
|
if (formats & format) {
|
|
2210
2696
|
var size = 0x00;
|
|
@@ -2226,8 +2712,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2226
2712
|
if (textData !== null) {
|
|
2227
2713
|
var tmpText = "";
|
|
2228
2714
|
|
|
2229
|
-
for (var
|
|
2230
|
-
tmpText += String.fromCharCode(textData[
|
|
2715
|
+
for (var _i5 = 0; _i5 < textData.length; _i5++) {
|
|
2716
|
+
tmpText += String.fromCharCode(textData[_i5]);
|
|
2231
2717
|
}
|
|
2232
2718
|
|
|
2233
2719
|
textData = tmpText;
|
|
@@ -2486,16 +2972,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2486
2972
|
return this._handleCursor();
|
|
2487
2973
|
|
|
2488
2974
|
case _encodings.encodings.pseudoEncodingQEMUExtendedKeyEvent:
|
|
2489
|
-
|
|
2490
|
-
try {
|
|
2491
|
-
var keyboardEvent = document.createEvent("keyboardEvent");
|
|
2492
|
-
|
|
2493
|
-
if (keyboardEvent.code !== undefined) {
|
|
2494
|
-
this._qemuExtKeyEventSupported = true;
|
|
2495
|
-
}
|
|
2496
|
-
} catch (err) {// Do nothing
|
|
2497
|
-
}
|
|
2498
|
-
|
|
2975
|
+
this._qemuExtKeyEventSupported = true;
|
|
2499
2976
|
return true;
|
|
2500
2977
|
|
|
2501
2978
|
case _encodings.encodings.pseudoEncodingDesktopName:
|
|
@@ -2823,7 +3300,10 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2823
3300
|
|
|
2824
3301
|
this._updateScale();
|
|
2825
3302
|
|
|
2826
|
-
this._updateContinuousUpdates();
|
|
3303
|
+
this._updateContinuousUpdates(); // Keep this size until browser client size changes
|
|
3304
|
+
|
|
3305
|
+
|
|
3306
|
+
this._saveExpectedClientSize();
|
|
2827
3307
|
}
|
|
2828
3308
|
}, {
|
|
2829
3309
|
key: "_xvpOp",
|
|
@@ -2882,151 +3362,21 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2882
3362
|
|
|
2883
3363
|
this._cursor.change(image.rgbaPixels, image.hotx, image.hoty, image.w, image.h);
|
|
2884
3364
|
}
|
|
2885
|
-
}, {
|
|
2886
|
-
key: "viewOnly",
|
|
2887
|
-
get: function get() {
|
|
2888
|
-
return this._viewOnly;
|
|
2889
|
-
},
|
|
2890
|
-
set: function set(viewOnly) {
|
|
2891
|
-
this._viewOnly = viewOnly;
|
|
2892
|
-
|
|
2893
|
-
if (this._rfbConnectionState === "connecting" || this._rfbConnectionState === "connected") {
|
|
2894
|
-
if (viewOnly) {
|
|
2895
|
-
this._keyboard.ungrab();
|
|
2896
|
-
} else {
|
|
2897
|
-
this._keyboard.grab();
|
|
2898
|
-
}
|
|
2899
|
-
}
|
|
2900
|
-
}
|
|
2901
|
-
}, {
|
|
2902
|
-
key: "capabilities",
|
|
2903
|
-
get: function get() {
|
|
2904
|
-
return this._capabilities;
|
|
2905
|
-
}
|
|
2906
|
-
}, {
|
|
2907
|
-
key: "touchButton",
|
|
2908
|
-
get: function get() {
|
|
2909
|
-
return 0;
|
|
2910
|
-
},
|
|
2911
|
-
set: function set(button) {
|
|
2912
|
-
Log.Warn("Using old API!");
|
|
2913
|
-
}
|
|
2914
|
-
}, {
|
|
2915
|
-
key: "clipViewport",
|
|
2916
|
-
get: function get() {
|
|
2917
|
-
return this._clipViewport;
|
|
2918
|
-
},
|
|
2919
|
-
set: function set(viewport) {
|
|
2920
|
-
this._clipViewport = viewport;
|
|
2921
|
-
|
|
2922
|
-
this._updateClip();
|
|
2923
|
-
}
|
|
2924
|
-
}, {
|
|
2925
|
-
key: "scaleViewport",
|
|
2926
|
-
get: function get() {
|
|
2927
|
-
return this._scaleViewport;
|
|
2928
|
-
},
|
|
2929
|
-
set: function set(scale) {
|
|
2930
|
-
this._scaleViewport = scale; // Scaling trumps clipping, so we may need to adjust
|
|
2931
|
-
// clipping when enabling or disabling scaling
|
|
2932
|
-
|
|
2933
|
-
if (scale && this._clipViewport) {
|
|
2934
|
-
this._updateClip();
|
|
2935
|
-
}
|
|
2936
|
-
|
|
2937
|
-
this._updateScale();
|
|
2938
|
-
|
|
2939
|
-
if (!scale && this._clipViewport) {
|
|
2940
|
-
this._updateClip();
|
|
2941
|
-
}
|
|
2942
|
-
}
|
|
2943
|
-
}, {
|
|
2944
|
-
key: "resizeSession",
|
|
2945
|
-
get: function get() {
|
|
2946
|
-
return this._resizeSession;
|
|
2947
|
-
},
|
|
2948
|
-
set: function set(resize) {
|
|
2949
|
-
this._resizeSession = resize;
|
|
2950
|
-
|
|
2951
|
-
if (resize) {
|
|
2952
|
-
this._requestRemoteResize();
|
|
2953
|
-
}
|
|
2954
|
-
}
|
|
2955
|
-
}, {
|
|
2956
|
-
key: "showDotCursor",
|
|
2957
|
-
get: function get() {
|
|
2958
|
-
return this._showDotCursor;
|
|
2959
|
-
},
|
|
2960
|
-
set: function set(show) {
|
|
2961
|
-
this._showDotCursor = show;
|
|
2962
|
-
|
|
2963
|
-
this._refreshCursor();
|
|
2964
|
-
}
|
|
2965
|
-
}, {
|
|
2966
|
-
key: "background",
|
|
2967
|
-
get: function get() {
|
|
2968
|
-
return this._screen.style.background;
|
|
2969
|
-
},
|
|
2970
|
-
set: function set(cssValue) {
|
|
2971
|
-
this._screen.style.background = cssValue;
|
|
2972
|
-
}
|
|
2973
|
-
}, {
|
|
2974
|
-
key: "qualityLevel",
|
|
2975
|
-
get: function get() {
|
|
2976
|
-
return this._qualityLevel;
|
|
2977
|
-
},
|
|
2978
|
-
set: function set(qualityLevel) {
|
|
2979
|
-
if (!Number.isInteger(qualityLevel) || qualityLevel < 0 || qualityLevel > 9) {
|
|
2980
|
-
Log.Error("qualityLevel must be an integer between 0 and 9");
|
|
2981
|
-
return;
|
|
2982
|
-
}
|
|
2983
|
-
|
|
2984
|
-
if (this._qualityLevel === qualityLevel) {
|
|
2985
|
-
return;
|
|
2986
|
-
}
|
|
2987
|
-
|
|
2988
|
-
this._qualityLevel = qualityLevel;
|
|
2989
|
-
|
|
2990
|
-
if (this._rfbConnectionState === 'connected') {
|
|
2991
|
-
this._sendEncodings();
|
|
2992
|
-
}
|
|
2993
|
-
}
|
|
2994
|
-
}, {
|
|
2995
|
-
key: "compressionLevel",
|
|
2996
|
-
get: function get() {
|
|
2997
|
-
return this._compressionLevel;
|
|
2998
|
-
},
|
|
2999
|
-
set: function set(compressionLevel) {
|
|
3000
|
-
if (!Number.isInteger(compressionLevel) || compressionLevel < 0 || compressionLevel > 9) {
|
|
3001
|
-
Log.Error("compressionLevel must be an integer between 0 and 9");
|
|
3002
|
-
return;
|
|
3003
|
-
}
|
|
3004
|
-
|
|
3005
|
-
if (this._compressionLevel === compressionLevel) {
|
|
3006
|
-
return;
|
|
3007
|
-
}
|
|
3008
|
-
|
|
3009
|
-
this._compressionLevel = compressionLevel;
|
|
3010
|
-
|
|
3011
|
-
if (this._rfbConnectionState === 'connected') {
|
|
3012
|
-
this._sendEncodings();
|
|
3013
|
-
}
|
|
3014
|
-
}
|
|
3015
3365
|
}], [{
|
|
3016
3366
|
key: "genDES",
|
|
3017
3367
|
value: function genDES(password, challenge) {
|
|
3018
3368
|
var passwordChars = password.split('').map(function (c) {
|
|
3019
3369
|
return c.charCodeAt(0);
|
|
3020
3370
|
});
|
|
3021
|
-
return new _des
|
|
3371
|
+
return new _des["default"](passwordChars).encrypt(challenge);
|
|
3022
3372
|
}
|
|
3023
3373
|
}]);
|
|
3024
3374
|
|
|
3025
3375
|
return RFB;
|
|
3026
|
-
}(_eventtarget
|
|
3376
|
+
}(_eventtarget["default"]); // Class Methods
|
|
3027
3377
|
|
|
3028
3378
|
|
|
3029
|
-
exports
|
|
3379
|
+
exports["default"] = RFB;
|
|
3030
3380
|
RFB.messages = {
|
|
3031
3381
|
keyEvent: function keyEvent(sock, keysym, down) {
|
|
3032
3382
|
var buff = sock._sQ;
|
|
@@ -3098,8 +3448,8 @@ RFB.messages = {
|
|
|
3098
3448
|
actionFlag |= actions[i];
|
|
3099
3449
|
}
|
|
3100
3450
|
|
|
3101
|
-
for (var
|
|
3102
|
-
formatFlag |= formats[
|
|
3451
|
+
for (var _i6 = 0; _i6 < formats.length; _i6++) {
|
|
3452
|
+
formatFlag |= formats[_i6];
|
|
3103
3453
|
}
|
|
3104
3454
|
|
|
3105
3455
|
data[0] = actionFlag >> 24; // Actions
|
|
@@ -3114,7 +3464,7 @@ RFB.messages = {
|
|
|
3114
3464
|
},
|
|
3115
3465
|
extendedClipboardProvide: function extendedClipboardProvide(sock, formats, inData) {
|
|
3116
3466
|
// Deflate incomming data and their sizes
|
|
3117
|
-
var deflator = new _deflator
|
|
3467
|
+
var deflator = new _deflator["default"]();
|
|
3118
3468
|
var dataToDeflate = [];
|
|
3119
3469
|
|
|
3120
3470
|
for (var i = 0; i < formats.length; i++) {
|
|
@@ -3350,11 +3700,11 @@ RFB.messages = {
|
|
|
3350
3700
|
|
|
3351
3701
|
buff[offset + 13] = (1 << bits) - 1; // blue-max
|
|
3352
3702
|
|
|
3353
|
-
buff[offset + 14] = bits *
|
|
3703
|
+
buff[offset + 14] = bits * 0; // red-shift
|
|
3354
3704
|
|
|
3355
3705
|
buff[offset + 15] = bits * 1; // green-shift
|
|
3356
3706
|
|
|
3357
|
-
buff[offset + 16] = bits *
|
|
3707
|
+
buff[offset + 16] = bits * 2; // blue-shift
|
|
3358
3708
|
|
|
3359
3709
|
buff[offset + 17] = 0; // padding
|
|
3360
3710
|
|