@novnc/novnc 1.3.0 → 1.4.0-beta

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 (64) hide show
  1. package/AUTHORS +2 -2
  2. package/LICENSE.txt +1 -1
  3. package/README.md +23 -7
  4. package/core/decoders/jpeg.js +141 -0
  5. package/core/decoders/raw.js +1 -1
  6. package/core/decoders/zrle.js +185 -0
  7. package/core/des.js +1 -1
  8. package/core/display.js +12 -0
  9. package/core/encodings.js +4 -0
  10. package/core/input/keyboard.js +10 -0
  11. package/core/ra2.js +567 -0
  12. package/core/rfb.js +469 -84
  13. package/core/util/browser.js +56 -7
  14. package/core/util/cursor.js +4 -0
  15. package/core/util/md5.js +79 -0
  16. package/docs/API.md +318 -157
  17. package/lib/base64.js +20 -34
  18. package/lib/decoders/copyrect.js +5 -12
  19. package/lib/decoders/hextile.js +17 -47
  20. package/lib/decoders/jpeg.js +149 -0
  21. package/lib/decoders/raw.js +10 -23
  22. package/lib/decoders/rre.js +5 -16
  23. package/lib/decoders/tight.js +13 -79
  24. package/lib/decoders/tightpng.js +8 -28
  25. package/lib/decoders/zrle.js +188 -0
  26. package/lib/deflator.js +9 -23
  27. package/lib/des.js +24 -37
  28. package/lib/display.js +62 -108
  29. package/lib/encodings.js +7 -8
  30. package/lib/inflator.js +6 -19
  31. package/lib/input/domkeytable.js +77 -48
  32. package/lib/input/fixedkeys.js +8 -3
  33. package/lib/input/gesturehandler.js +86 -153
  34. package/lib/input/keyboard.js +62 -91
  35. package/lib/input/keysym.js +14 -270
  36. package/lib/input/keysymdef.js +5 -7
  37. package/lib/input/util.js +43 -85
  38. package/lib/input/vkeys.js +0 -3
  39. package/lib/input/xtscancodes.js +1 -168
  40. package/lib/ra2.js +1005 -0
  41. package/lib/rfb.js +795 -923
  42. package/lib/util/browser.js +66 -29
  43. package/lib/util/cursor.js +29 -66
  44. package/lib/util/element.js +3 -5
  45. package/lib/util/events.js +23 -30
  46. package/lib/util/eventtarget.js +5 -14
  47. package/lib/util/int.js +1 -2
  48. package/lib/util/logging.js +1 -19
  49. package/lib/util/md5.js +77 -0
  50. package/lib/util/strings.js +3 -5
  51. package/lib/vendor/pako/lib/utils/common.js +8 -17
  52. package/lib/vendor/pako/lib/zlib/adler32.js +3 -7
  53. package/lib/vendor/pako/lib/zlib/constants.js +2 -5
  54. package/lib/vendor/pako/lib/zlib/crc32.js +5 -12
  55. package/lib/vendor/pako/lib/zlib/deflate.js +213 -618
  56. package/lib/vendor/pako/lib/zlib/gzheader.js +1 -13
  57. package/lib/vendor/pako/lib/zlib/inffast.js +60 -176
  58. package/lib/vendor/pako/lib/zlib/inflate.js +398 -888
  59. package/lib/vendor/pako/lib/zlib/inftrees.js +63 -169
  60. package/lib/vendor/pako/lib/zlib/messages.js +1 -11
  61. package/lib/vendor/pako/lib/zlib/trees.js +246 -588
  62. package/lib/vendor/pako/lib/zlib/zstream.js +2 -18
  63. package/lib/websock.js +37 -88
  64. package/package.json +32 -35
package/docs/API.md CHANGED
@@ -16,126 +16,139 @@ protocol stream.
16
16
 
17
17
  ### Properties
18
18
 
19
- `viewOnly`
20
- - Is a `boolean` indicating if any events (e.g. key presses or mouse
21
- movement) should be prevented from being sent to the server.
22
- Disabled by default.
19
+ `background`
20
+ - Is a valid CSS [background][mdn-bg] style value indicating which
21
+ background style should be applied to the element containing the
22
+ remote session screen. The default value is `rgb(40, 40, 40)` (solid
23
+ gray color).
23
24
 
