@jait/gateway 0.1.256 → 0.1.258

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 (205) hide show
  1. package/dist/routes/preview.d.ts.map +1 -1
  2. package/dist/routes/preview.js +41 -2
  3. package/dist/routes/preview.js.map +1 -1
  4. package/dist/security/sandbox-manager.d.ts +8 -0
  5. package/dist/security/sandbox-manager.d.ts.map +1 -1
  6. package/dist/security/sandbox-manager.js +131 -2
  7. package/dist/security/sandbox-manager.js.map +1 -1
  8. package/dist/services/live-view-manager.d.ts +25 -0
  9. package/dist/services/live-view-manager.d.ts.map +1 -0
  10. package/dist/services/live-view-manager.js +178 -0
  11. package/dist/services/live-view-manager.js.map +1 -0
  12. package/dist/services/preview.d.ts +21 -2
  13. package/dist/services/preview.d.ts.map +1 -1
  14. package/dist/services/preview.js +140 -2
  15. package/dist/services/preview.js.map +1 -1
  16. package/dist/surfaces/browser.d.ts +51 -1
  17. package/dist/surfaces/browser.d.ts.map +1 -1
  18. package/dist/surfaces/browser.js +238 -20
  19. package/dist/surfaces/browser.js.map +1 -1
  20. package/dist/tools/preview-tools.d.ts.map +1 -1
  21. package/dist/tools/preview-tools.js +6 -3
  22. package/dist/tools/preview-tools.js.map +1 -1
  23. package/package.json +1 -1
  24. package/web-dist/assets/{_basePickBy-B5ojxQyY.js → _basePickBy-B1Q85huU.js} +1 -1
  25. package/web-dist/assets/{_baseUniq-BVcMC3e3.js → _baseUniq-xbSl0CM3.js} +1 -1
  26. package/web-dist/assets/{arc-B8rKyks5.js → arc-BPQiaftr.js} +1 -1
  27. package/web-dist/assets/{architectureDiagram-2XIMDMQ5-D5Rn0_M_.js → architectureDiagram-2XIMDMQ5-DAG0yXkD.js} +1 -1
  28. package/web-dist/assets/{blockDiagram-WCTKOSBZ-Dn0EedHT.js → blockDiagram-WCTKOSBZ-BHwTxFpO.js} +1 -1
  29. package/web-dist/assets/{c4Diagram-IC4MRINW-BYTFS9YT.js → c4Diagram-IC4MRINW-DSo8jOax.js} +1 -1
  30. package/web-dist/assets/channel-D0UG72Sd.js +1 -0
  31. package/web-dist/assets/{chunk-4BX2VUAB-c51Qw6zZ.js → chunk-4BX2VUAB-BvHzmUEU.js} +1 -1
  32. package/web-dist/assets/{chunk-55IACEB6-BLJEbYZY.js → chunk-55IACEB6-DRwUUfw9.js} +1 -1
  33. package/web-dist/assets/{chunk-FMBD7UC4-BTQRsQCz.js → chunk-FMBD7UC4-C-og1AV4.js} +1 -1
  34. package/web-dist/assets/{chunk-JSJVCQXG-BCQCgV3v.js → chunk-JSJVCQXG-DQ_Nx-12.js} +1 -1
  35. package/web-dist/assets/{chunk-KX2RTZJC-BdxNziNu.js → chunk-KX2RTZJC-DJt22pKX.js} +1 -1
  36. package/web-dist/assets/{chunk-NQ4KR5QH-DvtJCn0C.js → chunk-NQ4KR5QH-DwqccJna.js} +1 -1
  37. package/web-dist/assets/{chunk-QZHKN3VN-Bv5UUhJr.js → chunk-QZHKN3VN-t2Z5FHem.js} +1 -1
  38. package/web-dist/assets/{chunk-WL4C6EOR-DgCZzsOT.js → chunk-WL4C6EOR-DhnNywRj.js} +1 -1
  39. package/web-dist/assets/classDiagram-VBA2DB6C-Dnib5gxK.js +1 -0
  40. package/web-dist/assets/classDiagram-v2-RAHNMMFH-Dnib5gxK.js +1 -0
  41. package/web-dist/assets/clone-jMsfbHCu.js +1 -0
  42. package/web-dist/assets/{cose-bilkent-S5V4N54A-CmDdGIef.js → cose-bilkent-S5V4N54A-CLw8R8jY.js} +1 -1
  43. package/web-dist/assets/{dagre-KLK3FWXG-BzeF6p1D.js → dagre-KLK3FWXG-DG-8BOX_.js} +1 -1
  44. package/web-dist/assets/{diagram-E7M64L7V-lDeWArgl.js → diagram-E7M64L7V-I6Ok2sG0.js} +1 -1
  45. package/web-dist/assets/{diagram-IFDJBPK2-BguEZbUg.js → diagram-IFDJBPK2-ertAk1QG.js} +1 -1
  46. package/web-dist/assets/{diagram-P4PSJMXO-CnTxg2wa.js → diagram-P4PSJMXO-B9Yr9iab.js} +1 -1
  47. package/web-dist/assets/{erDiagram-INFDFZHY-D2aGee-H.js → erDiagram-INFDFZHY-BMva8gYu.js} +1 -1
  48. package/web-dist/assets/{flowDiagram-PKNHOUZH-DYPu_lOt.js → flowDiagram-PKNHOUZH-D1dJMWaL.js} +1 -1
  49. package/web-dist/assets/{ganttDiagram-A5KZAMGK-D-9aApiK.js → ganttDiagram-A5KZAMGK-qRDi6l_-.js} +1 -1
  50. package/web-dist/assets/{gitGraphDiagram-K3NZZRJ6-CGHZTbqZ.js → gitGraphDiagram-K3NZZRJ6-X8idci3H.js} +1 -1
  51. package/web-dist/assets/{graph-xl1n4wd4.js → graph-6RqPLKMD.js} +1 -1
  52. package/web-dist/assets/{index-CNdW3yYd.js → index-B0GgFn4l.js} +306 -306
  53. package/web-dist/assets/{index-qWyAYgAD.css → index-DFW3_r8A.css} +1 -1
  54. package/web-dist/assets/{infoDiagram-LFFYTUFH-JQ1DhuIN.js → infoDiagram-LFFYTUFH-CMk_Yj9c.js} +1 -1
  55. package/web-dist/assets/{ishikawaDiagram-PHBUUO56-BiQo9puY.js → ishikawaDiagram-PHBUUO56-CwBIr6E2.js} +1 -1
  56. package/web-dist/assets/{journeyDiagram-4ABVD52K-BWvVCFKb.js → journeyDiagram-4ABVD52K-BgD5iS1h.js} +1 -1
  57. package/web-dist/assets/{kanban-definition-K7BYSVSG-B1pZvgm7.js → kanban-definition-K7BYSVSG-CzjxHzou.js} +1 -1
  58. package/web-dist/assets/{layout-C_VnOnT4.js → layout-b5fe_UxD.js} +1 -1
  59. package/web-dist/assets/{linear-BeBoVpvX.js → linear-ChI_4a9O.js} +1 -1
  60. package/web-dist/assets/{mindmap-definition-YRQLILUH-B3U5ZJAw.js → mindmap-definition-YRQLILUH-e_vvWWg8.js} +1 -1
  61. package/web-dist/assets/{pieDiagram-SKSYHLDU-B9JMxGDx.js → pieDiagram-SKSYHLDU-CJtQ5J0D.js} +1 -1
  62. package/web-dist/assets/{quadrantDiagram-337W2JSQ-DNAEOevf.js → quadrantDiagram-337W2JSQ-Cf_x_2ej.js} +1 -1
  63. package/web-dist/assets/{requirementDiagram-Z7DCOOCP-Dcgzabvl.js → requirementDiagram-Z7DCOOCP-DCQvoqk_.js} +1 -1
  64. package/web-dist/assets/{sankeyDiagram-WA2Y5GQK-BDcQVCtL.js → sankeyDiagram-WA2Y5GQK-D2eB9_Im.js} +1 -1
  65. package/web-dist/assets/{sequenceDiagram-2WXFIKYE-5kY7GmoR.js → sequenceDiagram-2WXFIKYE-Ccyyepsb.js} +1 -1
  66. package/web-dist/assets/{stateDiagram-RAJIS63D-BwQlMlEC.js → stateDiagram-RAJIS63D-DPMGShy8.js} +1 -1
  67. package/web-dist/assets/stateDiagram-v2-FVOUBMTO-BmvKM7hT.js +1 -0
  68. package/web-dist/assets/{timeline-definition-YZTLITO2-BE0IDpJe.js → timeline-definition-YZTLITO2-CHBPr8N4.js} +1 -1
  69. package/web-dist/assets/{treemap-KZPCXAKY-CHwtWAgO.js → treemap-KZPCXAKY-DnqeIQgk.js} +1 -1
  70. package/web-dist/assets/{vennDiagram-LZ73GAT5-ByqFK92_.js → vennDiagram-LZ73GAT5-BRIzanhU.js} +1 -1
  71. package/web-dist/assets/{xychartDiagram-JWTSCODW-BdCa1f3c.js → xychartDiagram-JWTSCODW-qjjqxrk2.js} +1 -1
  72. package/web-dist/index.html +2 -2
  73. package/web-dist/noVNC/LICENSE.txt +62 -0
  74. package/web-dist/noVNC/app/error-handler.js +79 -0
  75. package/web-dist/noVNC/app/images/alt.svg +92 -0
  76. package/web-dist/noVNC/app/images/clipboard.svg +106 -0
  77. package/web-dist/noVNC/app/images/connect.svg +96 -0
  78. package/web-dist/noVNC/app/images/ctrl.svg +96 -0
  79. package/web-dist/noVNC/app/images/ctrlaltdel.svg +100 -0
  80. package/web-dist/noVNC/app/images/disconnect.svg +94 -0
  81. package/web-dist/noVNC/app/images/drag.svg +76 -0
  82. package/web-dist/noVNC/app/images/error.svg +81 -0
  83. package/web-dist/noVNC/app/images/esc.svg +92 -0
  84. package/web-dist/noVNC/app/images/expander.svg +69 -0
  85. package/web-dist/noVNC/app/images/fullscreen.svg +93 -0
  86. package/web-dist/noVNC/app/images/handle.svg +82 -0
  87. package/web-dist/noVNC/app/images/handle_bg.svg +172 -0
  88. package/web-dist/noVNC/app/images/icons/Makefile +42 -0
  89. package/web-dist/noVNC/app/images/icons/novnc-icon-sm.svg +163 -0
  90. package/web-dist/noVNC/app/images/icons/novnc-icon.svg +163 -0
  91. package/web-dist/noVNC/app/images/icons/novnc-ios-120.png +0 -0
  92. package/web-dist/noVNC/app/images/icons/novnc-ios-152.png +0 -0
  93. package/web-dist/noVNC/app/images/icons/novnc-ios-167.png +0 -0
  94. package/web-dist/noVNC/app/images/icons/novnc-ios-180.png +0 -0
  95. package/web-dist/noVNC/app/images/icons/novnc-ios-40.png +0 -0
  96. package/web-dist/noVNC/app/images/icons/novnc-ios-58.png +0 -0
  97. package/web-dist/noVNC/app/images/icons/novnc-ios-60.png +0 -0
  98. package/web-dist/noVNC/app/images/icons/novnc-ios-80.png +0 -0
  99. package/web-dist/noVNC/app/images/icons/novnc-ios-87.png +0 -0
  100. package/web-dist/noVNC/app/images/icons/novnc-ios-icon.svg +183 -0
  101. package/web-dist/noVNC/app/images/icons/novnc.ico +0 -0
  102. package/web-dist/noVNC/app/images/info.svg +81 -0
  103. package/web-dist/noVNC/app/images/keyboard.svg +88 -0
  104. package/web-dist/noVNC/app/images/power.svg +87 -0
  105. package/web-dist/noVNC/app/images/settings.svg +76 -0
  106. package/web-dist/noVNC/app/images/tab.svg +86 -0
  107. package/web-dist/noVNC/app/images/toggleextrakeys.svg +90 -0
  108. package/web-dist/noVNC/app/images/warning.svg +81 -0
  109. package/web-dist/noVNC/app/images/windows.svg +65 -0
  110. package/web-dist/noVNC/app/locale/README +1 -0
  111. package/web-dist/noVNC/app/locale/cs.json +71 -0
  112. package/web-dist/noVNC/app/locale/de.json +74 -0
  113. package/web-dist/noVNC/app/locale/el.json +100 -0
  114. package/web-dist/noVNC/app/locale/es.json +68 -0
  115. package/web-dist/noVNC/app/locale/fr.json +82 -0
  116. package/web-dist/noVNC/app/locale/hu.json +80 -0
  117. package/web-dist/noVNC/app/locale/it.json +68 -0
  118. package/web-dist/noVNC/app/locale/ja.json +81 -0
  119. package/web-dist/noVNC/app/locale/ko.json +70 -0
  120. package/web-dist/noVNC/app/locale/nl.json +95 -0
  121. package/web-dist/noVNC/app/locale/pl.json +80 -0
  122. package/web-dist/noVNC/app/locale/pt_BR.json +72 -0
  123. package/web-dist/noVNC/app/locale/ru.json +72 -0
  124. package/web-dist/noVNC/app/locale/sv.json +83 -0
  125. package/web-dist/noVNC/app/locale/tr.json +69 -0
  126. package/web-dist/noVNC/app/locale/uk.json +81 -0
  127. package/web-dist/noVNC/app/locale/zh_CN.json +93 -0
  128. package/web-dist/noVNC/app/locale/zh_TW.json +69 -0
  129. package/web-dist/noVNC/app/localization.js +206 -0
  130. package/web-dist/noVNC/app/sounds/CREDITS +4 -0
  131. package/web-dist/noVNC/app/sounds/bell.mp3 +0 -0
  132. package/web-dist/noVNC/app/sounds/bell.oga +0 -0
  133. package/web-dist/noVNC/app/styles/Orbitron700.ttf +0 -0
  134. package/web-dist/noVNC/app/styles/Orbitron700.woff +0 -0
  135. package/web-dist/noVNC/app/styles/base.css +927 -0
  136. package/web-dist/noVNC/app/styles/constants.css +30 -0
  137. package/web-dist/noVNC/app/styles/input.css +628 -0
  138. package/web-dist/noVNC/app/ui.js +1873 -0
  139. package/web-dist/noVNC/app/wakelock.js +199 -0
  140. package/web-dist/noVNC/app/webutil.js +250 -0
  141. package/web-dist/noVNC/core/base64.js +104 -0
  142. package/web-dist/noVNC/core/clipboard.js +72 -0
  143. package/web-dist/noVNC/core/crypto/aes.js +178 -0
  144. package/web-dist/noVNC/core/crypto/bigint.js +34 -0
  145. package/web-dist/noVNC/core/crypto/crypto.js +90 -0
  146. package/web-dist/noVNC/core/crypto/des.js +330 -0
  147. package/web-dist/noVNC/core/crypto/dh.js +55 -0
  148. package/web-dist/noVNC/core/crypto/md5.js +82 -0
  149. package/web-dist/noVNC/core/crypto/rsa.js +132 -0
  150. package/web-dist/noVNC/core/decoders/copyrect.js +27 -0
  151. package/web-dist/noVNC/core/decoders/h264.js +321 -0
  152. package/web-dist/noVNC/core/decoders/hextile.js +181 -0
  153. package/web-dist/noVNC/core/decoders/jpeg.js +161 -0
  154. package/web-dist/noVNC/core/decoders/raw.js +59 -0
  155. package/web-dist/noVNC/core/decoders/rre.js +44 -0
  156. package/web-dist/noVNC/core/decoders/tight.js +393 -0
  157. package/web-dist/noVNC/core/decoders/tightpng.js +27 -0
  158. package/web-dist/noVNC/core/decoders/zlib.js +51 -0
  159. package/web-dist/noVNC/core/decoders/zrle.js +185 -0
  160. package/web-dist/noVNC/core/deflator.js +84 -0
  161. package/web-dist/noVNC/core/display.js +578 -0
  162. package/web-dist/noVNC/core/encodings.js +54 -0
  163. package/web-dist/noVNC/core/inflator.js +65 -0
  164. package/web-dist/noVNC/core/input/domkeytable.js +311 -0
  165. package/web-dist/noVNC/core/input/fixedkeys.js +129 -0
  166. package/web-dist/noVNC/core/input/gesturehandler.js +567 -0
  167. package/web-dist/noVNC/core/input/keyboard.js +294 -0
  168. package/web-dist/noVNC/core/input/keysym.js +616 -0
  169. package/web-dist/noVNC/core/input/keysymdef.js +688 -0
  170. package/web-dist/noVNC/core/input/util.js +191 -0
  171. package/web-dist/noVNC/core/input/vkeys.js +116 -0
  172. package/web-dist/noVNC/core/input/xtscancodes.js +173 -0
  173. package/web-dist/noVNC/core/ra2.js +312 -0
  174. package/web-dist/noVNC/core/rfb.js +3426 -0
  175. package/web-dist/noVNC/core/util/browser.js +266 -0
  176. package/web-dist/noVNC/core/util/cursor.js +249 -0
  177. package/web-dist/noVNC/core/util/element.js +32 -0
  178. package/web-dist/noVNC/core/util/events.js +138 -0
  179. package/web-dist/noVNC/core/util/eventtarget.js +35 -0
  180. package/web-dist/noVNC/core/util/int.js +15 -0
  181. package/web-dist/noVNC/core/util/logging.js +56 -0
  182. package/web-dist/noVNC/core/util/strings.js +28 -0
  183. package/web-dist/noVNC/core/websock.js +369 -0
  184. package/web-dist/noVNC/defaults.json +1 -0
  185. package/web-dist/noVNC/mandatory.json +1 -0
  186. package/web-dist/noVNC/vendor/pako/LICENSE +21 -0
  187. package/web-dist/noVNC/vendor/pako/README.md +6 -0
  188. package/web-dist/noVNC/vendor/pako/lib/utils/common.js +45 -0
  189. package/web-dist/noVNC/vendor/pako/lib/zlib/adler32.js +27 -0
  190. package/web-dist/noVNC/vendor/pako/lib/zlib/constants.js +47 -0
  191. package/web-dist/noVNC/vendor/pako/lib/zlib/crc32.js +36 -0
  192. package/web-dist/noVNC/vendor/pako/lib/zlib/deflate.js +1846 -0
  193. package/web-dist/noVNC/vendor/pako/lib/zlib/gzheader.js +35 -0
  194. package/web-dist/noVNC/vendor/pako/lib/zlib/inffast.js +324 -0
  195. package/web-dist/noVNC/vendor/pako/lib/zlib/inflate.js +1527 -0
  196. package/web-dist/noVNC/vendor/pako/lib/zlib/inftrees.js +322 -0
  197. package/web-dist/noVNC/vendor/pako/lib/zlib/messages.js +11 -0
  198. package/web-dist/noVNC/vendor/pako/lib/zlib/trees.js +1195 -0
  199. package/web-dist/noVNC/vendor/pako/lib/zlib/zstream.js +24 -0
  200. package/web-dist/noVNC/vnc_lite.html +180 -0
  201. package/web-dist/assets/channel-DlBBaM6I.js +0 -1
  202. package/web-dist/assets/classDiagram-VBA2DB6C-DixDm16f.js +0 -1
  203. package/web-dist/assets/classDiagram-v2-RAHNMMFH-DixDm16f.js +0 -1
  204. package/web-dist/assets/clone-DEDCKaxV.js +0 -1
  205. package/web-dist/assets/stateDiagram-v2-FVOUBMTO-Bdpt0e9f.js +0 -1
