@novnc/novnc 1.3.0-g1075cd8 → 1.3.0-g2f1e11b

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/core/rfb.js CHANGED
@@ -54,6 +54,21 @@ const GESTURE_SCRLSENS = 50;
54
54
  const DOUBLE_TAP_TIMEOUT = 1000;
55
55
  const DOUBLE_TAP_THRESHOLD = 50;
56
56
 
57
+ // Security types
58
+ const securityTypeNone = 1;
59
+ const securityTypeVNCAuth = 2;
60
+ const securityTypeRA2ne = 6;
61
+ const securityTypeTight = 16;
62
+ const securityTypeVeNCrypt = 19;
63
+ const securityTypeXVP = 22;
64
+ const securityTypeARD = 30;
65
+
66
+ // Special Tight security types
67
+ const securityTypeUnixLogon = 129;
68
+
69
+ // VeNCrypt security types
70
+ const securityTypePlain = 256;
71
+
57
72
  // Extended clipboard pseudo-encoding formats
58
73
  const extendedClipboardFormatText = 1;
59
74
  /*eslint-disable no-unused-vars */
@@ -79,6 +94,12 @@ export default class RFB extends EventTargetMixin {
79
94
  throw new Error("Must specify URL, WebSocket or RTCDataChannel");
80
95
  }
81
96
 
97
+ // We rely on modern APIs which might not be available in an
98
+ // insecure context
99
+ if (!window.isSecureContext) {
100
+ Log.Error("noVNC requires a secure context (TLS). Expect crashes!");
101
+ }
102
+
82
103
  super();
83
104
 
84
105
  this._target = target;
@@ -396,7 +417,7 @@ export default class RFB extends EventTargetMixin {
396
417
 
397
418
  sendCredentials(creds) {
398
419
  this._rfbCredentials = creds;
399
- setTimeout(this._initMsg.bind(this), 0);
420
+ this._resumeAuthentication();
400
421
  }
401
422
 
402
423
  sendCtrlAltDel() {
@@ -916,8 +937,15 @@ export default class RFB extends EventTargetMixin {
916
937
  }
917
938
  }
918
939
  break;
940
+ case 'connecting':
941
+ while (this._rfbConnectionState === 'connecting') {
942
+ if (!this._initMsg()) {
943
+ break;
944
+ }
945
+ }
946
+ break;
919
947
  default:
920
- this._initMsg();
948
+ Log.Error("Got data while in an invalid state");
921
949
  break;
922
950
  }
923
951
  }
@@ -1326,6 +1354,21 @@ export default class RFB extends EventTargetMixin {
1326
1354
  this._rfbInitState = 'Security';
1327
1355
  }
1328
1356
 
