@novnc/novnc 1.3.0-g32f9033 → 1.3.0-g367bfd2

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.
Files changed (57) hide show
  1. package/AUTHORS +2 -2
  2. package/LICENSE.txt +1 -1
  3. package/README.md +10 -4
  4. package/core/des.js +1 -1
  5. package/core/input/keyboard.js +10 -0
  6. package/core/rfb.js +97 -4
  7. package/core/util/browser.js +56 -7
  8. package/core/util/cursor.js +4 -0
  9. package/docs/API.md +275 -215
  10. package/lib/base64.js +19 -33
  11. package/lib/decoders/copyrect.js +4 -11
  12. package/lib/decoders/hextile.js +16 -46
  13. package/lib/decoders/jpeg.js +4 -43
  14. package/lib/decoders/raw.js +8 -21
  15. package/lib/decoders/rre.js +4 -15
  16. package/lib/decoders/tight.js +12 -78
  17. package/lib/decoders/tightpng.js +3 -23
  18. package/lib/decoders/zrle.js +6 -52
  19. package/lib/deflator.js +8 -22
  20. package/lib/des.js +23 -36
  21. package/lib/display.js +46 -107
  22. package/lib/encodings.js +1 -10
  23. package/lib/inflator.js +5 -18
  24. package/lib/input/domkeytable.js +77 -48
  25. package/lib/input/fixedkeys.js +8 -3
  26. package/lib/input/gesturehandler.js +85 -152
  27. package/lib/input/keyboard.js +61 -90
  28. package/lib/input/keysym.js +14 -270
  29. package/lib/input/keysymdef.js +5 -7
  30. package/lib/input/util.js +42 -84
  31. package/lib/input/vkeys.js +0 -3
  32. package/lib/input/xtscancodes.js +1 -168
  33. package/lib/ra2.js +501 -755
  34. package/lib/rfb.js +462 -1016
  35. package/lib/util/browser.js +65 -28
  36. package/lib/util/cursor.js +28 -65
  37. package/lib/util/element.js +3 -5
  38. package/lib/util/events.js +23 -30
  39. package/lib/util/eventtarget.js +4 -13
  40. package/lib/util/int.js +1 -2
  41. package/lib/util/logging.js +1 -19
  42. package/lib/util/md5.js +10 -36
  43. package/lib/util/strings.js +3 -5
  44. package/lib/vendor/pako/lib/utils/common.js +8 -17
  45. package/lib/vendor/pako/lib/zlib/adler32.js +3 -7
  46. package/lib/vendor/pako/lib/zlib/constants.js +2 -5
  47. package/lib/vendor/pako/lib/zlib/crc32.js +5 -12
  48. package/lib/vendor/pako/lib/zlib/deflate.js +212 -617
  49. package/lib/vendor/pako/lib/zlib/gzheader.js +1 -13
  50. package/lib/vendor/pako/lib/zlib/inffast.js +60 -176
  51. package/lib/vendor/pako/lib/zlib/inflate.js +397 -887
  52. package/lib/vendor/pako/lib/zlib/inftrees.js +62 -168
  53. package/lib/vendor/pako/lib/zlib/messages.js +1 -11
  54. package/lib/vendor/pako/lib/zlib/trees.js +245 -587
  55. package/lib/vendor/pako/lib/zlib/zstream.js +2 -18
  56. package/lib/websock.js +36 -87
  57. package/package.json +31 -31
package/AUTHORS CHANGED
@@ -1,9 +1,9 @@
1
1
  maintainers:
2
- - Joel Martin (@kanaka)
3
- - Solly Ross (@directxman12)
4
2
  - Samuel Mannehed for Cendio AB (@samhed)
5
3
  - Pierre Ossman for Cendio AB (@CendioOssman)
6
4
  maintainersEmeritus:
5
+ - Joel Martin (@kanaka)
6
+ - Solly Ross (@directxman12)
7
7
  - @astrand
8
8
  contributors:
9
9
  # There are a bunch of people that should be here.
package/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- noVNC is Copyright (C) 2019 The noVNC Authors
1
+ noVNC is Copyright (C) 2022 The noVNC Authors
2
2
  (./AUTHORS)
3
3
 