24
- `focusOnClick`
25
- - Is a `boolean` indicating if keyboard focus should automatically be
26
- moved to the remote session when a `mousedown` or `touchstart`
27
- event is received. Enabled by default.
25
+ [mdn-bg]: https://developer.mozilla.org/en-US/docs/Web/CSS/background
26
+
27
+ `capabilities` *Read only*
28
+ - Is an `Object` indicating which optional extensions are available
29
+ on the server. Some methods may only be called if the corresponding
30
+ capability is set. The following capabilities are defined:
31
+
32
+ | name | type | description
33
+ | -------- | --------- | -----------
34
+ | `power` | `boolean` | Machine power control is available
35
+
36
+ `clippingViewport` *Read only*
37
+ - Is a `boolean` indicating if the remote session is currently being
38
+ clipped to its container. Only relevant if `clipViewport` is
39
+ enabled.
28
40
 
29
41
  `clipViewport`
30
42
  - Is a `boolean` indicating if the remote session should be clipped
31
43
  to its container. When disabled scrollbars will be shown to handle
32
44
  the resulting overflow. Disabled by default.
33
45
 
46
+ `compressionLevel`
47
+ - Is an `int` in range `[0-9]` controlling the desired compression
48
+ level. Value `0` means no compression. Level 1 uses a minimum of CPU
49
+ resources and achieves weak compression ratios, while level 9 offers
50
+ best compression but is slow in terms of CPU consumption on the server
51
+ side. Use high levels with very slow network connections.
52
+ Default value is `2`.
53
+
34
54
  `dragViewport`
35
55
  - Is a `boolean` indicating if mouse events should control the
36
56
  relative position of a clipped remote session. Only relevant if
37
57
  `clipViewport` is enabled. Disabled by default.
38
58
 
39
- `scaleViewport`
40
- - Is a `boolean` indicating if the remote session should be scaled
41
- locally so it fits its container. When disabled it will be centered
42
- if the remote session is smaller than its container, or handled
43
- according to `clipViewport` if it is larger. Disabled by default.
59
+ `focusOnClick`
60
+ - Is a `boolean` indicating if keyboard focus should automatically be
61
+ moved to the remote session when a `mousedown` or `touchstart`
62
+ event is received. Enabled by default.
63
+
64
+ `qualityLevel`
65
+ - Is an `int` in range `[0-9]` controlling the desired JPEG quality.
66
+ Value `0` implies low quality and `9` implies high quality.
67
+ Default value is `6`.
44
68
 
45
69
  `resizeSession`
46
70
  - Is a `boolean` indicating if a request to resize the remote session
47
71
  should be sent whenever the container changes dimensions. Disabled
48
72
  by default.
49
73
 
74
+ `scaleViewport`
75
+ - Is a `boolean` indicating if the remote session should be scaled
76
+ locally so it fits its container. When disabled it will be centered
77
+ if the remote session is smaller than its container, or handled
78
+ according to `clipViewport` if it is larger. Disabled by default.
79
+
50
80
  `showDotCursor`
51
81
  - Is a `boolean` indicating whether a dot cursor should be shown
52
82
  instead of a zero-sized or fully-transparent cursor if the server
53
83
  sets such invisible cursor. Disabled by default.
54
84
 
