@novnc/novnc 1.3.0-beta → 1.3.0-g1075cd8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -3
- package/core/decoders/jpeg.js +141 -0
- package/core/decoders/raw.js +1 -1
- package/core/decoders/zrle.js +185 -0
- package/core/encodings.js +4 -0
- package/core/ra2.js +567 -0
- package/core/rfb.js +219 -8
- package/core/util/md5.js +79 -0
- package/docs/API.md +44 -4
- package/lib/base64.js +1 -1
- package/lib/decoders/copyrect.js +1 -1
- package/lib/decoders/hextile.js +2 -2
- package/lib/decoders/jpeg.js +188 -0
- package/lib/decoders/raw.js +2 -2
- package/lib/decoders/rre.js +1 -1
- package/lib/decoders/tight.js +2 -2
- package/lib/decoders/tightpng.js +3 -3
- package/lib/decoders/zrle.js +234 -0
- package/lib/deflator.js +1 -1
- package/lib/des.js +1 -1
- package/lib/display.js +2 -2
- package/lib/encodings.js +8 -0
- package/lib/inflator.js +1 -1
- package/lib/input/gesturehandler.js +1 -1
- package/lib/input/keyboard.js +2 -2
- package/lib/input/util.js +2 -2
- package/lib/ra2.js +1257 -0
- package/lib/rfb.js +373 -27
- package/lib/util/browser.js +10 -6
- package/lib/util/cursor.js +1 -1
- package/lib/util/events.js +2 -2
- package/lib/util/eventtarget.js +1 -1
- package/lib/util/int.js +1 -1
- package/lib/util/logging.js +2 -2
- package/lib/util/md5.js +103 -0
- package/lib/vendor/pako/lib/utils/common.js +2 -2
- package/lib/vendor/pako/lib/zlib/deflate.js +6 -5
- package/lib/vendor/pako/lib/zlib/inffast.js +6 -2
- package/lib/vendor/pako/lib/zlib/inflate.js +41 -18
- package/lib/vendor/pako/lib/zlib/inftrees.js +1 -1
- package/lib/vendor/pako/lib/zlib/trees.js +3 -3
- package/lib/websock.js +2 -2
- package/package.json +2 -7
package/lib/rfb.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -43,6 +43,10 @@ var _xtscancodes = _interopRequireDefault(require("./input/xtscancodes.js"));
|
|
|
43
43
|
|
|
44
44
|
var _encodings = require("./encodings.js");
|
|
45
45
|
|
|
46
|
+
var _ra = _interopRequireDefault(require("./ra2.js"));
|
|
47
|
+
|
|
48
|
+
var _md = require("./util/md5.js");
|
|
49
|
+
|
|
46
50
|
var _raw = _interopRequireDefault(require("./decoders/raw.js"));
|
|
47
51
|
|
|
48
52
|
var _copyrect = _interopRequireDefault(require("./decoders/copyrect.js"));
|
|
@@ -55,19 +59,39 @@ var _tight = _interopRequireDefault(require("./decoders/tight.js"));
|
|
|
55
59
|
|
|
56
60
|
var _tightpng = _interopRequireDefault(require("./decoders/tightpng.js"));
|
|
57
61
|
|
|
62
|
+
var _zrle = _interopRequireDefault(require("./decoders/zrle.js"));
|
|
63
|
+
|
|
64
|
+
var _jpeg = _interopRequireDefault(require("./decoders/jpeg.js"));
|
|
65
|
+
|
|
58
66
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
59
67
|
|
|
60
68
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
61
69
|
|
|
62
70
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
63
71
|
|
|
72
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
73
|
+
|
|
74
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
75
|
+
|
|
76
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
77
|
+
|
|
78
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
79
|
+
|
|
80
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
81
|
+
|
|
82
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
83
|
+
|
|
84
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
85
|
+
|
|
86
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
87
|
+
|
|
64
88
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
65
89
|
|
|
66
90
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
67
91
|
|
|
68
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
92
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
69
93
|
|
|
70
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
94
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
71
95
|
|
|
72
96
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
73
97
|
|
|
@@ -151,7 +175,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
151
175
|
_this._rfbConnectionState = '';
|
|
152
176
|
_this._rfbInitState = '';
|
|
153
177
|
_this._rfbAuthScheme = -1;
|
|
154
|
-
_this._rfbCleanDisconnect = true;
|
|
178
|
+
_this._rfbCleanDisconnect = true;
|
|
179
|
+
_this._rfbRSAAESAuthenticationState = null; // Server capabilities
|
|
155
180
|
|
|
156
181
|
_this._rfbVersion = 0;
|
|
157
182
|
_this._rfbMaxVersion = 3.8;
|
|
@@ -223,7 +248,9 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
223
248
|
handleResize: _this._handleResize.bind(_assertThisInitialized(_this)),
|
|
224
249
|
handleMouse: _this._handleMouse.bind(_assertThisInitialized(_this)),
|
|
225
250
|
handleWheel: _this._handleWheel.bind(_assertThisInitialized(_this)),
|
|
226
|
-
handleGesture: _this._handleGesture.bind(_assertThisInitialized(_this))
|
|
251
|
+
handleGesture: _this._handleGesture.bind(_assertThisInitialized(_this)),
|
|
252
|
+
handleRSAAESCredentialsRequired: _this._handleRSAAESCredentialsRequired.bind(_assertThisInitialized(_this)),
|
|
253
|
+
handleRSAAESServerVerification: _this._handleRSAAESServerVerification.bind(_assertThisInitialized(_this))
|
|
227
254
|
}; // main setup
|
|
228
255
|
|
|
229
256
|
Log.Debug(">> RFB.constructor"); // Create DOM elements
|
|
@@ -262,7 +289,9 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
262
289
|
_this._decoders[_encodings.encodings.encodingRRE] = new _rre["default"]();
|
|
263
290
|
_this._decoders[_encodings.encodings.encodingHextile] = new _hextile["default"]();
|
|
264
291
|
_this._decoders[_encodings.encodings.encodingTight] = new _tight["default"]();
|
|
265
|
-
_this._decoders[_encodings.encodings.encodingTightPNG] = new _tightpng["default"]();
|
|
292
|
+
_this._decoders[_encodings.encodings.encodingTightPNG] = new _tightpng["default"]();
|
|
293
|
+
_this._decoders[_encodings.encodings.encodingZRLE] = new _zrle["default"]();
|
|
294
|
+
_this._decoders[_encodings.encodings.encodingJPEG] = new _jpeg["default"](); // NB: nothing that needs explicit teardown should be done
|
|
266
295
|
// before this point, since this can throw an exception
|
|
267
296
|
|
|
268
297
|
try {
|
|
@@ -286,6 +315,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
286
315
|
|
|
287
316
|
_this._sock.on('error', _this._socketError.bind(_assertThisInitialized(_this)));
|
|
288
317
|
|
|
318
|
+
_this._expectedClientWidth = null;
|
|
319
|
+
_this._expectedClientHeight = null;
|
|
289
320
|
_this._resizeObserver = new ResizeObserver(_this._eventHandlers.handleResize); // All prepared, kick off the connection
|
|
290
321
|
|
|
291
322
|
_this._updateConnectionState('connecting');
|
|
@@ -452,6 +483,17 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
452
483
|
this._sock.off('message');
|
|
453
484
|
|
|
454
485
|
this._sock.off('open');
|
|
486
|
+
|
|
487
|
+
if (this._rfbRSAAESAuthenticationState !== null) {
|
|
488
|
+
this._rfbRSAAESAuthenticationState.disconnect();
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}, {
|
|
492
|
+
key: "approveServer",
|
|
493
|
+
value: function approveServer() {
|
|
494
|
+
if (this._rfbRSAAESAuthenticationState !== null) {
|
|
495
|
+
this._rfbRSAAESAuthenticationState.approveServer();
|
|
496
|
+
}
|
|
455
497
|
}
|
|
456
498
|
}, {
|
|
457
499
|
key: "sendCredentials",
|
|
@@ -522,8 +564,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
522
564
|
}
|
|
523
565
|
}, {
|
|
524
566
|
key: "focus",
|
|
525
|
-
value: function focus() {
|
|
526
|
-
this._canvas.focus();
|
|
567
|
+
value: function focus(options) {
|
|
568
|
+
this._canvas.focus(options);
|
|
527
569
|
}
|
|
528
570
|
}, {
|
|
529
571
|
key: "blur",
|
|
@@ -746,7 +788,9 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
746
788
|
return;
|
|
747
789
|
}
|
|
748
790
|
|
|
749
|
-
this.focus(
|
|
791
|
+
this.focus({
|
|
792
|
+
preventScroll: true
|
|
793
|
+
});
|
|
750
794
|
}
|
|
751
795
|
}, {
|
|
752
796
|
key: "_setDesktopName",
|
|
@@ -758,13 +802,39 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
758
802
|
}
|
|
759
803
|
}));
|
|
760
804
|
}
|
|
805
|
+
}, {
|
|
806
|
+
key: "_saveExpectedClientSize",
|
|
807
|
+
value: function _saveExpectedClientSize() {
|
|
808
|
+
this._expectedClientWidth = this._screen.clientWidth;
|
|
809
|
+
this._expectedClientHeight = this._screen.clientHeight;
|
|
810
|
+
}
|
|
811
|
+
}, {
|
|
812
|
+
key: "_currentClientSize",
|
|
813
|
+
value: function _currentClientSize() {
|
|
814
|
+
return [this._screen.clientWidth, this._screen.clientHeight];
|
|
815
|
+
}
|
|
816
|
+
}, {
|
|
817
|
+
key: "_clientHasExpectedSize",
|
|
818
|
+
value: function _clientHasExpectedSize() {
|
|
819
|
+
var _this$_currentClientS = this._currentClientSize(),
|
|
820
|
+
_this$_currentClientS2 = _slicedToArray(_this$_currentClientS, 2),
|
|
821
|
+
currentWidth = _this$_currentClientS2[0],
|
|
822
|
+
currentHeight = _this$_currentClientS2[1];
|
|
823
|
+
|
|
824
|
+
return currentWidth == this._expectedClientWidth && currentHeight == this._expectedClientHeight;
|
|
825
|
+
}
|
|
761
826
|
}, {
|
|
762
827
|
key: "_handleResize",
|
|
763
828
|
value: function _handleResize() {
|
|
764
829
|
var _this2 = this;
|
|
765
830
|
|
|
766
|
-
//
|
|
831
|
+
// Don't change anything if the client size is already as expected
|
|
832
|
+
if (this._clientHasExpectedSize()) {
|
|
833
|
+
return;
|
|
834
|
+
} // If the window resized then our screen element might have
|
|
767
835
|
// as well. Update the viewport dimensions.
|
|
836
|
+
|
|
837
|
+
|
|
768
838
|
window.requestAnimationFrame(function () {
|
|
769
839
|
_this2._updateClip();
|
|
770
840
|
|
|
@@ -805,6 +875,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
805
875
|
this._display.viewportChangeSize(size.w, size.h);
|
|
806
876
|
|
|
807
877
|
this._fixScrollbars();
|
|
878
|
+
} // When changing clipping we might show or hide scrollbars.
|
|
879
|
+
// This causes the expected client dimensions to change.
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
if (curClip !== newClip) {
|
|
883
|
+
this._saveExpectedClientSize();
|
|
808
884
|
}
|
|
809
885
|
}
|
|
810
886
|
}, {
|
|
@@ -851,11 +927,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
851
927
|
}, {
|
|
852
928
|
key: "_fixScrollbars",
|
|
853
929
|
value: function _fixScrollbars() {
|
|
854
|
-
// This is a hack because
|
|
855
|
-
// for when scrollbars are needed.
|
|
856
|
-
//
|
|
930
|
+
// This is a hack because Safari on macOS screws up the calculation
|
|
931
|
+
// for when scrollbars are needed. We get scrollbars when making the
|
|
932
|
+
// browser smaller, despite remote resize being enabled. So to fix it
|
|
933
|
+
// we temporarily toggle them off and on.
|
|
857
934
|
var orig = this._screen.style.overflow;
|
|
858
|
-
this._screen.style.overflow = 'hidden'; // Force
|
|
935
|
+
this._screen.style.overflow = 'hidden'; // Force Safari to recalculate the layout by asking for
|
|
859
936
|
// an element's dimensions
|
|
860
937
|
|
|
861
938
|
this._screen.getBoundingClientRect();
|
|
@@ -1503,10 +1580,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1503
1580
|
break;
|
|
1504
1581
|
|
|
1505
1582
|
case "003.003":
|
|
1506
|
-
case "003.006":
|
|
1507
|
-
|
|
1508
|
-
case "003.889":
|
|
1509
|
-
// Apple Remote Desktop
|
|
1583
|
+
case "003.006":
|
|
1584
|
+
// UltraVNC
|
|
1510
1585
|
this._rfbVersion = 3.3;
|
|
1511
1586
|
break;
|
|
1512
1587
|
|
|
@@ -1515,6 +1590,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1515
1590
|
break;
|
|
1516
1591
|
|
|
1517
1592
|
case "003.008":
|
|
1593
|
+
case "003.889": // Apple Remote Desktop
|
|
1594
|
+
|
|
1518
1595
|
case "004.000": // Intel AMT KVM
|
|
1519
1596
|
|
|
1520
1597
|
case "004.001": // RealVNC 4.6
|
|
@@ -1579,8 +1656,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1579
1656
|
this._rfbAuthScheme = 22; // XVP
|
|
1580
1657
|
} else if (types.includes(16)) {
|
|
1581
1658
|
this._rfbAuthScheme = 16; // Tight
|
|
1659
|
+
} else if (types.includes(6)) {
|
|
1660
|
+
this._rfbAuthScheme = 6; // RA2ne Auth
|
|
1582
1661
|
} else if (types.includes(2)) {
|
|
1583
1662
|
this._rfbAuthScheme = 2; // VNC Auth
|
|
1663
|
+
} else if (types.includes(30)) {
|
|
1664
|
+
this._rfbAuthScheme = 30; // ARD Auth
|
|
1584
1665
|
} else if (types.includes(19)) {
|
|
1585
1666
|
this._rfbAuthScheme = 19; // VeNCrypt Auth
|
|
1586
1667
|
} else {
|
|
@@ -1794,6 +1875,209 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1794
1875
|
this._rfbInitState = "SecurityResult";
|
|
1795
1876
|
return true;
|
|
1796
1877
|
}
|
|
1878
|
+
}, {
|
|
1879
|
+
key: "_negotiateARDAuth",
|
|
1880
|
+
value: function _negotiateARDAuth() {
|
|
1881
|
+
if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
|
|
1882
|
+
this.dispatchEvent(new CustomEvent("credentialsrequired", {
|
|
1883
|
+
detail: {
|
|
1884
|
+
types: ["username", "password"]
|
|
1885
|
+
}
|
|
1886
|
+
}));
|
|
1887
|
+
return false;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
if (this._rfbCredentials.ardPublicKey != undefined && this._rfbCredentials.ardCredentials != undefined) {
|
|
1891
|
+
// if the async web crypto is done return the results
|
|
1892
|
+
this._sock.send(this._rfbCredentials.ardCredentials);
|
|
1893
|
+
|
|
1894
|
+
this._sock.send(this._rfbCredentials.ardPublicKey);
|
|
1895
|
+
|
|
1896
|
+
this._rfbCredentials.ardCredentials = null;
|
|
1897
|
+
this._rfbCredentials.ardPublicKey = null;
|
|
1898
|
+
this._rfbInitState = "SecurityResult";
|
|
1899
|
+
return true;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
if (this._sock.rQwait("read ard", 4)) {
|
|
1903
|
+
return false;
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
var generator = this._sock.rQshiftBytes(2); // DH base generator value
|
|
1907
|
+
|
|
1908
|
+
|
|
1909
|
+
var keyLength = this._sock.rQshift16();
|
|
1910
|
+
|
|
1911
|
+
if (this._sock.rQwait("read ard keylength", keyLength * 2, 4)) {
|
|
1912
|
+
return false;
|
|
1913
|
+
} // read the server values
|
|
1914
|
+
|
|
1915
|
+
|
|
1916
|
+
var prime = this._sock.rQshiftBytes(keyLength); // predetermined prime modulus
|
|
1917
|
+
|
|
1918
|
+
|
|
1919
|
+
var serverPublicKey = this._sock.rQshiftBytes(keyLength); // other party's public key
|
|
1920
|
+
|
|
1921
|
+
|
|
1922
|
+
var clientPrivateKey = window.crypto.getRandomValues(new Uint8Array(keyLength));
|
|
1923
|
+
var padding = Array.from(window.crypto.getRandomValues(new Uint8Array(64)), function (_byte) {
|
|
1924
|
+
return String.fromCharCode(65 + _byte % 26);
|
|
1925
|
+
}).join('');
|
|
1926
|
+
|
|
1927
|
+
this._negotiateARDAuthAsync(generator, keyLength, prime, serverPublicKey, clientPrivateKey, padding);
|
|
1928
|
+
|
|
1929
|
+
return false;
|
|
1930
|
+
}
|
|
1931
|
+
}, {
|
|
1932
|
+
key: "_modPow",
|
|
1933
|
+
value: function _modPow(base, exponent, modulus) {
|
|
1934
|
+
var baseHex = "0x" + Array.from(base, function (_byte2) {
|
|
1935
|
+
return ('0' + (_byte2 & 0xFF).toString(16)).slice(-2);
|
|
1936
|
+
}).join('');
|
|
1937
|
+
var exponentHex = "0x" + Array.from(exponent, function (_byte3) {
|
|
1938
|
+
return ('0' + (_byte3 & 0xFF).toString(16)).slice(-2);
|
|
1939
|
+
}).join('');
|
|
1940
|
+
var modulusHex = "0x" + Array.from(modulus, function (_byte4) {
|
|
1941
|
+
return ('0' + (_byte4 & 0xFF).toString(16)).slice(-2);
|
|
1942
|
+
}).join('');
|
|
1943
|
+
var b = BigInt(baseHex);
|
|
1944
|
+
var e = BigInt(exponentHex);
|
|
1945
|
+
var m = BigInt(modulusHex);
|
|
1946
|
+
var r = 1n;
|
|
1947
|
+
b = b % m;
|
|
1948
|
+
|
|
1949
|
+
while (e > 0) {
|
|
1950
|
+
if (e % 2n === 1n) {
|
|
1951
|
+
r = r * b % m;
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
e = e / 2n;
|
|
1955
|
+
b = b * b % m;
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
var hexResult = r.toString(16);
|
|
1959
|
+
|
|
1960
|
+
while (hexResult.length / 2 < exponent.length || hexResult.length % 2 != 0) {
|
|
1961
|
+
hexResult = "0" + hexResult;
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
var bytesResult = [];
|
|
1965
|
+
|
|
1966
|
+
for (var c = 0; c < hexResult.length; c += 2) {
|
|
1967
|
+
bytesResult.push(parseInt(hexResult.substr(c, 2), 16));
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
return bytesResult;
|
|
1971
|
+
}
|
|
1972
|
+
}, {
|
|
1973
|
+
key: "_aesEcbEncrypt",
|
|
1974
|
+
value: function () {
|
|
1975
|
+
var _aesEcbEncrypt2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(string, key) {
|
|
1976
|
+
var keyString, aesKey, data, i, encrypted, _i2, block, encryptedBlock;
|
|
1977
|
+
|
|
1978
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1979
|
+
while (1) {
|
|
1980
|
+
switch (_context.prev = _context.next) {
|
|
1981
|
+
case 0:
|
|
1982
|
+
// perform AES-ECB blocks
|
|
1983
|
+
keyString = Array.from(key, function (_byte5) {
|
|
1984
|
+
return String.fromCharCode(_byte5);
|
|
1985
|
+
}).join('');
|
|
1986
|
+
_context.next = 3;
|
|
1987
|
+
return window.crypto.subtle.importKey("raw", (0, _md.MD5)(keyString), {
|
|
1988
|
+
name: "AES-CBC"
|
|
1989
|
+
}, false, ["encrypt"]);
|
|
1990
|
+
|
|
1991
|
+
case 3:
|
|
1992
|
+
aesKey = _context.sent;
|
|
1993
|
+
data = new Uint8Array(string.length);
|
|
1994
|
+
|
|
1995
|
+
for (i = 0; i < string.length; ++i) {
|
|
1996
|
+
data[i] = string.charCodeAt(i);
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
encrypted = new Uint8Array(data.length);
|
|
2000
|
+
_i2 = 0;
|
|
2001
|
+
|
|
2002
|
+
case 8:
|
|
2003
|
+
if (!(_i2 < data.length)) {
|
|
2004
|
+
_context.next = 17;
|
|
2005
|
+
break;
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
block = data.slice(_i2, _i2 + 16);
|
|
2009
|
+
_context.next = 12;
|
|
2010
|
+
return window.crypto.subtle.encrypt({
|
|
2011
|
+
name: "AES-CBC",
|
|
2012
|
+
iv: block
|
|
2013
|
+
}, aesKey, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]));
|
|
2014
|
+
|
|
2015
|
+
case 12:
|
|
2016
|
+
encryptedBlock = _context.sent;
|
|
2017
|
+
encrypted.set(new Uint8Array(encryptedBlock).slice(0, 16), _i2);
|
|
2018
|
+
|
|
2019
|
+
case 14:
|
|
2020
|
+
_i2 += 16;
|
|
2021
|
+
_context.next = 8;
|
|
2022
|
+
break;
|
|
2023
|
+
|
|
2024
|
+
case 17:
|
|
2025
|
+
return _context.abrupt("return", encrypted);
|
|
2026
|
+
|
|
2027
|
+
case 18:
|
|
2028
|
+
case "end":
|
|
2029
|
+
return _context.stop();
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
}, _callee);
|
|
2033
|
+
}));
|
|
2034
|
+
|
|
2035
|
+
function _aesEcbEncrypt(_x, _x2) {
|
|
2036
|
+
return _aesEcbEncrypt2.apply(this, arguments);
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
return _aesEcbEncrypt;
|
|
2040
|
+
}()
|
|
2041
|
+
}, {
|
|
2042
|
+
key: "_negotiateARDAuthAsync",
|
|
2043
|
+
value: function () {
|
|
2044
|
+
var _negotiateARDAuthAsync2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(generator, keyLength, prime, serverPublicKey, clientPrivateKey, padding) {
|
|
2045
|
+
var clientPublicKey, sharedKey, username, password, paddedUsername, paddedPassword, credentials, encrypted;
|
|
2046
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
2047
|
+
while (1) {
|
|
2048
|
+
switch (_context2.prev = _context2.next) {
|
|
2049
|
+
case 0:
|
|
2050
|
+
// calculate the DH keys
|
|
2051
|
+
clientPublicKey = this._modPow(generator, clientPrivateKey, prime);
|
|
2052
|
+
sharedKey = this._modPow(serverPublicKey, clientPrivateKey, prime);
|
|
2053
|
+
username = (0, _strings.encodeUTF8)(this._rfbCredentials.username).substring(0, 63);
|
|
2054
|
+
password = (0, _strings.encodeUTF8)(this._rfbCredentials.password).substring(0, 63);
|
|
2055
|
+
paddedUsername = username + '\0' + padding.substring(0, 63);
|
|
2056
|
+
paddedPassword = password + '\0' + padding.substring(0, 63);
|
|
2057
|
+
credentials = paddedUsername.substring(0, 64) + paddedPassword.substring(0, 64);
|
|
2058
|
+
_context2.next = 9;
|
|
2059
|
+
return this._aesEcbEncrypt(credentials, sharedKey);
|
|
2060
|
+
|
|
2061
|
+
case 9:
|
|
2062
|
+
encrypted = _context2.sent;
|
|
2063
|
+
this._rfbCredentials.ardCredentials = encrypted;
|
|
2064
|
+
this._rfbCredentials.ardPublicKey = clientPublicKey;
|
|
2065
|
+
setTimeout(this._initMsg.bind(this), 0);
|
|
2066
|
+
|
|
2067
|
+
case 13:
|
|
2068
|
+
case "end":
|
|
2069
|
+
return _context2.stop();
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
}, _callee2, this);
|
|
2073
|
+
}));
|
|
2074
|
+
|
|
2075
|
+
function _negotiateARDAuthAsync(_x3, _x4, _x5, _x6, _x7, _x8) {
|
|
2076
|
+
return _negotiateARDAuthAsync2.apply(this, arguments);
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
return _negotiateARDAuthAsync;
|
|
2080
|
+
}()
|
|
1797
2081
|
}, {
|
|
1798
2082
|
key: "_negotiateTightUnixAuth",
|
|
1799
2083
|
value: function _negotiateTightUnixAuth() {
|
|
@@ -1958,6 +2242,55 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1958
2242
|
|
|
1959
2243
|
return this._fail("No supported sub-auth types!");
|
|
1960
2244
|
}
|
|
2245
|
+
}, {
|
|
2246
|
+
key: "_handleRSAAESCredentialsRequired",
|
|
2247
|
+
value: function _handleRSAAESCredentialsRequired(event) {
|
|
2248
|
+
this.dispatchEvent(event);
|
|
2249
|
+
}
|
|
2250
|
+
}, {
|
|
2251
|
+
key: "_handleRSAAESServerVerification",
|
|
2252
|
+
value: function _handleRSAAESServerVerification(event) {
|
|
2253
|
+
this.dispatchEvent(event);
|
|
2254
|
+
}
|
|
2255
|
+
}, {
|
|
2256
|
+
key: "_negotiateRA2neAuth",
|
|
2257
|
+
value: function _negotiateRA2neAuth() {
|
|
2258
|
+
var _this5 = this;
|
|
2259
|
+
|
|
2260
|
+
if (this._rfbRSAAESAuthenticationState === null) {
|
|
2261
|
+
this._rfbRSAAESAuthenticationState = new _ra["default"](this._sock, function () {
|
|
2262
|
+
return _this5._rfbCredentials;
|
|
2263
|
+
});
|
|
2264
|
+
|
|
2265
|
+
this._rfbRSAAESAuthenticationState.addEventListener("serververification", this._eventHandlers.handleRSAAESServerVerification);
|
|
2266
|
+
|
|
2267
|
+
this._rfbRSAAESAuthenticationState.addEventListener("credentialsrequired", this._eventHandlers.handleRSAAESCredentialsRequired);
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
this._rfbRSAAESAuthenticationState.checkInternalEvents();
|
|
2271
|
+
|
|
2272
|
+
if (!this._rfbRSAAESAuthenticationState.hasStarted) {
|
|
2273
|
+
this._rfbRSAAESAuthenticationState.negotiateRA2neAuthAsync()["catch"](function (e) {
|
|
2274
|
+
if (e.message !== "disconnect normally") {
|
|
2275
|
+
_this5._fail(e.message);
|
|
2276
|
+
}
|
|
2277
|
+
}).then(function () {
|
|
2278
|
+
_this5.dispatchEvent(new CustomEvent('securityresult'));
|
|
2279
|
+
|
|
2280
|
+
_this5._rfbInitState = "SecurityResult";
|
|
2281
|
+
|
|
2282
|
+
_this5._initMsg();
|
|
2283
|
+
})["finally"](function () {
|
|
2284
|
+
_this5._rfbRSAAESAuthenticationState.removeEventListener("serververification", _this5._eventHandlers.handleRSAAESServerVerification);
|
|
2285
|
+
|
|
2286
|
+
_this5._rfbRSAAESAuthenticationState.removeEventListener("credentialsrequired", _this5._eventHandlers.handleRSAAESCredentialsRequired);
|
|
2287
|
+
|
|
2288
|
+
_this5._rfbRSAAESAuthenticationState = null;
|
|
2289
|
+
});
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
return false;
|
|
2293
|
+
}
|
|
1961
2294
|
}, {
|
|
1962
2295
|
key: "_negotiateAuthentication",
|
|
1963
2296
|
value: function _negotiateAuthentication() {
|
|
@@ -1976,6 +2309,10 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1976
2309
|
// XVP auth
|
|
1977
2310
|
return this._negotiateXvpAuth();
|
|
1978
2311
|
|
|
2312
|
+
case 30:
|
|
2313
|
+
// ARD auth
|
|
2314
|
+
return this._negotiateARDAuth();
|
|
2315
|
+
|
|
1979
2316
|
case 2:
|
|
1980
2317
|
// VNC authentication
|
|
1981
2318
|
return this._negotiateStdVNCAuth();
|
|
@@ -1992,6 +2329,10 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
1992
2329
|
// TightVNC UNIX Security Type
|
|
1993
2330
|
return this._negotiateTightUnixAuth();
|
|
1994
2331
|
|
|
2332
|
+
case 6:
|
|
2333
|
+
// RA2ne Security Type
|
|
2334
|
+
return this._negotiateRA2neAuth();
|
|
2335
|
+
|
|
1995
2336
|
default:
|
|
1996
2337
|
return this._fail("Unsupported auth scheme (scheme: " + this._rfbAuthScheme + ")");
|
|
1997
2338
|
}
|
|
@@ -2150,6 +2491,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2150
2491
|
if (this._fbDepth == 24) {
|
|
2151
2492
|
encs.push(_encodings.encodings.encodingTight);
|
|
2152
2493
|
encs.push(_encodings.encodings.encodingTightPNG);
|
|
2494
|
+
encs.push(_encodings.encodings.encodingZRLE);
|
|
2495
|
+
encs.push(_encodings.encodings.encodingJPEG);
|
|
2153
2496
|
encs.push(_encodings.encodings.encodingHextile);
|
|
2154
2497
|
encs.push(_encodings.encodings.encodingRRE);
|
|
2155
2498
|
}
|
|
@@ -2282,8 +2625,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2282
2625
|
} // Update our server capabilities for Actions
|
|
2283
2626
|
|
|
2284
2627
|
|
|
2285
|
-
for (var
|
|
2286
|
-
var _index = 1 <<
|
|
2628
|
+
for (var _i3 = 24; _i3 <= 31; _i3++) {
|
|
2629
|
+
var _index = 1 << _i3;
|
|
2287
2630
|
|
|
2288
2631
|
this._clipboardServerCapabilitiesActions[_index] = !!(actions & _index);
|
|
2289
2632
|
}
|
|
@@ -2346,8 +2689,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2346
2689
|
var textData = null;
|
|
2347
2690
|
streamInflator.setInput(zlibStream);
|
|
2348
2691
|
|
|
2349
|
-
for (var
|
|
2350
|
-
var format = 1 <<
|
|
2692
|
+
for (var _i4 = 0; _i4 <= 15; _i4++) {
|
|
2693
|
+
var format = 1 << _i4;
|
|
2351
2694
|
|
|
2352
2695
|
if (formats & format) {
|
|
2353
2696
|
var size = 0x00;
|
|
@@ -2369,8 +2712,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2369
2712
|
if (textData !== null) {
|
|
2370
2713
|
var tmpText = "";
|
|
2371
2714
|
|
|
2372
|
-
for (var
|
|
2373
|
-
tmpText += String.fromCharCode(textData[
|
|
2715
|
+
for (var _i5 = 0; _i5 < textData.length; _i5++) {
|
|
2716
|
+
tmpText += String.fromCharCode(textData[_i5]);
|
|
2374
2717
|
}
|
|
2375
2718
|
|
|
2376
2719
|
textData = tmpText;
|
|
@@ -2957,7 +3300,10 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2957
3300
|
|
|
2958
3301
|
this._updateScale();
|
|
2959
3302
|
|
|
2960
|
-
this._updateContinuousUpdates();
|
|
3303
|
+
this._updateContinuousUpdates(); // Keep this size until browser client size changes
|
|
3304
|
+
|
|
3305
|
+
|
|
3306
|
+
this._saveExpectedClientSize();
|
|
2961
3307
|
}
|
|
2962
3308
|
}, {
|
|
2963
3309
|
key: "_xvpOp",
|
|
@@ -3102,8 +3448,8 @@ RFB.messages = {
|
|
|
3102
3448
|
actionFlag |= actions[i];
|
|
3103
3449
|
}
|
|
3104
3450
|
|
|
3105
|
-
for (var
|
|
3106
|
-
formatFlag |= formats[
|
|
3451
|
+
for (var _i6 = 0; _i6 < formats.length; _i6++) {
|
|
3452
|
+
formatFlag |= formats[_i6];
|
|
3107
3453
|
}
|
|
3108
3454
|
|
|
3109
3455
|
data[0] = actionFlag >> 24; // Actions
|
package/lib/util/browser.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
8
|
+
exports.hasScrollbarGutter = exports.dragThreshold = void 0;
|
|
9
|
+
exports.isFirefox = isFirefox;
|
|
10
10
|
exports.isIOS = isIOS;
|
|
11
|
+
exports.isMac = isMac;
|
|
11
12
|
exports.isSafari = isSafari;
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
13
|
+
exports.isTouchDevice = void 0;
|
|
14
|
+
exports.isWindows = isWindows;
|
|
15
|
+
exports.supportsCursorURIs = void 0;
|
|
14
16
|
|
|
15
17
|
var Log = _interopRequireWildcard(require("./logging.js"));
|
|
16
18
|
|
|
@@ -28,7 +30,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
28
30
|
* Browser feature support detection
|
|
29
31
|
*/
|
|
30
32
|
// Touch detection
|
|
31
|
-
var isTouchDevice = 'ontouchstart' in document.documentElement ||
|
|
33
|
+
var isTouchDevice = 'ontouchstart' in document.documentElement || // requried for Chrome debugger
|
|
34
|
+
document.ontouchstart !== undefined || // required for MS Surface
|
|
35
|
+
navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
|
|
32
36
|
exports.isTouchDevice = isTouchDevice;
|
|
33
37
|
window.addEventListener('touchstart', function onFirstTouch() {
|
|
34
38
|
exports.isTouchDevice = isTouchDevice = true;
|
package/lib/util/cursor.js
CHANGED
|
@@ -11,7 +11,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
11
11
|
|
|
12
12
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
13
13
|
|
|
14
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
14
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
15
|
|
|
16
16
|
var useFallback = !_browser.supportsCursorURIs || _browser.isTouchDevice;
|
|
17
17
|
|
package/lib/util/events.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getPointerEvent = getPointerEvent;
|
|
7
|
-
exports.stopEvent = stopEvent;
|
|
8
|
-
exports.setCapture = setCapture;
|
|
9
7
|
exports.releaseCapture = releaseCapture;
|
|
8
|
+
exports.setCapture = setCapture;
|
|
9
|
+
exports.stopEvent = stopEvent;
|
|
10
10
|
|
|
11
11
|
/*
|
|
12
12
|
* noVNC: HTML5 VNC client
|
package/lib/util/eventtarget.js
CHANGED
|
@@ -9,7 +9,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
9
9
|
|
|
10
10
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
11
|
|
|
12
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
13
|
|
|
14
14
|
/*
|
|
15
15
|
* noVNC: HTML5 VNC client
|
package/lib/util/int.js
CHANGED