@novnc/novnc 1.3.0-gcdfb336 → 1.3.0-ge1f8232

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/display.js CHANGED
@@ -224,6 +224,18 @@ export default class Display {
224
224
  this.viewportChangePos(0, 0);
225
225
  }
226
226
 
227
+ getImageData() {
228
+ return this._drawCtx.getImageData(0, 0, this.width, this.height);
229
+ }
230
+
231
+ toDataURL(type, encoderOptions) {
232
+ return this._backbuffer.toDataURL(type, encoderOptions);
233
+ }
234
+
235
+ toBlob(callback, type, quality) {
236
+ return this._backbuffer.toBlob(callback, type, quality);
237
+ }
238
+
227
239
  // Track what parts of the visible canvas that need updating
228
240
  _damage(x, y, w, h) {
229
241
  if (x < this._damageBounds.left) {
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 */
@@ -402,7 +417,7 @@ export default class RFB extends EventTargetMixin {
402
417
 
403
418
  sendCredentials(creds) {
404
419
  this._rfbCredentials = creds;
405
- setTimeout(this._initMsg.bind(this), 0);
420
+ this._resumeAuthentication();
406
421
  }
407
422
 
408
423
  sendCtrlAltDel() {
@@ -485,6 +500,18 @@ export default class RFB extends EventTargetMixin {
485
500
  }
486
501
  }
487
502
 
503
+ getImageData() {
504
+ return this._display.getImageData();
505
+ }
506
+
507
+ toDataURL(type, encoderOptions) {
508
+ return this._display.toDataURL(type, encoderOptions);
509
+ }
510
+
511
+ toBlob(callback, type, quality) {
512
+ return this._display.toBlob(callback, type, quality);
513
+ }
514
+
488
515
  // ===== PRIVATE METHODS =====
489
516
 
490
517
  _connect() {
@@ -922,8 +949,15 @@ export default class RFB extends EventTargetMixin {
922
949
  }
923
950
  }
924
951
  break;
952
+ case 'connecting':
953
+ while (this._rfbConnectionState === 'connecting') {
954
+ if (!this._initMsg()) {
955
+ break;
956
+ }
957
+ }
958
+ break;
925
959
  default:
926
- this._initMsg();
960
+ Log.Error("Got data while in an invalid state");
927
961
  break;
928
962
  }
929
963
  }
@@ -1332,6 +1366,21 @@ export default class RFB extends EventTargetMixin {
1332
1366
  this._rfbInitState = 'Security';
1333
1367
  }
1334
1368
 
1369
+ _isSupportedSecurityType(type) {
1370
+ const clientTypes = [
1371
+ securityTypeNone,
1372
+ securityTypeVNCAuth,
1373
+ securityTypeRA2ne,
1374
+ securityTypeTight,
1375
+ securityTypeVeNCrypt,
1376
+ securityTypeXVP,
1377
+ securityTypeARD,
1378
+ securityTypePlain,
1379
+ ];
1380
+
1381
+ return clientTypes.includes(type);
1382
+ }
1383
+
1335
1384
  _negotiateSecurity() {
1336
1385
  if (this._rfbVersion >= 3.7) {
1337
1386
  // Server sends supported list, client decides
@@ -1342,28 +1391,23 @@ export default class RFB extends EventTargetMixin {
1342
1391
  this._rfbInitState = "SecurityReason";
1343
1392
  this._securityContext = "no security types";
1344
1393
  this._securityStatus = 1;
1345
- return this._initMsg();
1394
+ return true;
1346
1395
  }
1347
1396
 
1348
1397
  const types = this._sock.rQshiftBytes(numTypes);
1349
1398
  Log.Debug("Server security types: " + types);
1350
1399
 
1351
- // Look for each auth in preferred order
1352
- if (types.includes(1)) {
1353
- this._rfbAuthScheme = 1; // None
1354
- } else if (types.includes(22)) {
1355
- this._rfbAuthScheme = 22; // XVP
1356
- } else if (types.includes(16)) {
1357
- this._rfbAuthScheme = 16; // Tight
1358
- } else if (types.includes(6)) {
1359
- this._rfbAuthScheme = 6; // RA2ne Auth
1360
- } else if (types.includes(2)) {
1361
- this._rfbAuthScheme = 2; // VNC Auth
1362
- } else if (types.includes(30)) {
1363
- this._rfbAuthScheme = 30; // ARD Auth
1364
- } else if (types.includes(19)) {
1365
- this._rfbAuthScheme = 19; // VeNCrypt Auth
1366
- } else {
1400
+ // Look for a matching security type in the order that the
1401
+ // server prefers
1402
+ this._rfbAuthScheme = -1;
1403
+ for (let type of types) {
1404
+ if (this._isSupportedSecurityType(type)) {
1405
+ this._rfbAuthScheme = type;
1406
+ break;
1407
+ }
1408
+ }
1409
+
1410
+ if (this._rfbAuthScheme === -1) {
1367
1411
  return this._fail("Unsupported security types (types: " + types + ")");
1368
1412
  }
1369
1413
 
@@ -1377,14 +1421,14 @@ export default class RFB extends EventTargetMixin {
1377
1421
  this._rfbInitState = "SecurityReason";
1378
1422
  this._securityContext = "authentication scheme";
1379
1423
  this._securityStatus = 1;
1380
- return this._initMsg();
1424
+ return true;
1381
1425
  }
1382
1426
  }
1383
1427
 
1384
1428
  this._rfbInitState = 'Authentication';
1385
1429
  Log.Debug('Authenticating using scheme: ' + this._rfbAuthScheme);
1386
1430
 
1387
- return this._initMsg(); // jump to authentication
1431
+ return true;
1388
1432
  }
1389
1433
 
1390
1434
  _handleSecurityReason() {
@@ -1434,7 +1478,7 @@ export default class RFB extends EventTargetMixin {
1434
1478
  this._rfbCredentials.username +
1435
1479
  this._rfbCredentials.target;
1436
1480
  this._sock.sendString(xvpAuthStr);
1437
- this._rfbAuthScheme = 2;
1481
+ this._rfbAuthScheme = securityTypeVNCAuth;
1438
1482
  return this._negotiateAuthentication();
1439
1483
  }
1440
1484
 
@@ -1492,49 +1536,66 @@ export default class RFB extends EventTargetMixin {
1492
1536
  subtypes.push(this._sock.rQshift32());
1493
1537
  }
1494
1538
 
1495
- // 256 = Plain subtype
1496
- if (subtypes.indexOf(256) != -1) {
1497
- // 0x100 = 256
1498
- this._sock.send([0, 0, 1, 0]);
1499
- this._rfbVeNCryptState = 4;
1500
- } else {
1501
- return this._fail("VeNCrypt Plain subtype not offered by server");
1539
+ // Look for a matching security type in the order that the
1540
+ // server prefers
1541
+ this._rfbAuthScheme = -1;
1542
+ for (let type of subtypes) {
1543
+ // Avoid getting in to a loop
1544
+ if (type === securityTypeVeNCrypt) {
1545
+ continue;
1546
+ }
1547
+
1548
+ if (this._isSupportedSecurityType(type)) {
1549
+ this._rfbAuthScheme = type;
1550
+ break;
1551
+ }
1502
1552
  }
1503
- }
1504
1553
 
1505
- // negotiated Plain subtype, server waits for password
1506
- if (this._rfbVeNCryptState == 4) {
1507
- if (this._rfbCredentials.username === undefined ||
1508
- this._rfbCredentials.password === undefined) {
1509
- this.dispatchEvent(new CustomEvent(
1510
- "credentialsrequired",
1511
- { detail: { types: ["username", "password"] } }));
1512
- return false;
1554
+ if (this._rfbAuthScheme === -1) {
1555
+ return this._fail("Unsupported security types (types: " + subtypes + ")");
1513
1556
  }
1514
1557
 
1515
- const user = encodeUTF8(this._rfbCredentials.username);
1516
- const pass = encodeUTF8(this._rfbCredentials.password);
1517
-
1518
- this._sock.send([
1519
- (user.length >> 24) & 0xFF,
1520
- (user.length >> 16) & 0xFF,
1521
- (user.length >> 8) & 0xFF,
1522
- user.length & 0xFF
1523
- ]);
1524
- this._sock.send([
1525
- (pass.length >> 24) & 0xFF,
1526
- (pass.length >> 16) & 0xFF,
1527
- (pass.length >> 8) & 0xFF,
1528
- pass.length & 0xFF
1529
- ]);
1530
- this._sock.sendString(user);
1531
- this._sock.sendString(pass);
1558
+ this._sock.send([this._rfbAuthScheme >> 24,
1559
+ this._rfbAuthScheme >> 16,
1560
+ this._rfbAuthScheme >> 8,
1561
+ this._rfbAuthScheme]);
1532
1562
 
1533
- this._rfbInitState = "SecurityResult";
1563
+ this._rfbVeNCryptState == 4;
1534
1564
  return true;
1535
1565
  }
1536
1566
  }
1537
1567
 
1568
+ _negotiatePlainAuth() {
1569
+ if (this._rfbCredentials.username === undefined ||
1570
+ this._rfbCredentials.password === undefined) {
1571
+ this.dispatchEvent(new CustomEvent(
1572
+ "credentialsrequired",
1573
+ { detail: { types: ["username", "password"] } }));
1574
+ return false;
1575
+ }
1576
+
1577
+ const user = encodeUTF8(this._rfbCredentials.username);
1578
+ const pass = encodeUTF8(this._rfbCredentials.password);
1579
+
1580
+ this._sock.send([
1581
+ (user.length >> 24) & 0xFF,
1582
+ (user.length >> 16) & 0xFF,
1583
+ (user.length >> 8) & 0xFF,
1584
+ user.length & 0xFF
1585
+ ]);
1586
+ this._sock.send([
1587
+ (pass.length >> 24) & 0xFF,
1588
+ (pass.length >> 16) & 0xFF,
1589
+ (pass.length >> 8) & 0xFF,
1590
+ pass.length & 0xFF
1591
+ ]);
1592
+ this._sock.sendString(user);
1593
+ this._sock.sendString(pass);
1594
+
1595
+ this._rfbInitState = "SecurityResult";
1596
+ return true;
1597
+ }
1598
+
1538
1599
  _negotiateStdVNCAuth() {
1539
1600
  if (this._sock.rQwait("auth challenge", 16)) { return false; }
1540
1601
 
@@ -1661,7 +1722,7 @@ export default class RFB extends EventTargetMixin {
1661
1722
  this._rfbCredentials.ardCredentials = encrypted;
1662
1723
  this._rfbCredentials.ardPublicKey = clientPublicKey;
1663
1724
 
1664
- setTimeout(this._initMsg.bind(this), 0);
1725
+ this._resumeAuthentication();
1665
1726
  }
1666
1727
 
1667
1728
  _negotiateTightUnixAuth() {
@@ -1771,12 +1832,12 @@ export default class RFB extends EventTargetMixin {
1771
1832
  case 'STDVNOAUTH__': // no auth
1772
1833
  this._rfbInitState = 'SecurityResult';
1773
1834
  return true;
1774
- case 'STDVVNCAUTH_': // VNC auth
1775
- this._rfbAuthScheme = 2;
1776
- return this._initMsg();
1777
- case 'TGHTULGNAUTH': // UNIX auth
1778
- this._rfbAuthScheme = 129;
1779
- return this._initMsg();
1835
+ case 'STDVVNCAUTH_':
1836
+ this._rfbAuthScheme = securityTypeVNCAuth;
1837
+ return true;
1838
+ case 'TGHTULGNAUTH':
1839
+ this._rfbAuthScheme = securityTypeUnixLogon;
1840
+ return true;
1780
1841
  default:
1781
1842
  return this._fail("Unsupported tiny auth scheme " +
1782
1843
  "(scheme: " + authType + ")");
@@ -1813,7 +1874,7 @@ export default class RFB extends EventTargetMixin {
1813
1874
  }).then(() => {
1814
1875
  this.dispatchEvent(new CustomEvent('securityresult'));
1815
1876
  this._rfbInitState = "SecurityResult";
1816
- this._initMsg();
1877
+ return true;
1817
1878
  }).finally(() => {
1818
1879
  this._rfbRSAAESAuthenticationState.removeEventListener(
1819
1880
  "serververification", this._eventHandlers.handleRSAAESServerVerification);
@@ -1827,33 +1888,32 @@ export default class RFB extends EventTargetMixin {
1827
1888
 
1828
1889
  _negotiateAuthentication() {
1829
1890
  switch (this._rfbAuthScheme) {
1830
- case 1: // no auth
1831
- if (this._rfbVersion >= 3.8) {
1832
- this._rfbInitState = 'SecurityResult';
1833
- return true;
1834
- }
1835
- this._rfbInitState = 'ClientInitialisation';
1836
- return this._initMsg();
1891
+ case securityTypeNone:
1892
+ this._rfbInitState = 'SecurityResult';
1893
+ return true;
1837
1894
 
1838
- case 22: // XVP auth
1895
+ case securityTypeXVP:
1839
1896
  return this._negotiateXvpAuth();
1840
1897
 
1841
- case 30: // ARD auth
1898
+ case securityTypeARD:
1842
1899
  return this._negotiateARDAuth();
1843
1900
 
1844
- case 2: // VNC authentication
1901
+ case securityTypeVNCAuth:
1845
1902
  return this._negotiateStdVNCAuth();
1846
1903
 
1847
- case 16: // TightVNC Security Type
1904
+ case securityTypeTight:
1848
1905
  return this._negotiateTightAuth();
1849
1906
 
1850
- case 19: // VeNCrypt Security Type
1907
+ case securityTypeVeNCrypt:
1851
1908
  return this._negotiateVeNCryptAuth();
1852
1909
 
1853
- case 129: // TightVNC UNIX Security Type
1910
+ case securityTypePlain:
1911
+ return this._negotiatePlainAuth();
1912
+
1913
+ case securityTypeUnixLogon:
1854
1914
  return this._negotiateTightUnixAuth();
1855
1915
 
1856
- case 6: // RA2ne Security Type
1916
+ case securityTypeRA2ne:
1857
1917
  return this._negotiateRA2neAuth();
1858
1918
 
1859
1919
  default:
@@ -1863,6 +1923,13 @@ export default class RFB extends EventTargetMixin {
1863
1923
  }
1864
1924
 
1865
1925
  _handleSecurityResult() {
1926
+ // There is no security choice, and hence no security result
1927
+ // until RFB 3.7
1928
+ if (this._rfbVersion < 3.7) {
1929
+ this._rfbInitState = 'ClientInitialisation';
1930
+ return true;
1931
+ }
1932
+
1866
1933
  if (this._sock.rQwait('VNC auth response ', 4)) { return false; }
1867
1934
 
1868
1935
  const status = this._sock.rQshift32();
@@ -1870,13 +1937,13 @@ export default class RFB extends EventTargetMixin {
1870
1937
  if (status === 0) { // OK
1871
1938
  this._rfbInitState = 'ClientInitialisation';
1872
1939
  Log.Debug('Authentication OK');
1873
- return this._initMsg();
1940
+ return true;
1874
1941
  } else {
1875
1942
  if (this._rfbVersion >= 3.8) {
1876
1943
  this._rfbInitState = "SecurityReason";
1877
1944
  this._securityContext = "security result";
1878
1945
  this._securityStatus = status;
1879
- return this._initMsg();
1946
+ return true;
1880
1947
  } else {
1881
1948
  this.dispatchEvent(new CustomEvent(
1882
1949
  "securityfailure",
@@ -2052,6 +2119,14 @@ export default class RFB extends EventTargetMixin {
2052
2119
  }
2053
2120
  }
2054
2121
 
2122
+ // Resume authentication handshake after it was paused for some
2123
+ // reason, e.g. waiting for a password from the user
2124
+ _resumeAuthentication() {
2125
+ // We use setTimeout() so it's run in its own context, just like
2126
+ // it originally did via the WebSocket's event handler
2127
+ setTimeout(this._initMsg.bind(this), 0);
2128
+ }
2129
+
2055
2130
  _handleSetColourMapMsg() {
2056
2131
  Log.Debug("SetColorMapEntries");
2057
2132
 
package/docs/API.md CHANGED
@@ -155,6 +155,15 @@ protocol stream.
155
155
  [`RFB.clipboardPasteFrom()`](#rfbclipboardpastefrom)
156
156
  - Send clipboard contents to server.
157
157
 
158
+ [`RFB.getImageData()`](#rfbgetimagedata)
159
+ - Return the current content of the screen as an ImageData array.
160
+
161
+ [`RFB.toDataURL()`](#rfbtodataurl)
162
+ - Return the current content of the screen as data-url encoded image file.
163
+
164
+ [`RFB.toBlob()`](#rfbtoblob)
165
+ - Return the current content of the screen as Blob encoded image file.
166
+
158
167
  ### Details
159
168
 
160
169
  #### RFB()
@@ -423,3 +432,55 @@ to the remote server.
423
432
 
424
433
  **`text`**
425
434
  - A `DOMString` specifying the clipboard data to send.
435
+
436
+ #### RFB.getImageData()
437
+
438
+ The `RFB.getImageData()` method is used to return the current content of the
439
+ screen encoded as [`ImageData`](https://developer.mozilla.org/en-US/docs/Web/API/ImageData).
440
+
441
+ ##### Syntax
442
+
443
+ RFB.getImageData();
444
+
445
+ #### RFB.toDataURL()
446
+
447
+ The `RFB.toDataURL()` method is used to return the current content of the
448
+ screen encoded as a data URL that could for example be put in the `src` attribute
449
+ of an `img` tag.
450
+
451
+ ##### Syntax
452
+
453
+ RFB.toDataURL();
454
+ RFB.toDataURL(type);
455
+ RFB.toDataURL(type, encoderOptions);
456
+
457
+ ###### Parameters
458
+
459
+ **`type`** *Optional*
460
+ - A string indicating the requested MIME type of the image
461
+
462
+ **`encoderOptions`** *Optional*
463
+ - A number between 0 and 1 indicating the image quality.
464
+
465
+ #### RFB.toBlob()
466
+
467
+ The `RFB.toBlob()` method is used to return the current content of the
468
+ screen encoded as [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
469
+
470
+ ##### Syntax
471
+
472
+ RFB.toDataURL(callback);
473
+ RFB.toDataURL(callback, type);
474
+ RFB.toDataURL(callback, type, quality);
475
+
476
+ ###### Parameters
477
+
478
+ **`callback`**
479
+ - A callback function which will receive the resulting [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
480
+ as the single argument
481
+
482
+ **`type`** *Optional*
483
+ - A string indicating the requested MIME type of the image
484
+
485
+ **`encoderOptions`** *Optional*
486
+ - A number between 0 and 1 indicating the image quality.
@@ -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/display.js CHANGED
@@ -246,6 +246,21 @@ var Display = /*#__PURE__*/function () {
246
246
  var vp = this._viewportLoc;
247
247
  this.viewportChangeSize(vp.w, vp.h);
248
248
  this.viewportChangePos(0, 0);
249
+ }
250
+ }, {
251
+ key: "getImageData",
252
+ value: function getImageData() {
253
+ return this._drawCtx.getImageData(0, 0, this.width, this.height);
254
+ }
255
+ }, {
256
+ key: "toDataURL",
257
+ value: function toDataURL(type, encoderOptions) {
258
+ return this._backbuffer.toDataURL(type, encoderOptions);
259
+ }
260
+ }, {
261
+ key: "toBlob",
262
+ value: function toBlob(callback, type, quality) {
263
+ return this._backbuffer.toBlob(callback, type, quality);
249
264
  } // Track what parts of the visible canvas that need updating
250
265
 
251
266
  }, {
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 */
@@ -505,7 +521,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
505
521
  key: "sendCredentials",
506
522
  value: function sendCredentials(creds) {
507
523
  this._rfbCredentials = creds;
508
- setTimeout(this._initMsg.bind(this), 0);
524
+
525
+ this._resumeAuthentication();
509
526
  }
510
527
  }, {
511
528
  key: "sendCtrlAltDel",
@@ -598,6 +615,21 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
598
615
 
599
616
  RFB.messages.clientCutText(this._sock, data);
600
617
  }
618
+ }
619
+ }, {
620
+ key: "getImageData",
621
+ value: function getImageData() {
622
+ return this._display.getImageData();
623
+ }
624
+ }, {
625
+ key: "toDataURL",
626
+ value: function toDataURL(type, encoderOptions) {
627
+ return this._display.toDataURL(type, encoderOptions);
628
+ }
629
+ }, {
630
+ key: "toBlob",
631
+ value: function toBlob(callback, type, quality) {
632
+ return this._display.toBlob(callback, type, quality);
601
633
  } // ===== PRIVATE METHODS =====
602
634
 
603
635
  }, {
@@ -1129,10 +1161,18 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1129
1161
 
1130
1162
  break;
1131
1163
 
1132
- default:
1133
- this._initMsg();
1164
+ case 'connecting':
1165
+ while (this._rfbConnectionState === 'connecting') {
1166
+ if (!this._initMsg()) {
1167
+ break;
1168
+ }
1169
+ }
1134
1170
 
1135
1171
  break;
1172
+
1173
+ default:
1174
+ Log.Error("Got data while in an invalid state");
1175
+ break;
1136
1176
  }
1137
1177
  }
1138
1178
  }, {
@@ -1634,6 +1674,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1634
1674
  Log.Debug('Sent ProtocolVersion: ' + cversion);
1635
1675
  this._rfbInitState = 'Security';
1636
1676
  }
1677
+ }, {
1678
+ key: "_isSupportedSecurityType",
1679
+ value: function _isSupportedSecurityType(type) {
1680
+ var clientTypes = [securityTypeNone, securityTypeVNCAuth, securityTypeRA2ne, securityTypeTight, securityTypeVeNCrypt, securityTypeXVP, securityTypeARD, securityTypePlain];
1681
+ return clientTypes.includes(type);
1682
+ }
1637
1683
  }, {
1638
1684
  key: "_negotiateSecurity",
1639
1685
  value: function _negotiateSecurity() {
@@ -1649,28 +1695,35 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1649
1695
  this._rfbInitState = "SecurityReason";
1650
1696
  this._securityContext = "no security types";
1651
1697
  this._securityStatus = 1;
1652
- return this._initMsg();
1698
+ return true;
1653
1699
  }
1654
1700
 
1655
1701
  var types = this._sock.rQshiftBytes(numTypes);
1656
1702
 
1657
- Log.Debug("Server security types: " + types); // Look for each auth in preferred order
1658
-
1659
- if (types.includes(1)) {
1660
- this._rfbAuthScheme = 1; // None
1661
- } else if (types.includes(22)) {
1662
- this._rfbAuthScheme = 22; // XVP
1663
- } else if (types.includes(16)) {
1664
- this._rfbAuthScheme = 16; // Tight
1665
- } else if (types.includes(6)) {
1666
- this._rfbAuthScheme = 6; // RA2ne Auth
1667
- } else if (types.includes(2)) {
1668
- this._rfbAuthScheme = 2; // VNC Auth
1669
- } else if (types.includes(30)) {
1670
- this._rfbAuthScheme = 30; // ARD Auth
1671
- } else if (types.includes(19)) {
1672
- this._rfbAuthScheme = 19; // VeNCrypt Auth
1673
- } else {
1703
+ Log.Debug("Server security types: " + types); // Look for a matching security type in the order that the
1704
+ // server prefers
1705
+
1706
+ this._rfbAuthScheme = -1;
1707
+
1708
+ var _iterator = _createForOfIteratorHelper(types),
1709
+ _step;
1710
+
1711
+ try {
1712
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1713
+ var type = _step.value;
1714
+
1715
+ if (this._isSupportedSecurityType(type)) {
1716
+ this._rfbAuthScheme = type;
1717
+ break;
1718
+ }
1719
+ }
1720
+ } catch (err) {
1721
+ _iterator.e(err);
1722
+ } finally {
1723
+ _iterator.f();
1724
+ }
1725
+
1726
+ if (this._rfbAuthScheme === -1) {
1674
1727
  return this._fail("Unsupported security types (types: " + types + ")");
1675
1728
  }
1676
1729
 
@@ -1687,13 +1740,13 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1687
1740
  this._rfbInitState = "SecurityReason";
1688
1741
  this._securityContext = "authentication scheme";
1689
1742
  this._securityStatus = 1;
1690
- return this._initMsg();
1743
+ return true;
1691
1744
  }
1692
1745
  }
1693
1746
 
1694
1747
  this._rfbInitState = 'Authentication';
1695
1748
  Log.Debug('Authenticating using scheme: ' + this._rfbAuthScheme);
1696
- return this._initMsg(); // jump to authentication
1749
+ return true;
1697
1750
  }
1698
1751
  }, {
1699
1752
  key: "_handleSecurityReason",
@@ -1748,7 +1801,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1748
1801
 
1749
1802
  this._sock.sendString(xvpAuthStr);
1750
1803
 
1751
- this._rfbAuthScheme = 2;
1804
+ this._rfbAuthScheme = securityTypeVNCAuth;
1752
1805
  return this._negotiateAuthentication();
1753
1806
  } // VeNCrypt authentication, currently only supports version 0.2 and only Plain subtype
1754
1807
 
@@ -1817,44 +1870,61 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1817
1870
 
1818
1871
  for (var i = 0; i < this._rfbVeNCryptSubtypesLength; i++) {
1819
1872
  subtypes.push(this._sock.rQshift32());
1820
- } // 256 = Plain subtype
1873
+ } // Look for a matching security type in the order that the
1874
+ // server prefers
1821
1875
 
1822
1876
 
1823
- if (subtypes.indexOf(256) != -1) {
1824
- // 0x100 = 256
1825
- this._sock.send([0, 0, 1, 0]);
1877
+ this._rfbAuthScheme = -1;
1826
1878
 
1827
- this._rfbVeNCryptState = 4;
1828
- } else {
1829
- return this._fail("VeNCrypt Plain subtype not offered by server");
1830
- }
1831
- } // negotiated Plain subtype, server waits for password
1879
+ for (var _i2 = 0, _subtypes = subtypes; _i2 < _subtypes.length; _i2++) {
1880
+ var type = _subtypes[_i2];
1832
1881
 
1882
+ // Avoid getting in to a loop
1883
+ if (type === securityTypeVeNCrypt) {
1884
+ continue;
1885
+ }
1833
1886
 
1834
- if (this._rfbVeNCryptState == 4) {
1835
- if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
1836
- this.dispatchEvent(new CustomEvent("credentialsrequired", {
1837
- detail: {
1838
- types: ["username", "password"]
1839
- }
1840
- }));
1841
- return false;
1887
+ if (this._isSupportedSecurityType(type)) {
1888
+ this._rfbAuthScheme = type;
1889
+ break;
1890
+ }
1891
+ }
1892
+
1893
+ if (this._rfbAuthScheme === -1) {
1894
+ return this._fail("Unsupported security types (types: " + subtypes + ")");
1842
1895
  }
1843
1896
 
1844
- var user = (0, _strings.encodeUTF8)(this._rfbCredentials.username);
1845
- var pass = (0, _strings.encodeUTF8)(this._rfbCredentials.password);
1897
+ this._sock.send([this._rfbAuthScheme >> 24, this._rfbAuthScheme >> 16, this._rfbAuthScheme >> 8, this._rfbAuthScheme]);
1898
+
1899
+ this._rfbVeNCryptState == 4;
1900
+ return true;
1901
+ }
1902
+ }
1903
+ }, {
1904
+ key: "_negotiatePlainAuth",
1905
+ value: function _negotiatePlainAuth() {
1906
+ if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
1907
+ this.dispatchEvent(new CustomEvent("credentialsrequired", {
1908
+ detail: {
1909
+ types: ["username", "password"]
1910
+ }
1911
+ }));
1912
+ return false;
1913
+ }
1914
+
1915
+ var user = (0, _strings.encodeUTF8)(this._rfbCredentials.username);
1916
+ var pass = (0, _strings.encodeUTF8)(this._rfbCredentials.password);
1846
1917
 
1847
- this._sock.send([user.length >> 24 & 0xFF, user.length >> 16 & 0xFF, user.length >> 8 & 0xFF, user.length & 0xFF]);
1918
+ this._sock.send([user.length >> 24 & 0xFF, user.length >> 16 & 0xFF, user.length >> 8 & 0xFF, user.length & 0xFF]);
1848
1919
 
1849
- this._sock.send([pass.length >> 24 & 0xFF, pass.length >> 16 & 0xFF, pass.length >> 8 & 0xFF, pass.length & 0xFF]);
1920
+ this._sock.send([pass.length >> 24 & 0xFF, pass.length >> 16 & 0xFF, pass.length >> 8 & 0xFF, pass.length & 0xFF]);
1850
1921
 
1851
- this._sock.sendString(user);
1922
+ this._sock.sendString(user);
1852
1923
 
1853
- this._sock.sendString(pass);
1924
+ this._sock.sendString(pass);
1854
1925
 
1855
- this._rfbInitState = "SecurityResult";
1856
- return true;
1857
- }
1926
+ this._rfbInitState = "SecurityResult";
1927
+ return true;
1858
1928
  }
1859
1929
  }, {
1860
1930
  key: "_negotiateStdVNCAuth",
@@ -1978,10 +2048,10 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
1978
2048
  }, {
1979
2049
  key: "_aesEcbEncrypt",
1980
2050
  value: function () {
1981
- var _aesEcbEncrypt2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(string, key) {
1982
- var keyString, aesKey, data, i, encrypted, _i2, block, encryptedBlock;
2051
+ var _aesEcbEncrypt2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(string, key) {
2052
+ var keyString, aesKey, data, i, encrypted, _i3, block, encryptedBlock;
1983
2053
 
1984
- return regeneratorRuntime.wrap(function _callee$(_context) {
2054
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1985
2055
  while (1) {
1986
2056
  switch (_context.prev = _context.next) {
1987
2057
  case 0:
@@ -2003,15 +2073,15 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2003
2073
  }
2004
2074
 
2005
2075
  encrypted = new Uint8Array(data.length);
2006
- _i2 = 0;
2076
+ _i3 = 0;
2007
2077
 
2008
2078
  case 8:
2009
- if (!(_i2 < data.length)) {
2079
+ if (!(_i3 < data.length)) {
2010
2080
  _context.next = 17;
2011
2081
  break;
2012
2082
  }
2013
2083
 
2014
- block = data.slice(_i2, _i2 + 16);
2084
+ block = data.slice(_i3, _i3 + 16);
2015
2085
  _context.next = 12;
2016
2086
  return window.crypto.subtle.encrypt({
2017
2087
  name: "AES-CBC",
@@ -2020,10 +2090,10 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2020
2090
 
2021
2091
  case 12:
2022
2092
  encryptedBlock = _context.sent;
2023
- encrypted.set(new Uint8Array(encryptedBlock).slice(0, 16), _i2);
2093
+ encrypted.set(new Uint8Array(encryptedBlock).slice(0, 16), _i3);
2024
2094
 
2025
2095
  case 14:
2026
- _i2 += 16;
2096
+ _i3 += 16;
2027
2097
  _context.next = 8;
2028
2098
  break;
2029
2099
 
@@ -2047,9 +2117,9 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2047
2117
  }, {
2048
2118
  key: "_negotiateARDAuthAsync",
2049
2119
  value: function () {
2050
- var _negotiateARDAuthAsync2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(generator, keyLength, prime, serverPublicKey, clientPrivateKey, padding) {
2120
+ var _negotiateARDAuthAsync2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(generator, keyLength, prime, serverPublicKey, clientPrivateKey, padding) {
2051
2121
  var clientPublicKey, sharedKey, username, password, paddedUsername, paddedPassword, credentials, encrypted;
2052
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
2122
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2053
2123
  while (1) {
2054
2124
  switch (_context2.prev = _context2.next) {
2055
2125
  case 0:
@@ -2068,7 +2138,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2068
2138
  encrypted = _context2.sent;
2069
2139
  this._rfbCredentials.ardCredentials = encrypted;
2070
2140
  this._rfbCredentials.ardPublicKey = clientPublicKey;
2071
- setTimeout(this._initMsg.bind(this), 0);
2141
+
2142
+ this._resumeAuthentication();
2072
2143
 
2073
2144
  case 13:
2074
2145
  case "end":
@@ -2231,14 +2302,12 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2231
2302
  return true;
2232
2303
 
2233
2304
  case 'STDVVNCAUTH_':
2234
- // VNC auth
2235
- this._rfbAuthScheme = 2;
2236
- return this._initMsg();
2305
+ this._rfbAuthScheme = securityTypeVNCAuth;
2306
+ return true;
2237
2307
 
2238
2308
  case 'TGHTULGNAUTH':
2239
- // UNIX auth
2240
- this._rfbAuthScheme = 129;
2241
- return this._initMsg();
2309
+ this._rfbAuthScheme = securityTypeUnixLogon;
2310
+ return true;
2242
2311
 
2243
2312
  default:
2244
2313
  return this._fail("Unsupported tiny auth scheme " + "(scheme: " + authType + ")");
@@ -2284,8 +2353,7 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2284
2353
  _this5.dispatchEvent(new CustomEvent('securityresult'));
2285
2354
 
2286
2355
  _this5._rfbInitState = "SecurityResult";
2287
-
2288
- _this5._initMsg();
2356
+ return true;
2289
2357
  })["finally"](function () {
2290
2358
  _this5._rfbRSAAESAuthenticationState.removeEventListener("serververification", _this5._eventHandlers.handleRSAAESServerVerification);
2291
2359
 
@@ -2301,42 +2369,32 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2301
2369
  key: "_negotiateAuthentication",
2302
2370
  value: function _negotiateAuthentication() {
2303
2371
  switch (this._rfbAuthScheme) {
2304
- case 1:
2305
- // no auth
2306
- if (this._rfbVersion >= 3.8) {
2307
- this._rfbInitState = 'SecurityResult';
2308
- return true;
2309
- }
2310
-
2311
- this._rfbInitState = 'ClientInitialisation';
2312
- return this._initMsg();
2372
+ case securityTypeNone:
2373
+ this._rfbInitState = 'SecurityResult';
2374
+ return true;
2313
2375
 
2314
- case 22:
2315
- // XVP auth
2376
+ case securityTypeXVP:
2316
2377
  return this._negotiateXvpAuth();
2317
2378
 
2318
- case 30:
2319
- // ARD auth
2379
+ case securityTypeARD:
2320
2380
  return this._negotiateARDAuth();
2321
2381
 
2322
- case 2:
2323
- // VNC authentication
2382
+ case securityTypeVNCAuth:
2324
2383
  return this._negotiateStdVNCAuth();
2325
2384
 
2326
- case 16:
2327
- // TightVNC Security Type
2385
+ case securityTypeTight:
2328
2386
  return this._negotiateTightAuth();
2329
2387
 
2330
- case 19:
2331
- // VeNCrypt Security Type
2388
+ case securityTypeVeNCrypt:
2332
2389
  return this._negotiateVeNCryptAuth();
2333
2390
 
2334
- case 129:
2335
- // TightVNC UNIX Security Type
2391
+ case securityTypePlain:
2392
+ return this._negotiatePlainAuth();
2393
+
2394
+ case securityTypeUnixLogon:
2336
2395
  return this._negotiateTightUnixAuth();
2337
2396
 
2338
- case 6:
2339
- // RA2ne Security Type
2397
+ case securityTypeRA2ne:
2340
2398
  return this._negotiateRA2neAuth();
2341
2399
 
2342
2400
  default:
@@ -2346,6 +2404,13 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2346
2404
  }, {
2347
2405
  key: "_handleSecurityResult",
2348
2406
  value: function _handleSecurityResult() {
2407
+ // There is no security choice, and hence no security result
2408
+ // until RFB 3.7
2409
+ if (this._rfbVersion < 3.7) {
2410
+ this._rfbInitState = 'ClientInitialisation';
2411
+ return true;
2412
+ }
2413
+
2349
2414
  if (this._sock.rQwait('VNC auth response ', 4)) {
2350
2415
  return false;
2351
2416
  }
@@ -2356,13 +2421,13 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2356
2421
  // OK
2357
2422
  this._rfbInitState = 'ClientInitialisation';
2358
2423
  Log.Debug('Authentication OK');
2359
- return this._initMsg();
2424
+ return true;
2360
2425
  } else {
2361
2426
  if (this._rfbVersion >= 3.8) {
2362
2427
  this._rfbInitState = "SecurityReason";
2363
2428
  this._securityContext = "security result";
2364
2429
  this._securityStatus = status;
2365
- return this._initMsg();
2430
+ return true;
2366
2431
  } else {
2367
2432
  this.dispatchEvent(new CustomEvent("securityfailure", {
2368
2433
  detail: {
@@ -2565,6 +2630,15 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2565
2630
  default:
2566
2631
  return this._fail("Unknown init state (state: " + this._rfbInitState + ")");
2567
2632
  }
2633
+ } // Resume authentication handshake after it was paused for some
2634
+ // reason, e.g. waiting for a password from the user
2635
+
2636
+ }, {
2637
+ key: "_resumeAuthentication",
2638
+ value: function _resumeAuthentication() {
2639
+ // We use setTimeout() so it's run in its own context, just like
2640
+ // it originally did via the WebSocket's event handler
2641
+ setTimeout(this._initMsg.bind(this), 0);
2568
2642
  }
2569
2643
  }, {
2570
2644
  key: "_handleSetColourMapMsg",
@@ -2631,8 +2705,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2631
2705
  } // Update our server capabilities for Actions
2632
2706
 
2633
2707
 
2634
- for (var _i3 = 24; _i3 <= 31; _i3++) {
2635
- var _index = 1 << _i3;
2708
+ for (var _i4 = 24; _i4 <= 31; _i4++) {
2709
+ var _index = 1 << _i4;
2636
2710
 
2637
2711
  this._clipboardServerCapabilitiesActions[_index] = !!(actions & _index);
2638
2712
  }
@@ -2695,8 +2769,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2695
2769
  var textData = null;
2696
2770
  streamInflator.setInput(zlibStream);
2697
2771
 
2698
- for (var _i4 = 0; _i4 <= 15; _i4++) {
2699
- var format = 1 << _i4;
2772
+ for (var _i5 = 0; _i5 <= 15; _i5++) {
2773
+ var format = 1 << _i5;
2700
2774
 
2701
2775
  if (formats & format) {
2702
2776
  var size = 0x00;
@@ -2718,8 +2792,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
2718
2792
  if (textData !== null) {
2719
2793
  var tmpText = "";
2720
2794
 
2721
- for (var _i5 = 0; _i5 < textData.length; _i5++) {
2722
- tmpText += String.fromCharCode(textData[_i5]);
2795
+ for (var _i6 = 0; _i6 < textData.length; _i6++) {
2796
+ tmpText += String.fromCharCode(textData[_i6]);
2723
2797
  }
2724
2798
 
2725
2799
  textData = tmpText;
@@ -3454,8 +3528,8 @@ RFB.messages = {
3454
3528
  actionFlag |= actions[i];
3455
3529
  }
3456
3530
 
3457
- for (var _i6 = 0; _i6 < formats.length; _i6++) {
3458
- formatFlag |= formats[_i6];
3531
+ for (var _i7 = 0; _i7 < formats.length; _i7++) {
3532
+ formatFlag |= formats[_i7];
3459
3533
  }
3460
3534
 
3461
3535
  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-gcdfb336",
3
+ "version": "1.3.0-ge1f8232",
4
4
  "description": "An HTML5 VNC client",
5
5
  "browser": "lib/rfb",
6
6
  "directories": {