55
- `background`
56
- - Is a valid CSS [background](https://developer.mozilla.org/en-US/docs/Web/CSS/background)
57
- style value indicating which background style should be applied
58
- to the element containing the remote session screen. The default value is `rgb(40, 40, 40)`
59
- (solid gray color).
85
+ `viewOnly`
86
+ - Is a `boolean` indicating if any events (e.g. key presses or mouse
87
+ movement) should be prevented from being sent to the server.
88
+ Disabled by default.
60
89
 
61
- `qualityLevel`
62
- - Is an `int` in range `[0-9]` controlling the desired JPEG quality.
63
- Value `0` implies low quality and `9` implies high quality.
64
- Default value is `6`.
90
+ ### Events
65
91
 
66
- `compressionLevel`
67
- - Is an `int` in range `[0-9]` controlling the desired compression
68
- level. Value `0` means no compression. Level 1 uses a minimum of CPU
69
- resources and achieves weak compression ratios, while level 9 offers
70
- best compression but is slow in terms of CPU consumption on the server
71
- side. Use high levels with very slow network connections.
72
- Default value is `2`.
92
+ [`bell`](#bell)
93
+ - The `bell` event is fired when a audible bell request is received
94
+ from the server.
73
95
 
74
- `capabilities` *Read only*
75
- - Is an `Object` indicating which optional extensions are available
76
- on the server. Some methods may only be called if the corresponding
77
- capability is set. The following capabilities are defined:
96
+ [`capabilities`](#capabilities)
97
+ - The `capabilities` event is fired when `RFB.capabilities` is
98
+ updated.
78
99
 
79
- | name | type | description
80
- | -------- | --------- | -----------
81
- | `power` | `boolean` | Machine power control is available
100
+ [`clipboard`](#clipboard)
101
+ - The `clipboard` event is fired when clipboard data is received from
102
+ the server.
82
103
 
83
- ### Events
104
+ [`clippingviewport`](#clippingviewport)
105
+ - The `clippingviewport` event is fired when `RFB.clippingViewport` is
106
+ updated.
84
107
 
85
108
  [`connect`](#connect)
86
109
  - The `connect` event is fired when the `RFB` object has completed
87
110
  the connection and handshaking with the server.
88
111
 
89
- [`disconnect`](#disconnected)
90
- - The `disconnect` event is fired when the `RFB` object disconnects.
91
-
92
112
  [`credentialsrequired`](#credentialsrequired)
93
113
  - The `credentialsrequired` event is fired when more credentials must
94
114
  be given to continue.
95
115
 
116
+ [`desktopname`](#desktopname)
117
+ - The `desktopname` event is fired when the remote desktop name
118
+ changes.
119
+
120
+ [`disconnect`](#disconnect)
121
+ - The `disconnect` event is fired when the `RFB` object disconnects.
122
+
96
123
  [`securityfailure`](#securityfailure)
97
124
  - The `securityfailure` event is fired when the security negotiation
98
125
  with the server fails.
99
126
 
100
- [`clipboard`](#clipboard)
101
- - The `clipboard` event is fired when clipboard data is received from
102
- the server.
127
+ [`serververification`](#serververification)
128
+ - The `serververification` event is fired when the server identity
129
+ must be confirmed by the user.
103
130
 
104
- [`bell`](#bell)
105
- - The `bell` event is fired when a audible bell request is received
106
- from the server.
131
+ ### Methods
107
132
 
108
- [`desktopname`](#desktopname)
109
- - The `desktopname` event is fired when the remote desktop name
110
- changes.
133
+ [`RFB.approveServer()`](#rfbapproveserver)
134
+ - Proceed connecting to the server. Should be called after the
135
+ [`serververification`](#serververification) event has fired and the
136
+ user has verified the identity of the server.
111
137
 
112
- [`capabilities`](#capabilities)
113
- - The `capabilities` event is fired when `RFB.capabilities` is
114
- updated.
138
+ [`RFB.blur()`](#rfbblur)
139
+ - Remove keyboard focus from the remote session.
115
140
 
116
- ### Methods
141
+ [`RFB.clipboardPasteFrom()`](#rfbclipboardpastefrom)
142
+ - Send clipboard contents to server.
117
143
 
118
144
  [`RFB.disconnect()`](#rfbdisconnect)
119
145
  - Disconnect from the server.
120
146
 
121
- [`RFB.sendCredentials()`](#rfbsendcredentials)
122
- - Send credentials to server. Should be called after the
123
- [`credentialsrequired`](#credentialsrequired) event has fired.
124
-
125
- [`RFB.sendKey()`](#rfbsendKey)
126
- - Send a key event.
127
-
128
- [`RFB.sendCtrlAltDel()`](#rfbsendctrlaltdel)
129
- - Send Ctrl-Alt-Del key sequence.
130
-
131
147
  [`RFB.focus()`](#rfbfocus)
132
148
  - Move keyboard focus to the remote session.
133
149
 
134
- [`RFB.blur()`](#rfbblur)
135
- - Remove keyboard focus from the remote session.
136
-
137
- [`RFB.machineShutdown()`](#rfbmachineshutdown)
138
- - Request a shutdown of the remote machine.
150
+ [`RFB.getImageData()`](#rfbgetimagedata)
151
+ - Return the current content of the screen as an ImageData array.
139
152
 
140
153
  [`RFB.machineReboot()`](#rfbmachinereboot)
141
154
  - Request a reboot of the remote machine.
@@ -143,8 +156,24 @@ protocol stream.
143
156
  [`RFB.machineReset()`](#rfbmachinereset)
144
157
  - Request a reset of the remote machine.
145
158
 
146
- [`RFB.clipboardPasteFrom()`](#rfbclipboardPasteFrom)
147
- - Send clipboard contents to server.
159
+ [`RFB.machineShutdown()`](#rfbmachineshutdown)
160
+ - Request a shutdown of the remote machine.
161
+
162
+ [`RFB.sendCredentials()`](#rfbsendcredentials)
163
+ - Send credentials to server. Should be called after the
164
+ [`credentialsrequired`](#credentialsrequired) event has fired.
165
+
166
+ [`RFB.sendCtrlAltDel()`](#rfbsendctrlaltdel)
167
+ - Send Ctrl-Alt-Del key sequence.
168
+
169
+ [`RFB.sendKey()`](#rfbsendkey)
170
+ - Send a key event.
171
+
172
+ [`RFB.toBlob()`](#rfbtoblob)
173
+ - Return the current content of the screen as Blob encoded image file.
174
+
175
+ [`RFB.toDataURL()`](#rfbtodataurl)
176
+ - Return the current content of the screen as data-url encoded image file.
148
177
 
149
178
  ### Details
150
179
 
@@ -155,17 +184,22 @@ connection to a specified VNC server.
155
184
 
156
185
  ##### Syntax
157
186
 
158
- let rfb = new RFB( target, url [, options] );
187
+ ```js
188
+ new RFB(target, urlOrChannel);
189
+ new RFB(target, urlOrChannel, options);
190
+ ```
159
191
 
160
192
  ###### Parameters
161
193
 
162
194
  **`target`**
163
- - A block [`HTMLElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement)
164
- that specifies where the `RFB` object should attach itself. The
165
- existing contents of the `HTMLElement` will be untouched, but new
166
- elements will be added during the lifetime of the `RFB` object.
195
+ - A block [`HTMLElement`][mdn-elem] that specifies where the `RFB`
196
+ object should attach itself. The existing contents of the
197
+ `HTMLElement` will be untouched, but new elements will be added
198
+ during the lifetime of the `RFB` object.
199
+
200
+ [mdn-elem]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
167
201
 
168
- **`urlOrDataChannel`**
202
+ **`urlOrChannel`**
169
203
  - A `DOMString` specifying the VNC server to connect to. This must be
170
204
  a valid WebSocket URL. This can also be a `WebSocket` or `RTCDataChannel`.
171
205
 
@@ -198,12 +232,48 @@ connection to a specified VNC server.
198
232
  - An `Array` of `DOMString`s specifying the sub-protocols to use
199
233
  in the WebSocket connection. Empty by default.
200
234
 
235
+ #### bell
236
+
237
+ The `bell` event is fired when the server has requested an audible
238
+ bell.
239
+
240
+ #### capabilities
241
+
242
+ The `capabilities` event is fired whenever an entry is added or removed
243
+ from `RFB.capabilities`. The `detail` property is an `Object` with the
244
+ property `capabilities` containing the new value of `RFB.capabilities`.
245
+
246
+ #### clippingviewport
247
+
248
+ The `clippingviewport` event is fired whenever `RFB.clippingViewport`
249
+ changes between `true` and `false`. The `detail` property is a `boolean`
250
+ with the new value of `RFB.clippingViewport`.
251
+
252
+ #### clipboard
253
+
254
+ The `clipboard` event is fired when the server has sent clipboard data.
255
+ The `detail` property is an `Object` containing the property `text`
256
+ which is a `DOMString` with the clipboard data.
257
+
258
+ #### credentialsrequired
259
+
260
+ The `credentialsrequired` event is fired when the server requests more
261
+ credentials than were specified to [`RFB()`](#rfb-1). The `detail`
262
+ property is an `Object` containing the property `types` which is an
263
+ `Array` of `DOMString` listing the credentials that are required.
264
+
201
265
  #### connect
202
266
 
203
267
  The `connect` event is fired after all the handshaking with the server
204
268
  is completed and the connection is fully established. After this event
205
269
  the `RFB` object is ready to recieve graphics updates and to send input.
206
270
 
271
+ #### desktopname
272
+
273
+ The `desktopname` event is fired when the name of the remote desktop
274
+ changes. The `detail` property is an `Object` with the property `name`
275
+ which is a `DOMString` specifying the new name.
276
+
207
277
  #### disconnect
208
278
 
209
279
  The `disconnect` event is fired when the connection has been
@@ -212,13 +282,6 @@ property `clean`. `clean` is a `boolean` indicating if the termination
212
282
  was clean or not. In the event of an unexpected termination or an error
213
283
  `clean` will be set to false.
214
284
 
215
- #### credentialsrequired
216
-
217
- The `credentialsrequired` event is fired when the server requests more
218
- credentials than were specified to [`RFB()`](#rfb-1). The `detail`
219
- property is an `Object` containing the property `types` which is an
220
- `Array` of `DOMString` listing the credentials that are required.
221
-
222
285
  #### securityfailure
223
286
 
224
287
  The `securityfailure` event is fired when the handshaking process with
@@ -230,8 +293,7 @@ property is an `Object` containing the following properties:
230
293
  | `status` | `long` | The failure status code
231
294
  | `reason` | `DOMString` | The **optional** reason for the failure
232
295
 
233
- The property `status` corresponds to the
234
- [SecurityResult](https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#securityresult)
296
+ The property `status` corresponds to the [SecurityResult][rfb-secresult]
235
297
  status code in cases of failure. A status of zero will not be sent in
236
298
  this event since that indicates a successful security handshaking
237
299
  process. The optional property `reason` is provided by the server and
@@ -239,106 +301,130 @@ thus the language of the string is not known. However most servers will
239
301
  probably send English strings. The server can choose to not send a
240
302
  reason and in these cases the `reason` property will be omitted.
241
303
 
242
- #### clipboard
304
+ [rfb-secresult]: https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#securityresult
243
305
 
244
- The `clipboard` event is fired when the server has sent clipboard data.
245
- The `detail` property is an `Object` containing the property `text`
246
- which is a `DOMString` with the clipboard data.
306
+ #### serververification
247
307
 
248
- #### bell
308
+ The `serververification` event is fired when the server provides
309
+ information that allows the user to verify that it is the correct server
310
+ and protect against a man-in-the-middle attack. The `detail` property is
311
+ an `Object` containing the property `type` which is a `DOMString`
312
+ specifying which type of information the server has provided. Other
313
+ properties are also available, depending on the value of `type`:
249
314
 
250
- The `bell` event is fired when the server has requested an audible
251
- bell.
315
+ `"RSA"`
316
+ - The server identity is verified using just a RSA key. The property
317
+ `publickey` is a `Uint8Array` containing the public key in a unsigned
318
+ big endian representation.
252
319
 
253
- #### desktopname
320
+ #### RFB.approveServer()
254
321
 
255
- The `desktopname` event is fired when the name of the remote desktop
256
- changes. The `detail` property is an `Object` with the property `name`
257
- which is a `DOMString` specifying the new name.
322
+ The `RFB.approveServer()` method is used to signal that the user has
323
+ verified the server identity provided in a `serververification` event
324
+ and that the connection can continue.
258
325
 
259
- #### capabilities
326
+ ##### Syntax
260
327
 
261
- The `capabilities` event is fired whenever an entry is added or removed
262
- from `RFB.capabilities`. The `detail` property is an `Object` with the
263
- property `capabilities` containing the new value of `RFB.capabilities`.
328
+ ```js
329
+ RFB.approveServer();
330
+ ```
264
331
 
265
- #### RFB.disconnect()
332
+ #### RFB.blur()
266
333
 
267
- The `RFB.disconnect()` method is used to disconnect from the currently
268
- connected server.
334
+ The `RFB.blur()` method remove keyboard focus on the remote session.
335
+ Keyboard events will no longer be sent to the remote server after this
336
+ point.
269
337
 
270
338
  ##### Syntax
271
339
 
272
- RFB.disconnect( );
340
+ ```js
341
+ RFB.blur();
342
+ ```
273
343
 
274
- #### RFB.sendCredentials()
344
+ #### RFB.clipboardPasteFrom()
275
345
 
276
- The `RFB.sendCredentials()` method is used to provide the missing
277
- credentials after a `credentialsrequired` event has been fired.
346
+ The `RFB.clipboardPasteFrom()` method is used to send clipboard data
347
+ to the remote server.
278
348
 
279
349
  ##### Syntax
280
350
 
281
- RFB.sendCredentials( credentials );
351
+ ```js
352
+ RFB.clipboardPasteFrom(text);
353
+ ```
282
354
 
283
355
  ###### Parameters
284
356
 
285
- **`credentials`**
286
- - An `Object` specifying the credentials to provide to the server
287
- when authenticating. See [`RFB()`](#rfb-1) for details.
357
+ **`text`**
358
+ - A `DOMString` specifying the clipboard data to send.
288
359
 
289
- #### RFB.sendKey()
360
+ #### RFB.disconnect()
290
361
 
291
- The `RFB.sendKey()` method is used to send a key event to the server.
362
+ The `RFB.disconnect()` method is used to disconnect from the currently
363
+ connected server.
292
364
 
293
365
  ##### Syntax
294
366
 
295
- RFB.sendKey( keysym, code [, down] );
367
+ ```js
368
+ RFB.disconnect();
369
+ ```
370
+
371
+ #### RFB.focus()
372
+
373
+ The `RFB.focus()` method sets the keyboard focus on the remote session.
374
+ Keyboard events will be sent to the remote server after this point.
375
+
376
+ ##### Syntax
377
+
378
+ ```js
379
+ RFB.focus();
380
+ RFB.focus(options);
381
+ ```
296
382
 
297
383
  ###### Parameters
298
384
 
299
- **`keysym`**
300
- - A `long` specifying the RFB keysym to send. Can be `0` if a valid
301
- **`code`** is specified.
385
+ **`options`** *Optional*
386
+ - A `object` providing options to control how the focus will be
387
+ performed. Please see [`HTMLElement.focus()`][mdn-focus] for
388
+ available options.
302
389
 
303
- **`code`**
304
- - A `DOMString` specifying the physical key to send. Valid values are
305
- those that can be specified to
306
- [`KeyboardEvent.code`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code).
307
- If the physical key cannot be determined then `null` shall be
308
- specified.
390
+ [mdn-focus]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
309
391
 
310
- **`down`** *Optional*
311
- - A `boolean` specifying if a press or a release event should be
312
- sent. If omitted then both a press and release event are sent.
392
+ #### RFB.getImageData()
313
393
 
314
- #### RFB.sendCtrlAltDel()
394
+ The `RFB.getImageData()` method is used to return the current content of
395
+ the screen encoded as [`ImageData`][mdn-imagedata].
315
396
 
316
- The `RFB.sendCtrlAltDel()` method is used to send the key sequence
317
- *left Control*, *left Alt*, *Delete*. This is a convenience wrapper
318
- around [`RFB.sendKey()`](#rfbsendkey).
397
+ [mdn-imagedata]: https://developer.mozilla.org/en-US/docs/Web/API/ImageData
319
398
 
320
399
  ##### Syntax
321
400
 
322
- RFB.sendCtrlAltDel( );
401
+ ```js
402
+ RFB.getImageData();
403
+ ```
323
404
 
324
- #### RFB.focus()
405
+ #### RFB.machineReboot()
325
406
 
326
- The `RFB.focus()` method sets the keyboard focus on the remote session.
327
- Keyboard events will be sent to the remote server after this point.
407
+ The `RFB.machineReboot()` method is used to request a clean reboot of
408
+ the remote machine. The capability `power` must be set for this method
409
+ to have any effect.
328
410
 
329
411
  ##### Syntax
330
412
 
331
- RFB.focus( );
413
+ ```js
414
+ RFB.machineReboot();
415
+ ```
332
416
 
333
- #### RFB.blur()
417
+ #### RFB.machineReset()
334
418
 
335
- The `RFB.blur()` method remove keyboard focus on the remote session.
336
- Keyboard events will no longer be sent to the remote server after this
337
- point.
419
+ The `RFB.machineReset()` method is used to request a forced reset of
420
+ the remote machine. The capability `power` must be set for this method
421
+ to have any effect.
338
422
 
339
423
  ##### Syntax
340
424
 
341
- RFB.blur( );
425
+ ```js
426
+ RFB.machineReset();
427
+ ```
342
428
 
343
429
  #### RFB.machineShutdown()
344
430
 
@@ -348,38 +434,113 @@ have any effect.
348
434
 
349
435
  ##### Syntax
350
436
 
351
- RFB.machineShutdown( );
437
+ ```js
438
+ RFB.machineShutdown();
439
+ ```
352
440
 
353
- #### RFB.machineReboot()
441
+ #### RFB.sendCredentials()
354
442
 
355
- The `RFB.machineReboot()` method is used to request a clean reboot of
356
- the remote machine. The capability `power` must be set for this method
357
- to have any effect.
443
+ The `RFB.sendCredentials()` method is used to provide the missing
444
+ credentials after a `credentialsrequired` event has been fired.
358
445
 
359
446
  ##### Syntax
360
447
 
361
- RFB.machineReboot( );
448
+ ```js
449
+ RFB.sendCredentials(credentials);
450
+ ```
362
451
 
363
- #### RFB.machineReset()
452
+ ###### Parameters
364
453
 
365
- The `RFB.machineReset()` method is used to request a forced reset of
366
- the remote machine. The capability `power` must be set for this method
367
- to have any effect.
454
+ **`credentials`**
455
+ - An `Object` specifying the credentials to provide to the server
456
+ when authenticating. See [`RFB()`](#rfb-1) for details.
457
+
458
+ #### RFB.sendCtrlAltDel()
459
+
460
+ The `RFB.sendCtrlAltDel()` method is used to send the key sequence
461
+ *left Control*, *left Alt*, *Delete*. This is a convenience wrapper
462
+ around [`RFB.sendKey()`](#rfbsendkey).
368
463
 
369
464
  ##### Syntax
370
465
 
371
- RFB.machineReset( );
466
+ ```js
467
+ RFB.sendCtrlAltDel();
468
+ ```
372
469
 
373
- #### RFB.clipboardPasteFrom()
470
+ #### RFB.sendKey()
374
471
 
375
- The `RFB.clipboardPasteFrom()` method is used to send clipboard data
376
- to the remote server.
472
+ The `RFB.sendKey()` method is used to send a key event to the server.
377
473
 
378
474
  ##### Syntax
379
475
 
380
- RFB.clipboardPasteFrom( text );
476
+ ```js
477
+ RFB.sendKey(keysym, code);
478
+ RFB.sendKey(keysym, code, down);
479
+ ```
381
480
 
382
481
  ###### Parameters
383
482
 
384
- **`text`**
385
- - A `DOMString` specifying the clipboard data to send.
483
+ **`keysym`**
484
+ - A `long` specifying the RFB keysym to send. Can be `0` if a valid
485
+ **`code`** is specified.
486
+
487
+ **`code`**
488
+ - A `DOMString` specifying the physical key to send. Valid values are
489
+ those that can be specified to [`KeyboardEvent.code`][mdn-keycode].
490
+ If the physical key cannot be determined then `null` shall be
491
+ specified.
492
+
493
+ [mdn-keycode]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code
494
+
495
+ **`down`** *Optional*
496
+ - A `boolean` specifying if a press or a release event should be
497
+ sent. If omitted then both a press and release event are sent.
498
+
499
+ #### RFB.toBlob()
500
+
501
+ The `RFB.toBlob()` method is used to return the current content of the
502
+ screen encoded as [`Blob`][mdn-blob].
503
+
504
+ [mdn-blob]: https://developer.mozilla.org/en-US/docs/Web/API/Blob
505
+
506
+ ##### Syntax
507
+
508
+ ```js
509
+ RFB.toBlob(callback);
510
+ RFB.toBlob(callback, type);
511
+ RFB.toBlob(callback, type, quality);
512
+ ```
513
+
514
+ ###### Parameters
515
+
516
+ **`callback`**
517
+ - A callback function which will receive the resulting
518
+ [`Blob`][mdn-blob] as the single argument
519
+
520
+ **`type`** *Optional*
521
+ - A string indicating the requested MIME type of the image
522
+
523
+ **`quality`** *Optional*
524
+ - A number between 0 and 1 indicating the image quality.
525
+
526
+ #### RFB.toDataURL()
527
+
528
+ The `RFB.toDataURL()` method is used to return the current content of the
529
+ screen encoded as a data URL that could for example be put in the `src` attribute
530
+ of an `img` tag.
531
+
532
+ ##### Syntax
533
+
534
+ ```js
535
+ RFB.toDataURL();
536
+ RFB.toDataURL(type);
537
+ RFB.toDataURL(type, encoderOptions);
538
+ ```
539
+
540
+ ###### Parameters
541
+
542
+ **`type`** *Optional*
543
+ - A string indicating the requested MIME type of the image
544
+
545
+ **`encoderOptions`** *Optional*
546
+ - A number between 0 and 1 indicating the image quality.