@@ -0,0 +1,82 @@
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 an array of bytes, returns an array of bytes
11
+ */
12
+
13
+ export async function MD5(d) {
14
+ let s = "";
15
+ for (let i = 0; i < d.length; i++) {
16
+ s += String.fromCharCode(d[i]);
17
+ }
18
+ return M(V(Y(X(s), 8 * s.length)));
19
+ }
20
+
21
+ function M(d) {
22
+ let f = new Uint8Array(d.length);
23
+ for (let i=0;i<d.length;i++) {
24
+ f[i] = d.charCodeAt(i);
25
+ }
26
+ return f;
27
+ }
28
+
29
+ function X(d) {
30
+ let r = Array(d.length >> 2);
31
+ for (let m = 0; m < r.length; m++) r[m] = 0;
32
+ for (let m = 0; m < 8 * d.length; m += 8) r[m >> 5] |= (255 & d.charCodeAt(m / 8)) << m % 32;
33
+ return r;
34
+ }
35
+
36
+ function V(d) {
37
+ let r = "";
38
+ for (let m = 0; m < 32 * d.length; m += 8) r += String.fromCharCode(d[m >> 5] >>> m % 32 & 255);
39
+ return r;
40
+ }
41
+
42
+ function Y(d, g) {
43
+ d[g >> 5] |= 128 << g % 32, d[14 + (g + 64 >>> 9 << 4)] = g;
44
+ let m = 1732584193, f = -271733879, r = -1732584194, i = 271733878;
45
+ for (let n = 0; n < d.length; n += 16) {
46
+ let h = m,
47
+ t = f,
48
+ g = r,
49
+ e = i;
50
+ 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);
51
+ }
52
+ return Array(m, f, r, i);
53
+ }
54
+
55
+ function cmn(d, g, m, f, r, i) {
56
+ return add(rol(add(add(g, d), add(f, i)), r), m);
57
+ }
58
+
59
+ function ff(d, g, m, f, r, i, n) {
60
+ return cmn(g & m | ~g & f, d, g, r, i, n);
61
+ }
62
+
63
+ function gg(d, g, m, f, r, i, n) {
64
+ return cmn(g & f | m & ~f, d, g, r, i, n);
65
+ }
66
+
67
+ function hh(d, g, m, f, r, i, n) {
68
+ return cmn(g ^ m ^ f, d, g, r, i, n);
69
+ }
70
+
71
+ function ii(d, g, m, f, r, i, n) {
72
+ return cmn(m ^ (g | ~f), d, g, r, i, n);
73
+ }
74
+
75
+ function add(d, g) {
76
+ let m = (65535 & d) + (65535 & g);
77
+ return (d >> 16) + (g >> 16) + (m >> 16) << 16 | 65535 & m;
78
+ }
79
+
80
+ function rol(d, g) {
81
+ return d << g | d >>> 32 - g;
82
+ }
@@ -0,0 +1,132 @@
1
+ import Base64 from "../base64.js";
2
+ import { modPow, bigIntToU8Array, u8ArrayToBigInt } from "./bigint.js";
3
+
4
+ export class RSACipher {
5
+ constructor() {
6
+ this._keyLength = 0;
7
+ this._keyBytes = 0;
8
+ this._n = null;
9
+ this._e = null;
10
+ this._d = null;
11
+ this._nBigInt = null;
12
+ this._eBigInt = null;
13
+ this._dBigInt = null;
14
+ this._extractable = false;
15
+ }
16
+
17
+ get algorithm() {
18
+ return { name: "RSA-PKCS1-v1_5" };
19
+ }
20
+
21
+ _base64urlDecode(data) {
22
+ data = data.replace(/-/g, "+").replace(/_/g, "/");
23
+ data = data.padEnd(Math.ceil(data.length / 4) * 4, "=");
24
+ return Base64.decode(data);
25
+ }
26
+
27
+ _padArray(arr, length) {
28
+ const res = new Uint8Array(length);
29
+ res.set(arr, length - arr.length);
30
+ return res;
31
+ }
32
+
33
+ static async generateKey(algorithm, extractable, _keyUsages) {
34
+ const cipher = new RSACipher;
35
+ await cipher._generateKey(algorithm, extractable);
36
+ return { privateKey: cipher };
37
+ }
38
+
39
+ async _generateKey(algorithm, extractable) {
40
+ this._keyLength = algorithm.modulusLength;
41
+ this._keyBytes = Math.ceil(this._keyLength / 8);
42
+ const key = await window.crypto.subtle.generateKey(
43
+ {
44
+ name: "RSA-OAEP",
45
+ modulusLength: algorithm.modulusLength,
46
+ publicExponent: algorithm.publicExponent,
47
+ hash: {name: "SHA-256"},
48
+ },
49
+ true, ["encrypt", "decrypt"]);
50
+ const privateKey = await window.crypto.subtle.exportKey("jwk", key.privateKey);
51
+ this._n = this._padArray(this._base64urlDecode(privateKey.n), this._keyBytes);
52
+ this._nBigInt = u8ArrayToBigInt(this._n);
53
+ this._e = this._padArray(this._base64urlDecode(privateKey.e), this._keyBytes);
54
+ this._eBigInt = u8ArrayToBigInt(this._e);
55
+ this._d = this._padArray(this._base64urlDecode(privateKey.d), this._keyBytes);
56
+ this._dBigInt = u8ArrayToBigInt(this._d);
57
+ this._extractable = extractable;
58
+ }
59
+
60
+ static async importKey(key, _algorithm, extractable, keyUsages) {
61
+ if (keyUsages.length !== 1 || keyUsages[0] !== "encrypt") {
62
+ throw new Error("only support importing RSA public key");
63
+ }
64
+ const cipher = new RSACipher;
65
+ await cipher._importKey(key, extractable);
66
+ return cipher;
67
+ }
68
+
69
+ async _importKey(key, extractable) {
70
+ const n = key.n;
71
+ const e = key.e;
72
+ if (n.length !== e.length) {
73
+ throw new Error("the sizes of modulus and public exponent do not match");
74
+ }
75
+ this._keyBytes = n.length;
76
+ this._keyLength = this._keyBytes * 8;
77
+ this._n = new Uint8Array(this._keyBytes);
78
+ this._e = new Uint8Array(this._keyBytes);
79
+ this._n.set(n);
80
+ this._e.set(e);
81
+ this._nBigInt = u8ArrayToBigInt(this._n);
82
+ this._eBigInt = u8ArrayToBigInt(this._e);
83
+ this._extractable = extractable;
84
+ }
85
+
86
+ async encrypt(_algorithm, message) {
87
+ if (message.length > this._keyBytes - 11) {
88
+ return null;
89
+ }
90
+ const ps = new Uint8Array(this._keyBytes - message.length - 3);
91
+ window.crypto.getRandomValues(ps);
92
+ for (let i = 0; i < ps.length; i++) {
93
+ ps[i] = Math.floor(ps[i] * 254 / 255 + 1);
94
+ }
95
+ const em = new Uint8Array(this._keyBytes);
96
+ em[1] = 0x02;
97
+ em.set(ps, 2);
98
+ em.set(message, ps.length + 3);
99
+ const emBigInt = u8ArrayToBigInt(em);
100
+ const c = modPow(emBigInt, this._eBigInt, this._nBigInt);
101
+ return bigIntToU8Array(c, this._keyBytes);
102
+ }
103
+
104
+ async decrypt(_algorithm, message) {
105
+ if (message.length !== this._keyBytes) {
106
+ return null;
107
+ }
108
+ const msgBigInt = u8ArrayToBigInt(message);
109
+ const emBigInt = modPow(msgBigInt, this._dBigInt, this._nBigInt);
110
+ const em = bigIntToU8Array(emBigInt, this._keyBytes);
111
+ if (em[0] !== 0x00 || em[1] !== 0x02) {
112
+ return null;
113
+ }
114
+ let i = 2;
115
+ for (; i < em.length; i++) {
116
+ if (em[i] === 0x00) {
117
+ break;
118
+ }
119
+ }
120
+ if (i === em.length) {
121
+ return null;
122
+ }
123
+ return em.slice(i + 1, em.length);
124
+ }
125
+
126
+ async exportKey() {
127
+ if (!this._extractable) {
128
+ throw new Error("key is not extractable");
129
+ }
130
+ return { n: this._n, e: this._e, d: this._d };
131
+ }
132
+ }
@@ -0,0 +1,27 @@
1
+ /*
2
+ * noVNC: HTML5 VNC client
3
+ * Copyright (C) 2019 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
+ export default class CopyRectDecoder {
11
+ decodeRect(x, y, width, height, sock, display, depth) {
12
+ if (sock.rQwait("COPYRECT", 4)) {
13
+ return false;
14
+ }
15
+
16
+ let deltaX = sock.rQshift16();
17
+ let deltaY = sock.rQshift16();
18
+
19
+ if ((width === 0) || (height === 0)) {
20
+ return true;
21
+ }
22
+
23
+ display.copyImage(deltaX, deltaY, x, y, width, height);
24
+
25
+ return true;
26
+ }
27
+ }
@@ -0,0 +1,321 @@
1
+ /*
2
+ * noVNC: HTML5 VNC client
3
+ * Copyright (C) 2024 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
+ import * as Log from '../util/logging.js';
11
+
12
+ export class H264Parser {
13
+ constructor(data) {
14
+ this._data = data;
15
+ this._index = 0;
16
+ this.profileIdc = null;
17
+ this.constraintSet = null;
18
+ this.levelIdc = null;
19
+ }
20
+
21
+ _getStartSequenceLen(index) {
22
+ let data = this._data;
23
+ if (data[index + 0] == 0 && data[index + 1] == 0 && data[index + 2] == 0 && data[index + 3] == 1) {
24
+ return 4;
25
+ }
26
+ if (data[index + 0] == 0 && data[index + 1] == 0 && data[index + 2] == 1) {
27
+ return 3;
28
+ }
29
+ return 0;
30
+ }
31
+
32
+ _indexOfNextNalUnit(index) {
33
+ let data = this._data;
34
+ for (let i = index; i < data.length; ++i) {
35
+ if (this._getStartSequenceLen(i) != 0) {
36
+ return i;
37
+ }
38
+ }
39
+ return -1;
40
+ }
41
+
42
+ _parseSps(index) {
43
+ this.profileIdc = this._data[index];
44
+ this.constraintSet = this._data[index + 1];
45
+ this.levelIdc = this._data[index + 2];
46
+ }
47
+
48
+ _parseNalUnit(index) {
49
+ const firstByte = this._data[index];
50
+ if (firstByte & 0x80) {
51
+ throw new Error('H264 parsing sanity check failed, forbidden zero bit is set');
52
+ }
53
+ const unitType = firstByte & 0x1f;
54
+
55
+ switch (unitType) {
56
+ case 1: // coded slice, non-idr
57
+ return { slice: true };
58
+ case 5: // coded slice, idr
59
+ return { slice: true, key: true };
60
+ case 6: // sei
61
+ return {};
62
+ case 7: // sps
63
+ this._parseSps(index + 1);
64
+ return {};
65
+ case 8: // pps
66
+ return {};
67
+ default:
68
+ Log.Warn("Unhandled unit type: ", unitType);
69
+ break;
70
+ }
71
+ return {};
72
+ }
73
+
74
+ parse() {
75
+ const startIndex = this._index;
76
+ let isKey = false;
77
+
78
+ while (this._index < this._data.length) {
79
+ const startSequenceLen = this._getStartSequenceLen(this._index);
80
+ if (startSequenceLen == 0) {
81
+ throw new Error('Invalid start sequence in bit stream');
82
+ }
83
+
84
+ const { slice, key } = this._parseNalUnit(this._index + startSequenceLen);
85
+
86
+ let nextIndex = this._indexOfNextNalUnit(this._index + startSequenceLen);
87
+ if (nextIndex == -1) {
88
+ this._index = this._data.length;
89
+ } else {
90
+ this._index = nextIndex;
91
+ }
92
+
93
+ if (key) {
94
+ isKey = true;
95
+ }
96
+ if (slice) {
97
+ break;
98
+ }
99
+ }
100
+
101
+ if (startIndex === this._index) {
102
+ return null;
103
+ }
104
+
105
+ return {
106
+ frame: this._data.subarray(startIndex, this._index),
107
+ key: isKey,
108
+ };
109
+ }
110
+ }
111
+
112
+ export class H264Context {
113
+ constructor(width, height) {
114
+ this.lastUsed = 0;
115
+ this._width = width;
116
+ this._height = height;
117
+ this._profileIdc = null;
118
+ this._constraintSet = null;
119
+ this._levelIdc = null;
120
+ this._decoder = null;
121
+ this._pendingFrames = [];
122
+ }
123
+
124
+ _handleFrame(frame) {
125
+ let pending = this._pendingFrames.shift();
126
+ if (pending === undefined) {
127
+ throw new Error("Pending frame queue empty when receiving frame from decoder");
128
+ }
129
+
130
+ if (pending.timestamp != frame.timestamp) {
131
+ throw new Error("Video frame timestamp mismatch. Expected " +
132
+ frame.timestamp + " but but got " + pending.timestamp);
133
+ }
134
+
135
+ pending.frame = frame;
136
+ pending.ready = true;
137
+ pending.resolve();
138
+
139
+ if (!pending.keep) {
140
+ frame.close();
141
+ }
142
+ }
143
+
144
+ _handleError(e) {
145
+ throw new Error("Failed to decode frame: " + e.message);
146
+ }
147
+
148
+ _configureDecoder(profileIdc, constraintSet, levelIdc) {
149
+ if (this._decoder === null || this._decoder.state === 'closed') {
150
+ this._decoder = new VideoDecoder({
151
+ output: frame => this._handleFrame(frame),
152
+ error: e => this._handleError(e),
153
+ });
154
+ }
155
+ const codec = 'avc1.' +
156
+ profileIdc.toString(16).padStart(2, '0') +
157
+ constraintSet.toString(16).padStart(2, '0') +
158
+ levelIdc.toString(16).padStart(2, '0');
159
+ this._decoder.configure({
160
+ codec: codec,
161
+ codedWidth: this._width,
162
+ codedHeight: this._height,
163
+ optimizeForLatency: true,
164
+ });
165
+ }
166
+
167
+ _preparePendingFrame(timestamp) {
168
+ let pending = {
169
+ timestamp: timestamp,
170
+ promise: null,
171
+ resolve: null,
172
+ frame: null,
173
+ ready: false,
174
+ keep: false,
175
+ };
176
+ pending.promise = new Promise((resolve) => {
177
+ pending.resolve = resolve;
178
+ });
179
+ this._pendingFrames.push(pending);
180
+
181
+ return pending;
182
+ }
183
+
184
+ decode(payload) {
185
+ let parser = new H264Parser(payload);
186
+ let result = null;
187
+
188
+ // Ideally, this timestamp should come from the server, but we'll just
189
+ // approximate it instead.
190
+ let timestamp = Math.round(window.performance.now() * 1e3);
191
+
192
+ while (true) {
193
+ let encodedFrame = parser.parse();
194
+ if (encodedFrame === null) {
195
+ break;
196
+ }
197
+
198
+ if (parser.profileIdc !== null) {
199
+ self._profileIdc = parser.profileIdc;
200
+ self._constraintSet = parser.constraintSet;
201
+ self._levelIdc = parser.levelIdc;
202
+ }
203
+
204
+ if (this._decoder === null || this._decoder.state !== 'configured') {
205
+ if (!encodedFrame.key) {
206
+ Log.Warn("Missing key frame. Can't decode until one arrives");
207
+ continue;
208
+ }
209
+ if (self._profileIdc === null) {
210
+ Log.Warn('Cannot config decoder. Have not received SPS and PPS yet.');
211
+ continue;
212
+ }
213
+ this._configureDecoder(self._profileIdc, self._constraintSet,
214
+ self._levelIdc);
215
+ }
216
+
217
+ result = this._preparePendingFrame(timestamp);
218
+
219
+ const chunk = new EncodedVideoChunk({
220
+ timestamp: timestamp,
221
+ type: encodedFrame.key ? 'key' : 'delta',
222
+ data: encodedFrame.frame,
223
+ });
224
+
225
+ try {
226
+ this._decoder.decode(chunk);
227
+ } catch (e) {
228
+ Log.Warn("Failed to decode:", e);
229
+ }
230
+ }
231
+
232
+ // We only keep last frame of each payload
233
+ if (result !== null) {
234
+ result.keep = true;
235
+ }
236
+
237
+ return result;
238
+ }
239
+ }
240
+
241
+ export default class H264Decoder {
242
+ constructor() {
243
+ this._tick = 0;
244
+ this._contexts = {};
245
+ }
246
+
247
+ _contextId(x, y, width, height) {
248
+ return [x, y, width, height].join(',');
249
+ }
250
+
251
+ _findOldestContextId() {
252
+ let oldestTick = Number.MAX_VALUE;
253
+ let oldestKey = undefined;
254
+ for (const [key, value] of Object.entries(this._contexts)) {
255
+ if (value.lastUsed < oldestTick) {
256
+ oldestTick = value.lastUsed;
257
+ oldestKey = key;
258
+ }
259
+ }
260
+ return oldestKey;
261
+ }
262
+
263
+ _createContext(x, y, width, height) {
264
+ const maxContexts = 64;
265
+ if (Object.keys(this._contexts).length >= maxContexts) {
266
+ let oldestContextId = this._findOldestContextId();
267
+ delete this._contexts[oldestContextId];
268
+ }
269
+ let context = new H264Context(width, height);
270
+ this._contexts[this._contextId(x, y, width, height)] = context;
271
+ return context;
272
+ }
273
+
274
+ _getContext(x, y, width, height) {
275
+ let context = this._contexts[this._contextId(x, y, width, height)];
276
+ return context !== undefined ? context : this._createContext(x, y, width, height);
277
+ }
278
+
279
+ _resetContext(x, y, width, height) {
280
+ delete this._contexts[this._contextId(x, y, width, height)];
281
+ }
282
+
283
+ _resetAllContexts() {
284
+ this._contexts = {};
285
+ }
286
+
287
+ decodeRect(x, y, width, height, sock, display, depth) {
288
+ const resetContextFlag = 1;
289
+ const resetAllContextsFlag = 2;
290
+
291
+ if (sock.rQwait("h264 header", 8)) {
292
+ return false;
293
+ }
294
+
295
+ const length = sock.rQshift32();
296
+ const flags = sock.rQshift32();
297
+
298
+ if (sock.rQwait("h264 payload", length, 8)) {
299
+ return false;
300
+ }
301
+
302
+ if (flags & resetAllContextsFlag) {
303
+ this._resetAllContexts();
304
+ } else if (flags & resetContextFlag) {
305
+ this._resetContext(x, y, width, height);
306
+ }
307
+
308
+ let context = this._getContext(x, y, width, height);
309
+ context.lastUsed = this._tick++;
310
+
311
+ if (length !== 0) {
312
+ let payload = sock.rQshiftBytes(length, false);
313
+ let frame = context.decode(payload);
314
+ if (frame !== null) {
315
+ display.videoFrame(x, y, width, height, frame);
316
+ }
317
+ }
318
+
319
+ return true;
320
+ }
321
+ }