@novnc/novnc 1.3.0-beta → 1.3.0-g0cb5f23

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 (59) hide show
  1. package/README.md +13 -3
  2. package/core/decoders/jpeg.js +141 -0
  3. package/core/decoders/raw.js +1 -1
  4. package/core/decoders/zrle.js +185 -0
  5. package/core/display.js +12 -0
  6. package/core/encodings.js +4 -0
  7. package/core/input/keyboard.js +10 -0
  8. package/core/ra2.js +567 -0
  9. package/core/rfb.js +393 -84
  10. package/core/util/md5.js +79 -0
  11. package/docs/API.md +105 -4
  12. package/lib/base64.js +20 -34
  13. package/lib/decoders/copyrect.js +1 -11
  14. package/lib/decoders/hextile.js +14 -46
  15. package/lib/decoders/jpeg.js +146 -0
  16. package/lib/decoders/raw.js +6 -22
  17. package/lib/decoders/rre.js +1 -15
  18. package/lib/decoders/tight.js +10 -78
  19. package/lib/decoders/tightpng.js +5 -27
  20. package/lib/decoders/zrle.js +185 -0
  21. package/lib/deflator.js +5 -22
  22. package/lib/des.js +20 -36
  23. package/lib/display.js +59 -107
  24. package/lib/encodings.js +7 -8
  25. package/lib/inflator.js +2 -18
  26. package/lib/input/domkeytable.js +77 -48
  27. package/lib/input/fixedkeys.js +8 -3
  28. package/lib/input/gesturehandler.js +82 -152
  29. package/lib/input/keyboard.js +59 -90
  30. package/lib/input/keysym.js +14 -270
  31. package/lib/input/keysymdef.js +5 -7
  32. package/lib/input/util.js +44 -86
  33. package/lib/input/vkeys.js +0 -3
  34. package/lib/input/xtscancodes.js +1 -168
  35. package/lib/ra2.js +1033 -0
  36. package/lib/rfb.js +716 -922
  37. package/lib/util/browser.js +24 -29
  38. package/lib/util/cursor.js +21 -65
  39. package/lib/util/element.js +3 -5
  40. package/lib/util/events.js +25 -32
  41. package/lib/util/eventtarget.js +1 -13
  42. package/lib/util/int.js +2 -3
  43. package/lib/util/logging.js +3 -21
  44. package/lib/util/md5.js +83 -0
  45. package/lib/util/strings.js +3 -5
  46. package/lib/vendor/pako/lib/utils/common.js +10 -19
  47. package/lib/vendor/pako/lib/zlib/adler32.js +3 -7
  48. package/lib/vendor/pako/lib/zlib/constants.js +2 -5
  49. package/lib/vendor/pako/lib/zlib/crc32.js +5 -12
  50. package/lib/vendor/pako/lib/zlib/deflate.js +218 -622
  51. package/lib/vendor/pako/lib/zlib/gzheader.js +1 -13
  52. package/lib/vendor/pako/lib/zlib/inffast.js +60 -172
  53. package/lib/vendor/pako/lib/zlib/inflate.js +407 -874
  54. package/lib/vendor/pako/lib/zlib/inftrees.js +63 -169
  55. package/lib/vendor/pako/lib/zlib/messages.js +1 -11
  56. package/lib/vendor/pako/lib/zlib/trees.js +248 -590
  57. package/lib/vendor/pako/lib/zlib/zstream.js +2 -18
  58. package/lib/websock.js +33 -86
  59. package/package.json +32 -37