1357
+ _isSupportedSecurityType(type) {
1358
+ const clientTypes = [
1359
+ securityTypeNone,
1360
+ securityTypeVNCAuth,
1361
+ securityTypeRA2ne,
1362
+ securityTypeTight,
1363
+ securityTypeVeNCrypt,
1364
+ securityTypeXVP,
1365
+ securityTypeARD,
1366
+ securityTypePlain,
1367
+ ];
1368
+
1369
+ return clientTypes.includes(type);
1370
+ }
1371
+
1329
1372
  _negotiateSecurity() {
1330
1373
  if (this._rfbVersion >= 3.7) {
1331
1374
  // Server sends supported list, client decides
@@ -1336,28 +1379,23 @@ export default class RFB extends EventTargetMixin {
1336
1379
  this._rfbInitState = "SecurityReason";
1337
1380
  this._securityContext = "no security types";
1338
1381
  this._securityStatus = 1;
1339
- return this._initMsg();
1382
+ return true;
1340
1383
  }
1341
1384
 
1342
1385
  const types = this._sock.rQshiftBytes(numTypes);
1343
1386
  Log.Debug("Server security types: " + types);
1344
1387
 
1345
- // Look for each auth in preferred order
1346
- if (types.includes(1)) {
1347
- this._rfbAuthScheme = 1; // None
1348
- } else if (types.includes(22)) {
1349
- this._rfbAuthScheme = 22; // XVP
1350
- } else if (types.includes(16)) {
1351
- this._rfbAuthScheme = 16; // Tight
1352
- } else if (types.includes(6)) {
1353
- this._rfbAuthScheme = 6; // RA2ne Auth
1354
- } else if (types.includes(2)) {
1355
- this._rfbAuthScheme = 2; // VNC Auth
1356
- } else if (types.includes(30)) {
1357
- this._rfbAuthScheme = 30; // ARD Auth
1358
- } else if (types.includes(19)) {
1359
- this._rfbAuthScheme = 19; // VeNCrypt Auth
1360
- } else {
1388
+ // Look for a matching security type in the order that the
1389
+ // server prefers
1390
+ this._rfbAuthScheme = -1;
1391
+ for (let type of types) {
1392
+ if (this._isSupportedSecurityType(type)) {
1393
+ this._rfbAuthScheme = type;
1394
+ break;
1395
+ }
1396
+ }
1397
+
1398
+ if (this._rfbAuthScheme === -1) {
1361
1399
  return this._fail("Unsupported security types (types: " + types + ")");
1362
1400
  }
1363
1401
 
@@ -1371,14 +1409,14 @@ export default class RFB extends EventTargetMixin {
1371
1409
  this._rfbInitState = "SecurityReason";
1372
1410
  this._securityContext = "authentication scheme";
1373
1411
  this._securityStatus = 1;
1374
- return this._initMsg();
1412
+ return true;
1375
1413
  }
1376
1414
  }
1377
1415
 
1378
1416
  this._rfbInitState = 'Authentication';
1379
1417
  Log.Debug('Authenticating using scheme: ' + this._rfbAuthScheme);
1380
1418
 
1381
- return this._initMsg(); // jump to authentication
1419
+ return true;
1382
1420
  }
1383
1421
 
1384
1422
  _handleSecurityReason() {
@@ -1428,7 +1466,7 @@ export default class RFB extends EventTargetMixin {
1428
1466
  this._rfbCredentials.username +
1429
1467
  this._rfbCredentials.target;
1430
1468
  this._sock.sendString(xvpAuthStr);
1431
- this._rfbAuthScheme = 2;
1469
+ this._rfbAuthScheme = securityTypeVNCAuth;
1432
1470
  return this._negotiateAuthentication();
1433
1471
  }
1434
1472
 
@@ -1486,49 +1524,66 @@ export default class RFB extends EventTargetMixin {
1486
1524
  subtypes.push(this._sock.rQshift32());
1487
1525
  }
1488
1526
 
1489
- // 256 = Plain subtype
1490
- if (subtypes.indexOf(256) != -1) {
1491
- // 0x100 = 256
1492
- this._sock.send([0, 0, 1, 0]);
1493
- this._rfbVeNCryptState = 4;
1494
- } else {
1495
- return this._fail("VeNCrypt Plain subtype not offered by server");
1527
+ // Look for a matching security type in the order that the
1528
+ // server prefers
1529
+ this._rfbAuthScheme = -1;
1530
+ for (let type of subtypes) {
1531
+ // Avoid getting in to a loop
1532
+ if (type === securityTypeVeNCrypt) {
1533
+ continue;
1534
+ }
1535
+
1536
+ if (this._isSupportedSecurityType(type)) {
1537
+ this._rfbAuthScheme = type;
1538
+ break;
1539
+ }
1496
1540
  }
1497
- }
1498
1541
 
1499
- // negotiated Plain subtype, server waits for password
1500
- if (this._rfbVeNCryptState == 4) {
1501
- if (this._rfbCredentials.username === undefined ||
1502
- this._rfbCredentials.password === undefined) {
1503
- this.dispatchEvent(new CustomEvent(
1504
- "credentialsrequired",
1505
- { detail: { types: ["username", "password"] } }));
1506
- return false;
1542
+ if (this._rfbAuthScheme === -1) {
1543
+ return this._fail("Unsupported security types (types: " + subtypes + ")");
1507
1544
  }
1508
1545
 
1509
- const user = encodeUTF8(this._rfbCredentials.username);
1510
- const pass = encodeUTF8(this._rfbCredentials.password);
1511
-
1512
- this._sock.send([
1513
- (user.length >> 24) & 0xFF,
1514
- (user.length >> 16) & 0xFF,
1515
- (user.length >> 8) & 0xFF,
1516
- user.length & 0xFF
1517
- ]);
1518
- this._sock.send([
1519
- (pass.length >> 24) & 0xFF,
1520
- (pass.length >> 16) & 0xFF,
1521
- (pass.length >> 8) & 0xFF,
1522
- pass.length & 0xFF
1523
- ]);
1524
- this._sock.sendString(user);
1525
- this._sock.sendString(pass);
1546
+ this._sock.send([this._rfbAuthScheme >> 24,
1547
+ this._rfbAuthScheme >> 16,
1548
+ this._rfbAuthScheme >> 8,
1549
+ this._rfbAuthScheme]);
1526
1550
 
1527
- this._rfbInitState = "SecurityResult";
1551
+ this._rfbVeNCryptState == 4;
1528
1552
  return true;
1529
1553
  }
1530
1554
  }
1531
1555
 
1556
+ _negotiatePlainAuth() {
1557
+ if (this._rfbCredentials.username === undefined ||
1558
+ this._rfbCredentials.password === undefined) {
1559
+ this.dispatchEvent(new CustomEvent(
1560
+ "credentialsrequired",
1561
+ { detail: { types: ["username", "password"] } }));
1562
+ return false;
1563
+ }
1564
+
1565
+ const user = encodeUTF8(this._rfbCredentials.username);
1566
+ const pass = encodeUTF8(this._rfbCredentials.password);
1567
+
1568
+ this._sock.send([
1569
+ (user.length >> 24) & 0xFF,
1570
+ (user.length >> 16) & 0xFF,
1571
+ (user.length >> 8) & 0xFF,
1572
+ user.length & 0xFF
1573
+ ]);
1574
+ this._sock.send([
1575
+ (pass.length >> 24) & 0xFF,
1576
+ (pass.length >> 16) & 0xFF,
1577
+ (pass.length >> 8) & 0xFF,
1578
+ pass.length & 0xFF
1579
+ ]);
1580
+ this._sock.sendString(user);
1581
+ this._sock.sendString(pass);
1582
+
1583
+ this._rfbInitState = "SecurityResult";
1584
+ return true;
1585
+ }
1586
+
1532
1587
  _negotiateStdVNCAuth() {
1533
1588
  if (this._sock.rQwait("auth challenge", 16)) { return false; }
1534
1589
 
@@ -1655,7 +1710,7 @@ export default class RFB extends EventTargetMixin {
1655
1710
  this._rfbCredentials.ardCredentials = encrypted;
1656
1711
  this._rfbCredentials.ardPublicKey = clientPublicKey;
1657
1712
 
1658
- setTimeout(this._initMsg.bind(this), 0);
1713
+ this._resumeAuthentication();
1659
1714
  }
1660
1715
 
1661
1716
  _negotiateTightUnixAuth() {
@@ -1765,12 +1820,12 @@ export default class RFB extends EventTargetMixin {
1765
1820
  case 'STDVNOAUTH__': // no auth
1766
1821
  this._rfbInitState = 'SecurityResult';
1767
1822
  return true;
1768
- case 'STDVVNCAUTH_': // VNC auth
1769
- this._rfbAuthScheme = 2;
1770
- return this._initMsg();
1771
- case 'TGHTULGNAUTH': // UNIX auth
1772
- this._rfbAuthScheme = 129;
1773
- return this._initMsg();
1823
+ case 'STDVVNCAUTH_':
1824
+ this._rfbAuthScheme = securityTypeVNCAuth;
1825
+ return true;
1826
+ case 'TGHTULGNAUTH':
1827
+ this._rfbAuthScheme = securityTypeUnixLogon;
1828
+ return true;
1774
1829
  default:
1775
1830
  return this._fail("Unsupported tiny auth scheme " +
1776
1831
  "(scheme: " + authType + ")");
@@ -1807,7 +1862,7 @@ export default class RFB extends EventTargetMixin {
1807
1862
  }).then(() => {
1808
1863
  this.dispatchEvent(new CustomEvent('securityresult'));
1809
1864
  this._rfbInitState = "SecurityResult";
1810
- this._initMsg();
1865
+ return true;
1811
1866
  }).finally(() => {
1812
1867
  this._rfbRSAAESAuthenticationState.removeEventListener(
1813
1868
  "serververification", this._eventHandlers.handleRSAAESServerVerification);
@@ -1821,33 +1876,32 @@ export default class RFB extends EventTargetMixin {
1821
1876
 
1822
1877
  _negotiateAuthentication() {
1823
1878
  switch (this._rfbAuthScheme) {
1824
- case 1: // no auth
1825
- if (this._rfbVersion >= 3.8) {
1826
- this._rfbInitState = 'SecurityResult';
1827
- return true;
1828
- }
1829
- this._rfbInitState = 'ClientInitialisation';
1830
- return this._initMsg();
1879
+ case securityTypeNone:
1880
+ this._rfbInitState = 'SecurityResult';
1881
+ return true;
1831
1882
 
1832
- case 22: // XVP auth
1883
+ case securityTypeXVP:
1833
1884
  return this._negotiateXvpAuth();
1834
1885
 
1835
- case 30: // ARD auth
1886
+ case securityTypeARD:
1836
1887
  return this._negotiateARDAuth();
1837
1888
 
1838
- case 2: // VNC authentication
1889
+ case securityTypeVNCAuth:
1839
1890
  return this._negotiateStdVNCAuth();
1840
1891
 
1841
- case 16: // TightVNC Security Type
1892
+ case securityTypeTight:
1842
1893
  return this._negotiateTightAuth();
1843
1894
 
1844
- case 19: // VeNCrypt Security Type
1895
+ case securityTypeVeNCrypt:
1845
1896
  return this._negotiateVeNCryptAuth();
1846
1897
 
1847
- case 129: // TightVNC UNIX Security Type
1898
+ case securityTypePlain:
1899
+ return this._negotiatePlainAuth();
1900
+
1901
+ case securityTypeUnixLogon:
1848
1902
  return this._negotiateTightUnixAuth();
1849
1903
 
1850
- case 6: // RA2ne Security Type
1904
+ case securityTypeRA2ne:
1851
1905
  return this._negotiateRA2neAuth();
1852
1906
 
1853
1907
  default:
@@ -1857,6 +1911,13 @@ export default class RFB extends EventTargetMixin {
1857
1911
  }
1858
1912
 
1859
1913
  _handleSecurityResult() {
1914
+ // There is no security choice, and hence no security result
1915
+ // until RFB 3.7
1916
+ if (this._rfbVersion < 3.7) {
1917
+ this._rfbInitState = 'ClientInitialisation';
1918
+ return true;
1919
+ }
1920
+
1860
1921
  if (this._sock.rQwait('VNC auth response ', 4)) { return false; }
1861
1922
 
1862
1923
  const status = this._sock.rQshift32();
@@ -1864,13 +1925,13 @@ export default class RFB extends EventTargetMixin {
1864
1925
  if (status === 0) { // OK
1865
1926
  this._rfbInitState = 'ClientInitialisation';
1866
1927
  Log.Debug('Authentication OK');
1867
- return this._initMsg();
1928
+ return true;
1868
1929
  } else {
1869
1930
  if (this._rfbVersion >= 3.8) {
1870
1931
  this._rfbInitState = "SecurityReason";
1871
1932
  this._securityContext = "security result";
1872
1933
  this._securityStatus = status;
1873
- return this._initMsg();
1934
+ return true;
1874
1935
  } else {
1875
1936
  this.dispatchEvent(new CustomEvent(
1876
1937
  "securityfailure",
@@ -2046,6 +2107,14 @@ export default class RFB extends EventTargetMixin {
2046
2107
  }
2047
2108
  }
2048
2109
 
2110
+ // Resume authentication handshake after it was paused for some
2111
+ // reason, e.g. waiting for a password from the user
2112
+ _resumeAuthentication() {
2113
+ // We use setTimeout() so it's run in its own context, just like
2114
+ // it originally did via the WebSocket's event handler
2115
+ setTimeout(this._initMsg.bind(this), 0);
2116
+ }
2117
+
2049
2118
  _handleSetColourMapMsg() {
2050
2119
  Log.Debug("SetColorMapEntries");
2051
2120
 
@@ -19,7 +19,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
19
19
 
20
20
  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); }
21
21
 
22
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
22
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23
23
 
24
24
  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); }; }
25
25
 
@@ -29,7 +29,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
29
29
 
30
30
  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; } }
31
31
 
32
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
32
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
33
33
 
34
34
  var TightPNGDecoder = /*#__PURE__*/function (_TightDecoder) {
35
35
  _inherits(TightPNGDecoder, _TightDecoder);
package/lib/ra2.js CHANGED
@@ -17,7 +17,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
17
17
 
18
18
  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); }
19
19
 
20
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21
21
 
22
22
  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); }; }
23
23
 
@@ -27,7 +27,9 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
27
27
 
28
28
  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; } }
29
29
 
30
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
30
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
31
+
32
+ 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, $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 generator._invoke = function (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); } }; }(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; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return 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, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), 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 (object) { var 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; }
31
33
 