4
4
  The noVNC core library files are licensed under the MPL 2.0 (Mozilla
package/README.md CHANGED
@@ -65,10 +65,14 @@ Please tweet [@noVNC](http://www.twitter.com/noVNC) if you do.
65
65
  ### Features
66
66
 
67
67
  * Supports all modern browsers including mobile (iOS, Android)
68
- * Supported VNC encodings: raw, copyrect, rre, hextile, tight, tightPNG
68
+ * Supported authentication methods: none, classical VNC, RealVNC's
69
+ RSA-AES, Tight, VeNCrypt Plain, XVP, Apple's Diffie-Hellman,
70
+ UltraVNC's MSLogonII
71
+ * Supported VNC encodings: raw, copyrect, rre, hextile, tight, tightPNG,
72
+ ZRLE, JPEG
69
73
  * Supports scaling, clipping and resizing the desktop
70
74
  * Local cursor rendering
71
- * Clipboard copy/paste
75
+ * Clipboard copy/paste with full Unicode support
72
76
  * Translations
73
77
  * Touch gestures for emulating common mouse actions
74
78
  * Licensed mainly under the [MPL 2.0](http://www.mozilla.org/MPL/2.0/), see
@@ -203,11 +207,13 @@ See [AUTHORS](AUTHORS) for a (full-ish) list of authors. If you're not on
203
207
  that list and you think you should be, feel free to send a PR to fix that.
204
208
 
205
209
  * Core team:
206
- * [Joel Martin](https://github.com/kanaka)
207
210
  * [Samuel Mannehed](https://github.com/samhed) (Cendio)
208
- * [Solly Ross](https://github.com/DirectXMan12) (Red Hat / OpenStack)
209
211
  * [Pierre Ossman](https://github.com/CendioOssman) (Cendio)
210
212
 
213
+ * Previous core contributors:
214
+ * [Joel Martin](https://github.com/kanaka) (Project founder)
215
+ * [Solly Ross](https://github.com/DirectXMan12) (Red Hat / OpenStack)
216
+
211
217
  * Notable contributions:
212
218
  * UI and Icons : Pierre Ossman, Chris Gordon
213
219
  * Original Logo : Michael Sersen
package/core/des.js CHANGED
@@ -81,7 +81,7 @@
81
81
  const PC2 = [13,16,10,23, 0, 4, 2,27,14, 5,20, 9,22,18,11, 3,
82
82
  25, 7,15, 6,26,19,12, 1,40,51,30,36,46,54,29,39,
83
83
  50,44,32,47,43,48,38,55,33,52,45,41,49,35,28,31 ],
84
- totrot = [ 1, 2, 4, 6, 8,10,12,14,15,17,19,21,23,25,27,28];
84
+ totrot = [ 1, 2, 4, 6, 8,10,12,14,15,17,19,21,23,25,27,28];
85
85
 
86
86
  const z = 0x0;
87
87
  let a,b,c,d,e,f;
@@ -153,6 +153,16 @@ export default class Keyboard {
153
153
  keysym = this._keyDownList[code];
154
154
  }
155
155
 
156
+ // macOS doesn't send proper key releases if a key is pressed
157
+ // while meta is held down
158
+ if ((browser.isMac() || browser.isIOS()) &&
159
+ (e.metaKey && code !== 'MetaLeft' && code !== 'MetaRight')) {
160
+ this._sendKeyEvent(keysym, code, true);
161
+ this._sendKeyEvent(keysym, code, false);
162
+ stopEvent(e);
163
+ return;
164
+ }
165
+
156
166
  // macOS doesn't send proper key events for modifiers, only
157
167
  // state change events. That gets extra confusing for CapsLock
158
168
  // which toggles on each press, but not on release. So pretend
package/core/rfb.js CHANGED
@@ -62,6 +62,7 @@ const securityTypeTight = 16;
62
62
  const securityTypeVeNCrypt = 19;
63
63
  const securityTypeXVP = 22;
64
64
  const securityTypeARD = 30;
65
+ const securityTypeMSLogonII = 113;
65
66
 
66
67
  // Special Tight security types
67
68
  const securityTypeUnixLogon = 129;
@@ -286,6 +287,7 @@ export default class RFB extends EventTargetMixin {
286
287
 
287
288
  this._viewOnly = false;
288
289
  this._clipViewport = false;
290
+ this._clippingViewport = false;
289
291
  this._scaleViewport = false;
290
292
  this._resizeSession = false;
291
293
 
@@ -317,6 +319,16 @@ export default class RFB extends EventTargetMixin {
317
319
 
318
320
  get capabilities() { return this._capabilities; }
319
321
 
322
+ get clippingViewport() { return this._clippingViewport; }
323
+ _setClippingViewport(on) {
324
+ if (on === this._clippingViewport) {
325
+ return;
326
+ }
327
+ this._clippingViewport = on;
328
+ this.dispatchEvent(new CustomEvent("clippingviewport",
329
+ { detail: this._clippingViewport }));
330
+ }
331
+
320
332
  get touchButton() { return 0; }
321
333
  set touchButton(button) { Log.Warn("Using old API!"); }
322
334
 
@@ -490,10 +502,27 @@ export default class RFB extends EventTargetMixin {
490
502
  this._clipboardText = text;
491
503
  RFB.messages.extendedClipboardNotify(this._sock, [extendedClipboardFormatText]);
492
504
  } else {
493
- let data = new Uint8Array(text.length);
494
- for (let i = 0; i < text.length; i++) {
495
- // FIXME: text can have values outside of Latin1/Uint8
496
- data[i] = text.charCodeAt(i);
505
+ let length, i;
506
+ let data;
507
+
508
+ length = 0;
509
+ // eslint-disable-next-line no-unused-vars
510
+ for (let codePoint of text) {
511
+ length++;
512
+ }
513
+
514
+ data = new Uint8Array(length);
515
+
516
+ i = 0;
517
+ for (let codePoint of text) {
518
+ let code = codePoint.codePointAt(0);
519
+
520
+ /* Only ISO 8859-1 is supported */
521
+ if (code > 0xff) {
522
+ code = 0x3f; // '?'
523
+ }
524
+
525
+ data[i++] = code;
497
526
  }
498
527
 
499
528
  RFB.messages.clientCutText(this._sock, data);
@@ -731,6 +760,10 @@ export default class RFB extends EventTargetMixin {
731
760
  const size = this._screenSize();
732
761
  this._display.viewportChangeSize(size.w, size.h);
733
762
  this._fixScrollbars();
763
+ this._setClippingViewport(size.w < this._display.width ||
764
+ size.h < this._display.height);
765
+ } else {
766
+ this._setClippingViewport(false);
734
767
  }
735
768
 
736
769
  // When changing clipping we might show or hide scrollbars.
@@ -1375,6 +1408,7 @@ export default class RFB extends EventTargetMixin {
1375
1408
  securityTypeVeNCrypt,
1376
1409
  securityTypeXVP,
1377
1410
  securityTypeARD,
1411
+ securityTypeMSLogonII,
1378
1412
  securityTypePlain,
1379
1413
  ];
1380
1414
 
@@ -1886,6 +1920,62 @@ export default class RFB extends EventTargetMixin {
1886
1920
  return false;
1887
1921
  }
1888
1922
 
1923
+ _negotiateMSLogonIIAuth() {
1924
+ if (this._sock.rQwait("mslogonii dh param", 24)) { return false; }
1925
+
1926
+ if (this._rfbCredentials.username === undefined ||
1927
+ this._rfbCredentials.password === undefined) {
1928
+ this.dispatchEvent(new CustomEvent(
1929
+ "credentialsrequired",
1930
+ { detail: { types: ["username", "password"] } }));
1931
+ return false;
1932
+ }
1933
+
1934
+ const g = this._sock.rQshiftBytes(8);
1935
+ const p = this._sock.rQshiftBytes(8);
1936
+ const A = this._sock.rQshiftBytes(8);
1937
+ const b = window.crypto.getRandomValues(new Uint8Array(8));
1938
+ const B = new Uint8Array(this._modPow(g, b, p));
1939
+ const secret = new Uint8Array(this._modPow(A, b, p));
1940
+
1941
+ const des = new DES(secret);
1942
+ const username = encodeUTF8(this._rfbCredentials.username).substring(0, 255);
1943
+ const password = encodeUTF8(this._rfbCredentials.password).substring(0, 63);
1944
+ const usernameBytes = new Uint8Array(256);
1945
+ const passwordBytes = new Uint8Array(64);
1946
+ window.crypto.getRandomValues(usernameBytes);
1947
+ window.crypto.getRandomValues(passwordBytes);
1948
+ for (let i = 0; i < username.length; i++) {
1949
+ usernameBytes[i] = username.charCodeAt(i);
1950
+ }
1951
+ usernameBytes[username.length] = 0;
1952
+ for (let i = 0; i < password.length; i++) {
1953
+ passwordBytes[i] = password.charCodeAt(i);
1954
+ }
1955
+ passwordBytes[password.length] = 0;
1956
+ let x = new Uint8Array(secret);
1957
+ for (let i = 0; i < 32; i++) {
1958
+ for (let j = 0; j < 8; j++) {
1959
+ x[j] ^= usernameBytes[i * 8 + j];
1960
+ }
1961
+ x = des.enc8(x);
1962
+ usernameBytes.set(x, i * 8);
1963
+ }
1964
+ x = new Uint8Array(secret);
1965
+ for (let i = 0; i < 8; i++) {
1966
+ for (let j = 0; j < 8; j++) {
1967
+ x[j] ^= passwordBytes[i * 8 + j];
1968
+ }
1969
+ x = des.enc8(x);
1970
+ passwordBytes.set(x, i * 8);
1971
+ }
1972
+ this._sock.send(B);
1973
+ this._sock.send(usernameBytes);
1974
+ this._sock.send(passwordBytes);
1975
+ this._rfbInitState = "SecurityResult";
1976
+ return true;
1977
+ }
1978
+
1889
1979
  _negotiateAuthentication() {
1890
1980
  switch (this._rfbAuthScheme) {
1891
1981
  case securityTypeNone:
@@ -1916,6 +2006,9 @@ export default class RFB extends EventTargetMixin {
1916
2006
  case securityTypeRA2ne:
1917
2007
  return this._negotiateRA2neAuth();
1918
2008
 
2009
+ case securityTypeMSLogonII:
2010
+ return this._negotiateMSLogonIIAuth();
2011
+
1919
2012
  default:
1920
2013
  return this._fail("Unsupported auth scheme (scheme: " +
1921
2014
  this._rfbAuthScheme + ")");
@@ -77,27 +77,76 @@ export const hasScrollbarGutter = _hasScrollbarGutter;
77
77
  * It's better to use feature detection than platform detection.
78
78
  */
79
79
 
80
+ /* OS */
81
+
80
82
  export function isMac() {
81
- return navigator && !!(/mac/i).exec(navigator.platform);
83
+ return !!(/mac/i).exec(navigator.platform);
82
84
  }
83
85
 
84
86
  export function isWindows() {
85
- return navigator && !!(/win/i).exec(navigator.platform);
87
+ return !!(/win/i).exec(navigator.platform);
86
88
  }
87
89
 
88
90
  export function isIOS() {
89
- return navigator &&
90
- (!!(/ipad/i).exec(navigator.platform) ||
91
+ return (!!(/ipad/i).exec(navigator.platform) ||
91
92
  !!(/iphone/i).exec(navigator.platform) ||
92
93
  !!(/ipod/i).exec(navigator.platform));
93
94
  }
94
95
 
96
+ export function isAndroid() {
97
+ /* Android sets navigator.platform to Linux :/ */
98
+ return !!navigator.userAgent.match('Android ');
99
+ }
100
+
101
+ export function isChromeOS() {
102
+ /* ChromeOS sets navigator.platform to Linux :/ */
103
+ return !!navigator.userAgent.match(' CrOS ');
104
+ }
105
+
106
+ /* Browser */
107
+
95
108
  export function isSafari() {
96
- return navigator && (navigator.userAgent.indexOf('Safari') !== -1 &&
97
- navigator.userAgent.indexOf('Chrome') === -1);
109
+ return !!navigator.userAgent.match('Safari/...') &&
110
+ !navigator.userAgent.match('Chrome/...') &&
111
+ !navigator.userAgent.match('Chromium/...') &&
112
+ !navigator.userAgent.match('Epiphany/...');
98
113
  }
99
114
 
100
115
  export function isFirefox() {
101
- return navigator && !!(/firefox/i).exec(navigator.userAgent);
116
+ return !!navigator.userAgent.match('Firefox/...') &&
117
+ !navigator.userAgent.match('Seamonkey/...');
118
+ }
119
+
120
+ export function isChrome() {
121
+ return !!navigator.userAgent.match('Chrome/...') &&
122
+ !navigator.userAgent.match('Chromium/...') &&
123
+ !navigator.userAgent.match('Edg/...') &&
124
+ !navigator.userAgent.match('OPR/...');
125
+ }
126
+
127
+ export function isChromium() {
128
+ return !!navigator.userAgent.match('Chromium/...');
102
129
  }
103
130
 
131
+ export function isOpera() {
132
+ return !!navigator.userAgent.match('OPR/...');
133
+ }
134
+
135
+ export function isEdge() {
136
+ return !!navigator.userAgent.match('Edg/...');
137
+ }
138
+
139
+ /* Engine */
140
+
141
+ export function isGecko() {
142
+ return !!navigator.userAgent.match('Gecko/...');
143
+ }
144
+
145
+ export function isWebKit() {
146
+ return !!navigator.userAgent.match('AppleWebKit/...') &&
147
+ !navigator.userAgent.match('Chrome/...');
148
+ }
149
+
150
+ export function isBlink() {
151
+ return !!navigator.userAgent.match('Chrome/...');
152
+ }
@@ -18,6 +18,10 @@ export default class Cursor {
18
18
  this._canvas.style.position = 'fixed';
19
19
  this._canvas.style.zIndex = '65535';
20
20
  this._canvas.style.pointerEvents = 'none';
21
+ // Safari on iOS can select the cursor image
22
+ // https://bugs.webkit.org/show_bug.cgi?id=249223
23
+ this._canvas.style.userSelect = 'none';
24
+ this._canvas.style.WebkitUserSelect = 'none';
21
25
  // Can't use "display" because of Firefox bug #1445997
22
26
  this._canvas.style.visibility = 'hidden';
23
27
  }