@@ -0,0 +1,79 @@
1
+ /*
2
+ * noVNC: HTML5 VNC client
3
+ * Copyright (C) 2021 The noVNC Authors
4
+ * Licensed under MPL 2.0 (see LICENSE.txt)
5
+ *
6
+ * See README.md for usage and integration instructions.
7
+ */
8
+
9
+ /*
10
+ * Performs MD5 hashing on a string of binary characters, returns an array of bytes
11
+ */
12
+
13
+ export function MD5(d) {
14
+ let r = M(V(Y(X(d), 8 * d.length)));
15
+ return r;
16
+ }
17
+
18
+ function M(d) {
19
+ let f = new Uint8Array(d.length);
20
+ for (let i=0;i<d.length;i++) {
21
+ f[i] = d.charCodeAt(i);
22
+ }
23
+ return f;
24
+ }
25
+
26
+ function X(d) {
27
+ let r = Array(d.length >> 2);
28
+ for (let m = 0; m < r.length; m++) r[m] = 0;
29
+ for (let m = 0; m < 8 * d.length; m += 8) r[m >> 5] |= (255 & d.charCodeAt(m / 8)) << m % 32;
30
+ return r;
31
+ }
32
+
33
+ function V(d) {
34
+ let r = "";
35
+ for (let m = 0; m < 32 * d.length; m += 8) r += String.fromCharCode(d[m >> 5] >>> m % 32 & 255);
36
+ return r;
37
+ }
38
+
39
+ function Y(d, g) {
40
+ d[g >> 5] |= 128 << g % 32, d[14 + (g + 64 >>> 9 << 4)] = g;
41
+ let m = 1732584193, f = -271733879, r = -1732584194, i = 271733878;
42
+ for (let n = 0; n < d.length; n += 16) {
43
+ let h = m,
44
+ t = f,
45
+ g = r,
46
+ e = i;
47
+ f = ii(f = ii(f = ii(f = ii(f = hh(f = hh(f = hh(f = hh(f = gg(f = gg(f = gg(f = gg(f = ff(f = ff(f = ff(f = ff(f, r = ff(r, i = ff(i, m = ff(m, f, r, i, d[n + 0], 7, -680876936), f, r, d[n + 1], 12, -389564586), m, f, d[n + 2], 17, 606105819), i, m, d[n + 3], 22, -1044525330), r = ff(r, i = ff(i, m = ff(m, f, r, i, d[n + 4], 7, -176418897), f, r, d[n + 5], 12, 1200080426), m, f, d[n + 6], 17, -1473231341), i, m, d[n + 7], 22, -45705983), r = ff(r, i = ff(i, m = ff(m, f, r, i, d[n + 8], 7, 1770035416), f, r, d[n + 9], 12, -1958414417), m, f, d[n + 10], 17, -42063), i, m, d[n + 11], 22, -1990404162), r = ff(r, i = ff(i, m = ff(m, f, r, i, d[n + 12], 7, 1804603682), f, r, d[n + 13], 12, -40341101), m, f, d[n + 14], 17, -1502002290), i, m, d[n + 15], 22, 1236535329), r = gg(r, i = gg(i, m = gg(m, f, r, i, d[n + 1], 5, -165796510), f, r, d[n + 6], 9, -1069501632), m, f, d[n + 11], 14, 643717713), i, m, d[n + 0], 20, -373897302), r = gg(r, i = gg(i, m = gg(m, f, r, i, d[n + 5], 5, -701558691), f, r, d[n + 10], 9, 38016083), m, f, d[n + 15], 14, -660478335), i, m, d[n + 4], 20, -405537848), r = gg(r, i = gg(i, m = gg(m, f, r, i, d[n + 9], 5, 568446438), f, r, d[n + 14], 9, -1019803690), m, f, d[n + 3], 14, -187363961), i, m, d[n + 8], 20, 1163531501), r = gg(r, i = gg(i, m = gg(m, f, r, i, d[n + 13], 5, -1444681467), f, r, d[n + 2], 9, -51403784), m, f, d[n + 7], 14, 1735328473), i, m, d[n + 12], 20, -1926607734), r = hh(r, i = hh(i, m = hh(m, f, r, i, d[n + 5], 4, -378558), f, r, d[n + 8], 11, -2022574463), m, f, d[n + 11], 16, 1839030562), i, m, d[n + 14], 23, -35309556), r = hh(r, i = hh(i, m = hh(m, f, r, i, d[n + 1], 4, -1530992060), f, r, d[n + 4], 11, 1272893353), m, f, d[n + 7], 16, -155497632), i, m, d[n + 10], 23, -1094730640), r = hh(r, i = hh(i, m = hh(m, f, r, i, d[n + 13], 4, 681279174), f, r, d[n + 0], 11, -358537222), m, f, d[n + 3], 16, -722521979), i, m, d[n + 6], 23, 76029189), r = hh(r, i = hh(i, m = hh(m, f, r, i, d[n + 9], 4, -640364487), f, r, d[n + 12], 11, -421815835), m, f, d[n + 15], 16, 530742520), i, m, d[n + 2], 23, -995338651), r = ii(r, i = ii(i, m = ii(m, f, r, i, d[n + 0], 6, -198630844), f, r, d[n + 7], 10, 1126891415), m, f, d[n + 14], 15, -1416354905), i, m, d[n + 5], 21, -57434055), r = ii(r, i = ii(i, m = ii(m, f, r, i, d[n + 12], 6, 1700485571), f, r, d[n + 3], 10, -1894986606), m, f, d[n + 10], 15, -1051523), i, m, d[n + 1], 21, -2054922799), r = ii(r, i = ii(i, m = ii(m, f, r, i, d[n + 8], 6, 1873313359), f, r, d[n + 15], 10, -30611744), m, f, d[n + 6], 15, -1560198380), i, m, d[n + 13], 21, 1309151649), r = ii(r, i = ii(i, m = ii(m, f, r, i, d[n + 4], 6, -145523070), f, r, d[n + 11], 10, -1120210379), m, f, d[n + 2], 15, 718787259), i, m, d[n + 9], 21, -343485551), m = add(m, h), f = add(f, t), r = add(r, g), i = add(i, e);
48
+ }
49
+ return Array(m, f, r, i);
50
+ }
51
+
52
+ function cmn(d, g, m, f, r, i) {
53
+ return add(rol(add(add(g, d), add(f, i)), r), m);
54
+ }
55
+
56
+ function ff(d, g, m, f, r, i, n) {
57
+ return cmn(g & m | ~g & f, d, g, r, i, n);
58
+ }
59
+
60
+ function gg(d, g, m, f, r, i, n) {
61
+ return cmn(g & f | m & ~f, d, g, r, i, n);
62
+ }
63
+
64
+ function hh(d, g, m, f, r, i, n) {
65
+ return cmn(g ^ m ^ f, d, g, r, i, n);
66
+ }
67
+
68
+ function ii(d, g, m, f, r, i, n) {
69
+ return cmn(m ^ (g | ~f), d, g, r, i, n);
70
+ }
71
+
72
+ function add(d, g) {
73
+ let m = (65535 & d) + (65535 & g);
74
+ return (d >> 16) + (g >> 16) + (m >> 16) << 16 | 65535 & m;
75
+ }
76
+
77
+ function rol(d, g) {
78
+ return d << g | d >>> 32 - g;
79
+ }
package/docs/API.md CHANGED
@@ -86,9 +86,13 @@ protocol stream.
86
86
  - The `connect` event is fired when the `RFB` object has completed