32
34
  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); } }
33
35
 
@@ -55,9 +57,9 @@ var AESEAXCipher = /*#__PURE__*/function () {
55
57
  _createClass(AESEAXCipher, [{
56
58
  key: "_encryptBlock",
57
59
  value: function () {
58
- var _encryptBlock2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(block) {
60
+ var _encryptBlock2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(block) {
59
61
  var encrypted;
60
- return regeneratorRuntime.wrap(function _callee$(_context) {
62
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
61
63
  while (1) {
62
64
  switch (_context.prev = _context.next) {
63
65
  case 0:
@@ -88,9 +90,9 @@ var AESEAXCipher = /*#__PURE__*/function () {
88
90
  }, {
89
91
  key: "_initCMAC",
90
92
  value: function () {
91
- var _initCMAC2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
93
+ var _initCMAC2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
92
94
  var k1, k2, v, i, lut;
93
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
95
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
94
96
  while (1) {
95
97
  switch (_context2.prev = _context2.next) {
96
98
  case 0:
@@ -131,9 +133,9 @@ var AESEAXCipher = /*#__PURE__*/function () {
131
133
  }, {
132
134
  key: "_encryptCTR",
133
135
  value: function () {
134
- var _encryptCTR2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(data, counter) {
136
+ var _encryptCTR2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(data, counter) {
135
137
  var encrypted;
136
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
138
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
137
139
  while (1) {
138
140
  switch (_context3.prev = _context3.next) {
139
141
  case 0:
@@ -165,9 +167,9 @@ var AESEAXCipher = /*#__PURE__*/function () {
165
167
  }, {
166
168
  key: "_decryptCTR",
167
169
  value: function () {
168
- var _decryptCTR2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(data, counter) {
170
+ var _decryptCTR2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(data, counter) {
169
171
  var decrypted;
170
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
172
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
171
173
  while (1) {
172
174
  switch (_context4.prev = _context4.next) {
173
175
  case 0:
@@ -199,10 +201,10 @@ var AESEAXCipher = /*#__PURE__*/function () {
199
201
  }, {
200
202
  key: "_computeCMAC",
201
203
  value: function () {
202
- var _computeCMAC2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(data, prefixBlock) {
204
+ var _computeCMAC2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(data, prefixBlock) {
203
205
  var n, m, r, cbcData, i, _i, cbcEncrypted, mac;
204
206
 
205
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
207
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
206
208
  while (1) {
207
209
  switch (_context5.prev = _context5.next) {
208
210
  case 0:
@@ -262,8 +264,8 @@ var AESEAXCipher = /*#__PURE__*/function () {
262
264
  }, {
263
265
  key: "setKey",
264
266
  value: function () {
265
- var _setKey = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(key) {
266
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
267
+ var _setKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(key) {
268
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
267
269
  while (1) {
268
270
  switch (_context6.prev = _context6.next) {
269
271
  case 0:
@@ -302,9 +304,9 @@ var AESEAXCipher = /*#__PURE__*/function () {
302
304
  }, {
303
305
  key: "encrypt",
304
306
  value: function () {
305
- var _encrypt = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(message, associatedData, nonce) {
307
+ var _encrypt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(message, associatedData, nonce) {
306
308
  var nCMAC, encrypted, adCMAC, mac, i, res;
307
- return regeneratorRuntime.wrap(function _callee7$(_context7) {
309
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
308
310
  while (1) {
309
311
  switch (_context7.prev = _context7.next) {
310
312
  case 0:
@@ -355,10 +357,10 @@ var AESEAXCipher = /*#__PURE__*/function () {
355
357
  }, {
356
358
  key: "decrypt",
357
359
  value: function () {
358
- var _decrypt = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(encrypted, associatedData, nonce, mac) {
360
+ var _decrypt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(encrypted, associatedData, nonce, mac) {
359
361
  var nCMAC, adCMAC, computedMac, i, _i2, res;
360
362
 
361
- return regeneratorRuntime.wrap(function _callee8$(_context8) {
363
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
362
364
  while (1) {
363
365
  switch (_context8.prev = _context8.next) {
364
366
  case 0:
@@ -450,8 +452,8 @@ var RA2Cipher = /*#__PURE__*/function () {
450
452
  _createClass(RA2Cipher, [{
451
453
  key: "setKey",
452
454
  value: function () {
453
- var _setKey2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(key) {
454
- return regeneratorRuntime.wrap(function _callee9$(_context9) {
455
+ var _setKey2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(key) {
456
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
455
457
  while (1) {
456
458
  switch (_context9.prev = _context9.next) {
457
459
  case 0:
@@ -475,9 +477,9 @@ var RA2Cipher = /*#__PURE__*/function () {
475
477
  }, {
476
478
  key: "makeMessage",
477
479
  value: function () {
478
- var _makeMessage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(message) {
480
+ var _makeMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(message) {
479
481
  var ad, encrypted, i, res;
480
- return regeneratorRuntime.wrap(function _callee10$(_context10) {
482
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
481
483
  while (1) {
482
484
  switch (_context10.prev = _context10.next) {
483
485
  case 0:
@@ -514,9 +516,9 @@ var RA2Cipher = /*#__PURE__*/function () {
514
516
  }, {
515
517
  key: "receiveMessage",
516
518
  value: function () {
517
- var _receiveMessage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11(length, encrypted, mac) {
519
+ var _receiveMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(length, encrypted, mac) {
518
520
  var ad, res, i;
519
- return regeneratorRuntime.wrap(function _callee11$(_context11) {
521
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
520
522
  while (1) {
521
523
  switch (_context11.prev = _context11.next) {
522
524
  case 0:
@@ -638,9 +640,9 @@ var RSACipher = /*#__PURE__*/function () {
638
640
  }, {
639
641
  key: "generateKey",
640
642
  value: function () {
641
- var _generateKey = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {
643
+ var _generateKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
642
644
  var privateKey;
643
- return regeneratorRuntime.wrap(function _callee12$(_context12) {
645
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
644
646
  while (1) {
645
647
  switch (_context12.prev = _context12.next) {
646
648
  case 0:
@@ -915,10 +917,10 @@ var RSAAESAuthenticationState = /*#__PURE__*/function (_EventTargetMixin) {
915
917
  }, {
916
918
  key: "negotiateRA2neAuthAsync",
917
919
  value: function () {
918
- var _negotiateRA2neAuthAsync = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() {
920
+ var _negotiateRA2neAuthAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
919
921
  var serverKeyLengthBuffer, serverKeyLength, serverKeyBytes, serverN, serverE, serverRSACipher, serverPublickey, clientKeyLength, clientKeyBytes, clientRSACipher, clientN, clientE, clientPublicKey, clientRandom, clientEncryptedRandom, clientRandomMessage, serverEncryptedRandom, serverRandom, clientSessionKey, serverSessionKey, clientCipher, serverCipher, serverHash, clientHash, serverHashReceived, i, subtype, username, password, credentials, _i3, _i4;
920
922
 
921
- return regeneratorRuntime.wrap(function _callee13$(_context13) {
923
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
922
924
  while (1) {
923
925
  switch (_context13.prev = _context13.next) {
924
926
  case 0:
package/lib/rfb.js CHANGED
@@ -69,10 +69,14 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
69
69
 
70
70
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
71
71
 
72
+ 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, $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 generator._invoke = function (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); } }; }(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; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return 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, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), 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 (object) { var 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; }
73
+
72
74
  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
75
 
74
76
  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
77
 
78
+ 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; } } }; }
79
+
76
80
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
77
81
 
78
82
  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."); }
@@ -93,7 +97,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
93
97
 
94
98
  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); }
95
99
 
96
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
100
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
97
101
 
98
102
  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); }; }
99
103
 
@@ -103,7 +107,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
103
107
 
104
108
  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; } }
105
109
 
106
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
110
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
107
111
 
108
112
  // How many seconds to wait for a disconnect to finish
109
113
  var DISCONNECT_TIMEOUT = 3;
@@ -119,7 +123,19 @@ var WHEEL_LINE_HEIGHT = 19; // Assumed pixels for one line step
119
123
  var GESTURE_ZOOMSENS = 75;
120
124
  var GESTURE_SCRLSENS = 50;
121
125
  var DOUBLE_TAP_TIMEOUT = 1000;
122
- var DOUBLE_TAP_THRESHOLD = 50; // Extended clipboard pseudo-encoding formats
126
+ var DOUBLE_TAP_THRESHOLD = 50; // Security types
127
+
128
+ var securityTypeNone = 1;
129
+ var securityTypeVNCAuth = 2;
130
+ var securityTypeRA2ne = 6;
131
+ var securityTypeTight = 16;
132
+ var securityTypeVeNCrypt = 19;
133
+ var securityTypeXVP = 22;
134
+ var securityTypeARD = 30; // Special Tight security types
135
+
136
+ var securityTypeUnixLogon = 129; // VeNCrypt security types
137
+
138
+ var securityTypePlain = 256; // Extended clipboard pseudo-encoding formats
123
139
 
124
140
  var extendedClipboardFormatText = 1;
125
141
  /*eslint-disable no-unused-vars */
@@ -153,6 +169,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
153
169
 
154
170
  if (!urlOrChannel) {
155
171
  throw new Error("Must specify URL, WebSocket or RTCDataChannel");
172
+ } // We rely on modern APIs which might not be available in an
173
+ // insecure context
174
+
175
+
176
+ if (!window.isSecureContext) {
177
+ Log.Error("noVNC requires a secure context (TLS). Expect crashes!");
156
178
  }
157
179
 
158
180
  _this = _super.call(this);
@@ -499,7 +521,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
499
521
  key: "sendCredentials",
500
522
  value: function sendCredentials(creds) {
501
523
  this._rfbCredentials = creds;
502
- setTimeout(this._initMsg.bind(this), 0);
524
+
525
+ this._resumeAuthentication();
503
526
  }
504
527
  }, {
505
528
  key: "sendCtrlAltDel",
@@ -1123,9 +1146,17 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1123
1146
 
1124
1147
  break;
1125
1148
 
1126
- default:
1127
- this._initMsg();
1149
+ case 'connecting':
1150
+ while (this._rfbConnectionState === 'connecting') {
1151
+ if (!this._initMsg()) {
1152
+ break;
1153
+ }
1154
+ }
1155
+
1156
+ break;
1128
1157
 
1158
+ default:
1159
+ Log.Error("Got data while in an invalid state");
1129
1160
  break;
1130
1161
  }
1131
1162
  }
@@ -1628,6 +1659,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1628
1659
  Log.Debug('Sent ProtocolVersion: ' + cversion);
1629
1660
  this._rfbInitState = 'Security';
1630
1661
  }
1662
+ }, {
1663
+ key: "_isSupportedSecurityType",
1664
+ value: function _isSupportedSecurityType(type) {
1665
+ var clientTypes = [securityTypeNone, securityTypeVNCAuth, securityTypeRA2ne, securityTypeTight, securityTypeVeNCrypt, securityTypeXVP, securityTypeARD, securityTypePlain];
1666
+ return clientTypes.includes(type);
1667
+ }
1631
1668
  }, {
1632
1669
  key: "_negotiateSecurity",
1633
1670
  value: function _negotiateSecurity() {
@@ -1643,28 +1680,35 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1643
1680
  this._rfbInitState = "SecurityReason";
1644
1681
  this._securityContext = "no security types";
1645
1682
  this._securityStatus = 1;
1646
- return this._initMsg();
1683
+ return true;
1647
1684
  }
1648
1685
 
1649
1686
  var types = this._sock.rQshiftBytes(numTypes);
1650
1687
 
1651
- Log.Debug("Server security types: " + types); // Look for each auth in preferred order
1652
-
1653
- if (types.includes(1)) {
1654
- this._rfbAuthScheme = 1; // None
1655
- } else if (types.includes(22)) {
1656
- this._rfbAuthScheme = 22; // XVP
1657
- } else if (types.includes(16)) {
1658
- this._rfbAuthScheme = 16; // Tight
1659
- } else if (types.includes(6)) {
1660
- this._rfbAuthScheme = 6; // RA2ne Auth
1661
- } else if (types.includes(2)) {
1662
- this._rfbAuthScheme = 2; // VNC Auth
1663
- } else if (types.includes(30)) {
1664
- this._rfbAuthScheme = 30; // ARD Auth
1665
- } else if (types.includes(19)) {
1666
- this._rfbAuthScheme = 19; // VeNCrypt Auth
1667
- } else {
1688
+ Log.Debug("Server security types: " + types); // Look for a matching security type in the order that the
1689
+ // server prefers
1690
+
1691
+ this._rfbAuthScheme = -1;
1692
+
1693
+ var _iterator = _createForOfIteratorHelper(types),
1694
+ _step;
1695
+
1696
+ try {
1697
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1698
+ var type = _step.value;
1699
+
1700
+ if (this._isSupportedSecurityType(type)) {
1701
+ this._rfbAuthScheme = type;
1702
+ break;
1703
+ }
1704
+ }
1705
+ } catch (err) {
1706
+ _iterator.e(err);
1707
+ } finally {
1708
+ _iterator.f();
1709
+ }
1710
+
1711
+ if (this._rfbAuthScheme === -1) {
1668
1712
  return this._fail("Unsupported security types (types: " + types + ")");
1669
1713
  }
1670
1714
 
@@ -1681,13 +1725,13 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1681
1725
  this._rfbInitState = "SecurityReason";
1682
1726
  this._securityContext = "authentication scheme";
1683
1727
  this._securityStatus = 1;
1684
- return this._initMsg();
1728
+ return true;
1685
1729
  }
1686
1730
  }
1687
1731
 
1688
1732
  this._rfbInitState = 'Authentication';
1689
1733
  Log.Debug('Authenticating using scheme: ' + this._rfbAuthScheme);
1690
- return this._initMsg(); // jump to authentication
1734
+ return true;
1691
1735
  }
1692
1736
  }, {
1693
1737
  key: "_handleSecurityReason",
@@ -1742,7 +1786,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1742
1786
 
1743
1787
  this._sock.sendString(xvpAuthStr);
1744
1788
 
1745
- this._rfbAuthScheme = 2;
1789
+ this._rfbAuthScheme = securityTypeVNCAuth;
1746
1790
  return this._negotiateAuthentication();
1747
1791
  } // VeNCrypt authentication, currently only supports version 0.2 and only Plain subtype
1748
1792
 
@@ -1811,44 +1855,61 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1811
1855
 
1812
1856
  for (var i = 0; i < this._rfbVeNCryptSubtypesLength; i++) {
1813
1857
  subtypes.push(this._sock.rQshift32());
1814
- } // 256 = Plain subtype
1858
+ } // Look for a matching security type in the order that the
1859
+ // server prefers
1815
1860
 
1816
1861
 
1817
- if (subtypes.indexOf(256) != -1) {
1818
- // 0x100 = 256
1819
- this._sock.send([0, 0, 1, 0]);
1862
+ this._rfbAuthScheme = -1;
1820
1863
 
1821
- this._rfbVeNCryptState = 4;
1822
- } else {
1823
- return this._fail("VeNCrypt Plain subtype not offered by server");
1824
- }
1825
- } // negotiated Plain subtype, server waits for password
1864
+ for (var _i2 = 0, _subtypes = subtypes; _i2 < _subtypes.length; _i2++) {
1865
+ var type = _subtypes[_i2];
1826
1866
 
1867
+ // Avoid getting in to a loop
1868
+ if (type === securityTypeVeNCrypt) {
1869
+ continue;
1870
+ }
1827
1871
 
1828
- if (this._rfbVeNCryptState == 4) {
1829
- if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
1830
- this.dispatchEvent(new CustomEvent("credentialsrequired", {
1831
- detail: {
1832
- types: ["username", "password"]
1833
- }
1834
- }));
1835
- return false;
1872
+ if (this._isSupportedSecurityType(type)) {
1873
+ this._rfbAuthScheme = type;
1874
+ break;
1875
+ }
1836
1876
  }
1837
1877
 
1838
- var user = (0, _strings.encodeUTF8)(this._rfbCredentials.username);
1839
- var pass = (0, _strings.encodeUTF8)(this._rfbCredentials.password);
1878
+ if (this._rfbAuthScheme === -1) {
1879
+ return this._fail("Unsupported security types (types: " + subtypes + ")");
1880
+ }
1840
1881
 
1841
- this._sock.send([user.length >> 24 & 0xFF, user.length >> 16 & 0xFF, user.length >> 8 & 0xFF, user.length & 0xFF]);
1882
+ this._sock.send([this._rfbAuthScheme >> 24, this._rfbAuthScheme >> 16, this._rfbAuthScheme >> 8, this._rfbAuthScheme]);
1842
1883
 
1843
- this._sock.send([pass.length >> 24 & 0xFF, pass.length >> 16 & 0xFF, pass.length >> 8 & 0xFF, pass.length & 0xFF]);
1884
+ this._rfbVeNCryptState == 4;
1885
+ return true;
1886
+ }
1887
+ }
1888
+ }, {
1889
+ key: "_negotiatePlainAuth",
1890
+ value: function _negotiatePlainAuth() {
1891
+ if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
1892
+ this.dispatchEvent(new CustomEvent("credentialsrequired", {
1893
+ detail: {
1894
+ types: ["username", "password"]
1895
+ }
1896
+ }));
1897
+ return false;
1898
+ }
1844
1899
 
1845
- this._sock.sendString(user);
1900
+ var user = (0, _strings.encodeUTF8)(this._rfbCredentials.username);
1901
+ var pass = (0, _strings.encodeUTF8)(this._rfbCredentials.password);
1846
1902
 
1847
- this._sock.sendString(pass);
1903
+ this._sock.send([user.length >> 24 & 0xFF, user.length >> 16 & 0xFF, user.length >> 8 & 0xFF, user.length & 0xFF]);
1848
1904
 
1849
- this._rfbInitState = "SecurityResult";
1850
- return true;
1851
- }
1905
+ this._sock.send([pass.length >> 24 & 0xFF, pass.length >> 16 & 0xFF, pass.length >> 8 & 0xFF, pass.length & 0xFF]);
1906
+
1907
+ this._sock.sendString(user);
1908
+
1909
+ this._sock.sendString(pass);
1910
+
1911
+ this._rfbInitState = "SecurityResult";
1912
+ return true;
1852
1913
  }
1853
1914
  }, {
1854
1915
  key: "_negotiateStdVNCAuth",
@@ -1972,10 +2033,10 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1972
2033
  }, {
1973
2034
  key: "_aesEcbEncrypt",
1974
2035
  value: function () {
1975
- var _aesEcbEncrypt2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(string, key) {
1976
- var keyString, aesKey, data, i, encrypted, _i2, block, encryptedBlock;
2036
+ var _aesEcbEncrypt2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(string, key) {
2037
+ var keyString, aesKey, data, i, encrypted, _i3, block, encryptedBlock;
1977
2038
 
1978
- return regeneratorRuntime.wrap(function _callee$(_context) {
2039
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1979
2040
  while (1) {
1980
2041
  switch (_context.prev = _context.next) {
1981
2042
  case 0:
@@ -1997,15 +2058,15 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1997
2058
  }
1998
2059
 
1999
2060
  encrypted = new Uint8Array(data.length);
2000
- _i2 = 0;
2061
+ _i3 = 0;
2001
2062
 
2002
2063
  case 8:
2003
- if (!(_i2 < data.length)) {
2064
+ if (!(_i3 < data.length)) {
2004
2065
  _context.next = 17;
2005
2066
  break;
2006
2067
  }
2007
2068
 
2008
- block = data.slice(_i2, _i2 + 16);
2069
+ block = data.slice(_i3, _i3 + 16);
2009
2070
  _context.next = 12;
2010
2071
  return window.crypto.subtle.encrypt({
2011
2072
  name: "AES-CBC",
@@ -2014,10 +2075,10 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2014
2075
 
2015
2076
  case 12:
2016
2077
  encryptedBlock = _context.sent;
2017
- encrypted.set(new Uint8Array(encryptedBlock).slice(0, 16), _i2);
2078
+ encrypted.set(new Uint8Array(encryptedBlock).slice(0, 16), _i3);
2018
2079
 
2019
2080
  case 14:
2020
- _i2 += 16;
2081
+ _i3 += 16;
2021
2082
  _context.next = 8;
2022
2083
  break;
2023
2084
 
@@ -2041,9 +2102,9 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2041
2102
  }, {
2042
2103
  key: "_negotiateARDAuthAsync",
2043
2104
  value: function () {
2044
- var _negotiateARDAuthAsync2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(generator, keyLength, prime, serverPublicKey, clientPrivateKey, padding) {
2105
+ var _negotiateARDAuthAsync2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(generator, keyLength, prime, serverPublicKey, clientPrivateKey, padding) {
2045
2106
  var clientPublicKey, sharedKey, username, password, paddedUsername, paddedPassword, credentials, encrypted;
2046
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
2107
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2047
2108
  while (1) {
2048
2109
  switch (_context2.prev = _context2.next) {
2049
2110
  case 0:
@@ -2062,7 +2123,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2062
2123
  encrypted = _context2.sent;
2063
2124
  this._rfbCredentials.ardCredentials = encrypted;
2064
2125
  this._rfbCredentials.ardPublicKey = clientPublicKey;
2065
- setTimeout(this._initMsg.bind(this), 0);
2126
+
2127
+ this._resumeAuthentication();
2066
2128
 
2067
2129
  case 13:
2068
2130
  case "end":
@@ -2225,14 +2287,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2225
2287
  return true;
2226
2288
 
2227
2289
  case 'STDVVNCAUTH_':
2228
- // VNC auth
2229
- this._rfbAuthScheme = 2;
2230
- return this._initMsg();
2290
+ this._rfbAuthScheme = securityTypeVNCAuth;
2291
+ return true;
2231
2292
 
2232
2293
  case 'TGHTULGNAUTH':
2233
- // UNIX auth
2234
- this._rfbAuthScheme = 129;
2235
- return this._initMsg();
2294
+ this._rfbAuthScheme = securityTypeUnixLogon;
2295
+ return true;
2236
2296
 
2237
2297
  default:
2238
2298
  return this._fail("Unsupported tiny auth scheme " + "(scheme: " + authType + ")");
@@ -2278,8 +2338,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2278
2338
  _this5.dispatchEvent(new CustomEvent('securityresult'));
2279
2339
 
2280
2340
  _this5._rfbInitState = "SecurityResult";
2281
-
2282
- _this5._initMsg();
2341
+ return true;
2283
2342
  })["finally"](function () {
2284
2343
  _this5._rfbRSAAESAuthenticationState.removeEventListener("serververification", _this5._eventHandlers.handleRSAAESServerVerification);
2285
2344
 
@@ -2295,42 +2354,32 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2295
2354
  key: "_negotiateAuthentication",
2296
2355
  value: function _negotiateAuthentication() {
2297
2356
  switch (this._rfbAuthScheme) {
2298
- case 1:
2299
- // no auth
2300
- if (this._rfbVersion >= 3.8) {
2301
- this._rfbInitState = 'SecurityResult';
2302
- return true;
2303
- }
2304
-
2305
- this._rfbInitState = 'ClientInitialisation';
2306
- return this._initMsg();
2357
+ case securityTypeNone:
2358
+ this._rfbInitState = 'SecurityResult';
2359
+ return true;
2307
2360
 
2308
- case 22:
2309
- // XVP auth
2361
+ case securityTypeXVP:
2310
2362
  return this._negotiateXvpAuth();
2311
2363
 
2312
- case 30:
2313
- // ARD auth
2364
+ case securityTypeARD:
2314
2365
  return this._negotiateARDAuth();
2315
2366
 
2316
- case 2:
2317
- // VNC authentication
2367
+ case securityTypeVNCAuth:
2318
2368
  return this._negotiateStdVNCAuth();
2319
2369
 
2320
- case 16:
2321
- // TightVNC Security Type
2370
+ case securityTypeTight:
2322
2371
  return this._negotiateTightAuth();
2323
2372
 
2324
- case 19:
2325
- // VeNCrypt Security Type
2373
+ case securityTypeVeNCrypt:
2326
2374
  return this._negotiateVeNCryptAuth();
2327
2375
 
2328
- case 129:
2329
- // TightVNC UNIX Security Type
2376
+ case securityTypePlain:
2377
+ return this._negotiatePlainAuth();
2378
+
2379
+ case securityTypeUnixLogon:
2330
2380
  return this._negotiateTightUnixAuth();
2331
2381
 
2332
- case 6:
2333
- // RA2ne Security Type
2382
+ case securityTypeRA2ne:
2334
2383
  return this._negotiateRA2neAuth();
2335
2384
 
2336
2385
  default:
@@ -2340,6 +2389,13 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2340
2389
  }, {
2341
2390
  key: "_handleSecurityResult",
2342
2391
  value: function _handleSecurityResult() {
2392
+ // There is no security choice, and hence no security result
2393
+ // until RFB 3.7
2394
+ if (this._rfbVersion < 3.7) {
2395
+ this._rfbInitState = 'ClientInitialisation';
2396
+ return true;
2397
+ }
2398
+
2343
2399
  if (this._sock.rQwait('VNC auth response ', 4)) {
2344
2400
  return false;
2345
2401
  }
@@ -2350,13 +2406,13 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2350
2406
  // OK
2351
2407
  this._rfbInitState = 'ClientInitialisation';
2352
2408
  Log.Debug('Authentication OK');
2353
- return this._initMsg();
2409
+ return true;
2354
2410
  } else {
2355
2411
  if (this._rfbVersion >= 3.8) {
2356
2412
  this._rfbInitState = "SecurityReason";
2357
2413
  this._securityContext = "security result";
2358
2414
  this._securityStatus = status;
2359
- return this._initMsg();
2415
+ return true;
2360
2416
  } else {
2361
2417
  this.dispatchEvent(new CustomEvent("securityfailure", {
2362
2418
  detail: {
@@ -2559,6 +2615,15 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2559
2615
  default:
2560
2616
  return this._fail("Unknown init state (state: " + this._rfbInitState + ")");
2561
2617
  }
2618
+ } // Resume authentication handshake after it was paused for some
2619
+ // reason, e.g. waiting for a password from the user
2620
+
2621
+ }, {
2622
+ key: "_resumeAuthentication",
2623
+ value: function _resumeAuthentication() {
2624
+ // We use setTimeout() so it's run in its own context, just like
2625
+ // it originally did via the WebSocket's event handler
2626
+ setTimeout(this._initMsg.bind(this), 0);
2562
2627
  }
2563
2628
  }, {
2564
2629
  key: "_handleSetColourMapMsg",
@@ -2625,8 +2690,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2625
2690
  } // Update our server capabilities for Actions
2626
2691
 
2627
2692
 
2628
- for (var _i3 = 24; _i3 <= 31; _i3++) {
2629
- var _index = 1 << _i3;
2693
+ for (var _i4 = 24; _i4 <= 31; _i4++) {
2694
+ var _index = 1 << _i4;
2630
2695
 
2631
2696
  this._clipboardServerCapabilitiesActions[_index] = !!(actions & _index);
2632
2697
  }
@@ -2689,8 +2754,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2689
2754
  var textData = null;
2690
2755
  streamInflator.setInput(zlibStream);
2691
2756
 
2692
- for (var _i4 = 0; _i4 <= 15; _i4++) {
2693
- var format = 1 << _i4;
2757
+ for (var _i5 = 0; _i5 <= 15; _i5++) {
2758
+ var format = 1 << _i5;
2694
2759
 
2695
2760
  if (formats & format) {
2696
2761
  var size = 0x00;
@@ -2712,8 +2777,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2712
2777
  if (textData !== null) {
2713
2778
  var tmpText = "";
2714
2779
 
2715
- for (var _i5 = 0; _i5 < textData.length; _i5++) {
2716
- tmpText += String.fromCharCode(textData[_i5]);
2780
+ for (var _i6 = 0; _i6 < textData.length; _i6++) {
2781
+ tmpText += String.fromCharCode(textData[_i6]);
2717
2782
  }
2718
2783
 
2719
2784
  textData = tmpText;
@@ -3448,8 +3513,8 @@ RFB.messages = {
3448
3513
  actionFlag |= actions[i];
3449
3514
  }
3450
3515
 
3451
- for (var _i6 = 0; _i6 < formats.length; _i6++) {
3452
- formatFlag |= formats[_i6];
3516
+ for (var _i7 = 0; _i7 < formats.length; _i7++) {
3517
+ formatFlag |= formats[_i7];
3453
3518
  }
3454
3519
 
3455
3520
  data[0] = actionFlag >> 24; // Actions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novnc/novnc",
3
- "version": "1.3.0-g1075cd8",
3
+ "version": "1.3.0-g2f1e11b",
4
4
  "description": "An HTML5 VNC client",
5
5
  "browser": "lib/rfb",
6
6
  "directories": {