@novnc/novnc 1.3.0 → 1.4.0-beta
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/AUTHORS +2 -2
- package/LICENSE.txt +1 -1
- package/README.md +23 -7
- package/core/decoders/jpeg.js +141 -0
- package/core/decoders/raw.js +1 -1
- package/core/decoders/zrle.js +185 -0
- package/core/des.js +1 -1
- package/core/display.js +12 -0
- package/core/encodings.js +4 -0
- package/core/input/keyboard.js +10 -0
- package/core/ra2.js +567 -0
- package/core/rfb.js +469 -84
- package/core/util/browser.js +56 -7
- package/core/util/cursor.js +4 -0
- package/core/util/md5.js +79 -0
- package/docs/API.md +318 -157
- package/lib/base64.js +20 -34
- package/lib/decoders/copyrect.js +5 -12
- package/lib/decoders/hextile.js +17 -47
- package/lib/decoders/jpeg.js +149 -0
- package/lib/decoders/raw.js +10 -23
- package/lib/decoders/rre.js +5 -16
- package/lib/decoders/tight.js +13 -79
- package/lib/decoders/tightpng.js +8 -28
- package/lib/decoders/zrle.js +188 -0
- package/lib/deflator.js +9 -23
- package/lib/des.js +24 -37
- package/lib/display.js +62 -108
- package/lib/encodings.js +7 -8
- package/lib/inflator.js +6 -19
- package/lib/input/domkeytable.js +77 -48
- package/lib/input/fixedkeys.js +8 -3
- package/lib/input/gesturehandler.js +86 -153
- package/lib/input/keyboard.js +62 -91
- package/lib/input/keysym.js +14 -270
- package/lib/input/keysymdef.js +5 -7
- package/lib/input/util.js +43 -85
- package/lib/input/vkeys.js +0 -3
- package/lib/input/xtscancodes.js +1 -168
- package/lib/ra2.js +1005 -0
- package/lib/rfb.js +795 -923
- package/lib/util/browser.js +66 -29
- package/lib/util/cursor.js +29 -66
- package/lib/util/element.js +3 -5
- package/lib/util/events.js +23 -30
- package/lib/util/eventtarget.js +5 -14
- package/lib/util/int.js +1 -2
- package/lib/util/logging.js +1 -19
- package/lib/util/md5.js +77 -0
- package/lib/util/strings.js +3 -5
- package/lib/vendor/pako/lib/utils/common.js +8 -17
- package/lib/vendor/pako/lib/zlib/adler32.js +3 -7
- package/lib/vendor/pako/lib/zlib/constants.js +2 -5
- package/lib/vendor/pako/lib/zlib/crc32.js +5 -12
- package/lib/vendor/pako/lib/zlib/deflate.js +213 -618
- package/lib/vendor/pako/lib/zlib/gzheader.js +1 -13
- package/lib/vendor/pako/lib/zlib/inffast.js +60 -176
- package/lib/vendor/pako/lib/zlib/inflate.js +398 -888
- package/lib/vendor/pako/lib/zlib/inftrees.js +63 -169
- package/lib/vendor/pako/lib/zlib/messages.js +1 -11
- package/lib/vendor/pako/lib/zlib/trees.js +246 -588
- package/lib/vendor/pako/lib/zlib/zstream.js +2 -18
- package/lib/websock.js +37 -88
- package/package.json +32 -35
package/lib/rfb.js
CHANGED
|
@@ -1,158 +1,153 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
4
|
-
|
|
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); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _int = require("./util/int.js");
|
|
11
|
-
|
|
12
9
|
var Log = _interopRequireWildcard(require("./util/logging.js"));
|
|
13
|
-
|
|
14
10
|
var _strings = require("./util/strings.js");
|
|
15
|
-
|
|
16
11
|
var _browser = require("./util/browser.js");
|
|
17
|
-
|
|
18
12
|
var _element = require("./util/element.js");
|
|
19
|
-
|
|
20
13
|
var _events = require("./util/events.js");
|
|
21
|
-
|
|
22
14
|
var _eventtarget = _interopRequireDefault(require("./util/eventtarget.js"));
|
|
23
|
-
|
|
24
15
|
var _display = _interopRequireDefault(require("./display.js"));
|
|
25
|
-
|
|
26
16
|
var _inflator = _interopRequireDefault(require("./inflator.js"));
|
|
27
|
-
|
|
28
17
|
var _deflator = _interopRequireDefault(require("./deflator.js"));
|
|
29
|
-
|
|
30
18
|
var _keyboard = _interopRequireDefault(require("./input/keyboard.js"));
|
|
31
|
-
|
|
32
19
|
var _gesturehandler = _interopRequireDefault(require("./input/gesturehandler.js"));
|
|
33
|
-
|
|
34
20
|
var _cursor = _interopRequireDefault(require("./util/cursor.js"));
|
|
35
|
-
|
|
36
21
|
var _websock = _interopRequireDefault(require("./websock.js"));
|
|
37
|
-
|
|
38
22
|
var _des = _interopRequireDefault(require("./des.js"));
|
|
39
|
-
|
|
40
23
|
var _keysym = _interopRequireDefault(require("./input/keysym.js"));
|
|
41
|
-
|
|
42
24
|
var _xtscancodes = _interopRequireDefault(require("./input/xtscancodes.js"));
|
|
43
|
-
|
|
44
25
|
var _encodings = require("./encodings.js");
|
|
45
|
-
|
|
26
|
+
var _ra = _interopRequireDefault(require("./ra2.js"));
|
|
27
|
+
var _md = require("./util/md5.js");
|
|
46
28
|
var _raw = _interopRequireDefault(require("./decoders/raw.js"));
|
|
47
|
-
|
|
48
29
|
var _copyrect = _interopRequireDefault(require("./decoders/copyrect.js"));
|
|
49
|
-
|
|
50
30
|
var _rre = _interopRequireDefault(require("./decoders/rre.js"));
|
|
51
|
-
|
|
52
31
|
var _hextile = _interopRequireDefault(require("./decoders/hextile.js"));
|
|
53
|
-
|
|
54
32
|
var _tight = _interopRequireDefault(require("./decoders/tight.js"));
|
|
55
|
-
|
|
56
33
|
var _tightpng = _interopRequireDefault(require("./decoders/tightpng.js"));
|
|
57
|
-
|
|
34
|
+
var _zrle = _interopRequireDefault(require("./decoders/zrle.js"));
|
|
35
|
+
var _jpeg = _interopRequireDefault(require("./decoders/jpeg.js"));
|
|
58
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
59
|
-
|
|
60
37
|
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); }
|
|
61
|
-
|
|
62
38
|
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; }
|
|
63
|
-
|
|
39
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
40
|
+
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); } }
|
|
41
|
+
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); }); }; }
|
|
42
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
43
|
+
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."); }
|
|
44
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
45
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
46
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
47
|
+
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); }
|
|
48
|
+
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; }
|
|
64
49
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
65
|
-
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
73
|
-
|
|
50
|
+
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
51
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
52
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
53
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
54
|
+
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); }
|
|
55
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
74
56
|
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); }; }
|
|
75
|
-
|
|
76
57
|
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); }
|
|
77
|
-
|
|
78
58
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
79
|
-
|
|
80
59
|
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; } }
|
|
81
|
-
|
|
82
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
83
|
-
|
|
60
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
84
61
|
// How many seconds to wait for a disconnect to finish
|
|
85
62
|
var DISCONNECT_TIMEOUT = 3;
|
|
86
|
-
var DEFAULT_BACKGROUND = 'rgb(40, 40, 40)';
|
|
63
|
+
var DEFAULT_BACKGROUND = 'rgb(40, 40, 40)';
|
|
87
64
|
|
|
88
|
-
|
|
65
|
+
// Minimum wait (ms) between two mouse moves
|
|
66
|
+
var MOUSE_MOVE_DELAY = 17;
|
|
89
67
|
|
|
68
|
+
// Wheel thresholds
|
|
90
69
|
var WHEEL_STEP = 50; // Pixels needed for one step
|
|
91
|
-
|
|
92
70
|
var WHEEL_LINE_HEIGHT = 19; // Assumed pixels for one line step
|
|
93
|
-
// Gesture thresholds
|
|
94
71
|
|
|
72
|
+
// Gesture thresholds
|
|
95
73
|
var GESTURE_ZOOMSENS = 75;
|
|
96
74
|
var GESTURE_SCRLSENS = 50;
|
|
97
75
|
var DOUBLE_TAP_TIMEOUT = 1000;
|
|
98
|
-
var DOUBLE_TAP_THRESHOLD = 50;
|
|
76
|
+
var DOUBLE_TAP_THRESHOLD = 50;
|
|
77
|
+
|
|
78
|
+
// Security types
|
|
79
|
+
var securityTypeNone = 1;
|
|
80
|
+
var securityTypeVNCAuth = 2;
|
|
81
|
+
var securityTypeRA2ne = 6;
|
|
82
|
+
var securityTypeTight = 16;
|
|
83
|
+
var securityTypeVeNCrypt = 19;
|
|
84
|
+
var securityTypeXVP = 22;
|
|
85
|
+
var securityTypeARD = 30;
|
|
86
|
+
var securityTypeMSLogonII = 113;
|
|
87
|
+
|
|
88
|
+
// Special Tight security types
|
|
89
|
+
var securityTypeUnixLogon = 129;
|
|
99
90
|
|
|
91
|
+
// VeNCrypt security types
|
|
92
|
+
var securityTypePlain = 256;
|
|
93
|
+
|
|
94
|
+
// Extended clipboard pseudo-encoding formats
|
|
100
95
|
var extendedClipboardFormatText = 1;
|
|
101
96
|
/*eslint-disable no-unused-vars */
|
|
102
|
-
|
|
103
97
|
var extendedClipboardFormatRtf = 1 << 1;
|
|
104
98
|
var extendedClipboardFormatHtml = 1 << 2;
|
|
105
99
|
var extendedClipboardFormatDib = 1 << 3;
|
|
106
100
|
var extendedClipboardFormatFiles = 1 << 4;
|
|
107
101
|
/*eslint-enable */
|
|
108
|
-
// Extended clipboard pseudo-encoding actions
|
|
109
102
|
|
|
103
|
+
// Extended clipboard pseudo-encoding actions
|
|
110
104
|
var extendedClipboardActionCaps = 1 << 24;
|
|
111
105
|
var extendedClipboardActionRequest = 1 << 25;
|
|
112
106
|
var extendedClipboardActionPeek = 1 << 26;
|
|
113
107
|
var extendedClipboardActionNotify = 1 << 27;
|
|
114
108
|
var extendedClipboardActionProvide = 1 << 28;
|
|
115
|
-
|
|
116
109
|
var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
117
110
|
_inherits(RFB, _EventTargetMixin);
|
|
118
|
-
|
|
119
111
|
var _super = _createSuper(RFB);
|
|
120
|
-
|
|
121
112
|
function RFB(target, urlOrChannel, options) {
|
|
122
113
|
var _this;
|
|
123
|
-
|
|
124
114
|
_classCallCheck(this, RFB);
|
|
125
|
-
|
|
126
115
|
if (!target) {
|
|
127
116
|
throw new Error("Must specify target");
|
|
128
117
|
}
|
|
129
|
-
|
|
130
118
|
if (!urlOrChannel) {
|
|
131
119
|
throw new Error("Must specify URL, WebSocket or RTCDataChannel");
|
|
132
120
|
}
|
|
133
121
|
|
|
122
|
+
// We rely on modern APIs which might not be available in an
|
|
123
|
+
// insecure context
|
|
124
|
+
if (!window.isSecureContext) {
|
|
125
|
+
Log.Error("noVNC requires a secure context (TLS). Expect crashes!");
|
|
126
|
+
}
|
|
134
127
|
_this = _super.call(this);
|
|
135
128
|
_this._target = target;
|
|
136
|
-
|
|
137
129
|
if (typeof urlOrChannel === "string") {
|
|
138
130
|
_this._url = urlOrChannel;
|
|
139
131
|
} else {
|
|
140
132
|
_this._url = null;
|
|
141
133
|
_this._rawChannel = urlOrChannel;
|
|
142
|
-
}
|
|
143
|
-
|
|
134
|
+
}
|
|
144
135
|
|
|
136
|
+
// Connection details
|
|
145
137
|
options = options || {};
|
|
146
138
|
_this._rfbCredentials = options.credentials || {};
|
|
147
139
|
_this._shared = 'shared' in options ? !!options.shared : true;
|
|
148
140
|
_this._repeaterID = options.repeaterID || '';
|
|
149
|
-
_this._wsProtocols = options.wsProtocols || [];
|
|
141
|
+
_this._wsProtocols = options.wsProtocols || [];
|
|
150
142
|
|
|
143
|
+
// Internal state
|
|
151
144
|
_this._rfbConnectionState = '';
|
|
152
145
|
_this._rfbInitState = '';
|
|
153
146
|
_this._rfbAuthScheme = -1;
|
|
154
|
-
_this._rfbCleanDisconnect = true;
|
|
147
|
+
_this._rfbCleanDisconnect = true;
|
|
148
|
+
_this._rfbRSAAESAuthenticationState = null;
|
|
155
149
|
|
|
150
|
+
// Server capabilities
|
|
156
151
|
_this._rfbVersion = 0;
|
|
157
152
|
_this._rfbMaxVersion = 3.8;
|
|
158
153
|
_this._rfbTightVNC = false;
|
|
@@ -173,27 +168,22 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
173
168
|
_this._qemuExtKeyEventSupported = false;
|
|
174
169
|
_this._clipboardText = null;
|
|
175
170
|
_this._clipboardServerCapabilitiesActions = {};
|
|
176
|
-
_this._clipboardServerCapabilitiesFormats = {};
|
|
171
|
+
_this._clipboardServerCapabilitiesFormats = {};
|
|
177
172
|
|
|
173
|
+
// Internal objects
|
|
178
174
|
_this._sock = null; // Websock object
|
|
179
|
-
|
|
180
175
|
_this._display = null; // Display object
|
|
181
|
-
|
|
182
176
|
_this._flushing = false; // Display flushing state
|
|
183
|
-
|
|
184
177
|
_this._keyboard = null; // Keyboard input handler object
|
|
185
|
-
|
|
186
178
|
_this._gestures = null; // Gesture input handler object
|
|
187
|
-
|
|
188
179
|
_this._resizeObserver = null; // Resize observer object
|
|
189
|
-
// Timers
|
|
190
180
|
|
|
181
|
+
// Timers
|
|
191
182
|
_this._disconnTimer = null; // disconnection timer
|
|
192
|
-
|
|
193
183
|
_this._resizeTimeout = null; // resize rate limiting
|
|
184
|
+
_this._mouseMoveTimer = null;
|
|
194
185
|
|
|
195
|
-
|
|
196
|
-
|
|
186
|
+
// Decoder states
|
|
197
187
|
_this._decoders = {};
|
|
198
188
|
_this._FBU = {
|
|
199
189
|
rects: 0,
|
|
@@ -202,8 +192,9 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
202
192
|
width: 0,
|
|
203
193
|
height: 0,
|
|
204
194
|
encoding: null
|
|
205
|
-
};
|
|
195
|
+
};
|
|
206
196
|
|
|
197
|
+
// Mouse state
|
|
207
198
|
_this._mousePos = {};
|
|
208
199
|
_this._mouseButtonMask = 0;
|
|
209
200
|
_this._mouseLastMoveTime = 0;
|
|
@@ -211,23 +202,29 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
211
202
|
_this._viewportDragPos = {};
|
|
212
203
|
_this._viewportHasMoved = false;
|
|
213
204
|
_this._accumulatedWheelDeltaX = 0;
|
|
214
|
-
_this._accumulatedWheelDeltaY = 0;
|
|
205
|
+
_this._accumulatedWheelDeltaY = 0;
|
|
215
206
|
|
|
207
|
+
// Gesture state
|
|
216
208
|
_this._gestureLastTapTime = null;
|
|
217
209
|
_this._gestureFirstDoubleTapEv = null;
|
|
218
210
|
_this._gestureLastMagnitudeX = 0;
|
|
219
|
-
_this._gestureLastMagnitudeY = 0;
|
|
211
|
+
_this._gestureLastMagnitudeY = 0;
|
|
220
212
|
|
|
213
|
+
// Bound event handlers
|
|
221
214
|
_this._eventHandlers = {
|
|
222
215
|
focusCanvas: _this._focusCanvas.bind(_assertThisInitialized(_this)),
|
|
223
216
|
handleResize: _this._handleResize.bind(_assertThisInitialized(_this)),
|
|
224
217
|
handleMouse: _this._handleMouse.bind(_assertThisInitialized(_this)),
|
|
225
218
|
handleWheel: _this._handleWheel.bind(_assertThisInitialized(_this)),
|
|
226
|
-
handleGesture: _this._handleGesture.bind(_assertThisInitialized(_this))
|
|
227
|
-
|
|
219
|
+
handleGesture: _this._handleGesture.bind(_assertThisInitialized(_this)),
|
|
220
|
+
handleRSAAESCredentialsRequired: _this._handleRSAAESCredentialsRequired.bind(_assertThisInitialized(_this)),
|
|
221
|
+
handleRSAAESServerVerification: _this._handleRSAAESServerVerification.bind(_assertThisInitialized(_this))
|
|
222
|
+
};
|
|
228
223
|
|
|
229
|
-
|
|
224
|
+
// main setup
|
|
225
|
+
Log.Debug(">> RFB.constructor");
|
|
230
226
|
|
|
227
|
+
// Create DOM elements
|
|
231
228
|
_this._screen = document.createElement('div');
|
|
232
229
|
_this._screen.style.display = 'flex';
|
|
233
230
|
_this._screen.style.width = '100%';
|
|
@@ -235,17 +232,18 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
235
232
|
_this._screen.style.overflow = 'auto';
|
|
236
233
|
_this._screen.style.background = DEFAULT_BACKGROUND;
|
|
237
234
|
_this._canvas = document.createElement('canvas');
|
|
238
|
-
_this._canvas.style.margin = 'auto';
|
|
239
|
-
|
|
235
|
+
_this._canvas.style.margin = 'auto';
|
|
236
|
+
// Some browsers add an outline on focus
|
|
240
237
|
_this._canvas.style.outline = 'none';
|
|
241
238
|
_this._canvas.width = 0;
|
|
242
239
|
_this._canvas.height = 0;
|
|
243
240
|
_this._canvas.tabIndex = -1;
|
|
241
|
+
_this._screen.appendChild(_this._canvas);
|
|
244
242
|
|
|
245
|
-
|
|
243
|
+
// Cursor
|
|
244
|
+
_this._cursor = new _cursor["default"]();
|
|
246
245
|
|
|
247
|
-
|
|
248
|
-
_this._cursor = new _cursor["default"](); // XXX: TightVNC 2.8.11 sends no cursor at all until Windows changes
|
|
246
|
+
// XXX: TightVNC 2.8.11 sends no cursor at all until Windows changes
|
|
249
247
|
// it. Result: no cursor at all until a window border or an edit field
|
|
250
248
|
// is hit blindly. But there are also VNC servers that draw the cursor
|
|
251
249
|
// in the framebuffer and don't send the empty local cursor. There is
|
|
@@ -254,63 +252,63 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
254
252
|
// The spec is unclear on this "initial cursor" issue. Many other
|
|
255
253
|
// viewers (TigerVNC, RealVNC, Remmina) display an arrow as the
|
|
256
254
|
// initial cursor instead.
|
|
255
|
+
_this._cursorImage = RFB.cursors.none;
|
|
257
256
|
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
// populate decoder array with objects
|
|
260
258
|
_this._decoders[_encodings.encodings.encodingRaw] = new _raw["default"]();
|
|
261
259
|
_this._decoders[_encodings.encodings.encodingCopyRect] = new _copyrect["default"]();
|
|
262
260
|
_this._decoders[_encodings.encodings.encodingRRE] = new _rre["default"]();
|
|
263
261
|
_this._decoders[_encodings.encodings.encodingHextile] = new _hextile["default"]();
|
|
264
262
|
_this._decoders[_encodings.encodings.encodingTight] = new _tight["default"]();
|
|
265
|
-
_this._decoders[_encodings.encodings.encodingTightPNG] = new _tightpng["default"]();
|
|
266
|
-
|
|
263
|
+
_this._decoders[_encodings.encodings.encodingTightPNG] = new _tightpng["default"]();
|
|
264
|
+
_this._decoders[_encodings.encodings.encodingZRLE] = new _zrle["default"]();
|
|
265
|
+
_this._decoders[_encodings.encodings.encodingJPEG] = new _jpeg["default"]();
|
|
267
266
|
|
|
267
|
+
// NB: nothing that needs explicit teardown should be done
|
|
268
|
+
// before this point, since this can throw an exception
|
|
268
269
|
try {
|
|
269
270
|
_this._display = new _display["default"](_this._canvas);
|
|
270
271
|
} catch (exc) {
|
|
271
272
|
Log.Error("Display exception: " + exc);
|
|
272
273
|
throw exc;
|
|
273
274
|
}
|
|
274
|
-
|
|
275
275
|
_this._display.onflush = _this._onFlush.bind(_assertThisInitialized(_this));
|
|
276
276
|
_this._keyboard = new _keyboard["default"](_this._canvas);
|
|
277
277
|
_this._keyboard.onkeyevent = _this._handleKeyEvent.bind(_assertThisInitialized(_this));
|
|
278
278
|
_this._gestures = new _gesturehandler["default"]();
|
|
279
279
|
_this._sock = new _websock["default"]();
|
|
280
|
-
|
|
281
280
|
_this._sock.on('open', _this._socketOpen.bind(_assertThisInitialized(_this)));
|
|
282
|
-
|
|
283
281
|
_this._sock.on('close', _this._socketClose.bind(_assertThisInitialized(_this)));
|
|
284
|
-
|
|
285
282
|
_this._sock.on('message', _this._handleMessage.bind(_assertThisInitialized(_this)));
|
|
286
|
-
|
|
287
283
|
_this._sock.on('error', _this._socketError.bind(_assertThisInitialized(_this)));
|
|
284
|
+
_this._expectedClientWidth = null;
|
|
285
|
+
_this._expectedClientHeight = null;
|
|
286
|
+
_this._resizeObserver = new ResizeObserver(_this._eventHandlers.handleResize);
|
|
288
287
|
|
|
289
|
-
|
|
290
|
-
|
|
288
|
+
// All prepared, kick off the connection
|
|
291
289
|
_this._updateConnectionState('connecting');
|
|
290
|
+
Log.Debug("<< RFB.constructor");
|
|
292
291
|
|
|
293
|
-
|
|
292
|
+
// ===== PROPERTIES =====
|
|
294
293
|
|
|
295
294
|
_this.dragViewport = false;
|
|
296
295
|
_this.focusOnClick = true;
|
|
297
296
|
_this._viewOnly = false;
|
|
298
297
|
_this._clipViewport = false;
|
|
298
|
+
_this._clippingViewport = false;
|
|
299
299
|
_this._scaleViewport = false;
|
|
300
300
|
_this._resizeSession = false;
|
|
301
301
|
_this._showDotCursor = false;
|
|
302
|
-
|
|
303
302
|
if (options.showDotCursor !== undefined) {
|
|
304
303
|
Log.Warn("Specifying showDotCursor as a RFB constructor argument is deprecated");
|
|
305
304
|
_this._showDotCursor = options.showDotCursor;
|
|
306
305
|
}
|
|
307
|
-
|
|
308
306
|
_this._qualityLevel = 6;
|
|
309
307
|
_this._compressionLevel = 2;
|
|
310
308
|
return _this;
|
|
311
|
-
}
|
|
312
|
-
|
|
309
|
+
}
|
|
313
310
|
|
|
311
|
+
// ===== PROPERTIES =====
|
|
314
312
|
_createClass(RFB, [{
|
|
315
313
|
key: "viewOnly",
|
|
316
314
|
get: function get() {
|
|
@@ -318,7 +316,6 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
318
316
|
},
|
|
319
317
|
set: function set(viewOnly) {
|
|
320
318
|
this._viewOnly = viewOnly;
|
|
321
|
-
|
|
322
319
|
if (this._rfbConnectionState === "connecting" || this._rfbConnectionState === "connected") {
|
|
323
320
|
if (viewOnly) {
|
|
324
321
|
this._keyboard.ungrab();
|
|
@@ -332,6 +329,22 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
332
329
|
get: function get() {
|
|
333
330
|
return this._capabilities;
|
|
334
331
|
}
|
|
332
|
+
}, {
|
|
333
|
+
key: "clippingViewport",
|
|
334
|
+
get: function get() {
|
|
335
|
+
return this._clippingViewport;
|
|
336
|
+
}
|
|
337
|
+
}, {
|
|
338
|
+
key: "_setClippingViewport",
|
|
339
|
+
value: function _setClippingViewport(on) {
|
|
340
|
+
if (on === this._clippingViewport) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
this._clippingViewport = on;
|
|
344
|
+
this.dispatchEvent(new CustomEvent("clippingviewport", {
|
|
345
|
+
detail: this._clippingViewport
|
|
346
|
+
}));
|
|
347
|
+
}
|
|
335
348
|
}, {
|
|
336
349
|
key: "touchButton",
|
|
337
350
|
get: function get() {
|
|
@@ -347,7 +360,6 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
347
360
|
},
|
|
348
361
|
set: function set(viewport) {
|
|
349
362
|
this._clipViewport = viewport;
|
|
350
|
-
|
|
351
363
|
this._updateClip();
|
|
352
364
|
}
|
|
353
365
|
}, {
|
|
@@ -356,15 +368,13 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
356
368
|
return this._scaleViewport;
|
|
357
369
|
},
|
|
358
370
|
set: function set(scale) {
|
|
359
|
-
this._scaleViewport = scale;
|
|
371
|
+
this._scaleViewport = scale;
|
|
372
|
+
// Scaling trumps clipping, so we may need to adjust
|
|
360
373
|
// clipping when enabling or disabling scaling
|
|
361
|
-
|
|
362
374
|
if (scale && this._clipViewport) {
|
|
363
375
|
this._updateClip();
|
|
364
376
|
}
|
|
365
|
-
|
|
366
377
|
this._updateScale();
|
|
367
|
-
|
|
368
378
|
if (!scale && this._clipViewport) {
|
|
369
379
|
this._updateClip();
|
|
370
380
|
}
|
|
@@ -376,7 +386,6 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
376
386
|
},
|
|
377
387
|
set: function set(resize) {
|
|
378
388
|
this._resizeSession = resize;
|
|
379
|
-
|
|
380
389
|
if (resize) {
|
|
381
390
|
this._requestRemoteResize();
|
|
382
391
|
}
|
|
@@ -388,7 +397,6 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
388
397
|
},
|
|
389
398
|
set: function set(show) {
|
|
390
399
|
this._showDotCursor = show;
|
|
391
|
-
|
|
392
400
|
this._refreshCursor();
|
|
393
401
|
}
|
|
394
402
|
}, {
|
|
@@ -409,13 +417,10 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
409
417
|
Log.Error("qualityLevel must be an integer between 0 and 9");
|
|
410
418
|
return;
|
|
411
419
|
}
|
|
412
|
-
|
|
413
420
|
if (this._qualityLevel === qualityLevel) {
|
|
414
421
|
return;
|
|
415
422
|
}
|
|
416
|
-
|
|
417
423
|
this._qualityLevel = qualityLevel;
|
|
418
|
-
|
|
419
424
|
if (this._rfbConnectionState === 'connected') {
|
|
420
425
|
this._sendEncodings();
|
|
421
426
|
}
|
|
@@ -430,34 +435,39 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
430
435
|
Log.Error("compressionLevel must be an integer between 0 and 9");
|
|
431
436
|
return;
|
|
432
437
|
}
|
|
433
|
-
|
|
434
438
|
if (this._compressionLevel === compressionLevel) {
|
|
435
439
|
return;
|
|
436
440
|
}
|
|
437
|
-
|
|
438
441
|
this._compressionLevel = compressionLevel;
|
|
439
|
-
|
|
440
442
|
if (this._rfbConnectionState === 'connected') {
|
|
441
443
|
this._sendEncodings();
|
|
442
444
|
}
|
|
443
|
-
}
|
|
445
|
+
}
|
|
444
446
|
|
|
447
|
+
// ===== PUBLIC METHODS =====
|
|
445
448
|
}, {
|
|
446
449
|
key: "disconnect",
|
|
447
450
|
value: function disconnect() {
|
|
448
451
|
this._updateConnectionState('disconnecting');
|
|
449
|
-
|
|
450
452
|
this._sock.off('error');
|
|
451
|
-
|
|
452
453
|
this._sock.off('message');
|
|
453
|
-
|
|
454
454
|
this._sock.off('open');
|
|
455
|
+
if (this._rfbRSAAESAuthenticationState !== null) {
|
|
456
|
+
this._rfbRSAAESAuthenticationState.disconnect();
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}, {
|
|
460
|
+
key: "approveServer",
|
|
461
|
+
value: function approveServer() {
|
|
462
|
+
if (this._rfbRSAAESAuthenticationState !== null) {
|
|
463
|
+
this._rfbRSAAESAuthenticationState.approveServer();
|
|
464
|
+
}
|
|
455
465
|
}
|
|
456
466
|
}, {
|
|
457
467
|
key: "sendCredentials",
|
|
458
468
|
value: function sendCredentials(creds) {
|
|
459
469
|
this._rfbCredentials = creds;
|
|
460
|
-
|
|
470
|
+
this._resumeAuthentication();
|
|
461
471
|
}
|
|
462
472
|
}, {
|
|
463
473
|
key: "sendCtrlAltDel",
|
|
@@ -465,7 +475,6 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
465
475
|
if (this._rfbConnectionState !== 'connected' || this._viewOnly) {
|
|
466
476
|
return;
|
|
467
477
|
}
|
|
468
|
-
|
|
469
478
|
Log.Info("Sending Ctrl-Alt-Del");
|
|
470
479
|
this.sendKey(_keysym["default"].XK_Control_L, "ControlLeft", true);
|
|
471
480
|
this.sendKey(_keysym["default"].XK_Alt_L, "AltLeft", true);
|
|
@@ -488,24 +497,22 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
488
497
|
key: "machineReset",
|
|
489
498
|
value: function machineReset() {
|
|
490
499
|
this._xvpOp(1, 4);
|
|
491
|
-
}
|
|
492
|
-
// followed by an up key.
|
|
500
|
+
}
|
|
493
501
|
|
|
502
|
+
// Send a key press. If 'down' is not specified then send a down key
|
|
503
|
+
// followed by an up key.
|
|
494
504
|
}, {
|
|
495
505
|
key: "sendKey",
|
|
496
506
|
value: function sendKey(keysym, code, down) {
|
|
497
507
|
if (this._rfbConnectionState !== 'connected' || this._viewOnly) {
|
|
498
508
|
return;
|
|
499
509
|
}
|
|
500
|
-
|
|
501
510
|
if (down === undefined) {
|
|
502
511
|
this.sendKey(keysym, code, true);
|
|
503
512
|
this.sendKey(keysym, code, false);
|
|
504
513
|
return;
|
|
505
514
|
}
|
|
506
|
-
|
|
507
515
|
var scancode = _xtscancodes["default"][code];
|
|
508
|
-
|
|
509
516
|
if (this._qemuExtKeyEventSupported && scancode) {
|
|
510
517
|
// 0 is NoSymbol
|
|
511
518
|
keysym = keysym || 0;
|
|
@@ -515,15 +522,14 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
515
522
|
if (!keysym) {
|
|
516
523
|
return;
|
|
517
524
|
}
|
|
518
|
-
|
|
519
525
|
Log.Info("Sending keysym (" + (down ? "down" : "up") + "): " + keysym);
|
|
520
526
|
RFB.messages.keyEvent(this._sock, keysym, down ? 1 : 0);
|
|
521
527
|
}
|
|
522
528
|
}
|
|
523
529
|
}, {
|
|
524
530
|
key: "focus",
|
|
525
|
-
value: function focus() {
|
|
526
|
-
this._canvas.focus();
|
|
531
|
+
value: function focus(options) {
|
|
532
|
+
this._canvas.focus(options);
|
|
527
533
|
}
|
|
528
534
|
}, {
|
|
529
535
|
key: "blur",
|
|
@@ -536,138 +542,150 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
536
542
|
if (this._rfbConnectionState !== 'connected' || this._viewOnly) {
|
|
537
543
|
return;
|
|
538
544
|
}
|
|
539
|
-
|
|
540
545
|
if (this._clipboardServerCapabilitiesFormats[extendedClipboardFormatText] && this._clipboardServerCapabilitiesActions[extendedClipboardActionNotify]) {
|
|
541
546
|
this._clipboardText = text;
|
|
542
547
|
RFB.messages.extendedClipboardNotify(this._sock, [extendedClipboardFormatText]);
|
|
543
548
|
} else {
|
|
544
|
-
var
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
+
var length, i;
|
|
550
|
+
var data;
|
|
551
|
+
length = 0;
|
|
552
|
+
// eslint-disable-next-line no-unused-vars
|
|
553
|
+
var _iterator = _createForOfIteratorHelper(text),
|
|
554
|
+
_step;
|
|
555
|
+
try {
|
|
556
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
557
|
+
var codePoint = _step.value;
|
|
558
|
+
length++;
|
|
559
|
+
}
|
|
560
|
+
} catch (err) {
|
|
561
|
+
_iterator.e(err);
|
|
562
|
+
} finally {
|
|
563
|
+
_iterator.f();
|
|
549
564
|
}
|
|
565
|
+
data = new Uint8Array(length);
|
|
566
|
+
i = 0;
|
|
567
|
+
var _iterator2 = _createForOfIteratorHelper(text),
|
|
568
|
+
_step2;
|
|
569
|
+
try {
|
|
570
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
571
|
+
var _codePoint = _step2.value;
|
|
572
|
+
var code = _codePoint.codePointAt(0);
|
|
573
|
+
|
|
574
|
+
/* Only ISO 8859-1 is supported */
|
|
575
|
+
if (code > 0xff) {
|
|
576
|
+
code = 0x3f; // '?'
|
|
577
|
+
}
|
|
550
578
|
|
|
579
|
+
data[i++] = code;
|
|
580
|
+
}
|
|
581
|
+
} catch (err) {
|
|
582
|
+
_iterator2.e(err);
|
|
583
|
+
} finally {
|
|
584
|
+
_iterator2.f();
|
|
585
|
+
}
|
|
551
586
|
RFB.messages.clientCutText(this._sock, data);
|
|
552
587
|
}
|
|
553
|
-
}
|
|
588
|
+
}
|
|
589
|
+
}, {
|
|
590
|
+
key: "getImageData",
|
|
591
|
+
value: function getImageData() {
|
|
592
|
+
return this._display.getImageData();
|
|
593
|
+
}
|
|
594
|
+
}, {
|
|
595
|
+
key: "toDataURL",
|
|
596
|
+
value: function toDataURL(type, encoderOptions) {
|
|
597
|
+
return this._display.toDataURL(type, encoderOptions);
|
|
598
|
+
}
|
|
599
|
+
}, {
|
|
600
|
+
key: "toBlob",
|
|
601
|
+
value: function toBlob(callback, type, quality) {
|
|
602
|
+
return this._display.toBlob(callback, type, quality);
|
|
603
|
+
}
|
|
554
604
|
|
|
605
|
+
// ===== PRIVATE METHODS =====
|
|
555
606
|
}, {
|
|
556
607
|
key: "_connect",
|
|
557
608
|
value: function _connect() {
|
|
558
609
|
Log.Debug(">> RFB.connect");
|
|
559
|
-
|
|
560
610
|
if (this._url) {
|
|
561
611
|
Log.Info("connecting to ".concat(this._url));
|
|
562
|
-
|
|
563
612
|
this._sock.open(this._url, this._wsProtocols);
|
|
564
613
|
} else {
|
|
565
614
|
Log.Info("attaching ".concat(this._rawChannel, " to Websock"));
|
|
566
|
-
|
|
567
615
|
this._sock.attach(this._rawChannel);
|
|
568
|
-
|
|
569
616
|
if (this._sock.readyState === 'closed') {
|
|
570
617
|
throw Error("Cannot use already closed WebSocket/RTCDataChannel");
|
|
571
618
|
}
|
|
572
|
-
|
|
573
619
|
if (this._sock.readyState === 'open') {
|
|
574
620
|
// FIXME: _socketOpen() can in theory call _fail(), which
|
|
575
621
|
// isn't allowed this early, but I'm not sure that can
|
|
576
622
|
// happen without a bug messing up our state variables
|
|
577
623
|
this._socketOpen();
|
|
578
624
|
}
|
|
579
|
-
}
|
|
580
|
-
|
|
625
|
+
}
|
|
581
626
|
|
|
627
|
+
// Make our elements part of the page
|
|
582
628
|
this._target.appendChild(this._screen);
|
|
583
|
-
|
|
584
629
|
this._gestures.attach(this._canvas);
|
|
585
|
-
|
|
586
630
|
this._cursor.attach(this._canvas);
|
|
631
|
+
this._refreshCursor();
|
|
587
632
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
this._resizeObserver.observe(this._screen); // Always grab focus on some kind of click event
|
|
592
|
-
|
|
633
|
+
// Monitor size changes of the screen element
|
|
634
|
+
this._resizeObserver.observe(this._screen);
|
|
593
635
|
|
|
636
|
+
// Always grab focus on some kind of click event
|
|
594
637
|
this._canvas.addEventListener("mousedown", this._eventHandlers.focusCanvas);
|
|
638
|
+
this._canvas.addEventListener("touchstart", this._eventHandlers.focusCanvas);
|
|
595
639
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
640
|
+
// Mouse events
|
|
599
641
|
this._canvas.addEventListener('mousedown', this._eventHandlers.handleMouse);
|
|
600
|
-
|
|
601
642
|
this._canvas.addEventListener('mouseup', this._eventHandlers.handleMouse);
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
this._canvas.addEventListener('click', this._eventHandlers.handleMouse); // preventDefault() on mousedown doesn't stop this event for some
|
|
643
|
+
this._canvas.addEventListener('mousemove', this._eventHandlers.handleMouse);
|
|
644
|
+
// Prevent middle-click pasting (see handler for why we bind to document)
|
|
645
|
+
this._canvas.addEventListener('click', this._eventHandlers.handleMouse);
|
|
646
|
+
// preventDefault() on mousedown doesn't stop this event for some
|
|
607
647
|
// reason so we have to explicitly block it
|
|
648
|
+
this._canvas.addEventListener('contextmenu', this._eventHandlers.handleMouse);
|
|
608
649
|
|
|
650
|
+
// Wheel events
|
|
651
|
+
this._canvas.addEventListener("wheel", this._eventHandlers.handleWheel);
|
|
609
652
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
this._canvas.addEventListener("wheel", this._eventHandlers.handleWheel); // Gesture events
|
|
614
|
-
|
|
615
|
-
|
|
653
|
+
// Gesture events
|
|
616
654
|
this._canvas.addEventListener("gesturestart", this._eventHandlers.handleGesture);
|
|
617
|
-
|
|
618
655
|
this._canvas.addEventListener("gesturemove", this._eventHandlers.handleGesture);
|
|
619
|
-
|
|
620
656
|
this._canvas.addEventListener("gestureend", this._eventHandlers.handleGesture);
|
|
621
|
-
|
|
622
657
|
Log.Debug("<< RFB.connect");
|
|
623
658
|
}
|
|
624
659
|
}, {
|
|
625
660
|
key: "_disconnect",
|
|
626
661
|
value: function _disconnect() {
|
|
627
662
|
Log.Debug(">> RFB.disconnect");
|
|
628
|
-
|
|
629
663
|
this._cursor.detach();
|
|
630
|
-
|
|
631
664
|
this._canvas.removeEventListener("gesturestart", this._eventHandlers.handleGesture);
|
|
632
|
-
|
|
633
665
|
this._canvas.removeEventListener("gesturemove", this._eventHandlers.handleGesture);
|
|
634
|
-
|
|
635
666
|
this._canvas.removeEventListener("gestureend", this._eventHandlers.handleGesture);
|
|
636
|
-
|
|
637
667
|
this._canvas.removeEventListener("wheel", this._eventHandlers.handleWheel);
|
|
638
|
-
|
|
639
668
|
this._canvas.removeEventListener('mousedown', this._eventHandlers.handleMouse);
|
|
640
|
-
|
|
641
669
|
this._canvas.removeEventListener('mouseup', this._eventHandlers.handleMouse);
|
|
642
|
-
|
|
643
670
|
this._canvas.removeEventListener('mousemove', this._eventHandlers.handleMouse);
|
|
644
|
-
|
|
645
671
|
this._canvas.removeEventListener('click', this._eventHandlers.handleMouse);
|
|
646
|
-
|
|
647
672
|
this._canvas.removeEventListener('contextmenu', this._eventHandlers.handleMouse);
|
|
648
|
-
|
|
649
673
|
this._canvas.removeEventListener("mousedown", this._eventHandlers.focusCanvas);
|
|
650
|
-
|
|
651
674
|
this._canvas.removeEventListener("touchstart", this._eventHandlers.focusCanvas);
|
|
652
|
-
|
|
653
675
|
this._resizeObserver.disconnect();
|
|
654
|
-
|
|
655
676
|
this._keyboard.ungrab();
|
|
656
|
-
|
|
657
677
|
this._gestures.detach();
|
|
658
|
-
|
|
659
678
|
this._sock.close();
|
|
660
|
-
|
|
661
679
|
try {
|
|
662
680
|
this._target.removeChild(this._screen);
|
|
663
681
|
} catch (e) {
|
|
664
|
-
if (e.name === 'NotFoundError') {
|
|
682
|
+
if (e.name === 'NotFoundError') {
|
|
683
|
+
// Some cases where the initial connection fails
|
|
665
684
|
// can disconnect before the _screen is created
|
|
666
685
|
} else {
|
|
667
686
|
throw e;
|
|
668
687
|
}
|
|
669
688
|
}
|
|
670
|
-
|
|
671
689
|
clearTimeout(this._resizeTimeout);
|
|
672
690
|
clearTimeout(this._mouseMoveTimer);
|
|
673
691
|
Log.Debug("<< RFB.disconnect");
|
|
@@ -687,51 +705,35 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
687
705
|
value: function _socketClose(e) {
|
|
688
706
|
Log.Debug("WebSocket on-close event");
|
|
689
707
|
var msg = "";
|
|
690
|
-
|
|
691
708
|
if (e.code) {
|
|
692
709
|
msg = "(code: " + e.code;
|
|
693
|
-
|
|
694
710
|
if (e.reason) {
|
|
695
711
|
msg += ", reason: " + e.reason;
|
|
696
712
|
}
|
|
697
|
-
|
|
698
713
|
msg += ")";
|
|
699
714
|
}
|
|
700
|
-
|
|
701
715
|
switch (this._rfbConnectionState) {
|
|
702
716
|
case 'connecting':
|
|
703
717
|
this._fail("Connection closed " + msg);
|
|
704
|
-
|
|
705
718
|
break;
|
|
706
|
-
|
|
707
719
|
case 'connected':
|
|
708
720
|
// Handle disconnects that were initiated server-side
|
|
709
721
|
this._updateConnectionState('disconnecting');
|
|
710
|
-
|
|
711
722
|
this._updateConnectionState('disconnected');
|
|
712
|
-
|
|
713
723
|
break;
|
|
714
|
-
|
|
715
724
|
case 'disconnecting':
|
|
716
725
|
// Normal disconnection path
|
|
717
726
|
this._updateConnectionState('disconnected');
|
|
718
|
-
|
|
719
727
|
break;
|
|
720
|
-
|
|
721
728
|
case 'disconnected':
|
|
722
729
|
this._fail("Unexpected server disconnect " + "when already disconnected " + msg);
|
|
723
|
-
|
|
724
730
|
break;
|
|
725
|
-
|
|
726
731
|
default:
|
|
727
732
|
this._fail("Unexpected server disconnect before connecting " + msg);
|
|
728
|
-
|
|
729
733
|
break;
|
|
730
734
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
+
this._sock.off('close');
|
|
736
|
+
// Delete reference to raw channel to allow cleanup.
|
|
735
737
|
this._rawChannel = null;
|
|
736
738
|
}
|
|
737
739
|
}, {
|
|
@@ -745,8 +747,9 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
745
747
|
if (!this.focusOnClick) {
|
|
746
748
|
return;
|
|
747
749
|
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
+
this.focus({
|
|
751
|
+
preventScroll: true
|
|
752
|
+
});
|
|
750
753
|
}
|
|
751
754
|
}, {
|
|
752
755
|
key: "_setDesktopName",
|
|
@@ -758,53 +761,80 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
758
761
|
}
|
|
759
762
|
}));
|
|
760
763
|
}
|
|
764
|
+
}, {
|
|
765
|
+
key: "_saveExpectedClientSize",
|
|
766
|
+
value: function _saveExpectedClientSize() {
|
|
767
|
+
this._expectedClientWidth = this._screen.clientWidth;
|
|
768
|
+
this._expectedClientHeight = this._screen.clientHeight;
|
|
769
|
+
}
|
|
770
|
+
}, {
|
|
771
|
+
key: "_currentClientSize",
|
|
772
|
+
value: function _currentClientSize() {
|
|
773
|
+
return [this._screen.clientWidth, this._screen.clientHeight];
|
|
774
|
+
}
|
|
775
|
+
}, {
|
|
776
|
+
key: "_clientHasExpectedSize",
|
|
777
|
+
value: function _clientHasExpectedSize() {
|
|
778
|
+
var _this$_currentClientS = this._currentClientSize(),
|
|
779
|
+
_this$_currentClientS2 = _slicedToArray(_this$_currentClientS, 2),
|
|
780
|
+
currentWidth = _this$_currentClientS2[0],
|
|
781
|
+
currentHeight = _this$_currentClientS2[1];
|
|
782
|
+
return currentWidth == this._expectedClientWidth && currentHeight == this._expectedClientHeight;
|
|
783
|
+
}
|
|
761
784
|
}, {
|
|
762
785
|
key: "_handleResize",
|
|
763
786
|
value: function _handleResize() {
|
|
764
787
|
var _this2 = this;
|
|
765
|
-
|
|
788
|
+
// Don't change anything if the client size is already as expected
|
|
789
|
+
if (this._clientHasExpectedSize()) {
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
766
792
|
// If the window resized then our screen element might have
|
|
767
793
|
// as well. Update the viewport dimensions.
|
|
768
794
|
window.requestAnimationFrame(function () {
|
|
769
795
|
_this2._updateClip();
|
|
770
|
-
|
|
771
796
|
_this2._updateScale();
|
|
772
797
|
});
|
|
773
|
-
|
|
774
798
|
if (this._resizeSession) {
|
|
775
799
|
// Request changing the resolution of the remote display to
|
|
776
800
|
// the size of the local browser viewport.
|
|
801
|
+
|
|
777
802
|
// In order to not send multiple requests before the browser-resize
|
|
778
803
|
// is finished we wait 0.5 seconds before sending the request.
|
|
779
804
|
clearTimeout(this._resizeTimeout);
|
|
780
805
|
this._resizeTimeout = setTimeout(this._requestRemoteResize.bind(this), 500);
|
|
781
806
|
}
|
|
782
|
-
}
|
|
783
|
-
// configured viewport matches the current screen size
|
|
807
|
+
}
|
|
784
808
|
|
|
809
|
+
// Update state of clipping in Display object, and make sure the
|
|
810
|
+
// configured viewport matches the current screen size
|
|
785
811
|
}, {
|
|
786
812
|
key: "_updateClip",
|
|
787
813
|
value: function _updateClip() {
|
|
788
814
|
var curClip = this._display.clipViewport;
|
|
789
815
|
var newClip = this._clipViewport;
|
|
790
|
-
|
|
791
816
|
if (this._scaleViewport) {
|
|
792
817
|
// Disable viewport clipping if we are scaling
|
|
793
818
|
newClip = false;
|
|
794
819
|
}
|
|
795
|
-
|
|
796
820
|
if (curClip !== newClip) {
|
|
797
821
|
this._display.clipViewport = newClip;
|
|
798
822
|
}
|
|
799
|
-
|
|
800
823
|
if (newClip) {
|
|
801
824
|
// When clipping is enabled, the screen is limited to
|
|
802
825
|
// the size of the container.
|
|
803
826
|
var size = this._screenSize();
|
|
804
|
-
|
|
805
827
|
this._display.viewportChangeSize(size.w, size.h);
|
|
806
|
-
|
|
807
828
|
this._fixScrollbars();
|
|
829
|
+
this._setClippingViewport(size.w < this._display.width || size.h < this._display.height);
|
|
830
|
+
} else {
|
|
831
|
+
this._setClippingViewport(false);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// When changing clipping we might show or hide scrollbars.
|
|
835
|
+
// This causes the expected client dimensions to change.
|
|
836
|
+
if (curClip !== newClip) {
|
|
837
|
+
this._saveExpectedClientSize();
|
|
808
838
|
}
|
|
809
839
|
}
|
|
810
840
|
}, {
|
|
@@ -814,35 +844,31 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
814
844
|
this._display.scale = 1.0;
|
|
815
845
|
} else {
|
|
816
846
|
var size = this._screenSize();
|
|
817
|
-
|
|
818
847
|
this._display.autoscale(size.w, size.h);
|
|
819
848
|
}
|
|
820
|
-
|
|
821
849
|
this._fixScrollbars();
|
|
822
|
-
}
|
|
823
|
-
// and may only be sent if we have received an ExtendedDesktopSize message
|
|
850
|
+
}
|
|
824
851
|
|
|
852
|
+
// Requests a change of remote desktop size. This message is an extension
|
|
853
|
+
// and may only be sent if we have received an ExtendedDesktopSize message
|
|
825
854
|
}, {
|
|
826
855
|
key: "_requestRemoteResize",
|
|
827
856
|
value: function _requestRemoteResize() {
|
|
828
857
|
clearTimeout(this._resizeTimeout);
|
|
829
858
|
this._resizeTimeout = null;
|
|
830
|
-
|
|
831
859
|
if (!this._resizeSession || this._viewOnly || !this._supportsSetDesktopSize) {
|
|
832
860
|
return;
|
|
833
861
|
}
|
|
834
|
-
|
|
835
862
|
var size = this._screenSize();
|
|
836
|
-
|
|
837
863
|
RFB.messages.setDesktopSize(this._sock, Math.floor(size.w), Math.floor(size.h), this._screenID, this._screenFlags);
|
|
838
864
|
Log.Debug('Requested new desktop size: ' + size.w + 'x' + size.h);
|
|
839
|
-
}
|
|
865
|
+
}
|
|
840
866
|
|
|
867
|
+
// Gets the the size of the available screen
|
|
841
868
|
}, {
|
|
842
869
|
key: "_screenSize",
|
|
843
870
|
value: function _screenSize() {
|
|
844
871
|
var r = this._screen.getBoundingClientRect();
|
|
845
|
-
|
|
846
872
|
return {
|
|
847
873
|
w: r.width,
|
|
848
874
|
h: r.height
|
|
@@ -851,17 +877,18 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
851
877
|
}, {
|
|
852
878
|
key: "_fixScrollbars",
|
|
853
879
|
value: function _fixScrollbars() {
|
|
854
|
-
// This is a hack because
|
|
855
|
-
// for when scrollbars are needed.
|
|
856
|
-
//
|
|
880
|
+
// This is a hack because Safari on macOS screws up the calculation
|
|
881
|
+
// for when scrollbars are needed. We get scrollbars when making the
|
|
882
|
+
// browser smaller, despite remote resize being enabled. So to fix it
|
|
883
|
+
// we temporarily toggle them off and on.
|
|
857
884
|
var orig = this._screen.style.overflow;
|
|
858
|
-
this._screen.style.overflow = 'hidden';
|
|
885
|
+
this._screen.style.overflow = 'hidden';
|
|
886
|
+
// Force Safari to recalculate the layout by asking for
|
|
859
887
|
// an element's dimensions
|
|
860
|
-
|
|
861
888
|
this._screen.getBoundingClientRect();
|
|
862
|
-
|
|
863
889
|
this._screen.style.overflow = orig;
|
|
864
890
|
}
|
|
891
|
+
|
|
865
892
|
/*
|
|
866
893
|
* Connection states:
|
|
867
894
|
* connecting
|
|
@@ -869,98 +896,81 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
869
896
|
* disconnecting
|
|
870
897
|
* disconnected - permanent state
|
|
871
898
|
*/
|
|
872
|
-
|
|
873
899
|
}, {
|
|
874
900
|
key: "_updateConnectionState",
|
|
875
901
|
value: function _updateConnectionState(state) {
|
|
876
902
|
var _this3 = this;
|
|
877
|
-
|
|
878
903
|
var oldstate = this._rfbConnectionState;
|
|
879
|
-
|
|
880
904
|
if (state === oldstate) {
|
|
881
905
|
Log.Debug("Already in state '" + state + "', ignoring");
|
|
882
906
|
return;
|
|
883
|
-
}
|
|
884
|
-
|
|
907
|
+
}
|
|
885
908
|
|
|
909
|
+
// The 'disconnected' state is permanent for each RFB object
|
|
886
910
|
if (oldstate === 'disconnected') {
|
|
887
911
|
Log.Error("Tried changing state of a disconnected RFB object");
|
|
888
912
|
return;
|
|
889
|
-
}
|
|
890
|
-
|
|
913
|
+
}
|
|
891
914
|
|
|
915
|
+
// Ensure proper transitions before doing anything
|
|
892
916
|
switch (state) {
|
|
893
917
|
case 'connected':
|
|
894
918
|
if (oldstate !== 'connecting') {
|
|
895
919
|
Log.Error("Bad transition to connected state, " + "previous connection state: " + oldstate);
|
|
896
920
|
return;
|
|
897
921
|
}
|
|
898
|
-
|
|
899
922
|
break;
|
|
900
|
-
|
|
901
923
|
case 'disconnected':
|
|
902
924
|
if (oldstate !== 'disconnecting') {
|
|
903
925
|
Log.Error("Bad transition to disconnected state, " + "previous connection state: " + oldstate);
|
|
904
926
|
return;
|
|
905
927
|
}
|
|
906
|
-
|
|
907
928
|
break;
|
|
908
|
-
|
|
909
929
|
case 'connecting':
|
|
910
930
|
if (oldstate !== '') {
|
|
911
931
|
Log.Error("Bad transition to connecting state, " + "previous connection state: " + oldstate);
|
|
912
932
|
return;
|
|
913
933
|
}
|
|
914
|
-
|
|
915
934
|
break;
|
|
916
|
-
|
|
917
935
|
case 'disconnecting':
|
|
918
936
|
if (oldstate !== 'connected' && oldstate !== 'connecting') {
|
|
919
937
|
Log.Error("Bad transition to disconnecting state, " + "previous connection state: " + oldstate);
|
|
920
938
|
return;
|
|
921
939
|
}
|
|
922
|
-
|
|
923
940
|
break;
|
|
924
|
-
|
|
925
941
|
default:
|
|
926
942
|
Log.Error("Unknown connection state: " + state);
|
|
927
943
|
return;
|
|
928
|
-
}
|
|
944
|
+
}
|
|
929
945
|
|
|
946
|
+
// State change actions
|
|
930
947
|
|
|
931
948
|
this._rfbConnectionState = state;
|
|
932
949
|
Log.Debug("New state '" + state + "', was '" + oldstate + "'.");
|
|
933
|
-
|
|
934
950
|
if (this._disconnTimer && state !== 'disconnecting') {
|
|
935
951
|
Log.Debug("Clearing disconnect timer");
|
|
936
952
|
clearTimeout(this._disconnTimer);
|
|
937
|
-
this._disconnTimer = null;
|
|
953
|
+
this._disconnTimer = null;
|
|
938
954
|
|
|
955
|
+
// make sure we don't get a double event
|
|
939
956
|
this._sock.off('close');
|
|
940
957
|
}
|
|
941
|
-
|
|
942
958
|
switch (state) {
|
|
943
959
|
case 'connecting':
|
|
944
960
|
this._connect();
|
|
945
|
-
|
|
946
961
|
break;
|
|
947
|
-
|
|
948
962
|
case 'connected':
|
|
949
963
|
this.dispatchEvent(new CustomEvent("connect", {
|
|
950
964
|
detail: {}
|
|
951
965
|
}));
|
|
952
966
|
break;
|
|
953
|
-
|
|
954
967
|
case 'disconnecting':
|
|
955
968
|
this._disconnect();
|
|
956
|
-
|
|
957
969
|
this._disconnTimer = setTimeout(function () {
|
|
958
970
|
Log.Error("Disconnection timed out.");
|
|
959
|
-
|
|
960
971
|
_this3._updateConnectionState('disconnected');
|
|
961
972
|
}, DISCONNECT_TIMEOUT * 1000);
|
|
962
973
|
break;
|
|
963
|
-
|
|
964
974
|
case 'disconnected':
|
|
965
975
|
this.dispatchEvent(new CustomEvent("disconnect", {
|
|
966
976
|
detail: {
|
|
@@ -970,12 +980,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
970
980
|
break;
|
|
971
981
|
}
|
|
972
982
|
}
|
|
983
|
+
|
|
973
984
|
/* Print errors and disconnect
|
|
974
985
|
*
|
|
975
986
|
* The parameter 'details' is used for information that
|
|
976
987
|
* should be logged but not sent to the user interface.
|
|
977
988
|
*/
|
|
978
|
-
|
|
979
989
|
}, {
|
|
980
990
|
key: "_fail",
|
|
981
991
|
value: function _fail(details) {
|
|
@@ -983,27 +993,21 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
983
993
|
case 'disconnecting':
|
|
984
994
|
Log.Error("Failed when disconnecting: " + details);
|
|
985
995
|
break;
|
|
986
|
-
|
|
987
996
|
case 'connected':
|
|
988
997
|
Log.Error("Failed while connected: " + details);
|
|
989
998
|
break;
|
|
990
|
-
|
|
991
999
|
case 'connecting':
|
|
992
1000
|
Log.Error("Failed when connecting: " + details);
|
|
993
1001
|
break;
|
|
994
|
-
|
|
995
1002
|
default:
|
|
996
1003
|
Log.Error("RFB failure: " + details);
|
|
997
1004
|
break;
|
|
998
1005
|
}
|
|
999
|
-
|
|
1000
1006
|
this._rfbCleanDisconnect = false; //This is sent to the UI
|
|
1001
|
-
// Transition to disconnected without waiting for socket to close
|
|
1002
1007
|
|
|
1008
|
+
// Transition to disconnected without waiting for socket to close
|
|
1003
1009
|
this._updateConnectionState('disconnecting');
|
|
1004
|
-
|
|
1005
1010
|
this._updateConnectionState('disconnected');
|
|
1006
|
-
|
|
1007
1011
|
return false;
|
|
1008
1012
|
}
|
|
1009
1013
|
}, {
|
|
@@ -1023,32 +1027,32 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1023
1027
|
Log.Warn("handleMessage called on an empty receive queue");
|
|
1024
1028
|
return;
|
|
1025
1029
|
}
|
|
1026
|
-
|
|
1027
1030
|
switch (this._rfbConnectionState) {
|
|
1028
1031
|
case 'disconnected':
|
|
1029
1032
|
Log.Error("Got data while disconnected");
|
|
1030
1033
|
break;
|
|
1031
|
-
|
|
1032
1034
|
case 'connected':
|
|
1033
1035
|
while (true) {
|
|
1034
1036
|
if (this._flushing) {
|
|
1035
1037
|
break;
|
|
1036
1038
|
}
|
|
1037
|
-
|
|
1038
1039
|
if (!this._normalMsg()) {
|
|
1039
1040
|
break;
|
|
1040
1041
|
}
|
|
1041
|
-
|
|
1042
1042
|
if (this._sock.rQlen === 0) {
|
|
1043
1043
|
break;
|
|
1044
1044
|
}
|
|
1045
1045
|
}
|
|
1046
|
-
|
|
1047
1046
|
break;
|
|
1048
|
-
|
|
1047
|
+
case 'connecting':
|
|
1048
|
+
while (this._rfbConnectionState === 'connecting') {
|
|
1049
|
+
if (!this._initMsg()) {
|
|
1050
|
+
break;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
break;
|
|
1049
1054
|
default:
|
|
1050
|
-
|
|
1051
|
-
|
|
1055
|
+
Log.Error("Got data while in an invalid state");
|
|
1052
1056
|
break;
|
|
1053
1057
|
}
|
|
1054
1058
|
}
|
|
@@ -1064,6 +1068,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1064
1068
|
* We don't check connection status or viewOnly here as the
|
|
1065
1069
|
* mouse events might be used to control the viewport
|
|
1066
1070
|
*/
|
|
1071
|
+
|
|
1067
1072
|
if (ev.type === 'click') {
|
|
1068
1073
|
/*
|
|
1069
1074
|
* Note: This is only needed for the 'click' event as it fails
|
|
@@ -1073,35 +1078,26 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1073
1078
|
if (ev.target !== this._canvas) {
|
|
1074
1079
|
return;
|
|
1075
1080
|
}
|
|
1076
|
-
}
|
|
1077
|
-
// should we stop events?
|
|
1078
|
-
|
|
1081
|
+
}
|
|
1079
1082
|
|
|
1083
|
+
// FIXME: if we're in view-only and not dragging,
|
|
1084
|
+
// should we stop events?
|
|
1080
1085
|
ev.stopPropagation();
|
|
1081
1086
|
ev.preventDefault();
|
|
1082
|
-
|
|
1083
1087
|
if (ev.type === 'click' || ev.type === 'contextmenu') {
|
|
1084
1088
|
return;
|
|
1085
1089
|
}
|
|
1086
|
-
|
|
1087
1090
|
var pos = (0, _element.clientToElement)(ev.clientX, ev.clientY, this._canvas);
|
|
1088
|
-
|
|
1089
1091
|
switch (ev.type) {
|
|
1090
1092
|
case 'mousedown':
|
|
1091
1093
|
(0, _events.setCapture)(this._canvas);
|
|
1092
|
-
|
|
1093
1094
|
this._handleMouseButton(pos.x, pos.y, true, 1 << ev.button);
|
|
1094
|
-
|
|
1095
1095
|
break;
|
|
1096
|
-
|
|
1097
1096
|
case 'mouseup':
|
|
1098
1097
|
this._handleMouseButton(pos.x, pos.y, false, 1 << ev.button);
|
|
1099
|
-
|
|
1100
1098
|
break;
|
|
1101
|
-
|
|
1102
1099
|
case 'mousemove':
|
|
1103
1100
|
this._handleMouseMove(pos.x, pos.y);
|
|
1104
|
-
|
|
1105
1101
|
break;
|
|
1106
1102
|
}
|
|
1107
1103
|
}
|
|
@@ -1115,74 +1111,68 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1115
1111
|
'x': x,
|
|
1116
1112
|
'y': y
|
|
1117
1113
|
};
|
|
1118
|
-
this._viewportHasMoved = false;
|
|
1114
|
+
this._viewportHasMoved = false;
|
|
1119
1115
|
|
|
1116
|
+
// Skip sending mouse events
|
|
1120
1117
|
return;
|
|
1121
1118
|
} else {
|
|
1122
|
-
this._viewportDragging = false;
|
|
1123
|
-
// here and should not send any mouse events
|
|
1119
|
+
this._viewportDragging = false;
|
|
1124
1120
|
|
|
1121
|
+
// If we actually performed a drag then we are done
|
|
1122
|
+
// here and should not send any mouse events
|
|
1125
1123
|
if (this._viewportHasMoved) {
|
|
1126
1124
|
return;
|
|
1127
|
-
}
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// Otherwise we treat this as a mouse click event.
|
|
1128
1128
|
// Send the button down event here, as the button up
|
|
1129
1129
|
// event is sent at the end of this function.
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
1130
|
this._sendMouse(x, y, bmask);
|
|
1133
1131
|
}
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1132
|
+
}
|
|
1136
1133
|
|
|
1134
|
+
// Flush waiting move event first
|
|
1137
1135
|
if (this._mouseMoveTimer !== null) {
|
|
1138
1136
|
clearTimeout(this._mouseMoveTimer);
|
|
1139
1137
|
this._mouseMoveTimer = null;
|
|
1140
|
-
|
|
1141
1138
|
this._sendMouse(x, y, this._mouseButtonMask);
|
|
1142
1139
|
}
|
|
1143
|
-
|
|
1144
1140
|
if (down) {
|
|
1145
1141
|
this._mouseButtonMask |= bmask;
|
|
1146
1142
|
} else {
|
|
1147
1143
|
this._mouseButtonMask &= ~bmask;
|
|
1148
1144
|
}
|
|
1149
|
-
|
|
1150
1145
|
this._sendMouse(x, y, this._mouseButtonMask);
|
|
1151
1146
|
}
|
|
1152
1147
|
}, {
|
|
1153
1148
|
key: "_handleMouseMove",
|
|
1154
1149
|
value: function _handleMouseMove(x, y) {
|
|
1155
1150
|
var _this4 = this;
|
|
1156
|
-
|
|
1157
1151
|
if (this._viewportDragging) {
|
|
1158
1152
|
var deltaX = this._viewportDragPos.x - x;
|
|
1159
1153
|
var deltaY = this._viewportDragPos.y - y;
|
|
1160
|
-
|
|
1161
1154
|
if (this._viewportHasMoved || Math.abs(deltaX) > _browser.dragThreshold || Math.abs(deltaY) > _browser.dragThreshold) {
|
|
1162
1155
|
this._viewportHasMoved = true;
|
|
1163
1156
|
this._viewportDragPos = {
|
|
1164
1157
|
'x': x,
|
|
1165
1158
|
'y': y
|
|
1166
1159
|
};
|
|
1167
|
-
|
|
1168
1160
|
this._display.viewportChangePos(deltaX, deltaY);
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1161
|
+
}
|
|
1171
1162
|
|
|
1163
|
+
// Skip sending mouse events
|
|
1172
1164
|
return;
|
|
1173
1165
|
}
|
|
1174
|
-
|
|
1175
1166
|
this._mousePos = {
|
|
1176
1167
|
'x': x,
|
|
1177
1168
|
'y': y
|
|
1178
|
-
};
|
|
1169
|
+
};
|
|
1179
1170
|
|
|
1171
|
+
// Limit many mouse move events to one every MOUSE_MOVE_DELAY ms
|
|
1180
1172
|
if (this._mouseMoveTimer == null) {
|
|
1181
1173
|
var timeSinceLastMove = Date.now() - this._mouseLastMoveTime;
|
|
1182
|
-
|
|
1183
1174
|
if (timeSinceLastMove > MOUSE_MOVE_DELAY) {
|
|
1184
1175
|
this._sendMouse(x, y, this._mouseButtonMask);
|
|
1185
|
-
|
|
1186
1176
|
this._mouseLastMoveTime = Date.now();
|
|
1187
1177
|
} else {
|
|
1188
1178
|
// Too soon since the latest move, wait the remaining time
|
|
@@ -1196,9 +1186,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1196
1186
|
key: "_handleDelayedMouseMove",
|
|
1197
1187
|
value: function _handleDelayedMouseMove() {
|
|
1198
1188
|
this._mouseMoveTimer = null;
|
|
1199
|
-
|
|
1200
1189
|
this._sendMouse(this._mousePos.x, this._mousePos.y, this._mouseButtonMask);
|
|
1201
|
-
|
|
1202
1190
|
this._mouseLastMoveTime = Date.now();
|
|
1203
1191
|
}
|
|
1204
1192
|
}, {
|
|
@@ -1207,12 +1195,10 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1207
1195
|
if (this._rfbConnectionState !== 'connected') {
|
|
1208
1196
|
return;
|
|
1209
1197
|
}
|
|
1210
|
-
|
|
1211
1198
|
if (this._viewOnly) {
|
|
1212
1199
|
return;
|
|
1213
1200
|
} // View only, skip mouse events
|
|
1214
1201
|
|
|
1215
|
-
|
|
1216
1202
|
RFB.messages.pointerEvent(this._sock, this._display.absX(x), this._display.absY(y), mask);
|
|
1217
1203
|
}
|
|
1218
1204
|
}, {
|
|
@@ -1221,59 +1207,52 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1221
1207
|
if (this._rfbConnectionState !== 'connected') {
|
|
1222
1208
|
return;
|
|
1223
1209
|
}
|
|
1224
|
-
|
|
1225
1210
|
if (this._viewOnly) {
|
|
1226
1211
|
return;
|
|
1227
1212
|
} // View only, skip mouse events
|
|
1228
1213
|
|
|
1229
|
-
|
|
1230
1214
|
ev.stopPropagation();
|
|
1231
1215
|
ev.preventDefault();
|
|
1232
1216
|
var pos = (0, _element.clientToElement)(ev.clientX, ev.clientY, this._canvas);
|
|
1233
1217
|
var dX = ev.deltaX;
|
|
1234
|
-
var dY = ev.deltaY;
|
|
1218
|
+
var dY = ev.deltaY;
|
|
1219
|
+
|
|
1220
|
+
// Pixel units unless it's non-zero.
|
|
1235
1221
|
// Note that if deltamode is line or page won't matter since we aren't
|
|
1236
1222
|
// sending the mouse wheel delta to the server anyway.
|
|
1237
1223
|
// The difference between pixel and line can be important however since
|
|
1238
1224
|
// we have a threshold that can be smaller than the line height.
|
|
1239
|
-
|
|
1240
1225
|
if (ev.deltaMode !== 0) {
|
|
1241
1226
|
dX *= WHEEL_LINE_HEIGHT;
|
|
1242
1227
|
dY *= WHEEL_LINE_HEIGHT;
|
|
1243
|
-
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// Mouse wheel events are sent in steps over VNC. This means that the VNC
|
|
1244
1231
|
// protocol can't handle a wheel event with specific distance or speed.
|
|
1245
1232
|
// Therefor, if we get a lot of small mouse wheel events we combine them.
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
1233
|
this._accumulatedWheelDeltaX += dX;
|
|
1249
|
-
this._accumulatedWheelDeltaY += dY;
|
|
1250
|
-
// for one of the axes is large enough.
|
|
1234
|
+
this._accumulatedWheelDeltaY += dY;
|
|
1251
1235
|
|
|
1236
|
+
// Generate a mouse wheel step event when the accumulated delta
|
|
1237
|
+
// for one of the axes is large enough.
|
|
1252
1238
|
if (Math.abs(this._accumulatedWheelDeltaX) >= WHEEL_STEP) {
|
|
1253
1239
|
if (this._accumulatedWheelDeltaX < 0) {
|
|
1254
1240
|
this._handleMouseButton(pos.x, pos.y, true, 1 << 5);
|
|
1255
|
-
|
|
1256
1241
|
this._handleMouseButton(pos.x, pos.y, false, 1 << 5);
|
|
1257
1242
|
} else if (this._accumulatedWheelDeltaX > 0) {
|
|
1258
1243
|
this._handleMouseButton(pos.x, pos.y, true, 1 << 6);
|
|
1259
|
-
|
|
1260
1244
|
this._handleMouseButton(pos.x, pos.y, false, 1 << 6);
|
|
1261
1245
|
}
|
|
1262
|
-
|
|
1263
1246
|
this._accumulatedWheelDeltaX = 0;
|
|
1264
1247
|
}
|
|
1265
|
-
|
|
1266
1248
|
if (Math.abs(this._accumulatedWheelDeltaY) >= WHEEL_STEP) {
|
|
1267
1249
|
if (this._accumulatedWheelDeltaY < 0) {
|
|
1268
1250
|
this._handleMouseButton(pos.x, pos.y, true, 1 << 3);
|
|
1269
|
-
|
|
1270
1251
|
this._handleMouseButton(pos.x, pos.y, false, 1 << 3);
|
|
1271
1252
|
} else if (this._accumulatedWheelDeltaY > 0) {
|
|
1272
1253
|
this._handleMouseButton(pos.x, pos.y, true, 1 << 4);
|
|
1273
|
-
|
|
1274
1254
|
this._handleMouseButton(pos.x, pos.y, false, 1 << 4);
|
|
1275
1255
|
}
|
|
1276
|
-
|
|
1277
1256
|
this._accumulatedWheelDeltaY = 0;
|
|
1278
1257
|
}
|
|
1279
1258
|
}
|
|
@@ -1281,20 +1260,20 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1281
1260
|
key: "_fakeMouseMove",
|
|
1282
1261
|
value: function _fakeMouseMove(ev, elementX, elementY) {
|
|
1283
1262
|
this._handleMouseMove(elementX, elementY);
|
|
1284
|
-
|
|
1285
1263
|
this._cursor.move(ev.detail.clientX, ev.detail.clientY);
|
|
1286
1264
|
}
|
|
1287
1265
|
}, {
|
|
1288
1266
|
key: "_handleTapEvent",
|
|
1289
1267
|
value: function _handleTapEvent(ev, bmask) {
|
|
1290
|
-
var pos = (0, _element.clientToElement)(ev.detail.clientX, ev.detail.clientY, this._canvas);
|
|
1268
|
+
var pos = (0, _element.clientToElement)(ev.detail.clientX, ev.detail.clientY, this._canvas);
|
|
1269
|
+
|
|
1270
|
+
// If the user quickly taps multiple times we assume they meant to
|
|
1291
1271
|
// hit the same spot, so slightly adjust coordinates
|
|
1292
1272
|
|
|
1293
1273
|
if (this._gestureLastTapTime !== null && Date.now() - this._gestureLastTapTime < DOUBLE_TAP_TIMEOUT && this._gestureFirstDoubleTapEv.detail.type === ev.detail.type) {
|
|
1294
1274
|
var dx = this._gestureFirstDoubleTapEv.detail.clientX - ev.detail.clientX;
|
|
1295
1275
|
var dy = this._gestureFirstDoubleTapEv.detail.clientY - ev.detail.clientY;
|
|
1296
1276
|
var distance = Math.hypot(dx, dy);
|
|
1297
|
-
|
|
1298
1277
|
if (distance < DOUBLE_TAP_THRESHOLD) {
|
|
1299
1278
|
pos = (0, _element.clientToElement)(this._gestureFirstDoubleTapEv.detail.clientX, this._gestureFirstDoubleTapEv.detail.clientY, this._canvas);
|
|
1300
1279
|
} else {
|
|
@@ -1303,13 +1282,9 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1303
1282
|
} else {
|
|
1304
1283
|
this._gestureFirstDoubleTapEv = ev;
|
|
1305
1284
|
}
|
|
1306
|
-
|
|
1307
1285
|
this._gestureLastTapTime = Date.now();
|
|
1308
|
-
|
|
1309
1286
|
this._fakeMouseMove(this._gestureFirstDoubleTapEv, pos.x, pos.y);
|
|
1310
|
-
|
|
1311
1287
|
this._handleMouseButton(pos.x, pos.y, true, bmask);
|
|
1312
|
-
|
|
1313
1288
|
this._handleMouseButton(pos.x, pos.y, false, bmask);
|
|
1314
1289
|
}
|
|
1315
1290
|
}, {
|
|
@@ -1317,145 +1292,96 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1317
1292
|
value: function _handleGesture(ev) {
|
|
1318
1293
|
var magnitude;
|
|
1319
1294
|
var pos = (0, _element.clientToElement)(ev.detail.clientX, ev.detail.clientY, this._canvas);
|
|
1320
|
-
|
|
1321
1295
|
switch (ev.type) {
|
|
1322
1296
|
case 'gesturestart':
|
|
1323
1297
|
switch (ev.detail.type) {
|
|
1324
1298
|
case 'onetap':
|
|
1325
1299
|
this._handleTapEvent(ev, 0x1);
|
|
1326
|
-
|
|
1327
1300
|
break;
|
|
1328
|
-
|
|
1329
1301
|
case 'twotap':
|
|
1330
1302
|
this._handleTapEvent(ev, 0x4);
|
|
1331
|
-
|
|
1332
1303
|
break;
|
|
1333
|
-
|
|
1334
1304
|
case 'threetap':
|
|
1335
1305
|
this._handleTapEvent(ev, 0x2);
|
|
1336
|
-
|
|
1337
1306
|
break;
|
|
1338
|
-
|
|
1339
1307
|
case 'drag':
|
|
1340
1308
|
this._fakeMouseMove(ev, pos.x, pos.y);
|
|
1341
|
-
|
|
1342
1309
|
this._handleMouseButton(pos.x, pos.y, true, 0x1);
|
|
1343
|
-
|
|
1344
1310
|
break;
|
|
1345
|
-
|
|
1346
1311
|
case 'longpress':
|
|
1347
1312
|
this._fakeMouseMove(ev, pos.x, pos.y);
|
|
1348
|
-
|
|
1349
1313
|
this._handleMouseButton(pos.x, pos.y, true, 0x4);
|
|
1350
|
-
|
|
1351
1314
|
break;
|
|
1352
|
-
|
|
1353
1315
|
case 'twodrag':
|
|
1354
1316
|
this._gestureLastMagnitudeX = ev.detail.magnitudeX;
|
|
1355
1317
|
this._gestureLastMagnitudeY = ev.detail.magnitudeY;
|
|
1356
|
-
|
|
1357
1318
|
this._fakeMouseMove(ev, pos.x, pos.y);
|
|
1358
|
-
|
|
1359
1319
|
break;
|
|
1360
|
-
|
|
1361
1320
|
case 'pinch':
|
|
1362
1321
|
this._gestureLastMagnitudeX = Math.hypot(ev.detail.magnitudeX, ev.detail.magnitudeY);
|
|
1363
|
-
|
|
1364
1322
|
this._fakeMouseMove(ev, pos.x, pos.y);
|
|
1365
|
-
|
|
1366
1323
|
break;
|
|
1367
1324
|
}
|
|
1368
|
-
|
|
1369
1325
|
break;
|
|
1370
|
-
|
|
1371
1326
|
case 'gesturemove':
|
|
1372
1327
|
switch (ev.detail.type) {
|
|
1373
1328
|
case 'onetap':
|
|
1374
1329
|
case 'twotap':
|
|
1375
1330
|
case 'threetap':
|
|
1376
1331
|
break;
|
|
1377
|
-
|
|
1378
1332
|
case 'drag':
|
|
1379
1333
|
case 'longpress':
|
|
1380
1334
|
this._fakeMouseMove(ev, pos.x, pos.y);
|
|
1381
|
-
|
|
1382
1335
|
break;
|
|
1383
|
-
|
|
1384
1336
|
case 'twodrag':
|
|
1385
1337
|
// Always scroll in the same position.
|
|
1386
1338
|
// We don't know if the mouse was moved so we need to move it
|
|
1387
1339
|
// every update.
|
|
1388
1340
|
this._fakeMouseMove(ev, pos.x, pos.y);
|
|
1389
|
-
|
|
1390
1341
|
while (ev.detail.magnitudeY - this._gestureLastMagnitudeY > GESTURE_SCRLSENS) {
|
|
1391
1342
|
this._handleMouseButton(pos.x, pos.y, true, 0x8);
|
|
1392
|
-
|
|
1393
1343
|
this._handleMouseButton(pos.x, pos.y, false, 0x8);
|
|
1394
|
-
|
|
1395
1344
|
this._gestureLastMagnitudeY += GESTURE_SCRLSENS;
|
|
1396
1345
|
}
|
|
1397
|
-
|
|
1398
1346
|
while (ev.detail.magnitudeY - this._gestureLastMagnitudeY < -GESTURE_SCRLSENS) {
|
|
1399
1347
|
this._handleMouseButton(pos.x, pos.y, true, 0x10);
|
|
1400
|
-
|
|
1401
1348
|
this._handleMouseButton(pos.x, pos.y, false, 0x10);
|
|
1402
|
-
|
|
1403
1349
|
this._gestureLastMagnitudeY -= GESTURE_SCRLSENS;
|
|
1404
1350
|
}
|
|
1405
|
-
|
|
1406
1351
|
while (ev.detail.magnitudeX - this._gestureLastMagnitudeX > GESTURE_SCRLSENS) {
|
|
1407
1352
|
this._handleMouseButton(pos.x, pos.y, true, 0x20);
|
|
1408
|
-
|
|
1409
1353
|
this._handleMouseButton(pos.x, pos.y, false, 0x20);
|
|
1410
|
-
|
|
1411
1354
|
this._gestureLastMagnitudeX += GESTURE_SCRLSENS;
|
|
1412
1355
|
}
|
|
1413
|
-
|
|
1414
1356
|
while (ev.detail.magnitudeX - this._gestureLastMagnitudeX < -GESTURE_SCRLSENS) {
|
|
1415
1357
|
this._handleMouseButton(pos.x, pos.y, true, 0x40);
|
|
1416
|
-
|
|
1417
1358
|
this._handleMouseButton(pos.x, pos.y, false, 0x40);
|
|
1418
|
-
|
|
1419
1359
|
this._gestureLastMagnitudeX -= GESTURE_SCRLSENS;
|
|
1420
1360
|
}
|
|
1421
|
-
|
|
1422
1361
|
break;
|
|
1423
|
-
|
|
1424
1362
|
case 'pinch':
|
|
1425
1363
|
// Always scroll in the same position.
|
|
1426
1364
|
// We don't know if the mouse was moved so we need to move it
|
|
1427
1365
|
// every update.
|
|
1428
1366
|
this._fakeMouseMove(ev, pos.x, pos.y);
|
|
1429
|
-
|
|
1430
1367
|
magnitude = Math.hypot(ev.detail.magnitudeX, ev.detail.magnitudeY);
|
|
1431
|
-
|
|
1432
1368
|
if (Math.abs(magnitude - this._gestureLastMagnitudeX) > GESTURE_ZOOMSENS) {
|
|
1433
1369
|
this._handleKeyEvent(_keysym["default"].XK_Control_L, "ControlLeft", true);
|
|
1434
|
-
|
|
1435
1370
|
while (magnitude - this._gestureLastMagnitudeX > GESTURE_ZOOMSENS) {
|
|
1436
1371
|
this._handleMouseButton(pos.x, pos.y, true, 0x8);
|
|
1437
|
-
|
|
1438
1372
|
this._handleMouseButton(pos.x, pos.y, false, 0x8);
|
|
1439
|
-
|
|
1440
1373
|
this._gestureLastMagnitudeX += GESTURE_ZOOMSENS;
|
|
1441
1374
|
}
|
|
1442
|
-
|
|
1443
1375
|
while (magnitude - this._gestureLastMagnitudeX < -GESTURE_ZOOMSENS) {
|
|
1444
1376
|
this._handleMouseButton(pos.x, pos.y, true, 0x10);
|
|
1445
|
-
|
|
1446
1377
|
this._handleMouseButton(pos.x, pos.y, false, 0x10);
|
|
1447
|
-
|
|
1448
1378
|
this._gestureLastMagnitudeX -= GESTURE_ZOOMSENS;
|
|
1449
1379
|
}
|
|
1450
1380
|
}
|
|
1451
|
-
|
|
1452
1381
|
this._handleKeyEvent(_keysym["default"].XK_Control_L, "ControlLeft", false);
|
|
1453
|
-
|
|
1454
1382
|
break;
|
|
1455
1383
|
}
|
|
1456
|
-
|
|
1457
1384
|
break;
|
|
1458
|
-
|
|
1459
1385
|
case 'gestureend':
|
|
1460
1386
|
switch (ev.detail.type) {
|
|
1461
1387
|
case 'onetap':
|
|
@@ -1464,149 +1390,131 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1464
1390
|
case 'pinch':
|
|
1465
1391
|
case 'twodrag':
|
|
1466
1392
|
break;
|
|
1467
|
-
|
|
1468
1393
|
case 'drag':
|
|
1469
1394
|
this._fakeMouseMove(ev, pos.x, pos.y);
|
|
1470
|
-
|
|
1471
1395
|
this._handleMouseButton(pos.x, pos.y, false, 0x1);
|
|
1472
|
-
|
|
1473
1396
|
break;
|
|
1474
|
-
|
|
1475
1397
|
case 'longpress':
|
|
1476
1398
|
this._fakeMouseMove(ev, pos.x, pos.y);
|
|
1477
|
-
|
|
1478
1399
|
this._handleMouseButton(pos.x, pos.y, false, 0x4);
|
|
1479
|
-
|
|
1480
1400
|
break;
|
|
1481
1401
|
}
|
|
1482
|
-
|
|
1483
1402
|
break;
|
|
1484
1403
|
}
|
|
1485
|
-
}
|
|
1404
|
+
}
|
|
1486
1405
|
|
|
1406
|
+
// Message Handlers
|
|
1487
1407
|
}, {
|
|
1488
1408
|
key: "_negotiateProtocolVersion",
|
|
1489
1409
|
value: function _negotiateProtocolVersion() {
|
|
1490
1410
|
if (this._sock.rQwait("version", 12)) {
|
|
1491
1411
|
return false;
|
|
1492
1412
|
}
|
|
1493
|
-
|
|
1494
1413
|
var sversion = this._sock.rQshiftStr(12).substr(4, 7);
|
|
1495
|
-
|
|
1496
1414
|
Log.Info("Server ProtocolVersion: " + sversion);
|
|
1497
1415
|
var isRepeater = 0;
|
|
1498
|
-
|
|
1499
1416
|
switch (sversion) {
|
|
1500
1417
|
case "000.000":
|
|
1501
1418
|
// UltraVNC repeater
|
|
1502
1419
|
isRepeater = 1;
|
|
1503
1420
|
break;
|
|
1504
|
-
|
|
1505
1421
|
case "003.003":
|
|
1506
|
-
case "003.006":
|
|
1507
|
-
|
|
1508
|
-
case "003.889":
|
|
1509
|
-
// Apple Remote Desktop
|
|
1422
|
+
case "003.006":
|
|
1423
|
+
// UltraVNC
|
|
1510
1424
|
this._rfbVersion = 3.3;
|
|
1511
1425
|
break;
|
|
1512
|
-
|
|
1513
1426
|
case "003.007":
|
|
1514
1427
|
this._rfbVersion = 3.7;
|
|
1515
1428
|
break;
|
|
1516
|
-
|
|
1517
1429
|
case "003.008":
|
|
1430
|
+
case "003.889": // Apple Remote Desktop
|
|
1518
1431
|
case "004.000": // Intel AMT KVM
|
|
1519
|
-
|
|
1520
1432
|
case "004.001": // RealVNC 4.6
|
|
1521
|
-
|
|
1522
1433
|
case "005.000":
|
|
1523
1434
|
// RealVNC 5.3
|
|
1524
1435
|
this._rfbVersion = 3.8;
|
|
1525
1436
|
break;
|
|
1526
|
-
|
|
1527
1437
|
default:
|
|
1528
1438
|
return this._fail("Invalid server version " + sversion);
|
|
1529
1439
|
}
|
|
1530
|
-
|
|
1531
1440
|
if (isRepeater) {
|
|
1532
1441
|
var repeaterID = "ID:" + this._repeaterID;
|
|
1533
|
-
|
|
1534
1442
|
while (repeaterID.length < 250) {
|
|
1535
1443
|
repeaterID += "\0";
|
|
1536
1444
|
}
|
|
1537
|
-
|
|
1538
1445
|
this._sock.sendString(repeaterID);
|
|
1539
|
-
|
|
1540
1446
|
return true;
|
|
1541
1447
|
}
|
|
1542
|
-
|
|
1543
1448
|
if (this._rfbVersion > this._rfbMaxVersion) {
|
|
1544
1449
|
this._rfbVersion = this._rfbMaxVersion;
|
|
1545
1450
|
}
|
|
1546
|
-
|
|
1547
1451
|
var cversion = "00" + parseInt(this._rfbVersion, 10) + ".00" + this._rfbVersion * 10 % 10;
|
|
1548
|
-
|
|
1549
1452
|
this._sock.sendString("RFB " + cversion + "\n");
|
|
1550
|
-
|
|
1551
1453
|
Log.Debug('Sent ProtocolVersion: ' + cversion);
|
|
1552
1454
|
this._rfbInitState = 'Security';
|
|
1553
1455
|
}
|
|
1456
|
+
}, {
|
|
1457
|
+
key: "_isSupportedSecurityType",
|
|
1458
|
+
value: function _isSupportedSecurityType(type) {
|
|
1459
|
+
var clientTypes = [securityTypeNone, securityTypeVNCAuth, securityTypeRA2ne, securityTypeTight, securityTypeVeNCrypt, securityTypeXVP, securityTypeARD, securityTypeMSLogonII, securityTypePlain];
|
|
1460
|
+
return clientTypes.includes(type);
|
|
1461
|
+
}
|
|
1554
1462
|
}, {
|
|
1555
1463
|
key: "_negotiateSecurity",
|
|
1556
1464
|
value: function _negotiateSecurity() {
|
|
1557
1465
|
if (this._rfbVersion >= 3.7) {
|
|
1558
1466
|
// Server sends supported list, client decides
|
|
1559
1467
|
var numTypes = this._sock.rQshift8();
|
|
1560
|
-
|
|
1561
1468
|
if (this._sock.rQwait("security type", numTypes, 1)) {
|
|
1562
1469
|
return false;
|
|
1563
1470
|
}
|
|
1564
|
-
|
|
1565
1471
|
if (numTypes === 0) {
|
|
1566
1472
|
this._rfbInitState = "SecurityReason";
|
|
1567
1473
|
this._securityContext = "no security types";
|
|
1568
1474
|
this._securityStatus = 1;
|
|
1569
|
-
return
|
|
1475
|
+
return true;
|
|
1570
1476
|
}
|
|
1571
|
-
|
|
1572
1477
|
var types = this._sock.rQshiftBytes(numTypes);
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1478
|
+
Log.Debug("Server security types: " + types);
|
|
1479
|
+
|
|
1480
|
+
// Look for a matching security type in the order that the
|
|
1481
|
+
// server prefers
|
|
1482
|
+
this._rfbAuthScheme = -1;
|
|
1483
|
+
var _iterator3 = _createForOfIteratorHelper(types),
|
|
1484
|
+
_step3;
|
|
1485
|
+
try {
|
|
1486
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1487
|
+
var type = _step3.value;
|
|
1488
|
+
if (this._isSupportedSecurityType(type)) {
|
|
1489
|
+
this._rfbAuthScheme = type;
|
|
1490
|
+
break;
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
} catch (err) {
|
|
1494
|
+
_iterator3.e(err);
|
|
1495
|
+
} finally {
|
|
1496
|
+
_iterator3.f();
|
|
1497
|
+
}
|
|
1498
|
+
if (this._rfbAuthScheme === -1) {
|
|
1587
1499
|
return this._fail("Unsupported security types (types: " + types + ")");
|
|
1588
1500
|
}
|
|
1589
|
-
|
|
1590
1501
|
this._sock.send([this._rfbAuthScheme]);
|
|
1591
1502
|
} else {
|
|
1592
1503
|
// Server decides
|
|
1593
1504
|
if (this._sock.rQwait("security scheme", 4)) {
|
|
1594
1505
|
return false;
|
|
1595
1506
|
}
|
|
1596
|
-
|
|
1597
1507
|
this._rfbAuthScheme = this._sock.rQshift32();
|
|
1598
|
-
|
|
1599
1508
|
if (this._rfbAuthScheme == 0) {
|
|
1600
1509
|
this._rfbInitState = "SecurityReason";
|
|
1601
1510
|
this._securityContext = "authentication scheme";
|
|
1602
1511
|
this._securityStatus = 1;
|
|
1603
|
-
return
|
|
1512
|
+
return true;
|
|
1604
1513
|
}
|
|
1605
1514
|
}
|
|
1606
|
-
|
|
1607
1515
|
this._rfbInitState = 'Authentication';
|
|
1608
1516
|
Log.Debug('Authenticating using scheme: ' + this._rfbAuthScheme);
|
|
1609
|
-
return
|
|
1517
|
+
return true;
|
|
1610
1518
|
}
|
|
1611
1519
|
}, {
|
|
1612
1520
|
key: "_handleSecurityReason",
|
|
@@ -1614,19 +1522,14 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1614
1522
|
if (this._sock.rQwait("reason length", 4)) {
|
|
1615
1523
|
return false;
|
|
1616
1524
|
}
|
|
1617
|
-
|
|
1618
1525
|
var strlen = this._sock.rQshift32();
|
|
1619
|
-
|
|
1620
1526
|
var reason = "";
|
|
1621
|
-
|
|
1622
1527
|
if (strlen > 0) {
|
|
1623
1528
|
if (this._sock.rQwait("reason", strlen, 4)) {
|
|
1624
1529
|
return false;
|
|
1625
1530
|
}
|
|
1626
|
-
|
|
1627
1531
|
reason = this._sock.rQshiftStr(strlen);
|
|
1628
1532
|
}
|
|
1629
|
-
|
|
1630
1533
|
if (reason !== "") {
|
|
1631
1534
|
this.dispatchEvent(new CustomEvent("securityfailure", {
|
|
1632
1535
|
detail: {
|
|
@@ -1643,8 +1546,9 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1643
1546
|
}));
|
|
1644
1547
|
return this._fail("Security negotiation failed on " + this._securityContext);
|
|
1645
1548
|
}
|
|
1646
|
-
}
|
|
1549
|
+
}
|
|
1647
1550
|
|
|
1551
|
+
// authentication
|
|
1648
1552
|
}, {
|
|
1649
1553
|
key: "_negotiateXvpAuth",
|
|
1650
1554
|
value: function _negotiateXvpAuth() {
|
|
@@ -1656,15 +1560,13 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1656
1560
|
}));
|
|
1657
1561
|
return false;
|
|
1658
1562
|
}
|
|
1659
|
-
|
|
1660
1563
|
var xvpAuthStr = String.fromCharCode(this._rfbCredentials.username.length) + String.fromCharCode(this._rfbCredentials.target.length) + this._rfbCredentials.username + this._rfbCredentials.target;
|
|
1661
|
-
|
|
1662
1564
|
this._sock.sendString(xvpAuthStr);
|
|
1663
|
-
|
|
1664
|
-
this._rfbAuthScheme = 2;
|
|
1565
|
+
this._rfbAuthScheme = securityTypeVNCAuth;
|
|
1665
1566
|
return this._negotiateAuthentication();
|
|
1666
|
-
}
|
|
1567
|
+
}
|
|
1667
1568
|
|
|
1569
|
+
// VeNCrypt authentication, currently only supports version 0.2 and only Plain subtype
|
|
1668
1570
|
}, {
|
|
1669
1571
|
key: "_negotiateVeNCryptAuth",
|
|
1670
1572
|
value: function _negotiateVeNCryptAuth() {
|
|
@@ -1673,109 +1575,100 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1673
1575
|
if (this._sock.rQwait("vencrypt version", 2)) {
|
|
1674
1576
|
return false;
|
|
1675
1577
|
}
|
|
1676
|
-
|
|
1677
1578
|
var major = this._sock.rQshift8();
|
|
1678
|
-
|
|
1679
1579
|
var minor = this._sock.rQshift8();
|
|
1680
|
-
|
|
1681
1580
|
if (!(major == 0 && minor == 2)) {
|
|
1682
1581
|
return this._fail("Unsupported VeNCrypt version " + major + "." + minor);
|
|
1683
1582
|
}
|
|
1684
|
-
|
|
1685
1583
|
this._sock.send([0, 2]);
|
|
1686
|
-
|
|
1687
1584
|
this._rfbVeNCryptState = 1;
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1585
|
+
}
|
|
1690
1586
|
|
|
1587
|
+
// waiting for ACK
|
|
1691
1588
|
if (this._rfbVeNCryptState == 1) {
|
|
1692
1589
|
if (this._sock.rQwait("vencrypt ack", 1)) {
|
|
1693
1590
|
return false;
|
|
1694
1591
|
}
|
|
1695
|
-
|
|
1696
1592
|
var res = this._sock.rQshift8();
|
|
1697
|
-
|
|
1698
1593
|
if (res != 0) {
|
|
1699
1594
|
return this._fail("VeNCrypt failure " + res);
|
|
1700
1595
|
}
|
|
1701
|
-
|
|
1702
1596
|
this._rfbVeNCryptState = 2;
|
|
1703
|
-
}
|
|
1597
|
+
}
|
|
1598
|
+
// must fall through here (i.e. no "else if"), beacause we may have already received
|
|
1704
1599
|
// the subtypes length and won't be called again
|
|
1705
1600
|
|
|
1706
|
-
|
|
1707
1601
|
if (this._rfbVeNCryptState == 2) {
|
|
1708
1602
|
// waiting for subtypes length
|
|
1709
1603
|
if (this._sock.rQwait("vencrypt subtypes length", 1)) {
|
|
1710
1604
|
return false;
|
|
1711
1605
|
}
|
|
1712
|
-
|
|
1713
1606
|
var subtypesLength = this._sock.rQshift8();
|
|
1714
|
-
|
|
1715
1607
|
if (subtypesLength < 1) {
|
|
1716
1608
|
return this._fail("VeNCrypt subtypes empty");
|
|
1717
1609
|
}
|
|
1718
|
-
|
|
1719
1610
|
this._rfbVeNCryptSubtypesLength = subtypesLength;
|
|
1720
1611
|
this._rfbVeNCryptState = 3;
|
|
1721
|
-
}
|
|
1722
|
-
|
|
1612
|
+
}
|
|
1723
1613
|
|
|
1614
|
+
// waiting for subtypes list
|
|
1724
1615
|
if (this._rfbVeNCryptState == 3) {
|
|
1725
1616
|
if (this._sock.rQwait("vencrypt subtypes", 4 * this._rfbVeNCryptSubtypesLength)) {
|
|
1726
1617
|
return false;
|
|
1727
1618
|
}
|
|
1728
|
-
|
|
1729
1619
|
var subtypes = [];
|
|
1730
|
-
|
|
1731
1620
|
for (var i = 0; i < this._rfbVeNCryptSubtypesLength; i++) {
|
|
1732
1621
|
subtypes.push(this._sock.rQshift32());
|
|
1733
|
-
} // 256 = Plain subtype
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
if (subtypes.indexOf(256) != -1) {
|
|
1737
|
-
// 0x100 = 256
|
|
1738
|
-
this._sock.send([0, 0, 1, 0]);
|
|
1739
|
-
|
|
1740
|
-
this._rfbVeNCryptState = 4;
|
|
1741
|
-
} else {
|
|
1742
|
-
return this._fail("VeNCrypt Plain subtype not offered by server");
|
|
1743
1622
|
}
|
|
1744
|
-
} // negotiated Plain subtype, server waits for password
|
|
1745
|
-
|
|
1746
1623
|
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1624
|
+
// Look for a matching security type in the order that the
|
|
1625
|
+
// server prefers
|
|
1626
|
+
this._rfbAuthScheme = -1;
|
|
1627
|
+
for (var _i2 = 0, _subtypes = subtypes; _i2 < _subtypes.length; _i2++) {
|
|
1628
|
+
var type = _subtypes[_i2];
|
|
1629
|
+
// Avoid getting in to a loop
|
|
1630
|
+
if (type === securityTypeVeNCrypt) {
|
|
1631
|
+
continue;
|
|
1632
|
+
}
|
|
1633
|
+
if (this._isSupportedSecurityType(type)) {
|
|
1634
|
+
this._rfbAuthScheme = type;
|
|
1635
|
+
break;
|
|
1636
|
+
}
|
|
1755
1637
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
this.
|
|
1761
|
-
|
|
1762
|
-
this._sock.send([pass.length >> 24 & 0xFF, pass.length >> 16 & 0xFF, pass.length >> 8 & 0xFF, pass.length & 0xFF]);
|
|
1763
|
-
|
|
1764
|
-
this._sock.sendString(user);
|
|
1765
|
-
|
|
1766
|
-
this._sock.sendString(pass);
|
|
1767
|
-
|
|
1768
|
-
this._rfbInitState = "SecurityResult";
|
|
1638
|
+
if (this._rfbAuthScheme === -1) {
|
|
1639
|
+
return this._fail("Unsupported security types (types: " + subtypes + ")");
|
|
1640
|
+
}
|
|
1641
|
+
this._sock.send([this._rfbAuthScheme >> 24, this._rfbAuthScheme >> 16, this._rfbAuthScheme >> 8, this._rfbAuthScheme]);
|
|
1642
|
+
this._rfbVeNCryptState == 4;
|
|
1769
1643
|
return true;
|
|
1770
1644
|
}
|
|
1771
1645
|
}
|
|
1646
|
+
}, {
|
|
1647
|
+
key: "_negotiatePlainAuth",
|
|
1648
|
+
value: function _negotiatePlainAuth() {
|
|
1649
|
+
if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
|
|
1650
|
+
this.dispatchEvent(new CustomEvent("credentialsrequired", {
|
|
1651
|
+
detail: {
|
|
1652
|
+
types: ["username", "password"]
|
|
1653
|
+
}
|
|
1654
|
+
}));
|
|
1655
|
+
return false;
|
|
1656
|
+
}
|
|
1657
|
+
var user = (0, _strings.encodeUTF8)(this._rfbCredentials.username);
|
|
1658
|
+
var pass = (0, _strings.encodeUTF8)(this._rfbCredentials.password);
|
|
1659
|
+
this._sock.send([user.length >> 24 & 0xFF, user.length >> 16 & 0xFF, user.length >> 8 & 0xFF, user.length & 0xFF]);
|
|
1660
|
+
this._sock.send([pass.length >> 24 & 0xFF, pass.length >> 16 & 0xFF, pass.length >> 8 & 0xFF, pass.length & 0xFF]);
|
|
1661
|
+
this._sock.sendString(user);
|
|
1662
|
+
this._sock.sendString(pass);
|
|
1663
|
+
this._rfbInitState = "SecurityResult";
|
|
1664
|
+
return true;
|
|
1665
|
+
}
|
|
1772
1666
|
}, {
|
|
1773
1667
|
key: "_negotiateStdVNCAuth",
|
|
1774
1668
|
value: function _negotiateStdVNCAuth() {
|
|
1775
1669
|
if (this._sock.rQwait("auth challenge", 16)) {
|
|
1776
1670
|
return false;
|
|
1777
1671
|
}
|
|
1778
|
-
|
|
1779
1672
|
if (this._rfbCredentials.password === undefined) {
|
|
1780
1673
|
this.dispatchEvent(new CustomEvent("credentialsrequired", {
|
|
1781
1674
|
detail: {
|
|
@@ -1783,17 +1676,179 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1783
1676
|
}
|
|
1784
1677
|
}));
|
|
1785
1678
|
return false;
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1679
|
+
}
|
|
1788
1680
|
|
|
1681
|
+
// TODO(directxman12): make genDES not require an Array
|
|
1789
1682
|
var challenge = Array.prototype.slice.call(this._sock.rQshiftBytes(16));
|
|
1790
1683
|
var response = RFB.genDES(this._rfbCredentials.password, challenge);
|
|
1791
|
-
|
|
1792
1684
|
this._sock.send(response);
|
|
1793
|
-
|
|
1794
1685
|
this._rfbInitState = "SecurityResult";
|
|
1795
1686
|
return true;
|
|
1796
1687
|
}
|
|
1688
|
+
}, {
|
|
1689
|
+
key: "_negotiateARDAuth",
|
|
1690
|
+
value: function _negotiateARDAuth() {
|
|
1691
|
+
if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
|
|
1692
|
+
this.dispatchEvent(new CustomEvent("credentialsrequired", {
|
|
1693
|
+
detail: {
|
|
1694
|
+
types: ["username", "password"]
|
|
1695
|
+
}
|
|
1696
|
+
}));
|
|
1697
|
+
return false;
|
|
1698
|
+
}
|
|
1699
|
+
if (this._rfbCredentials.ardPublicKey != undefined && this._rfbCredentials.ardCredentials != undefined) {
|
|
1700
|
+
// if the async web crypto is done return the results
|
|
1701
|
+
this._sock.send(this._rfbCredentials.ardCredentials);
|
|
1702
|
+
this._sock.send(this._rfbCredentials.ardPublicKey);
|
|
1703
|
+
this._rfbCredentials.ardCredentials = null;
|
|
1704
|
+
this._rfbCredentials.ardPublicKey = null;
|
|
1705
|
+
this._rfbInitState = "SecurityResult";
|
|
1706
|
+
return true;
|
|
1707
|
+
}
|
|
1708
|
+
if (this._sock.rQwait("read ard", 4)) {
|
|
1709
|
+
return false;
|
|
1710
|
+
}
|
|
1711
|
+
var generator = this._sock.rQshiftBytes(2); // DH base generator value
|
|
1712
|
+
|
|
1713
|
+
var keyLength = this._sock.rQshift16();
|
|
1714
|
+
if (this._sock.rQwait("read ard keylength", keyLength * 2, 4)) {
|
|
1715
|
+
return false;
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
// read the server values
|
|
1719
|
+
var prime = this._sock.rQshiftBytes(keyLength); // predetermined prime modulus
|
|
1720
|
+
var serverPublicKey = this._sock.rQshiftBytes(keyLength); // other party's public key
|
|
1721
|
+
|
|
1722
|
+
var clientPrivateKey = window.crypto.getRandomValues(new Uint8Array(keyLength));
|
|
1723
|
+
var padding = Array.from(window.crypto.getRandomValues(new Uint8Array(64)), function (_byte) {
|
|
1724
|
+
return String.fromCharCode(65 + _byte % 26);
|
|
1725
|
+
}).join('');
|
|
1726
|
+
this._negotiateARDAuthAsync(generator, keyLength, prime, serverPublicKey, clientPrivateKey, padding);
|
|
1727
|
+
return false;
|
|
1728
|
+
}
|
|
1729
|
+
}, {
|
|
1730
|
+
key: "_modPow",
|
|
1731
|
+
value: function _modPow(base, exponent, modulus) {
|
|
1732
|
+
var baseHex = "0x" + Array.from(base, function (_byte2) {
|
|
1733
|
+
return ('0' + (_byte2 & 0xFF).toString(16)).slice(-2);
|
|
1734
|
+
}).join('');
|
|
1735
|
+
var exponentHex = "0x" + Array.from(exponent, function (_byte3) {
|
|
1736
|
+
return ('0' + (_byte3 & 0xFF).toString(16)).slice(-2);
|
|
1737
|
+
}).join('');
|
|
1738
|
+
var modulusHex = "0x" + Array.from(modulus, function (_byte4) {
|
|
1739
|
+
return ('0' + (_byte4 & 0xFF).toString(16)).slice(-2);
|
|
1740
|
+
}).join('');
|
|
1741
|
+
var b = BigInt(baseHex);
|
|
1742
|
+
var e = BigInt(exponentHex);
|
|
1743
|
+
var m = BigInt(modulusHex);
|
|
1744
|
+
var r = 1n;
|
|
1745
|
+
b = b % m;
|
|
1746
|
+
while (e > 0) {
|
|
1747
|
+
if (e % 2n === 1n) {
|
|
1748
|
+
r = r * b % m;
|
|
1749
|
+
}
|
|
1750
|
+
e = e / 2n;
|
|
1751
|
+
b = b * b % m;
|
|
1752
|
+
}
|
|
1753
|
+
var hexResult = r.toString(16);
|
|
1754
|
+
while (hexResult.length / 2 < exponent.length || hexResult.length % 2 != 0) {
|
|
1755
|
+
hexResult = "0" + hexResult;
|
|
1756
|
+
}
|
|
1757
|
+
var bytesResult = [];
|
|
1758
|
+
for (var c = 0; c < hexResult.length; c += 2) {
|
|
1759
|
+
bytesResult.push(parseInt(hexResult.substr(c, 2), 16));
|
|
1760
|
+
}
|
|
1761
|
+
return bytesResult;
|
|
1762
|
+
}
|
|
1763
|
+
}, {
|
|
1764
|
+
key: "_aesEcbEncrypt",
|
|
1765
|
+
value: function () {
|
|
1766
|
+
var _aesEcbEncrypt2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(string, key) {
|
|
1767
|
+
var keyString, aesKey, data, i, encrypted, _i3, block, encryptedBlock;
|
|
1768
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1769
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1770
|
+
case 0:
|
|
1771
|
+
// perform AES-ECB blocks
|
|
1772
|
+
keyString = Array.from(key, function (_byte5) {
|
|
1773
|
+
return String.fromCharCode(_byte5);
|
|
1774
|
+
}).join('');
|
|
1775
|
+
_context.next = 3;
|
|
1776
|
+
return window.crypto.subtle.importKey("raw", (0, _md.MD5)(keyString), {
|
|
1777
|
+
name: "AES-CBC"
|
|
1778
|
+
}, false, ["encrypt"]);
|
|
1779
|
+
case 3:
|
|
1780
|
+
aesKey = _context.sent;
|
|
1781
|
+
data = new Uint8Array(string.length);
|
|
1782
|
+
for (i = 0; i < string.length; ++i) {
|
|
1783
|
+
data[i] = string.charCodeAt(i);
|
|
1784
|
+
}
|
|
1785
|
+
encrypted = new Uint8Array(data.length);
|
|
1786
|
+
_i3 = 0;
|
|
1787
|
+
case 8:
|
|
1788
|
+
if (!(_i3 < data.length)) {
|
|
1789
|
+
_context.next = 17;
|
|
1790
|
+
break;
|
|
1791
|
+
}
|
|
1792
|
+
block = data.slice(_i3, _i3 + 16);
|
|
1793
|
+
_context.next = 12;
|
|
1794
|
+
return window.crypto.subtle.encrypt({
|
|
1795
|
+
name: "AES-CBC",
|
|
1796
|
+
iv: block
|
|
1797
|
+
}, aesKey, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]));
|
|
1798
|
+
case 12:
|
|
1799
|
+
encryptedBlock = _context.sent;
|
|
1800
|
+
encrypted.set(new Uint8Array(encryptedBlock).slice(0, 16), _i3);
|
|
1801
|
+
case 14:
|
|
1802
|
+
_i3 += 16;
|
|
1803
|
+
_context.next = 8;
|
|
1804
|
+
break;
|
|
1805
|
+
case 17:
|
|
1806
|
+
return _context.abrupt("return", encrypted);
|
|
1807
|
+
case 18:
|
|
1808
|
+
case "end":
|
|
1809
|
+
return _context.stop();
|
|
1810
|
+
}
|
|
1811
|
+
}, _callee);
|
|
1812
|
+
}));
|
|
1813
|
+
function _aesEcbEncrypt(_x2, _x3) {
|
|
1814
|
+
return _aesEcbEncrypt2.apply(this, arguments);
|
|
1815
|
+
}
|
|
1816
|
+
return _aesEcbEncrypt;
|
|
1817
|
+
}()
|
|
1818
|
+
}, {
|
|
1819
|
+
key: "_negotiateARDAuthAsync",
|
|
1820
|
+
value: function () {
|
|
1821
|
+
var _negotiateARDAuthAsync2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(generator, keyLength, prime, serverPublicKey, clientPrivateKey, padding) {
|
|
1822
|
+
var clientPublicKey, sharedKey, username, password, paddedUsername, paddedPassword, credentials, encrypted;
|
|
1823
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1824
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1825
|
+
case 0:
|
|
1826
|
+
// calculate the DH keys
|
|
1827
|
+
clientPublicKey = this._modPow(generator, clientPrivateKey, prime);
|
|
1828
|
+
sharedKey = this._modPow(serverPublicKey, clientPrivateKey, prime);
|
|
1829
|
+
username = (0, _strings.encodeUTF8)(this._rfbCredentials.username).substring(0, 63);
|
|
1830
|
+
password = (0, _strings.encodeUTF8)(this._rfbCredentials.password).substring(0, 63);
|
|
1831
|
+
paddedUsername = username + '\0' + padding.substring(0, 63);
|
|
1832
|
+
paddedPassword = password + '\0' + padding.substring(0, 63);
|
|
1833
|
+
credentials = paddedUsername.substring(0, 64) + paddedPassword.substring(0, 64);
|
|
1834
|
+
_context2.next = 9;
|
|
1835
|
+
return this._aesEcbEncrypt(credentials, sharedKey);
|
|
1836
|
+
case 9:
|
|
1837
|
+
encrypted = _context2.sent;
|
|
1838
|
+
this._rfbCredentials.ardCredentials = encrypted;
|
|
1839
|
+
this._rfbCredentials.ardPublicKey = clientPublicKey;
|
|
1840
|
+
this._resumeAuthentication();
|
|
1841
|
+
case 13:
|
|
1842
|
+
case "end":
|
|
1843
|
+
return _context2.stop();
|
|
1844
|
+
}
|
|
1845
|
+
}, _callee2, this);
|
|
1846
|
+
}));
|
|
1847
|
+
function _negotiateARDAuthAsync(_x4, _x5, _x6, _x7, _x8, _x9) {
|
|
1848
|
+
return _negotiateARDAuthAsync2.apply(this, arguments);
|
|
1849
|
+
}
|
|
1850
|
+
return _negotiateARDAuthAsync;
|
|
1851
|
+
}()
|
|
1797
1852
|
}, {
|
|
1798
1853
|
key: "_negotiateTightUnixAuth",
|
|
1799
1854
|
value: function _negotiateTightUnixAuth() {
|
|
@@ -1805,15 +1860,10 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1805
1860
|
}));
|
|
1806
1861
|
return false;
|
|
1807
1862
|
}
|
|
1808
|
-
|
|
1809
1863
|
this._sock.send([0, 0, 0, this._rfbCredentials.username.length]);
|
|
1810
|
-
|
|
1811
1864
|
this._sock.send([0, 0, 0, this._rfbCredentials.password.length]);
|
|
1812
|
-
|
|
1813
1865
|
this._sock.sendString(this._rfbCredentials.username);
|
|
1814
|
-
|
|
1815
1866
|
this._sock.sendString(this._rfbCredentials.password);
|
|
1816
|
-
|
|
1817
1867
|
this._rfbInitState = "SecurityResult";
|
|
1818
1868
|
return true;
|
|
1819
1869
|
}
|
|
@@ -1826,44 +1876,37 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1826
1876
|
signature: 'NOTUNNEL'
|
|
1827
1877
|
}
|
|
1828
1878
|
};
|
|
1829
|
-
var serverSupportedTunnelTypes = {};
|
|
1830
|
-
|
|
1879
|
+
var serverSupportedTunnelTypes = {};
|
|
1880
|
+
// receive tunnel capabilities
|
|
1831
1881
|
for (var i = 0; i < numTunnels; i++) {
|
|
1832
1882
|
var capCode = this._sock.rQshift32();
|
|
1833
|
-
|
|
1834
1883
|
var capVendor = this._sock.rQshiftStr(4);
|
|
1835
|
-
|
|
1836
1884
|
var capSignature = this._sock.rQshiftStr(8);
|
|
1837
|
-
|
|
1838
1885
|
serverSupportedTunnelTypes[capCode] = {
|
|
1839
1886
|
vendor: capVendor,
|
|
1840
1887
|
signature: capSignature
|
|
1841
1888
|
};
|
|
1842
1889
|
}
|
|
1890
|
+
Log.Debug("Server Tight tunnel types: " + serverSupportedTunnelTypes);
|
|
1843
1891
|
|
|
1844
|
-
|
|
1892
|
+
// Siemens touch panels have a VNC server that supports NOTUNNEL,
|
|
1845
1893
|
// but forgets to advertise it. Try to detect such servers by
|
|
1846
1894
|
// looking for their custom tunnel type.
|
|
1847
|
-
|
|
1848
1895
|
if (serverSupportedTunnelTypes[1] && serverSupportedTunnelTypes[1].vendor === "SICR" && serverSupportedTunnelTypes[1].signature === "SCHANNEL") {
|
|
1849
1896
|
Log.Debug("Detected Siemens server. Assuming NOTUNNEL support.");
|
|
1850
1897
|
serverSupportedTunnelTypes[0] = {
|
|
1851
1898
|
vendor: 'TGHT',
|
|
1852
1899
|
signature: 'NOTUNNEL'
|
|
1853
1900
|
};
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1901
|
+
}
|
|
1856
1902
|
|
|
1903
|
+
// choose the notunnel type
|
|
1857
1904
|
if (serverSupportedTunnelTypes[0]) {
|
|
1858
1905
|
if (serverSupportedTunnelTypes[0].vendor != clientSupportedTunnelTypes[0].vendor || serverSupportedTunnelTypes[0].signature != clientSupportedTunnelTypes[0].signature) {
|
|
1859
1906
|
return this._fail("Client's tunnel type had the incorrect " + "vendor or signature");
|
|
1860
1907
|
}
|
|
1861
|
-
|
|
1862
1908
|
Log.Debug("Selected tunnel type: " + clientSupportedTunnelTypes[0]);
|
|
1863
|
-
|
|
1864
1909
|
this._sock.send([0, 0, 0, 0]); // use NOTUNNEL
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
1910
|
return false; // wait until we receive the sub auth count to continue
|
|
1868
1911
|
} else {
|
|
1869
1912
|
return this._fail("Server wanted tunnels, but doesn't support " + "the notunnel type");
|
|
@@ -1877,121 +1920,185 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1877
1920
|
if (this._sock.rQwait("num tunnels", 4)) {
|
|
1878
1921
|
return false;
|
|
1879
1922
|
}
|
|
1880
|
-
|
|
1881
1923
|
var numTunnels = this._sock.rQshift32();
|
|
1882
|
-
|
|
1883
1924
|
if (numTunnels > 0 && this._sock.rQwait("tunnel capabilities", 16 * numTunnels, 4)) {
|
|
1884
1925
|
return false;
|
|
1885
1926
|
}
|
|
1886
|
-
|
|
1887
1927
|
this._rfbTightVNC = true;
|
|
1888
|
-
|
|
1889
1928
|
if (numTunnels > 0) {
|
|
1890
1929
|
this._negotiateTightTunnels(numTunnels);
|
|
1891
|
-
|
|
1892
1930
|
return false; // wait until we receive the sub auth to continue
|
|
1893
1931
|
}
|
|
1894
|
-
}
|
|
1895
|
-
|
|
1932
|
+
}
|
|
1896
1933
|
|
|
1934
|
+
// second pass, do the sub-auth negotiation
|
|
1897
1935
|
if (this._sock.rQwait("sub auth count", 4)) {
|
|
1898
1936
|
return false;
|
|
1899
1937
|
}
|
|
1900
|
-
|
|
1901
1938
|
var subAuthCount = this._sock.rQshift32();
|
|
1902
|
-
|
|
1903
1939
|
if (subAuthCount === 0) {
|
|
1904
1940
|
// empty sub-auth list received means 'no auth' subtype selected
|
|
1905
1941
|
this._rfbInitState = 'SecurityResult';
|
|
1906
1942
|
return true;
|
|
1907
1943
|
}
|
|
1908
|
-
|
|
1909
1944
|
if (this._sock.rQwait("sub auth capabilities", 16 * subAuthCount, 4)) {
|
|
1910
1945
|
return false;
|
|
1911
1946
|
}
|
|
1912
|
-
|
|
1913
1947
|
var clientSupportedTypes = {
|
|
1914
1948
|
'STDVNOAUTH__': 1,
|
|
1915
1949
|
'STDVVNCAUTH_': 2,
|
|
1916
1950
|
'TGHTULGNAUTH': 129
|
|
1917
1951
|
};
|
|
1918
1952
|
var serverSupportedTypes = [];
|
|
1919
|
-
|
|
1920
1953
|
for (var i = 0; i < subAuthCount; i++) {
|
|
1921
1954
|
this._sock.rQshift32(); // capNum
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
1955
|
var capabilities = this._sock.rQshiftStr(12);
|
|
1925
|
-
|
|
1926
1956
|
serverSupportedTypes.push(capabilities);
|
|
1927
1957
|
}
|
|
1928
|
-
|
|
1929
1958
|
Log.Debug("Server Tight authentication types: " + serverSupportedTypes);
|
|
1930
|
-
|
|
1931
1959
|
for (var authType in clientSupportedTypes) {
|
|
1932
1960
|
if (serverSupportedTypes.indexOf(authType) != -1) {
|
|
1933
1961
|
this._sock.send([0, 0, 0, clientSupportedTypes[authType]]);
|
|
1934
|
-
|
|
1935
1962
|
Log.Debug("Selected authentication type: " + authType);
|
|
1936
|
-
|
|
1937
1963
|
switch (authType) {
|
|
1938
1964
|
case 'STDVNOAUTH__':
|
|
1939
1965
|
// no auth
|
|
1940
1966
|
this._rfbInitState = 'SecurityResult';
|
|
1941
1967
|
return true;
|
|
1942
|
-
|
|
1943
1968
|
case 'STDVVNCAUTH_':
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
return this._initMsg();
|
|
1947
|
-
|
|
1969
|
+
this._rfbAuthScheme = securityTypeVNCAuth;
|
|
1970
|
+
return true;
|
|
1948
1971
|
case 'TGHTULGNAUTH':
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
return this._initMsg();
|
|
1952
|
-
|
|
1972
|
+
this._rfbAuthScheme = securityTypeUnixLogon;
|
|
1973
|
+
return true;
|
|
1953
1974
|
default:
|
|
1954
1975
|
return this._fail("Unsupported tiny auth scheme " + "(scheme: " + authType + ")");
|
|
1955
1976
|
}
|
|
1956
1977
|
}
|
|
1957
1978
|
}
|
|
1958
|
-
|
|
1959
1979
|
return this._fail("No supported sub-auth types!");
|
|
1960
1980
|
}
|
|
1981
|
+
}, {
|
|
1982
|
+
key: "_handleRSAAESCredentialsRequired",
|
|
1983
|
+
value: function _handleRSAAESCredentialsRequired(event) {
|
|
1984
|
+
this.dispatchEvent(event);
|
|
1985
|
+
}
|
|
1986
|
+
}, {
|
|
1987
|
+
key: "_handleRSAAESServerVerification",
|
|
1988
|
+
value: function _handleRSAAESServerVerification(event) {
|
|
1989
|
+
this.dispatchEvent(event);
|
|
1990
|
+
}
|
|
1991
|
+
}, {
|
|
1992
|
+
key: "_negotiateRA2neAuth",
|
|
1993
|
+
value: function _negotiateRA2neAuth() {
|
|
1994
|
+
var _this5 = this;
|
|
1995
|
+
if (this._rfbRSAAESAuthenticationState === null) {
|
|
1996
|
+
this._rfbRSAAESAuthenticationState = new _ra["default"](this._sock, function () {
|
|
1997
|
+
return _this5._rfbCredentials;
|
|
1998
|
+
});
|
|
1999
|
+
this._rfbRSAAESAuthenticationState.addEventListener("serververification", this._eventHandlers.handleRSAAESServerVerification);
|
|
2000
|
+
this._rfbRSAAESAuthenticationState.addEventListener("credentialsrequired", this._eventHandlers.handleRSAAESCredentialsRequired);
|
|
2001
|
+
}
|
|
2002
|
+
this._rfbRSAAESAuthenticationState.checkInternalEvents();
|
|
2003
|
+
if (!this._rfbRSAAESAuthenticationState.hasStarted) {
|
|
2004
|
+
this._rfbRSAAESAuthenticationState.negotiateRA2neAuthAsync()["catch"](function (e) {
|
|
2005
|
+
if (e.message !== "disconnect normally") {
|
|
2006
|
+
_this5._fail(e.message);
|
|
2007
|
+
}
|
|
2008
|
+
}).then(function () {
|
|
2009
|
+
_this5.dispatchEvent(new CustomEvent('securityresult'));
|
|
2010
|
+
_this5._rfbInitState = "SecurityResult";
|
|
2011
|
+
return true;
|
|
2012
|
+
})["finally"](function () {
|
|
2013
|
+
_this5._rfbRSAAESAuthenticationState.removeEventListener("serververification", _this5._eventHandlers.handleRSAAESServerVerification);
|
|
2014
|
+
_this5._rfbRSAAESAuthenticationState.removeEventListener("credentialsrequired", _this5._eventHandlers.handleRSAAESCredentialsRequired);
|
|
2015
|
+
_this5._rfbRSAAESAuthenticationState = null;
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
return false;
|
|
2019
|
+
}
|
|
2020
|
+
}, {
|
|
2021
|
+
key: "_negotiateMSLogonIIAuth",
|
|
2022
|
+
value: function _negotiateMSLogonIIAuth() {
|
|
2023
|
+
if (this._sock.rQwait("mslogonii dh param", 24)) {
|
|
2024
|
+
return false;
|
|
2025
|
+
}
|
|
2026
|
+
if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
|
|
2027
|
+
this.dispatchEvent(new CustomEvent("credentialsrequired", {
|
|
2028
|
+
detail: {
|
|
2029
|
+
types: ["username", "password"]
|
|
2030
|
+
}
|
|
2031
|
+
}));
|
|
2032
|
+
return false;
|
|
2033
|
+
}
|
|
2034
|
+
var g = this._sock.rQshiftBytes(8);
|
|
2035
|
+
var p = this._sock.rQshiftBytes(8);
|
|
2036
|
+
var A = this._sock.rQshiftBytes(8);
|
|
2037
|
+
var b = window.crypto.getRandomValues(new Uint8Array(8));
|
|
2038
|
+
var B = new Uint8Array(this._modPow(g, b, p));
|
|
2039
|
+
var secret = new Uint8Array(this._modPow(A, b, p));
|
|
2040
|
+
var des = new _des["default"](secret);
|
|
2041
|
+
var username = (0, _strings.encodeUTF8)(this._rfbCredentials.username).substring(0, 255);
|
|
2042
|
+
var password = (0, _strings.encodeUTF8)(this._rfbCredentials.password).substring(0, 63);
|
|
2043
|
+
var usernameBytes = new Uint8Array(256);
|
|
2044
|
+
var passwordBytes = new Uint8Array(64);
|
|
2045
|
+
window.crypto.getRandomValues(usernameBytes);
|
|
2046
|
+
window.crypto.getRandomValues(passwordBytes);
|
|
2047
|
+
for (var i = 0; i < username.length; i++) {
|
|
2048
|
+
usernameBytes[i] = username.charCodeAt(i);
|
|
2049
|
+
}
|
|
2050
|
+
usernameBytes[username.length] = 0;
|
|
2051
|
+
for (var _i4 = 0; _i4 < password.length; _i4++) {
|
|
2052
|
+
passwordBytes[_i4] = password.charCodeAt(_i4);
|
|
2053
|
+
}
|
|
2054
|
+
passwordBytes[password.length] = 0;
|
|
2055
|
+
var x = new Uint8Array(secret);
|
|
2056
|
+
for (var _i5 = 0; _i5 < 32; _i5++) {
|
|
2057
|
+
for (var j = 0; j < 8; j++) {
|
|
2058
|
+
x[j] ^= usernameBytes[_i5 * 8 + j];
|
|
2059
|
+
}
|
|
2060
|
+
x = des.enc8(x);
|
|
2061
|
+
usernameBytes.set(x, _i5 * 8);
|
|
2062
|
+
}
|
|
2063
|
+
x = new Uint8Array(secret);
|
|
2064
|
+
for (var _i6 = 0; _i6 < 8; _i6++) {
|
|
2065
|
+
for (var _j = 0; _j < 8; _j++) {
|
|
2066
|
+
x[_j] ^= passwordBytes[_i6 * 8 + _j];
|
|
2067
|
+
}
|
|
2068
|
+
x = des.enc8(x);
|
|
2069
|
+
passwordBytes.set(x, _i6 * 8);
|
|
2070
|
+
}
|
|
2071
|
+
this._sock.send(B);
|
|
2072
|
+
this._sock.send(usernameBytes);
|
|
2073
|
+
this._sock.send(passwordBytes);
|
|
2074
|
+
this._rfbInitState = "SecurityResult";
|
|
2075
|
+
return true;
|
|
2076
|
+
}
|
|
1961
2077
|
}, {
|
|
1962
2078
|
key: "_negotiateAuthentication",
|
|
1963
2079
|
value: function _negotiateAuthentication() {
|
|
1964
2080
|
switch (this._rfbAuthScheme) {
|
|
1965
|
-
case
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
return true;
|
|
1970
|
-
}
|
|
1971
|
-
|
|
1972
|
-
this._rfbInitState = 'ClientInitialisation';
|
|
1973
|
-
return this._initMsg();
|
|
1974
|
-
|
|
1975
|
-
case 22:
|
|
1976
|
-
// XVP auth
|
|
2081
|
+
case securityTypeNone:
|
|
2082
|
+
this._rfbInitState = 'SecurityResult';
|
|
2083
|
+
return true;
|
|
2084
|
+
case securityTypeXVP:
|
|
1977
2085
|
return this._negotiateXvpAuth();
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
2086
|
+
case securityTypeARD:
|
|
2087
|
+
return this._negotiateARDAuth();
|
|
2088
|
+
case securityTypeVNCAuth:
|
|
1981
2089
|
return this._negotiateStdVNCAuth();
|
|
1982
|
-
|
|
1983
|
-
case 16:
|
|
1984
|
-
// TightVNC Security Type
|
|
2090
|
+
case securityTypeTight:
|
|
1985
2091
|
return this._negotiateTightAuth();
|
|
1986
|
-
|
|
1987
|
-
case 19:
|
|
1988
|
-
// VeNCrypt Security Type
|
|
2092
|
+
case securityTypeVeNCrypt:
|
|
1989
2093
|
return this._negotiateVeNCryptAuth();
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
2094
|
+
case securityTypePlain:
|
|
2095
|
+
return this._negotiatePlainAuth();
|
|
2096
|
+
case securityTypeUnixLogon:
|
|
1993
2097
|
return this._negotiateTightUnixAuth();
|
|
1994
|
-
|
|
2098
|
+
case securityTypeRA2ne:
|
|
2099
|
+
return this._negotiateRA2neAuth();
|
|
2100
|
+
case securityTypeMSLogonII:
|
|
2101
|
+
return this._negotiateMSLogonIIAuth();
|
|
1995
2102
|
default:
|
|
1996
2103
|
return this._fail("Unsupported auth scheme (scheme: " + this._rfbAuthScheme + ")");
|
|
1997
2104
|
}
|
|
@@ -1999,23 +2106,27 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1999
2106
|
}, {
|
|
2000
2107
|
key: "_handleSecurityResult",
|
|
2001
2108
|
value: function _handleSecurityResult() {
|
|
2109
|
+
// There is no security choice, and hence no security result
|
|
2110
|
+
// until RFB 3.7
|
|
2111
|
+
if (this._rfbVersion < 3.7) {
|
|
2112
|
+
this._rfbInitState = 'ClientInitialisation';
|
|
2113
|
+
return true;
|
|
2114
|
+
}
|
|
2002
2115
|
if (this._sock.rQwait('VNC auth response ', 4)) {
|
|
2003
2116
|
return false;
|
|
2004
2117
|
}
|
|
2005
|
-
|
|
2006
2118
|
var status = this._sock.rQshift32();
|
|
2007
|
-
|
|
2008
2119
|
if (status === 0) {
|
|
2009
2120
|
// OK
|
|
2010
2121
|
this._rfbInitState = 'ClientInitialisation';
|
|
2011
2122
|
Log.Debug('Authentication OK');
|
|
2012
|
-
return
|
|
2123
|
+
return true;
|
|
2013
2124
|
} else {
|
|
2014
2125
|
if (this._rfbVersion >= 3.8) {
|
|
2015
2126
|
this._rfbInitState = "SecurityReason";
|
|
2016
2127
|
this._securityContext = "security result";
|
|
2017
2128
|
this._securityStatus = status;
|
|
2018
|
-
return
|
|
2129
|
+
return true;
|
|
2019
2130
|
} else {
|
|
2020
2131
|
this.dispatchEvent(new CustomEvent("securityfailure", {
|
|
2021
2132
|
detail: {
|
|
@@ -2032,130 +2143,102 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2032
2143
|
if (this._sock.rQwait("server initialization", 24)) {
|
|
2033
2144
|
return false;
|
|
2034
2145
|
}
|
|
2035
|
-
/* Screen size */
|
|
2036
|
-
|
|
2037
2146
|
|
|
2147
|
+
/* Screen size */
|
|
2038
2148
|
var width = this._sock.rQshift16();
|
|
2039
|
-
|
|
2040
2149
|
var height = this._sock.rQshift16();
|
|
2041
|
-
/* PIXEL_FORMAT */
|
|
2042
|
-
|
|
2043
2150
|
|
|
2151
|
+
/* PIXEL_FORMAT */
|
|
2044
2152
|
var bpp = this._sock.rQshift8();
|
|
2045
|
-
|
|
2046
2153
|
var depth = this._sock.rQshift8();
|
|
2047
|
-
|
|
2048
2154
|
var bigEndian = this._sock.rQshift8();
|
|
2049
|
-
|
|
2050
2155
|
var trueColor = this._sock.rQshift8();
|
|
2051
|
-
|
|
2052
2156
|
var redMax = this._sock.rQshift16();
|
|
2053
|
-
|
|
2054
2157
|
var greenMax = this._sock.rQshift16();
|
|
2055
|
-
|
|
2056
2158
|
var blueMax = this._sock.rQshift16();
|
|
2057
|
-
|
|
2058
2159
|
var redShift = this._sock.rQshift8();
|
|
2059
|
-
|
|
2060
2160
|
var greenShift = this._sock.rQshift8();
|
|
2061
|
-
|
|
2062
2161
|
var blueShift = this._sock.rQshift8();
|
|
2063
|
-
|
|
2064
2162
|
this._sock.rQskipBytes(3); // padding
|
|
2163
|
+
|
|
2065
2164
|
// NB(directxman12): we don't want to call any callbacks or print messages until
|
|
2066
2165
|
// *after* we're past the point where we could backtrack
|
|
2067
2166
|
|
|
2068
2167
|
/* Connection name/title */
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
2168
|
var nameLength = this._sock.rQshift32();
|
|
2072
|
-
|
|
2073
2169
|
if (this._sock.rQwait('server init name', nameLength, 24)) {
|
|
2074
2170
|
return false;
|
|
2075
2171
|
}
|
|
2076
|
-
|
|
2077
2172
|
var name = this._sock.rQshiftStr(nameLength);
|
|
2078
|
-
|
|
2079
2173
|
name = (0, _strings.decodeUTF8)(name, true);
|
|
2080
|
-
|
|
2081
2174
|
if (this._rfbTightVNC) {
|
|
2082
2175
|
if (this._sock.rQwait('TightVNC extended server init header', 8, 24 + nameLength)) {
|
|
2083
2176
|
return false;
|
|
2084
|
-
}
|
|
2085
|
-
|
|
2086
|
-
|
|
2177
|
+
}
|
|
2178
|
+
// In TightVNC mode, ServerInit message is extended
|
|
2087
2179
|
var numServerMessages = this._sock.rQshift16();
|
|
2088
|
-
|
|
2089
2180
|
var numClientMessages = this._sock.rQshift16();
|
|
2090
|
-
|
|
2091
2181
|
var numEncodings = this._sock.rQshift16();
|
|
2092
|
-
|
|
2093
2182
|
this._sock.rQskipBytes(2); // padding
|
|
2094
2183
|
|
|
2095
|
-
|
|
2096
2184
|
var totalMessagesLength = (numServerMessages + numClientMessages + numEncodings) * 16;
|
|
2097
|
-
|
|
2098
2185
|
if (this._sock.rQwait('TightVNC extended server init header', totalMessagesLength, 32 + nameLength)) {
|
|
2099
2186
|
return false;
|
|
2100
|
-
}
|
|
2101
|
-
// so we just skip the all of this.
|
|
2102
|
-
// TIGHT server message capabilities
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
this._sock.rQskipBytes(16 * numServerMessages); // TIGHT client message capabilities
|
|
2187
|
+
}
|
|
2106
2188
|
|
|
2189
|
+
// we don't actually do anything with the capability information that TIGHT sends,
|
|
2190
|
+
// so we just skip the all of this.
|
|
2107
2191
|
|
|
2108
|
-
|
|
2192
|
+
// TIGHT server message capabilities
|
|
2193
|
+
this._sock.rQskipBytes(16 * numServerMessages);
|
|
2109
2194
|
|
|
2195
|
+
// TIGHT client message capabilities
|
|
2196
|
+
this._sock.rQskipBytes(16 * numClientMessages);
|
|
2110
2197
|
|
|
2198
|
+
// TIGHT encoding capabilities
|
|
2111
2199
|
this._sock.rQskipBytes(16 * numEncodings);
|
|
2112
|
-
}
|
|
2113
|
-
// if we backtrack
|
|
2114
|
-
|
|
2200
|
+
}
|
|
2115
2201
|
|
|
2116
|
-
|
|
2202
|
+
// NB(directxman12): these are down here so that we don't run them multiple times
|
|
2203
|
+
// if we backtrack
|
|
2204
|
+
Log.Info("Screen: " + width + "x" + height + ", bpp: " + bpp + ", depth: " + depth + ", bigEndian: " + bigEndian + ", trueColor: " + trueColor + ", redMax: " + redMax + ", greenMax: " + greenMax + ", blueMax: " + blueMax + ", redShift: " + redShift + ", greenShift: " + greenShift + ", blueShift: " + blueShift);
|
|
2117
2205
|
|
|
2206
|
+
// we're past the point where we could backtrack, so it's safe to call this
|
|
2118
2207
|
this._setDesktopName(name);
|
|
2119
|
-
|
|
2120
2208
|
this._resize(width, height);
|
|
2121
|
-
|
|
2122
2209
|
if (!this._viewOnly) {
|
|
2123
2210
|
this._keyboard.grab();
|
|
2124
2211
|
}
|
|
2125
|
-
|
|
2126
2212
|
this._fbDepth = 24;
|
|
2127
|
-
|
|
2128
2213
|
if (this._fbName === "Intel(r) AMT KVM") {
|
|
2129
2214
|
Log.Warn("Intel AMT KVM only supports 8/16 bit depths. Using low color mode.");
|
|
2130
2215
|
this._fbDepth = 8;
|
|
2131
2216
|
}
|
|
2132
|
-
|
|
2133
2217
|
RFB.messages.pixelFormat(this._sock, this._fbDepth, true);
|
|
2134
|
-
|
|
2135
2218
|
this._sendEncodings();
|
|
2136
|
-
|
|
2137
2219
|
RFB.messages.fbUpdateRequest(this._sock, false, 0, 0, this._fbWidth, this._fbHeight);
|
|
2138
|
-
|
|
2139
2220
|
this._updateConnectionState('connected');
|
|
2140
|
-
|
|
2141
2221
|
return true;
|
|
2142
2222
|
}
|
|
2143
2223
|
}, {
|
|
2144
2224
|
key: "_sendEncodings",
|
|
2145
2225
|
value: function _sendEncodings() {
|
|
2146
|
-
var encs = [];
|
|
2147
|
-
|
|
2148
|
-
encs.push(_encodings.encodings.encodingCopyRect); // Only supported with full depth support
|
|
2226
|
+
var encs = [];
|
|
2149
2227
|
|
|
2228
|
+
// In preference order
|
|
2229
|
+
encs.push(_encodings.encodings.encodingCopyRect);
|
|
2230
|
+
// Only supported with full depth support
|
|
2150
2231
|
if (this._fbDepth == 24) {
|
|
2151
2232
|
encs.push(_encodings.encodings.encodingTight);
|
|
2152
2233
|
encs.push(_encodings.encodings.encodingTightPNG);
|
|
2234
|
+
encs.push(_encodings.encodings.encodingZRLE);
|
|
2235
|
+
encs.push(_encodings.encodings.encodingJPEG);
|
|
2153
2236
|
encs.push(_encodings.encodings.encodingHextile);
|
|
2154
2237
|
encs.push(_encodings.encodings.encodingRRE);
|
|
2155
2238
|
}
|
|
2239
|
+
encs.push(_encodings.encodings.encodingRaw);
|
|
2156
2240
|
|
|
2157
|
-
|
|
2158
|
-
|
|
2241
|
+
// Psuedo-encoding settings
|
|
2159
2242
|
encs.push(_encodings.encodings.pseudoEncodingQualityLevel0 + this._qualityLevel);
|
|
2160
2243
|
encs.push(_encodings.encodings.pseudoEncodingCompressLevel0 + this._compressionLevel);
|
|
2161
2244
|
encs.push(_encodings.encodings.pseudoEncodingDesktopSize);
|
|
@@ -2167,14 +2250,13 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2167
2250
|
encs.push(_encodings.encodings.pseudoEncodingContinuousUpdates);
|
|
2168
2251
|
encs.push(_encodings.encodings.pseudoEncodingDesktopName);
|
|
2169
2252
|
encs.push(_encodings.encodings.pseudoEncodingExtendedClipboard);
|
|
2170
|
-
|
|
2171
2253
|
if (this._fbDepth == 24) {
|
|
2172
2254
|
encs.push(_encodings.encodings.pseudoEncodingVMwareCursor);
|
|
2173
2255
|
encs.push(_encodings.encodings.pseudoEncodingCursor);
|
|
2174
2256
|
}
|
|
2175
|
-
|
|
2176
2257
|
RFB.messages.clientEncodings(this._sock, encs);
|
|
2177
2258
|
}
|
|
2259
|
+
|
|
2178
2260
|
/* RFB protocol initialization states:
|
|
2179
2261
|
* ProtocolVersion
|
|
2180
2262
|
* Security
|
|
@@ -2183,40 +2265,40 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2183
2265
|
* ClientInitialization - not triggered by server message
|
|
2184
2266
|
* ServerInitialization
|
|
2185
2267
|
*/
|
|
2186
|
-
|
|
2187
2268
|
}, {
|
|
2188
2269
|
key: "_initMsg",
|
|
2189
2270
|
value: function _initMsg() {
|
|
2190
2271
|
switch (this._rfbInitState) {
|
|
2191
2272
|
case 'ProtocolVersion':
|
|
2192
2273
|
return this._negotiateProtocolVersion();
|
|
2193
|
-
|
|
2194
2274
|
case 'Security':
|
|
2195
2275
|
return this._negotiateSecurity();
|
|
2196
|
-
|
|
2197
2276
|
case 'Authentication':
|
|
2198
2277
|
return this._negotiateAuthentication();
|
|
2199
|
-
|
|
2200
2278
|
case 'SecurityResult':
|
|
2201
2279
|
return this._handleSecurityResult();
|
|
2202
|
-
|
|
2203
2280
|
case 'SecurityReason':
|
|
2204
2281
|
return this._handleSecurityReason();
|
|
2205
|
-
|
|
2206
2282
|
case 'ClientInitialisation':
|
|
2207
2283
|
this._sock.send([this._shared ? 1 : 0]); // ClientInitialisation
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
2284
|
this._rfbInitState = 'ServerInitialisation';
|
|
2211
2285
|
return true;
|
|
2212
|
-
|
|
2213
2286
|
case 'ServerInitialisation':
|
|
2214
2287
|
return this._negotiateServerInit();
|
|
2215
|
-
|
|
2216
2288
|
default:
|
|
2217
2289
|
return this._fail("Unknown init state (state: " + this._rfbInitState + ")");
|
|
2218
2290
|
}
|
|
2219
2291
|
}
|
|
2292
|
+
|
|
2293
|
+
// Resume authentication handshake after it was paused for some
|
|
2294
|
+
// reason, e.g. waiting for a password from the user
|
|
2295
|
+
}, {
|
|
2296
|
+
key: "_resumeAuthentication",
|
|
2297
|
+
value: function _resumeAuthentication() {
|
|
2298
|
+
// We use setTimeout() so it's run in its own context, just like
|
|
2299
|
+
// it originally did via the WebSocket's event handler
|
|
2300
|
+
setTimeout(this._initMsg.bind(this), 0);
|
|
2301
|
+
}
|
|
2220
2302
|
}, {
|
|
2221
2303
|
key: "_handleSetColourMapMsg",
|
|
2222
2304
|
value: function _handleSetColourMapMsg() {
|
|
@@ -2227,30 +2309,22 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2227
2309
|
key: "_handleServerCutText",
|
|
2228
2310
|
value: function _handleServerCutText() {
|
|
2229
2311
|
Log.Debug("ServerCutText");
|
|
2230
|
-
|
|
2231
2312
|
if (this._sock.rQwait("ServerCutText header", 7, 1)) {
|
|
2232
2313
|
return false;
|
|
2233
2314
|
}
|
|
2234
|
-
|
|
2235
2315
|
this._sock.rQskipBytes(3); // Padding
|
|
2236
2316
|
|
|
2237
|
-
|
|
2238
2317
|
var length = this._sock.rQshift32();
|
|
2239
|
-
|
|
2240
2318
|
length = (0, _int.toSigned32bit)(length);
|
|
2241
|
-
|
|
2242
2319
|
if (this._sock.rQwait("ServerCutText content", Math.abs(length), 8)) {
|
|
2243
2320
|
return false;
|
|
2244
2321
|
}
|
|
2245
|
-
|
|
2246
2322
|
if (length >= 0) {
|
|
2247
2323
|
//Standard msg
|
|
2248
2324
|
var text = this._sock.rQshiftStr(length);
|
|
2249
|
-
|
|
2250
2325
|
if (this._viewOnly) {
|
|
2251
2326
|
return true;
|
|
2252
2327
|
}
|
|
2253
|
-
|
|
2254
2328
|
this.dispatchEvent(new CustomEvent("clipboard", {
|
|
2255
2329
|
detail: {
|
|
2256
2330
|
text: text
|
|
@@ -2259,38 +2333,35 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2259
2333
|
} else {
|
|
2260
2334
|
//Extended msg.
|
|
2261
2335
|
length = Math.abs(length);
|
|
2262
|
-
|
|
2263
2336
|
var flags = this._sock.rQshift32();
|
|
2264
|
-
|
|
2265
2337
|
var formats = flags & 0x0000FFFF;
|
|
2266
2338
|
var actions = flags & 0xFF000000;
|
|
2267
2339
|
var isCaps = !!(actions & extendedClipboardActionCaps);
|
|
2268
|
-
|
|
2269
2340
|
if (isCaps) {
|
|
2270
2341
|
this._clipboardServerCapabilitiesFormats = {};
|
|
2271
|
-
this._clipboardServerCapabilitiesActions = {};
|
|
2342
|
+
this._clipboardServerCapabilitiesActions = {};
|
|
2272
2343
|
|
|
2344
|
+
// Update our server capabilities for Formats
|
|
2273
2345
|
for (var i = 0; i <= 15; i++) {
|
|
2274
|
-
var index = 1 << i;
|
|
2346
|
+
var index = 1 << i;
|
|
2275
2347
|
|
|
2348
|
+
// Check if format flag is set.
|
|
2276
2349
|
if (formats & index) {
|
|
2277
|
-
this._clipboardServerCapabilitiesFormats[index] = true;
|
|
2350
|
+
this._clipboardServerCapabilitiesFormats[index] = true;
|
|
2351
|
+
// We don't send unsolicited clipboard, so we
|
|
2278
2352
|
// ignore the size
|
|
2279
|
-
|
|
2280
2353
|
this._sock.rQshift32();
|
|
2281
|
-
}
|
|
2282
|
-
}
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
for (var _i = 24; _i <= 31; _i++) {
|
|
2286
|
-
var _index = 1 << _i;
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2287
2356
|
|
|
2357
|
+
// Update our server capabilities for Actions
|
|
2358
|
+
for (var _i7 = 24; _i7 <= 31; _i7++) {
|
|
2359
|
+
var _index = 1 << _i7;
|
|
2288
2360
|
this._clipboardServerCapabilitiesActions[_index] = !!(actions & _index);
|
|
2289
2361
|
}
|
|
2362
|
+
|
|
2290
2363
|
/* Caps handling done, send caps with the clients
|
|
2291
2364
|
capabilities set as a response */
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
2365
|
var clientActions = [extendedClipboardActionCaps, extendedClipboardActionRequest, extendedClipboardActionPeek, extendedClipboardActionNotify, extendedClipboardActionProvide];
|
|
2295
2366
|
RFB.messages.extendedClipboardCaps(this._sock, clientActions, {
|
|
2296
2367
|
extendedClipboardFormatText: 0
|
|
@@ -2298,9 +2369,9 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2298
2369
|
} else if (actions === extendedClipboardActionRequest) {
|
|
2299
2370
|
if (this._viewOnly) {
|
|
2300
2371
|
return true;
|
|
2301
|
-
}
|
|
2302
|
-
|
|
2372
|
+
}
|
|
2303
2373
|
|
|
2374
|
+
// Check if server has told us it can handle Provide and there is clipboard data to send.
|
|
2304
2375
|
if (this._clipboardText != null && this._clipboardServerCapabilitiesActions[extendedClipboardActionProvide]) {
|
|
2305
2376
|
if (formats & extendedClipboardFormatText) {
|
|
2306
2377
|
RFB.messages.extendedClipboardProvide(this._sock, [extendedClipboardFormatText], [this._clipboardText]);
|
|
@@ -2310,7 +2381,6 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2310
2381
|
if (this._viewOnly) {
|
|
2311
2382
|
return true;
|
|
2312
2383
|
}
|
|
2313
|
-
|
|
2314
2384
|
if (this._clipboardServerCapabilitiesActions[extendedClipboardActionNotify]) {
|
|
2315
2385
|
if (this._clipboardText != null) {
|
|
2316
2386
|
RFB.messages.extendedClipboardNotify(this._sock, [extendedClipboardFormatText]);
|
|
@@ -2322,7 +2392,6 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2322
2392
|
if (this._viewOnly) {
|
|
2323
2393
|
return true;
|
|
2324
2394
|
}
|
|
2325
|
-
|
|
2326
2395
|
if (this._clipboardServerCapabilitiesActions[extendedClipboardActionRequest]) {
|
|
2327
2396
|
if (formats & extendedClipboardFormatText) {
|
|
2328
2397
|
RFB.messages.extendedClipboardRequest(this._sock, [extendedClipboardFormatText]);
|
|
@@ -2332,23 +2401,19 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2332
2401
|
if (this._viewOnly) {
|
|
2333
2402
|
return true;
|
|
2334
2403
|
}
|
|
2335
|
-
|
|
2336
2404
|
if (!(formats & extendedClipboardFormatText)) {
|
|
2337
2405
|
return true;
|
|
2338
|
-
}
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
this._clipboardText = null; // FIXME: Should probably verify that this data was actually requested
|
|
2406
|
+
}
|
|
2407
|
+
// Ignore what we had in our clipboard client side.
|
|
2408
|
+
this._clipboardText = null;
|
|
2342
2409
|
|
|
2410
|
+
// FIXME: Should probably verify that this data was actually requested
|
|
2343
2411
|
var zlibStream = this._sock.rQshiftBytes(length - 4);
|
|
2344
|
-
|
|
2345
2412
|
var streamInflator = new _inflator["default"]();
|
|
2346
2413
|
var textData = null;
|
|
2347
2414
|
streamInflator.setInput(zlibStream);
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
var format = 1 << _i2;
|
|
2351
|
-
|
|
2415
|
+
for (var _i8 = 0; _i8 <= 15; _i8++) {
|
|
2416
|
+
var format = 1 << _i8;
|
|
2352
2417
|
if (formats & format) {
|
|
2353
2418
|
var size = 0x00;
|
|
2354
2419
|
var sizeArray = streamInflator.inflate(4);
|
|
@@ -2357,29 +2422,22 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2357
2422
|
size |= sizeArray[2] << 8;
|
|
2358
2423
|
size |= sizeArray[3];
|
|
2359
2424
|
var chunk = streamInflator.inflate(size);
|
|
2360
|
-
|
|
2361
2425
|
if (format === extendedClipboardFormatText) {
|
|
2362
2426
|
textData = chunk;
|
|
2363
2427
|
}
|
|
2364
2428
|
}
|
|
2365
2429
|
}
|
|
2366
|
-
|
|
2367
2430
|
streamInflator.setInput(null);
|
|
2368
|
-
|
|
2369
2431
|
if (textData !== null) {
|
|
2370
2432
|
var tmpText = "";
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
tmpText += String.fromCharCode(textData[_i3]);
|
|
2433
|
+
for (var _i9 = 0; _i9 < textData.length; _i9++) {
|
|
2434
|
+
tmpText += String.fromCharCode(textData[_i9]);
|
|
2374
2435
|
}
|
|
2375
|
-
|
|
2376
2436
|
textData = tmpText;
|
|
2377
2437
|
textData = (0, _strings.decodeUTF8)(textData);
|
|
2378
|
-
|
|
2379
2438
|
if (textData.length > 0 && "\0" === textData.charAt(textData.length - 1)) {
|
|
2380
2439
|
textData = textData.slice(0, -1);
|
|
2381
2440
|
}
|
|
2382
|
-
|
|
2383
2441
|
textData = textData.replace("\r\n", "\n");
|
|
2384
2442
|
this.dispatchEvent(new CustomEvent("clipboard", {
|
|
2385
2443
|
detail: {
|
|
@@ -2391,7 +2449,6 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2391
2449
|
return this._fail("Unexpected action in extended clipboard message: " + actions);
|
|
2392
2450
|
}
|
|
2393
2451
|
}
|
|
2394
|
-
|
|
2395
2452
|
return true;
|
|
2396
2453
|
}
|
|
2397
2454
|
}, {
|
|
@@ -2400,26 +2457,19 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2400
2457
|
if (this._sock.rQwait("ServerFence header", 8, 1)) {
|
|
2401
2458
|
return false;
|
|
2402
2459
|
}
|
|
2403
|
-
|
|
2404
2460
|
this._sock.rQskipBytes(3); // Padding
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
2461
|
var flags = this._sock.rQshift32();
|
|
2408
|
-
|
|
2409
2462
|
var length = this._sock.rQshift8();
|
|
2410
|
-
|
|
2411
2463
|
if (this._sock.rQwait("ServerFence payload", length, 9)) {
|
|
2412
2464
|
return false;
|
|
2413
2465
|
}
|
|
2414
|
-
|
|
2415
2466
|
if (length > 64) {
|
|
2416
2467
|
Log.Warn("Bad payload length (" + length + ") in fence response");
|
|
2417
2468
|
length = 64;
|
|
2418
2469
|
}
|
|
2419
|
-
|
|
2420
2470
|
var payload = this._sock.rQshiftStr(length);
|
|
2421
|
-
|
|
2422
2471
|
this._supportsFence = true;
|
|
2472
|
+
|
|
2423
2473
|
/*
|
|
2424
2474
|
* Fence flags
|
|
2425
2475
|
*
|
|
@@ -2431,14 +2481,15 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2431
2481
|
|
|
2432
2482
|
if (!(flags & 1 << 31)) {
|
|
2433
2483
|
return this._fail("Unexpected fence response");
|
|
2434
|
-
}
|
|
2435
|
-
// FIXME: support syncNext
|
|
2484
|
+
}
|
|
2436
2485
|
|
|
2486
|
+
// Filter out unsupported flags
|
|
2487
|
+
// FIXME: support syncNext
|
|
2488
|
+
flags &= 1 << 0 | 1 << 1;
|
|
2437
2489
|
|
|
2438
|
-
|
|
2490
|
+
// BlockBefore and BlockAfter are automatically handled by
|
|
2439
2491
|
// the fact that we process each incoming message
|
|
2440
2492
|
// synchronuosly.
|
|
2441
|
-
|
|
2442
2493
|
RFB.messages.clientFence(this._sock, flags, payload);
|
|
2443
2494
|
return true;
|
|
2444
2495
|
}
|
|
@@ -2448,65 +2499,47 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2448
2499
|
if (this._sock.rQwait("XVP version and message", 3, 1)) {
|
|
2449
2500
|
return false;
|
|
2450
2501
|
}
|
|
2451
|
-
|
|
2452
2502
|
this._sock.rQskipBytes(1); // Padding
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
2503
|
var xvpVer = this._sock.rQshift8();
|
|
2456
|
-
|
|
2457
2504
|
var xvpMsg = this._sock.rQshift8();
|
|
2458
|
-
|
|
2459
2505
|
switch (xvpMsg) {
|
|
2460
2506
|
case 0:
|
|
2461
2507
|
// XVP_FAIL
|
|
2462
2508
|
Log.Error("XVP Operation Failed");
|
|
2463
2509
|
break;
|
|
2464
|
-
|
|
2465
2510
|
case 1:
|
|
2466
2511
|
// XVP_INIT
|
|
2467
2512
|
this._rfbXvpVer = xvpVer;
|
|
2468
2513
|
Log.Info("XVP extensions enabled (version " + this._rfbXvpVer + ")");
|
|
2469
|
-
|
|
2470
2514
|
this._setCapability("power", true);
|
|
2471
|
-
|
|
2472
2515
|
break;
|
|
2473
|
-
|
|
2474
2516
|
default:
|
|
2475
2517
|
this._fail("Illegal server XVP message (msg: " + xvpMsg + ")");
|
|
2476
|
-
|
|
2477
2518
|
break;
|
|
2478
2519
|
}
|
|
2479
|
-
|
|
2480
2520
|
return true;
|
|
2481
2521
|
}
|
|
2482
2522
|
}, {
|
|
2483
2523
|
key: "_normalMsg",
|
|
2484
2524
|
value: function _normalMsg() {
|
|
2485
2525
|
var msgType;
|
|
2486
|
-
|
|
2487
2526
|
if (this._FBU.rects > 0) {
|
|
2488
2527
|
msgType = 0;
|
|
2489
2528
|
} else {
|
|
2490
2529
|
msgType = this._sock.rQshift8();
|
|
2491
2530
|
}
|
|
2492
|
-
|
|
2493
2531
|
var first, ret;
|
|
2494
|
-
|
|
2495
2532
|
switch (msgType) {
|
|
2496
2533
|
case 0:
|
|
2497
2534
|
// FramebufferUpdate
|
|
2498
2535
|
ret = this._framebufferUpdate();
|
|
2499
|
-
|
|
2500
2536
|
if (ret && !this._enabledContinuousUpdates) {
|
|
2501
2537
|
RFB.messages.fbUpdateRequest(this._sock, true, 0, 0, this._fbWidth, this._fbHeight);
|
|
2502
2538
|
}
|
|
2503
|
-
|
|
2504
2539
|
return ret;
|
|
2505
|
-
|
|
2506
2540
|
case 1:
|
|
2507
2541
|
// SetColorMapEntries
|
|
2508
2542
|
return this._handleSetColourMapMsg();
|
|
2509
|
-
|
|
2510
2543
|
case 2:
|
|
2511
2544
|
// Bell
|
|
2512
2545
|
Log.Debug("Bell");
|
|
@@ -2514,40 +2547,31 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2514
2547
|
detail: {}
|
|
2515
2548
|
}));
|
|
2516
2549
|
return true;
|
|
2517
|
-
|
|
2518
2550
|
case 3:
|
|
2519
2551
|
// ServerCutText
|
|
2520
2552
|
return this._handleServerCutText();
|
|
2521
|
-
|
|
2522
2553
|
case 150:
|
|
2523
2554
|
// EndOfContinuousUpdates
|
|
2524
2555
|
first = !this._supportsContinuousUpdates;
|
|
2525
2556
|
this._supportsContinuousUpdates = true;
|
|
2526
2557
|
this._enabledContinuousUpdates = false;
|
|
2527
|
-
|
|
2528
2558
|
if (first) {
|
|
2529
2559
|
this._enabledContinuousUpdates = true;
|
|
2530
|
-
|
|
2531
2560
|
this._updateContinuousUpdates();
|
|
2532
|
-
|
|
2533
2561
|
Log.Info("Enabling continuous updates.");
|
|
2534
|
-
} else {
|
|
2562
|
+
} else {
|
|
2563
|
+
// FIXME: We need to send a framebufferupdaterequest here
|
|
2535
2564
|
// if we add support for turning off continuous updates
|
|
2536
2565
|
}
|
|
2537
|
-
|
|
2538
2566
|
return true;
|
|
2539
|
-
|
|
2540
2567
|
case 248:
|
|
2541
2568
|
// ServerFence
|
|
2542
2569
|
return this._handleServerFenceMsg();
|
|
2543
|
-
|
|
2544
2570
|
case 250:
|
|
2545
2571
|
// XVP
|
|
2546
2572
|
return this._handleXvpMsg();
|
|
2547
|
-
|
|
2548
2573
|
default:
|
|
2549
2574
|
this._fail("Unexpected server message (type " + msgType + ")");
|
|
2550
|
-
|
|
2551
2575
|
Log.Debug("sock.rQslice(0, 30): " + this._sock.rQslice(0, 30));
|
|
2552
2576
|
return true;
|
|
2553
2577
|
}
|
|
@@ -2555,8 +2579,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2555
2579
|
}, {
|
|
2556
2580
|
key: "_onFlush",
|
|
2557
2581
|
value: function _onFlush() {
|
|
2558
|
-
this._flushing = false;
|
|
2559
|
-
|
|
2582
|
+
this._flushing = false;
|
|
2583
|
+
// Resume processing
|
|
2560
2584
|
if (this._sock.rQlen > 0) {
|
|
2561
2585
|
this._handleMessage();
|
|
2562
2586
|
}
|
|
@@ -2568,22 +2592,17 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2568
2592
|
if (this._sock.rQwait("FBU header", 3, 1)) {
|
|
2569
2593
|
return false;
|
|
2570
2594
|
}
|
|
2571
|
-
|
|
2572
2595
|
this._sock.rQskipBytes(1); // Padding
|
|
2596
|
+
this._FBU.rects = this._sock.rQshift16();
|
|
2573
2597
|
|
|
2574
|
-
|
|
2575
|
-
this._FBU.rects = this._sock.rQshift16(); // Make sure the previous frame is fully rendered first
|
|
2598
|
+
// Make sure the previous frame is fully rendered first
|
|
2576
2599
|
// to avoid building up an excessive queue
|
|
2577
|
-
|
|
2578
2600
|
if (this._display.pending()) {
|
|
2579
2601
|
this._flushing = true;
|
|
2580
|
-
|
|
2581
2602
|
this._display.flush();
|
|
2582
|
-
|
|
2583
2603
|
return false;
|
|
2584
2604
|
}
|
|
2585
2605
|
}
|
|
2586
|
-
|
|
2587
2606
|
while (this._FBU.rects > 0) {
|
|
2588
2607
|
if (this._FBU.encoding === null) {
|
|
2589
2608
|
if (this._sock.rQwait("rect header", 12)) {
|
|
@@ -2591,26 +2610,20 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2591
2610
|
}
|
|
2592
2611
|
/* New FramebufferUpdate */
|
|
2593
2612
|
|
|
2594
|
-
|
|
2595
2613
|
var hdr = this._sock.rQshiftBytes(12);
|
|
2596
|
-
|
|
2597
2614
|
this._FBU.x = (hdr[0] << 8) + hdr[1];
|
|
2598
2615
|
this._FBU.y = (hdr[2] << 8) + hdr[3];
|
|
2599
2616
|
this._FBU.width = (hdr[4] << 8) + hdr[5];
|
|
2600
2617
|
this._FBU.height = (hdr[6] << 8) + hdr[7];
|
|
2601
2618
|
this._FBU.encoding = parseInt((hdr[8] << 24) + (hdr[9] << 16) + (hdr[10] << 8) + hdr[11], 10);
|
|
2602
2619
|
}
|
|
2603
|
-
|
|
2604
2620
|
if (!this._handleRect()) {
|
|
2605
2621
|
return false;
|
|
2606
2622
|
}
|
|
2607
|
-
|
|
2608
2623
|
this._FBU.rects--;
|
|
2609
2624
|
this._FBU.encoding = null;
|
|
2610
2625
|
}
|
|
2611
|
-
|
|
2612
2626
|
this._display.flip();
|
|
2613
|
-
|
|
2614
2627
|
return true; // We finished this FBU
|
|
2615
2628
|
}
|
|
2616
2629
|
}, {
|
|
@@ -2619,30 +2632,21 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2619
2632
|
switch (this._FBU.encoding) {
|
|
2620
2633
|
case _encodings.encodings.pseudoEncodingLastRect:
|
|
2621
2634
|
this._FBU.rects = 1; // Will be decreased when we return
|
|
2622
|
-
|
|
2623
2635
|
return true;
|
|
2624
|
-
|
|
2625
2636
|
case _encodings.encodings.pseudoEncodingVMwareCursor:
|
|
2626
2637
|
return this._handleVMwareCursor();
|
|
2627
|
-
|
|
2628
2638
|
case _encodings.encodings.pseudoEncodingCursor:
|
|
2629
2639
|
return this._handleCursor();
|
|
2630
|
-
|
|
2631
2640
|
case _encodings.encodings.pseudoEncodingQEMUExtendedKeyEvent:
|
|
2632
2641
|
this._qemuExtKeyEventSupported = true;
|
|
2633
2642
|
return true;
|
|
2634
|
-
|
|
2635
2643
|
case _encodings.encodings.pseudoEncodingDesktopName:
|
|
2636
2644
|
return this._handleDesktopName();
|
|
2637
|
-
|
|
2638
2645
|
case _encodings.encodings.pseudoEncodingDesktopSize:
|
|
2639
2646
|
this._resize(this._FBU.width, this._FBU.height);
|
|
2640
|
-
|
|
2641
2647
|
return true;
|
|
2642
|
-
|
|
2643
2648
|
case _encodings.encodings.pseudoEncodingExtendedDesktopSize:
|
|
2644
2649
|
return this._handleExtendedDesktopSize();
|
|
2645
|
-
|
|
2646
2650
|
default:
|
|
2647
2651
|
return this._handleDataRect();
|
|
2648
2652
|
}
|
|
@@ -2651,46 +2655,35 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2651
2655
|
key: "_handleVMwareCursor",
|
|
2652
2656
|
value: function _handleVMwareCursor() {
|
|
2653
2657
|
var hotx = this._FBU.x; // hotspot-x
|
|
2654
|
-
|
|
2655
2658
|
var hoty = this._FBU.y; // hotspot-y
|
|
2656
|
-
|
|
2657
2659
|
var w = this._FBU.width;
|
|
2658
2660
|
var h = this._FBU.height;
|
|
2659
|
-
|
|
2660
2661
|
if (this._sock.rQwait("VMware cursor encoding", 1)) {
|
|
2661
2662
|
return false;
|
|
2662
2663
|
}
|
|
2663
|
-
|
|
2664
2664
|
var cursorType = this._sock.rQshift8();
|
|
2665
|
-
|
|
2666
2665
|
this._sock.rQshift8(); //Padding
|
|
2667
2666
|
|
|
2668
|
-
|
|
2669
2667
|
var rgba;
|
|
2670
|
-
var bytesPerPixel = 4;
|
|
2668
|
+
var bytesPerPixel = 4;
|
|
2671
2669
|
|
|
2670
|
+
//Classic cursor
|
|
2672
2671
|
if (cursorType == 0) {
|
|
2673
2672
|
//Used to filter away unimportant bits.
|
|
2674
2673
|
//OR is used for correct conversion in js.
|
|
2675
2674
|
var PIXEL_MASK = 0xffffff00 | 0;
|
|
2676
2675
|
rgba = new Array(w * h * bytesPerPixel);
|
|
2677
|
-
|
|
2678
2676
|
if (this._sock.rQwait("VMware cursor classic encoding", w * h * bytesPerPixel * 2, 2)) {
|
|
2679
2677
|
return false;
|
|
2680
2678
|
}
|
|
2681
|
-
|
|
2682
2679
|
var andMask = new Array(w * h);
|
|
2683
|
-
|
|
2684
2680
|
for (var pixel = 0; pixel < w * h; pixel++) {
|
|
2685
2681
|
andMask[pixel] = this._sock.rQshift32();
|
|
2686
2682
|
}
|
|
2687
|
-
|
|
2688
2683
|
var xorMask = new Array(w * h);
|
|
2689
|
-
|
|
2690
2684
|
for (var _pixel = 0; _pixel < w * h; _pixel++) {
|
|
2691
2685
|
xorMask[_pixel] = this._sock.rQshift32();
|
|
2692
2686
|
}
|
|
2693
|
-
|
|
2694
2687
|
for (var _pixel2 = 0; _pixel2 < w * h; _pixel2++) {
|
|
2695
2688
|
if (andMask[_pixel2] == 0) {
|
|
2696
2689
|
//Fully opaque pixel
|
|
@@ -2699,11 +2692,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2699
2692
|
var g = bgr >> 16 & 0xff;
|
|
2700
2693
|
var b = bgr >> 24 & 0xff;
|
|
2701
2694
|
rgba[_pixel2 * bytesPerPixel] = r; //r
|
|
2702
|
-
|
|
2703
2695
|
rgba[_pixel2 * bytesPerPixel + 1] = g; //g
|
|
2704
|
-
|
|
2705
2696
|
rgba[_pixel2 * bytesPerPixel + 2] = b; //b
|
|
2706
|
-
|
|
2707
2697
|
rgba[_pixel2 * bytesPerPixel + 3] = 0xff; //a
|
|
2708
2698
|
} else if ((andMask[_pixel2] & PIXEL_MASK) == PIXEL_MASK) {
|
|
2709
2699
|
//Only screen value matters, no mouse colouring
|
|
@@ -2734,60 +2724,47 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2734
2724
|
rgba[_pixel2 * bytesPerPixel + 2] = 0x00;
|
|
2735
2725
|
rgba[_pixel2 * bytesPerPixel + 3] = 0xff;
|
|
2736
2726
|
}
|
|
2737
|
-
}
|
|
2727
|
+
}
|
|
2738
2728
|
|
|
2729
|
+
//Alpha cursor.
|
|
2739
2730
|
} else if (cursorType == 1) {
|
|
2740
2731
|
if (this._sock.rQwait("VMware cursor alpha encoding", w * h * 4, 2)) {
|
|
2741
2732
|
return false;
|
|
2742
2733
|
}
|
|
2743
|
-
|
|
2744
2734
|
rgba = new Array(w * h * bytesPerPixel);
|
|
2745
|
-
|
|
2746
2735
|
for (var _pixel3 = 0; _pixel3 < w * h; _pixel3++) {
|
|
2747
2736
|
var data = this._sock.rQshift32();
|
|
2748
|
-
|
|
2749
2737
|
rgba[_pixel3 * 4] = data >> 24 & 0xff; //r
|
|
2750
|
-
|
|
2751
2738
|
rgba[_pixel3 * 4 + 1] = data >> 16 & 0xff; //g
|
|
2752
|
-
|
|
2753
2739
|
rgba[_pixel3 * 4 + 2] = data >> 8 & 0xff; //b
|
|
2754
|
-
|
|
2755
2740
|
rgba[_pixel3 * 4 + 3] = data & 0xff; //a
|
|
2756
2741
|
}
|
|
2757
2742
|
} else {
|
|
2758
2743
|
Log.Warn("The given cursor type is not supported: " + cursorType + " given.");
|
|
2759
2744
|
return false;
|
|
2760
2745
|
}
|
|
2761
|
-
|
|
2762
2746
|
this._updateCursor(rgba, hotx, hoty, w, h);
|
|
2763
|
-
|
|
2764
2747
|
return true;
|
|
2765
2748
|
}
|
|
2766
2749
|
}, {
|
|
2767
2750
|
key: "_handleCursor",
|
|
2768
2751
|
value: function _handleCursor() {
|
|
2769
2752
|
var hotx = this._FBU.x; // hotspot-x
|
|
2770
|
-
|
|
2771
2753
|
var hoty = this._FBU.y; // hotspot-y
|
|
2772
|
-
|
|
2773
2754
|
var w = this._FBU.width;
|
|
2774
2755
|
var h = this._FBU.height;
|
|
2775
2756
|
var pixelslength = w * h * 4;
|
|
2776
2757
|
var masklength = Math.ceil(w / 8) * h;
|
|
2777
2758
|
var bytes = pixelslength + masklength;
|
|
2778
|
-
|
|
2779
2759
|
if (this._sock.rQwait("cursor encoding", bytes)) {
|
|
2780
2760
|
return false;
|
|
2781
|
-
}
|
|
2782
|
-
|
|
2761
|
+
}
|
|
2783
2762
|
|
|
2763
|
+
// Decode from BGRX pixels + bit mask to RGBA
|
|
2784
2764
|
var pixels = this._sock.rQshiftBytes(pixelslength);
|
|
2785
|
-
|
|
2786
2765
|
var mask = this._sock.rQshiftBytes(masklength);
|
|
2787
|
-
|
|
2788
2766
|
var rgba = new Uint8Array(w * h * 4);
|
|
2789
2767
|
var pixIdx = 0;
|
|
2790
|
-
|
|
2791
2768
|
for (var y = 0; y < h; y++) {
|
|
2792
2769
|
for (var x = 0; x < w; x++) {
|
|
2793
2770
|
var maskIdx = y * Math.ceil(w / 8) + Math.floor(x / 8);
|
|
@@ -2799,9 +2776,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2799
2776
|
pixIdx += 4;
|
|
2800
2777
|
}
|
|
2801
2778
|
}
|
|
2802
|
-
|
|
2803
2779
|
this._updateCursor(rgba, hotx, hoty, w, h);
|
|
2804
|
-
|
|
2805
2780
|
return true;
|
|
2806
2781
|
}
|
|
2807
2782
|
}, {
|
|
@@ -2810,19 +2785,13 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2810
2785
|
if (this._sock.rQwait("DesktopName", 4)) {
|
|
2811
2786
|
return false;
|
|
2812
2787
|
}
|
|
2813
|
-
|
|
2814
2788
|
var length = this._sock.rQshift32();
|
|
2815
|
-
|
|
2816
2789
|
if (this._sock.rQwait("DesktopName", length, 4)) {
|
|
2817
2790
|
return false;
|
|
2818
2791
|
}
|
|
2819
|
-
|
|
2820
2792
|
var name = this._sock.rQshiftStr(length);
|
|
2821
|
-
|
|
2822
2793
|
name = (0, _strings.decodeUTF8)(name, true);
|
|
2823
|
-
|
|
2824
2794
|
this._setDesktopName(name);
|
|
2825
|
-
|
|
2826
2795
|
return true;
|
|
2827
2796
|
}
|
|
2828
2797
|
}, {
|
|
@@ -2831,53 +2800,38 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2831
2800
|
if (this._sock.rQwait("ExtendedDesktopSize", 4)) {
|
|
2832
2801
|
return false;
|
|
2833
2802
|
}
|
|
2834
|
-
|
|
2835
2803
|
var numberOfScreens = this._sock.rQpeek8();
|
|
2836
|
-
|
|
2837
2804
|
var bytes = 4 + numberOfScreens * 16;
|
|
2838
|
-
|
|
2839
2805
|
if (this._sock.rQwait("ExtendedDesktopSize", bytes)) {
|
|
2840
2806
|
return false;
|
|
2841
2807
|
}
|
|
2842
|
-
|
|
2843
2808
|
var firstUpdate = !this._supportsSetDesktopSize;
|
|
2844
|
-
this._supportsSetDesktopSize = true;
|
|
2809
|
+
this._supportsSetDesktopSize = true;
|
|
2810
|
+
|
|
2811
|
+
// Normally we only apply the current resize mode after a
|
|
2845
2812
|
// window resize event. However there is no such trigger on the
|
|
2846
2813
|
// initial connect. And we don't know if the server supports
|
|
2847
2814
|
// resizing until we've gotten here.
|
|
2848
|
-
|
|
2849
2815
|
if (firstUpdate) {
|
|
2850
2816
|
this._requestRemoteResize();
|
|
2851
2817
|
}
|
|
2852
|
-
|
|
2853
2818
|
this._sock.rQskipBytes(1); // number-of-screens
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
2819
|
this._sock.rQskipBytes(3); // padding
|
|
2857
2820
|
|
|
2858
|
-
|
|
2859
2821
|
for (var i = 0; i < numberOfScreens; i += 1) {
|
|
2860
2822
|
// Save the id and flags of the first screen
|
|
2861
2823
|
if (i === 0) {
|
|
2862
2824
|
this._screenID = this._sock.rQshiftBytes(4); // id
|
|
2863
|
-
|
|
2864
2825
|
this._sock.rQskipBytes(2); // x-position
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
2826
|
this._sock.rQskipBytes(2); // y-position
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
2827
|
this._sock.rQskipBytes(2); // width
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
2828
|
this._sock.rQskipBytes(2); // height
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
2829
|
this._screenFlags = this._sock.rQshiftBytes(4); // flags
|
|
2877
2830
|
} else {
|
|
2878
2831
|
this._sock.rQskipBytes(16);
|
|
2879
2832
|
}
|
|
2880
2833
|
}
|
|
2834
|
+
|
|
2881
2835
|
/*
|
|
2882
2836
|
* The x-position indicates the reason for the change:
|
|
2883
2837
|
*
|
|
@@ -2885,53 +2839,43 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2885
2839
|
* 1 - this client requested the resize
|
|
2886
2840
|
* 2 - another client requested the resize
|
|
2887
2841
|
*/
|
|
2888
|
-
// We need to handle errors when we requested the resize.
|
|
2889
|
-
|
|
2890
2842
|
|
|
2843
|
+
// We need to handle errors when we requested the resize.
|
|
2891
2844
|
if (this._FBU.x === 1 && this._FBU.y !== 0) {
|
|
2892
|
-
var msg = "";
|
|
2893
|
-
|
|
2845
|
+
var msg = "";
|
|
2846
|
+
// The y-position indicates the status code from the server
|
|
2894
2847
|
switch (this._FBU.y) {
|
|
2895
2848
|
case 1:
|
|
2896
2849
|
msg = "Resize is administratively prohibited";
|
|
2897
2850
|
break;
|
|
2898
|
-
|
|
2899
2851
|
case 2:
|
|
2900
2852
|
msg = "Out of resources";
|
|
2901
2853
|
break;
|
|
2902
|
-
|
|
2903
2854
|
case 3:
|
|
2904
2855
|
msg = "Invalid screen layout";
|
|
2905
2856
|
break;
|
|
2906
|
-
|
|
2907
2857
|
default:
|
|
2908
2858
|
msg = "Unknown reason";
|
|
2909
2859
|
break;
|
|
2910
2860
|
}
|
|
2911
|
-
|
|
2912
2861
|
Log.Warn("Server did not accept the resize request: " + msg);
|
|
2913
2862
|
} else {
|
|
2914
2863
|
this._resize(this._FBU.width, this._FBU.height);
|
|
2915
2864
|
}
|
|
2916
|
-
|
|
2917
2865
|
return true;
|
|
2918
2866
|
}
|
|
2919
2867
|
}, {
|
|
2920
2868
|
key: "_handleDataRect",
|
|
2921
2869
|
value: function _handleDataRect() {
|
|
2922
2870
|
var decoder = this._decoders[this._FBU.encoding];
|
|
2923
|
-
|
|
2924
2871
|
if (!decoder) {
|
|
2925
2872
|
this._fail("Unsupported encoding (encoding: " + this._FBU.encoding + ")");
|
|
2926
|
-
|
|
2927
2873
|
return false;
|
|
2928
2874
|
}
|
|
2929
|
-
|
|
2930
2875
|
try {
|
|
2931
2876
|
return decoder.decodeRect(this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height, this._sock, this._display, this._fbDepth);
|
|
2932
2877
|
} catch (err) {
|
|
2933
2878
|
this._fail("Error decoding rect: " + err);
|
|
2934
|
-
|
|
2935
2879
|
return false;
|
|
2936
2880
|
}
|
|
2937
2881
|
}
|
|
@@ -2941,7 +2885,6 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2941
2885
|
if (!this._enabledContinuousUpdates) {
|
|
2942
2886
|
return;
|
|
2943
2887
|
}
|
|
2944
|
-
|
|
2945
2888
|
RFB.messages.enableContinuousUpdates(this._sock, true, 0, 0, this._fbWidth, this._fbHeight);
|
|
2946
2889
|
}
|
|
2947
2890
|
}, {
|
|
@@ -2949,15 +2892,15 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2949
2892
|
value: function _resize(width, height) {
|
|
2950
2893
|
this._fbWidth = width;
|
|
2951
2894
|
this._fbHeight = height;
|
|
2895
|
+
this._display.resize(this._fbWidth, this._fbHeight);
|
|
2952
2896
|
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2897
|
+
// Adjust the visible viewport based on the new dimensions
|
|
2956
2898
|
this._updateClip();
|
|
2957
|
-
|
|
2958
2899
|
this._updateScale();
|
|
2959
|
-
|
|
2960
2900
|
this._updateContinuousUpdates();
|
|
2901
|
+
|
|
2902
|
+
// Keep this size until browser client size changes
|
|
2903
|
+
this._saveExpectedClientSize();
|
|
2961
2904
|
}
|
|
2962
2905
|
}, {
|
|
2963
2906
|
key: "_xvpOp",
|
|
@@ -2965,7 +2908,6 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2965
2908
|
if (this._rfbXvpVer < ver) {
|
|
2966
2909
|
return;
|
|
2967
2910
|
}
|
|
2968
|
-
|
|
2969
2911
|
Log.Info("Sending XVP operation " + op + " (version " + ver + ")");
|
|
2970
2912
|
RFB.messages.xvpOp(this._sock, ver, op);
|
|
2971
2913
|
}
|
|
@@ -2979,7 +2921,6 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2979
2921
|
w: w,
|
|
2980
2922
|
h: h
|
|
2981
2923
|
};
|
|
2982
|
-
|
|
2983
2924
|
this._refreshCursor();
|
|
2984
2925
|
}
|
|
2985
2926
|
}, {
|
|
@@ -2989,20 +2930,20 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2989
2930
|
if (!this._showDotCursor) {
|
|
2990
2931
|
// User does not want to see the dot, so...
|
|
2991
2932
|
return false;
|
|
2992
|
-
}
|
|
2933
|
+
}
|
|
2934
|
+
|
|
2935
|
+
// The dot should not be shown if the cursor is already visible,
|
|
2993
2936
|
// i.e. contains at least one not-fully-transparent pixel.
|
|
2994
2937
|
// So iterate through all alpha bytes in rgba and stop at the
|
|
2995
2938
|
// first non-zero.
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
2939
|
for (var i = 3; i < this._cursorImage.rgbaPixels.length; i += 4) {
|
|
2999
2940
|
if (this._cursorImage.rgbaPixels[i]) {
|
|
3000
2941
|
return false;
|
|
3001
2942
|
}
|
|
3002
|
-
}
|
|
3003
|
-
// the user wants to see the dot instead of this.
|
|
3004
|
-
|
|
2943
|
+
}
|
|
3005
2944
|
|
|
2945
|
+
// At this point, we know that the cursor is fully transparent, and
|
|
2946
|
+
// the user wants to see the dot instead of this.
|
|
3006
2947
|
return true;
|
|
3007
2948
|
}
|
|
3008
2949
|
}, {
|
|
@@ -3011,9 +2952,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
3011
2952
|
if (this._rfbConnectionState !== "connecting" && this._rfbConnectionState !== "connected") {
|
|
3012
2953
|
return;
|
|
3013
2954
|
}
|
|
3014
|
-
|
|
3015
2955
|
var image = this._shouldShowDotCursor() ? RFB.cursors.dot : this._cursorImage;
|
|
3016
|
-
|
|
3017
2956
|
this._cursor.change(image.rgbaPixels, image.hotx, image.hoty, image.w, image.h);
|
|
3018
2957
|
}
|
|
3019
2958
|
}], [{
|
|
@@ -3025,18 +2964,14 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
3025
2964
|
return new _des["default"](passwordChars).encrypt(challenge);
|
|
3026
2965
|
}
|
|
3027
2966
|
}]);
|
|
3028
|
-
|
|
3029
2967
|
return RFB;
|
|
3030
2968
|
}(_eventtarget["default"]); // Class Methods
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
2969
|
exports["default"] = RFB;
|
|
3034
2970
|
RFB.messages = {
|
|
3035
2971
|
keyEvent: function keyEvent(sock, keysym, down) {
|
|
3036
2972
|
var buff = sock._sQ;
|
|
3037
2973
|
var offset = sock._sQlen;
|
|
3038
2974
|
buff[offset] = 4; // msg-type
|
|
3039
|
-
|
|
3040
2975
|
buff[offset + 1] = down;
|
|
3041
2976
|
buff[offset + 2] = 0;
|
|
3042
2977
|
buff[offset + 3] = 0;
|
|
@@ -3051,18 +2986,14 @@ RFB.messages = {
|
|
|
3051
2986
|
function getRFBkeycode(xtScanCode) {
|
|
3052
2987
|
var upperByte = keycode >> 8;
|
|
3053
2988
|
var lowerByte = keycode & 0x00ff;
|
|
3054
|
-
|
|
3055
2989
|
if (upperByte === 0xe0 && lowerByte < 0x7f) {
|
|
3056
2990
|
return lowerByte | 0x80;
|
|
3057
2991
|
}
|
|
3058
|
-
|
|
3059
2992
|
return xtScanCode;
|
|
3060
2993
|
}
|
|
3061
|
-
|
|
3062
2994
|
var buff = sock._sQ;
|
|
3063
2995
|
var offset = sock._sQlen;
|
|
3064
2996
|
buff[offset] = 255; // msg-type
|
|
3065
|
-
|
|
3066
2997
|
buff[offset + 1] = 0; // sub msg-type
|
|
3067
2998
|
|
|
3068
2999
|
buff[offset + 2] = down >> 8;
|
|
@@ -3097,21 +3028,15 @@ RFB.messages = {
|
|
|
3097
3028
|
var data = new Uint8Array(4);
|
|
3098
3029
|
var formatFlag = 0x00000000;
|
|
3099
3030
|
var actionFlag = 0x00000000;
|
|
3100
|
-
|
|
3101
3031
|
for (var i = 0; i < actions.length; i++) {
|
|
3102
3032
|
actionFlag |= actions[i];
|
|
3103
3033
|
}
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
formatFlag |= formats[_i4];
|
|
3034
|
+
for (var _i10 = 0; _i10 < formats.length; _i10++) {
|
|
3035
|
+
formatFlag |= formats[_i10];
|
|
3107
3036
|
}
|
|
3108
|
-
|
|
3109
3037
|
data[0] = actionFlag >> 24; // Actions
|
|
3110
|
-
|
|
3111
3038
|
data[1] = 0x00; // Reserved
|
|
3112
|
-
|
|
3113
3039
|
data[2] = 0x00; // Reserved
|
|
3114
|
-
|
|
3115
3040
|
data[3] = formatFlag; // Formats
|
|
3116
3041
|
|
|
3117
3042
|
return data;
|
|
@@ -3120,26 +3045,25 @@ RFB.messages = {
|
|
|
3120
3045
|
// Deflate incomming data and their sizes
|
|
3121
3046
|
var deflator = new _deflator["default"]();
|
|
3122
3047
|
var dataToDeflate = [];
|
|
3123
|
-
|
|
3124
3048
|
for (var i = 0; i < formats.length; i++) {
|
|
3125
3049
|
// We only support the format Text at this time
|
|
3126
3050
|
if (formats[i] != extendedClipboardFormatText) {
|
|
3127
3051
|
throw new Error("Unsupported extended clipboard format for Provide message.");
|
|
3128
|
-
}
|
|
3129
|
-
|
|
3052
|
+
}
|
|
3130
3053
|
|
|
3131
|
-
|
|
3054
|
+
// Change lone \r or \n into \r\n as defined in rfbproto
|
|
3055
|
+
inData[i] = inData[i].replace(/\r\n|\r|\n/gm, "\r\n");
|
|
3132
3056
|
|
|
3057
|
+
// Check if it already has \0
|
|
3133
3058
|
var text = (0, _strings.encodeUTF8)(inData[i] + "\0");
|
|
3134
3059
|
dataToDeflate.push(text.length >> 24 & 0xFF, text.length >> 16 & 0xFF, text.length >> 8 & 0xFF, text.length & 0xFF);
|
|
3135
|
-
|
|
3136
3060
|
for (var j = 0; j < text.length; j++) {
|
|
3137
3061
|
dataToDeflate.push(text.charCodeAt(j));
|
|
3138
3062
|
}
|
|
3139
3063
|
}
|
|
3064
|
+
var deflatedData = deflator.deflate(new Uint8Array(dataToDeflate));
|
|
3140
3065
|
|
|
3141
|
-
|
|
3142
|
-
|
|
3066
|
+
// Build data to send
|
|
3143
3067
|
var data = new Uint8Array(4 + deflatedData.length);
|
|
3144
3068
|
data.set(RFB.messages._buildExtendedClipboardFlags([extendedClipboardActionProvide], formats));
|
|
3145
3069
|
data.set(deflatedData, 4);
|
|
@@ -3147,12 +3071,10 @@ RFB.messages = {
|
|
|
3147
3071
|
},
|
|
3148
3072
|
extendedClipboardNotify: function extendedClipboardNotify(sock, formats) {
|
|
3149
3073
|
var flags = RFB.messages._buildExtendedClipboardFlags([extendedClipboardActionNotify], formats);
|
|
3150
|
-
|
|
3151
3074
|
RFB.messages.clientCutText(sock, flags, true);
|
|
3152
3075
|
},
|
|
3153
3076
|
extendedClipboardRequest: function extendedClipboardRequest(sock, formats) {
|
|
3154
3077
|
var flags = RFB.messages._buildExtendedClipboardFlags([extendedClipboardActionRequest], formats);
|
|
3155
|
-
|
|
3156
3078
|
RFB.messages.clientCutText(sock, flags, true);
|
|
3157
3079
|
},
|
|
3158
3080
|
extendedClipboardCaps: function extendedClipboardCaps(sock, actions, formats) {
|
|
@@ -3166,7 +3088,6 @@ RFB.messages = {
|
|
|
3166
3088
|
});
|
|
3167
3089
|
data.set(RFB.messages._buildExtendedClipboardFlags(actions, []));
|
|
3168
3090
|
var loopOffset = 4;
|
|
3169
|
-
|
|
3170
3091
|
for (var i = 0; i < formatKeys.length; i++) {
|
|
3171
3092
|
data[loopOffset] = formats[formatKeys[i]] >> 24;
|
|
3172
3093
|
data[loopOffset + 1] = formats[formatKeys[i]] >> 16;
|
|
@@ -3185,36 +3106,30 @@ RFB.messages = {
|
|
|
3185
3106
|
buff[offset] = 6; // msg-type
|
|
3186
3107
|
|
|
3187
3108
|
buff[offset + 1] = 0; // padding
|
|
3188
|
-
|
|
3189
3109
|
buff[offset + 2] = 0; // padding
|
|
3190
|
-
|
|
3191
3110
|
buff[offset + 3] = 0; // padding
|
|
3192
3111
|
|
|
3193
3112
|
var length;
|
|
3194
|
-
|
|
3195
3113
|
if (extended) {
|
|
3196
3114
|
length = (0, _int.toUnsigned32bit)(-data.length);
|
|
3197
3115
|
} else {
|
|
3198
3116
|
length = data.length;
|
|
3199
3117
|
}
|
|
3200
|
-
|
|
3201
3118
|
buff[offset + 4] = length >> 24;
|
|
3202
3119
|
buff[offset + 5] = length >> 16;
|
|
3203
3120
|
buff[offset + 6] = length >> 8;
|
|
3204
3121
|
buff[offset + 7] = length;
|
|
3205
|
-
sock._sQlen += 8;
|
|
3206
|
-
// buffer for the flush in the next iteration.
|
|
3122
|
+
sock._sQlen += 8;
|
|
3207
3123
|
|
|
3124
|
+
// We have to keep track of from where in the data we begin creating the
|
|
3125
|
+
// buffer for the flush in the next iteration.
|
|
3208
3126
|
var dataOffset = 0;
|
|
3209
3127
|
var remaining = data.length;
|
|
3210
|
-
|
|
3211
3128
|
while (remaining > 0) {
|
|
3212
3129
|
var flushSize = Math.min(remaining, sock._sQbufferSize - sock._sQlen);
|
|
3213
|
-
|
|
3214
3130
|
for (var i = 0; i < flushSize; i++) {
|
|
3215
3131
|
buff[sock._sQlen + i] = data[dataOffset + i];
|
|
3216
3132
|
}
|
|
3217
|
-
|
|
3218
3133
|
sock._sQlen += flushSize;
|
|
3219
3134
|
sock.flush();
|
|
3220
3135
|
remaining -= flushSize;
|
|
@@ -3225,39 +3140,28 @@ RFB.messages = {
|
|
|
3225
3140
|
var buff = sock._sQ;
|
|
3226
3141
|
var offset = sock._sQlen;
|
|
3227
3142
|
buff[offset] = 251; // msg-type
|
|
3228
|
-
|
|
3229
3143
|
buff[offset + 1] = 0; // padding
|
|
3230
|
-
|
|
3231
3144
|
buff[offset + 2] = width >> 8; // width
|
|
3232
|
-
|
|
3233
3145
|
buff[offset + 3] = width;
|
|
3234
3146
|
buff[offset + 4] = height >> 8; // height
|
|
3235
|
-
|
|
3236
3147
|
buff[offset + 5] = height;
|
|
3237
3148
|
buff[offset + 6] = 1; // number-of-screens
|
|
3238
|
-
|
|
3239
3149
|
buff[offset + 7] = 0; // padding
|
|
3240
|
-
// screen array
|
|
3241
3150
|
|
|
3151
|
+
// screen array
|
|
3242
3152
|
buff[offset + 8] = id >> 24; // id
|
|
3243
|
-
|
|
3244
3153
|
buff[offset + 9] = id >> 16;
|
|
3245
3154
|
buff[offset + 10] = id >> 8;
|
|
3246
3155
|
buff[offset + 11] = id;
|
|
3247
3156
|
buff[offset + 12] = 0; // x-position
|
|
3248
|
-
|
|
3249
3157
|
buff[offset + 13] = 0;
|
|
3250
3158
|
buff[offset + 14] = 0; // y-position
|
|
3251
|
-
|
|
3252
3159
|
buff[offset + 15] = 0;
|
|
3253
3160
|
buff[offset + 16] = width >> 8; // width
|
|
3254
|
-
|
|
3255
3161
|
buff[offset + 17] = width;
|
|
3256
3162
|
buff[offset + 18] = height >> 8; // height
|
|
3257
|
-
|
|
3258
3163
|
buff[offset + 19] = height;
|
|
3259
3164
|
buff[offset + 20] = flags >> 24; // flags
|
|
3260
|
-
|
|
3261
3165
|
buff[offset + 21] = flags >> 16;
|
|
3262
3166
|
buff[offset + 22] = flags >> 8;
|
|
3263
3167
|
buff[offset + 23] = flags;
|
|
@@ -3270,13 +3174,10 @@ RFB.messages = {
|
|
|
3270
3174
|
buff[offset] = 248; // msg-type
|
|
3271
3175
|
|
|
3272
3176
|
buff[offset + 1] = 0; // padding
|
|
3273
|
-
|
|
3274
3177
|
buff[offset + 2] = 0; // padding
|
|
3275
|
-
|
|
3276
3178
|
buff[offset + 3] = 0; // padding
|
|
3277
3179
|
|
|
3278
3180
|
buff[offset + 4] = flags >> 24; // flags
|
|
3279
|
-
|
|
3280
3181
|
buff[offset + 5] = flags >> 16;
|
|
3281
3182
|
buff[offset + 6] = flags >> 8;
|
|
3282
3183
|
buff[offset + 7] = flags;
|
|
@@ -3286,7 +3187,6 @@ RFB.messages = {
|
|
|
3286
3187
|
for (var i = 0; i < n; i++) {
|
|
3287
3188
|
buff[offset + 9 + i] = payload.charCodeAt(i);
|
|
3288
3189
|
}
|
|
3289
|
-
|
|
3290
3190
|
sock._sQlen += 9 + n;
|
|
3291
3191
|
sock.flush();
|
|
3292
3192
|
},
|
|
@@ -3294,20 +3194,15 @@ RFB.messages = {
|
|
|
3294
3194
|
var buff = sock._sQ;
|
|
3295
3195
|
var offset = sock._sQlen;
|
|
3296
3196
|
buff[offset] = 150; // msg-type
|
|
3297
|
-
|
|
3298
3197
|
buff[offset + 1] = enable; // enable-flag
|
|
3299
3198
|
|
|
3300
3199
|
buff[offset + 2] = x >> 8; // x
|
|
3301
|
-
|
|
3302
3200
|
buff[offset + 3] = x;
|
|
3303
3201
|
buff[offset + 4] = y >> 8; // y
|
|
3304
|
-
|
|
3305
3202
|
buff[offset + 5] = y;
|
|
3306
3203
|
buff[offset + 6] = width >> 8; // width
|
|
3307
|
-
|
|
3308
3204
|
buff[offset + 7] = width;
|
|
3309
3205
|
buff[offset + 8] = height >> 8; // height
|
|
3310
|
-
|
|
3311
3206
|
buff[offset + 9] = height;
|
|
3312
3207
|
sock._sQlen += 10;
|
|
3313
3208
|
sock.flush();
|
|
@@ -3316,7 +3211,6 @@ RFB.messages = {
|
|
|
3316
3211
|
var buff = sock._sQ;
|
|
3317
3212
|
var offset = sock._sQlen;
|
|
3318
3213
|
var bpp;
|
|
3319
|
-
|
|
3320
3214
|
if (depth > 16) {
|
|
3321
3215
|
bpp = 32;
|
|
3322
3216
|
} else if (depth > 8) {
|
|
@@ -3324,46 +3218,33 @@ RFB.messages = {
|
|
|
3324
3218
|
} else {
|
|
3325
3219
|
bpp = 8;
|
|
3326
3220
|
}
|
|
3327
|
-
|
|
3328
3221
|
var bits = Math.floor(depth / 3);
|
|
3329
3222
|
buff[offset] = 0; // msg-type
|
|
3330
3223
|
|
|
3331
3224
|
buff[offset + 1] = 0; // padding
|
|
3332
|
-
|
|
3333
3225
|
buff[offset + 2] = 0; // padding
|
|
3334
|
-
|
|
3335
3226
|
buff[offset + 3] = 0; // padding
|
|
3336
3227
|
|
|
3337
3228
|
buff[offset + 4] = bpp; // bits-per-pixel
|
|
3338
|
-
|
|
3339
3229
|
buff[offset + 5] = depth; // depth
|
|
3340
|
-
|
|
3341
3230
|
buff[offset + 6] = 0; // little-endian
|
|
3342
|
-
|
|
3343
3231
|
buff[offset + 7] = trueColor ? 1 : 0; // true-color
|
|
3344
3232
|
|
|
3345
3233
|
buff[offset + 8] = 0; // red-max
|
|
3346
|
-
|
|
3347
3234
|
buff[offset + 9] = (1 << bits) - 1; // red-max
|
|
3348
3235
|
|
|
3349
3236
|
buff[offset + 10] = 0; // green-max
|
|
3350
|
-
|
|
3351
3237
|
buff[offset + 11] = (1 << bits) - 1; // green-max
|
|
3352
3238
|
|
|
3353
3239
|
buff[offset + 12] = 0; // blue-max
|
|
3354
|
-
|
|
3355
3240
|
buff[offset + 13] = (1 << bits) - 1; // blue-max
|
|
3356
3241
|
|
|
3357
3242
|
buff[offset + 14] = bits * 0; // red-shift
|
|
3358
|
-
|
|
3359
3243
|
buff[offset + 15] = bits * 1; // green-shift
|
|
3360
|
-
|
|
3361
3244
|
buff[offset + 16] = bits * 2; // blue-shift
|
|
3362
3245
|
|
|
3363
3246
|
buff[offset + 17] = 0; // padding
|
|
3364
|
-
|
|
3365
3247
|
buff[offset + 18] = 0; // padding
|
|
3366
|
-
|
|
3367
3248
|
buff[offset + 19] = 0; // padding
|
|
3368
3249
|
|
|
3369
3250
|
sock._sQlen += 20;
|
|
@@ -3373,13 +3254,11 @@ RFB.messages = {
|
|
|
3373
3254
|
var buff = sock._sQ;
|
|
3374
3255
|
var offset = sock._sQlen;
|
|
3375
3256
|
buff[offset] = 2; // msg-type
|
|
3376
|
-
|
|
3377
3257
|
buff[offset + 1] = 0; // padding
|
|
3378
3258
|
|
|
3379
3259
|
buff[offset + 2] = encodings.length >> 8;
|
|
3380
3260
|
buff[offset + 3] = encodings.length;
|
|
3381
3261
|
var j = offset + 4;
|
|
3382
|
-
|
|
3383
3262
|
for (var i = 0; i < encodings.length; i++) {
|
|
3384
3263
|
var enc = encodings[i];
|
|
3385
3264
|
buff[j] = enc >> 24;
|
|
@@ -3388,24 +3267,19 @@ RFB.messages = {
|
|
|
3388
3267
|
buff[j + 3] = enc;
|
|
3389
3268
|
j += 4;
|
|
3390
3269
|
}
|
|
3391
|
-
|
|
3392
3270
|
sock._sQlen += j - offset;
|
|
3393
3271
|
sock.flush();
|
|
3394
3272
|
},
|
|
3395
3273
|
fbUpdateRequest: function fbUpdateRequest(sock, incremental, x, y, w, h) {
|
|
3396
3274
|
var buff = sock._sQ;
|
|
3397
3275
|
var offset = sock._sQlen;
|
|
3398
|
-
|
|
3399
3276
|
if (typeof x === "undefined") {
|
|
3400
3277
|
x = 0;
|
|
3401
3278
|
}
|
|
3402
|
-
|
|
3403
3279
|
if (typeof y === "undefined") {
|
|
3404
3280
|
y = 0;
|
|
3405
3281
|
}
|
|
3406
|
-
|
|
3407
3282
|
buff[offset] = 3; // msg-type
|
|
3408
|
-
|
|
3409
3283
|
buff[offset + 1] = incremental ? 1 : 0;
|
|
3410
3284
|
buff[offset + 2] = x >> 8 & 0xFF;
|
|
3411
3285
|
buff[offset + 3] = x & 0xFF;
|
|
@@ -3422,7 +3296,6 @@ RFB.messages = {
|
|
|
3422
3296
|
var buff = sock._sQ;
|
|
3423
3297
|
var offset = sock._sQlen;
|
|
3424
3298
|
buff[offset] = 250; // msg-type
|
|
3425
|
-
|
|
3426
3299
|
buff[offset + 1] = 0; // padding
|
|
3427
3300
|
|
|
3428
3301
|
buff[offset + 2] = ver;
|
|
@@ -3442,7 +3315,6 @@ RFB.cursors = {
|
|
|
3442
3315
|
dot: {
|
|
3443
3316
|
/* eslint-disable indent */
|
|
3444
3317
|
rgbaPixels: new Uint8Array([255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255]),
|
|
3445
|
-
|
|
3446
3318
|
/* eslint-enable indent */
|
|
3447
3319
|
w: 3,
|
|
3448
3320
|
h: 3,
|