87
87
  the connection and handshaking with the server.
88
88
 
89
- [`disconnect`](#disconnected)
89
+ [`disconnect`](#disconnect)
90
90
  - The `disconnect` event is fired when the `RFB` object disconnects.
91
91
 
92
+ [`serververification`](#serververification)
93
+ - The `serververification` event is fired when the server identity
94
+ must be confirmed by the user.
95
+
92
96
  [`credentialsrequired`](#credentialsrequired)
93
97
  - The `credentialsrequired` event is fired when more credentials must
94
98
  be given to continue.
@@ -118,11 +122,16 @@ protocol stream.
118
122
  [`RFB.disconnect()`](#rfbdisconnect)
119
123
  - Disconnect from the server.
120
124
 
125
+ [`RFB.approveServer()`](#rfbapproveserver)
126
+ - Proceed connecting to the server. Should be called after the
127
+ [`serververification`](#serververification) event has fired and the
128
+ user has verified the identity of the server.
129
+
121
130
  [`RFB.sendCredentials()`](#rfbsendcredentials)
122
131
  - Send credentials to server. Should be called after the
123
132
  [`credentialsrequired`](#credentialsrequired) event has fired.
124
133
 
125
- [`RFB.sendKey()`](#rfbsendKey)
134
+ [`RFB.sendKey()`](#rfbsendkey)
126
135
  - Send a key event.
127
136
 
128
137
  [`RFB.sendCtrlAltDel()`](#rfbsendctrlaltdel)
@@ -143,9 +152,18 @@ protocol stream.
143
152
  [`RFB.machineReset()`](#rfbmachinereset)
144
153
  - Request a reset of the remote machine.
145
154
 
146
- [`RFB.clipboardPasteFrom()`](#rfbclipboardPasteFrom)
155
+ [`RFB.clipboardPasteFrom()`](#rfbclipboardpastefrom)
147
156
  - Send clipboard contents to server.
148
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
+
149
167
  ### Details
150
168
 
151
169
  #### RFB()
@@ -212,6 +230,20 @@ property `clean`. `clean` is a `boolean` indicating if the termination
212
230
  was clean or not. In the event of an unexpected termination or an error
213
231
  `clean` will be set to false.
214
232
 
233
+ #### serververification
234
+
235
+ The `serververification` event is fired when the server provides
236
+ information that allows the user to verify that it is the correct server
237
+ and protect against a man-in-the-middle attack. The `detail` property is
238
+ an `Object` containing the property `type` which is a `DOMString`
239
+ specifying which type of information the server has provided. Other
240
+ properties are also available, depending on the value of `type`:
241
+
242
+ `"RSA"`
243
+ - The server identity is verified using just a RSA key. The property
244
+ `publickey` is a `Uint8Array` containing the public key in a unsigned
245
+ big endian representation.
246
+
215
247
  #### credentialsrequired
216
248
 
217
249
  The `credentialsrequired` event is fired when the server requests more
@@ -271,6 +303,16 @@ connected server.
271
303
 
272
304
  RFB.disconnect( );
273
305
 
306
+ #### RFB.approveServer()
307
+
308
+ The `RFB.approveServer()` method is used to signal that the user has
309
+ verified the server identity provided in a `serververification` event
310
+ and that the connection can continue.
311
+
312
+ ##### Syntax
313
+
314
+ RFB.approveServer( );
315
+
274
316
  #### RFB.sendCredentials()
275
317
 
276
318
  The `RFB.sendCredentials()` method is used to provide the missing
@@ -328,7 +370,14 @@ Keyboard events will be sent to the remote server after this point.
328
370
 
329
371
  ##### Syntax
330
372
 
331
- RFB.focus( );
373
+ RFB.focus( [options] );
374
+
375
+ ###### Parameters
376
+
377
+ **`options`** *Optional*
378
+ - A `object` providing options to control how the focus will be
379
+ performed. Please see [`HTMLElement.focus()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus)
380
+ for available options.
332
381
 
333
382
  #### RFB.blur()
334
383
 
@@ -383,3 +432,55 @@ to the remote server.
383
432
 
384
433
  **`text`**
385
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.
package/lib/base64.js CHANGED
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = void 0;
9
-
10
8
  var Log = _interopRequireWildcard(require("./util/logging.js"));
11
-
12
9
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
-
14
10
  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; }
15
-
16
11
  /* This Source Code Form is subject to the terms of the Mozilla Public
17
12
  * License, v. 2.0. If a copy of the MPL was not distributed with this
18
13
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@@ -26,18 +21,18 @@ var _default = {
26
21
 
27
22
  var result = '';
28
23
  var length = data.length;
29
- var lengthpad = length % 3; // Convert every three bytes to 4 ascii characters.
24
+ var lengthpad = length % 3;
25
+ // Convert every three bytes to 4 ascii characters.
30
26
 
31
27
  for (var i = 0; i < length - 2; i += 3) {
32
28
  result += this.toBase64Table[data[i] >> 2];
33
29
  result += this.toBase64Table[((data[i] & 0x03) << 4) + (data[i + 1] >> 4)];
34
30
  result += this.toBase64Table[((data[i + 1] & 0x0f) << 2) + (data[i + 2] >> 6)];
35
31
  result += this.toBase64Table[data[i + 2] & 0x3f];
36
- } // Convert the remaining 1 or 2 bytes, pad out to 4 characters.
37
-
32
+ }
38
33
 
34
+ // Convert the remaining 1 or 2 bytes, pad out to 4 characters.
39
35
  var j = length - lengthpad;
40
-
41
36
  if (lengthpad === 2) {
42
37
  result += this.toBase64Table[data[j] >> 2];
43
38
  result += this.toBase64Table[((data[j] & 0x03) << 4) + (data[j + 1] >> 4)];
@@ -49,67 +44,58 @@ var _default = {
49
44
  result += this.toBase64Table[64];
50
45
  result += this.toBase64Table[64];
51
46
  }
52
-
53
47
  return result;
54
48
  },
55
-
56
49
  /* Convert Base64 data to a string */
57
-
58
50
  /* eslint-disable comma-spacing */
59
51
  toBinaryTable: [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1],
60
-
61
- /* eslint-enable comma-spacing */
62
- decode: function decode(data) {
52
+ /* eslint-enable comma-spacing */decode: function decode(data) {
63
53
  var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
64
54
  var dataLength = data.indexOf('=') - offset;
65
-
66
55
  if (dataLength < 0) {
67
56
  dataLength = data.length - offset;
68
57
  }
69
- /* Every four characters is 3 resulting numbers */
70
-
71
58
 
59
+ /* Every four characters is 3 resulting numbers */
72
60
  var resultLength = (dataLength >> 2) * 3 + Math.floor(dataLength % 4 / 1.5);
73
- var result = new Array(resultLength); // Convert one by one.
61
+ var result = new Array(resultLength);
74
62
 
75
- var leftbits = 0; // number of bits decoded, but yet to be appended
63
+ // Convert one by one.
76
64
 
65
+ var leftbits = 0; // number of bits decoded, but yet to be appended
77
66
  var leftdata = 0; // bits decoded, but yet to be appended
78
-
79
67
  for (var idx = 0, i = offset; i < data.length; i++) {
80
68
  var c = this.toBinaryTable[data.charCodeAt(i) & 0x7f];
81
- var padding = data.charAt(i) === this.base64Pad; // Skip illegal characters and whitespace
82
-
69
+ var padding = data.charAt(i) === this.base64Pad;
70
+ // Skip illegal characters and whitespace
83
71
  if (c === -1) {
84
72
  Log.Error("Illegal character code " + data.charCodeAt(i) + " at position " + i);
85
73
  continue;
86
- } // Collect data into leftdata, update bitcount
87
-
74
+ }
88
75
 
76
+ // Collect data into leftdata, update bitcount
89
77
  leftdata = leftdata << 6 | c;
90
- leftbits += 6; // If we have 8 or more bits, append 8 bits to the result
78
+ leftbits += 6;
91
79
 
80
+ // If we have 8 or more bits, append 8 bits to the result
92
81
  if (leftbits >= 8) {
93
- leftbits -= 8; // Append if not padding.
94
-
82
+ leftbits -= 8;
83
+ // Append if not padding.
95
84
  if (!padding) {
96
85
  result[idx++] = leftdata >> leftbits & 0xff;
97
86
  }
98
-
99
87
  leftdata &= (1 << leftbits) - 1;
100
88
  }
101
- } // If there are any bits left, the base64 string was corrupted
102
-
89
+ }
103
90
 
91
+ // If there are any bits left, the base64 string was corrupted
104
92
  if (leftbits) {
105
93
  var err = new Error('Corrupted base64 string');
106
94
  err.name = 'Base64-Error';
107
95
  throw err;
108
96
  }
109
-
110
97
  return result;
111
98
  }
112
99
  };
113
100
  /* End of Base64 namespace */
114
-
115
101
  exports["default"] = _default;
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
-
10
8
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11
-
12
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
13
-
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
14
10
  /*
15
11
  * noVNC: HTML5 VNC client
16
12
  * Copyright (C) 2019 The noVNC Authors
@@ -23,27 +19,21 @@ var CopyRectDecoder = /*#__PURE__*/function () {
23
19
  function CopyRectDecoder() {
24
20
  _classCallCheck(this, CopyRectDecoder);
25
21
  }
26
-
27
22
  _createClass(CopyRectDecoder, [{
28
23
  key: "decodeRect",
29
24
  value: function decodeRect(x, y, width, height, sock, display, depth) {
30
25
  if (sock.rQwait("COPYRECT", 4)) {
31
26
  return false;
32
27
  }
33
-
34
28
  var deltaX = sock.rQshift16();
35
29
  var deltaY = sock.rQshift16();
36
-
37
30
  if (width === 0 || height === 0) {
38
31
  return true;
39
32
  }
40
-
41
33
  display.copyImage(deltaX, deltaY, x, y, width, height);
42
34
  return true;
43
35
  }
44
36
  }]);
45
-
46
37
  return CopyRectDecoder;
47
38
  }();
48
-
49
39
  exports["default"] = CopyRectDecoder;
@@ -1,33 +1,23 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = void 0;
9
-
10
8
  var Log = _interopRequireWildcard(require("../util/logging.js"));
11
-
12
9
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
-
14
10
  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; }
15
-
16
11
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
-
18
12
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19
-
20
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
21
-
13
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
22
14
  var HextileDecoder = /*#__PURE__*/function () {
23
15
  function HextileDecoder() {
24
16
  _classCallCheck(this, HextileDecoder);
25
-
26
17
  this._tiles = 0;
27
18
  this._lastsubencoding = 0;
28
19
  this._tileBuffer = new Uint8Array(16 * 16 * 4);
29
20
  }
30
-
31
21
  _createClass(HextileDecoder, [{
32
22
  key: "decodeRect",
33
23
  value: function decodeRect(x, y, width, height, sock, display, depth) {
@@ -37,31 +27,27 @@ var HextileDecoder = /*#__PURE__*/function () {
37
27
  this._totalTiles = this._tilesX * this._tilesY;
38
28
  this._tiles = this._totalTiles;
39
29
  }
40
-
41
30
  while (this._tiles > 0) {
42
31
  var bytes = 1;
43
-
44
32
  if (sock.rQwait("HEXTILE", bytes)) {
45
33
  return false;
46
34
  }
47
-
48
35
  var rQ = sock.rQ;
49
36
  var rQi = sock.rQi;
50
37
  var subencoding = rQ[rQi]; // Peek
51
-
52
38
  if (subencoding > 30) {
53
39
  // Raw
54
40
  throw new Error("Illegal hextile subencoding (subencoding: " + subencoding + ")");
55
41
  }
56
-
57
42
  var currTile = this._totalTiles - this._tiles;
58
43
  var tileX = currTile % this._tilesX;
59
44
  var tileY = Math.floor(currTile / this._tilesX);
60
45
  var tx = x + tileX * 16;
61
46
  var ty = y + tileY * 16;
62
47
  var tw = Math.min(16, x + width - tx);
63
- var th = Math.min(16, y + height - ty); // Figure out how much we are expecting
48
+ var th = Math.min(16, y + height - ty);
64
49
 
50
+ // Figure out how much we are expecting
65
51
  if (subencoding & 0x01) {
66
52
  // Raw
67
53
  bytes += tw * th * 4;
@@ -70,12 +56,10 @@ var HextileDecoder = /*#__PURE__*/function () {
70
56
  // Background
71
57
  bytes += 4;
72
58
  }
73
-
74
59
  if (subencoding & 0x04) {
75
60
  // Foreground
76
61
  bytes += 4;
77
62
  }
78
-
79
63
  if (subencoding & 0x08) {
80
64
  // AnySubrects
81
65
  bytes++; // Since we aren't shifting it off
@@ -83,9 +67,7 @@ var HextileDecoder = /*#__PURE__*/function () {
83
67
  if (sock.rQwait("HEXTILE", bytes)) {
84
68
  return false;
85
69
  }
86
-
87
70
  var subrects = rQ[rQi + bytes - 1]; // Peek
88
-
89
71
  if (subencoding & 0x10) {
90
72
  // SubrectsColoured
91
73
  bytes += subrects * (4 + 2);
@@ -94,14 +76,12 @@ var HextileDecoder = /*#__PURE__*/function () {
94
76
  }
95
77
  }
96
78
  }
97
-
98
79
  if (sock.rQwait("HEXTILE", bytes)) {
99
80
  return false;
100
- } // We know the encoding and have a whole tile
101
-
81
+ }
102
82
 
83
+ // We know the encoding and have a whole tile
103
84
  rQi++;
104
-
105
85
  if (subencoding === 0) {
106
86
  if (this._lastsubencoding & 0x01) {
107
87
  // Weird: ignore blanks are RAW
@@ -111,12 +91,11 @@ var HextileDecoder = /*#__PURE__*/function () {
111
91
  }
112
92
  } else if (subencoding & 0x01) {
113
93
  // Raw
114
- var pixels = tw * th; // Max sure the image is fully opaque
115
-
94
+ var pixels = tw * th;
95
+ // Max sure the image is fully opaque
116
96
  for (var i = 0; i < pixels; i++) {
117
97
  rQ[rQi + i * 4 + 3] = 255;
118
98
  }
119
-
120
99
  display.blitImage(tx, ty, tw, th, rQ, rQi);
121
100
  rQi += bytes - 1;
122
101
  } else {
@@ -125,23 +104,18 @@ var HextileDecoder = /*#__PURE__*/function () {
125
104
  this._background = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
126
105
  rQi += 4;
127
106
  }
128
-
129
107
  if (subencoding & 0x04) {
130
108
  // Foreground
131
109
  this._foreground = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
132
110
  rQi += 4;
133
111
  }
134
-
135
112
  this._startTile(tx, ty, tw, th, this._background);
136
-
137
113
  if (subencoding & 0x08) {
138
114
  // AnySubrects
139
115
  var _subrects = rQ[rQi];
140
116
  rQi++;
141
-
142
117
  for (var s = 0; s < _subrects; s++) {
143
118
  var color = void 0;
144
-
145
119
  if (subencoding & 0x10) {
146
120
  // SubrectsColoured
147
121
  color = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
@@ -149,7 +123,6 @@ var HextileDecoder = /*#__PURE__*/function () {
149
123
  } else {
150
124
  color = this._foreground;
151
125
  }
152
-
153
126
  var xy = rQ[rQi];
154
127
  rQi++;
155
128
  var sx = xy >> 4;
@@ -158,22 +131,19 @@ var HextileDecoder = /*#__PURE__*/function () {
158
131
  rQi++;
159
132
  var sw = (wh >> 4) + 1;
160
133
  var sh = (wh & 0x0f) + 1;
161
-
162
134
  this._subTile(sx, sy, sw, sh, color);
163
135
  }
164
136
  }
165
-
166
137
  this._finishTile(display);
167
138
  }
168
-
169
139
  sock.rQi = rQi;
170
140
  this._lastsubencoding = subencoding;
171
141
  this._tiles--;
172
142
  }
173
-
174
143
  return true;
175
- } // start updating a tile
144
+ }
176
145
 
146
+ // start updating a tile
177
147
  }, {
178
148
  key: "_startTile",
179
149
  value: function _startTile(x, y, width, height, color) {
@@ -185,15 +155,15 @@ var HextileDecoder = /*#__PURE__*/function () {
185
155
  var green = color[1];
186
156
  var blue = color[2];
187
157
  var data = this._tileBuffer;
188
-
189
158
  for (var i = 0; i < width * height * 4; i += 4) {
190
159
  data[i] = red;
191
160
  data[i + 1] = green;
192
161
  data[i + 2] = blue;
193
162
  data[i + 3] = 255;
194
163
  }
195
- } // update sub-rectangle of the current tile
164
+ }
196
165
 
166
+ // update sub-rectangle of the current tile
197
167
  }, {
198
168
  key: "_subTile",
199
169
  value: function _subTile(x, y, w, h, color) {
@@ -204,7 +174,6 @@ var HextileDecoder = /*#__PURE__*/function () {
204
174
  var yend = y + h;
205
175
  var data = this._tileBuffer;
206
176
  var width = this._tileW;
207
-
208
177
  for (var j = y; j < yend; j++) {
209
178
  for (var i = x; i < xend; i++) {
210
179
  var p = (i + j * width) * 4;
@@ -214,16 +183,15 @@ var HextileDecoder = /*#__PURE__*/function () {
214
183
  data[p + 3] = 255;
215
184
  }
216
185
  }
217
- } // draw the current tile to the screen
186
+ }
218
187
 
188
+ // draw the current tile to the screen
219
189
  }, {
220
190
  key: "_finishTile",
221
191
  value: function _finishTile(display) {
222
192
  display.blitImage(this._tileX, this._tileY, this._tileW, this._tileH, this._tileBuffer, 0);
223
193
  }
224
194
  }]);
225
-
226
195
  return HextileDecoder;
227
196
  }();
228
-
229
197
  exports["default"] = HextileDecoder;