@novnc/novnc 1.3.0-beta → 1.3.0-g0ef7582
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -3
- package/core/decoders/jpeg.js +141 -0
- package/core/decoders/raw.js +1 -1
- package/core/decoders/zrle.js +185 -0
- package/core/display.js +12 -0
- package/core/encodings.js +4 -0
- package/core/input/keyboard.js +10 -0
- package/core/ra2.js +567 -0
- package/core/rfb.js +393 -84
- package/core/util/md5.js +79 -0
- package/docs/API.md +105 -4
- package/lib/base64.js +20 -34
- package/lib/decoders/copyrect.js +1 -11
- package/lib/decoders/hextile.js +14 -46
- package/lib/decoders/jpeg.js +146 -0
- package/lib/decoders/raw.js +6 -22
- package/lib/decoders/rre.js +1 -15
- package/lib/decoders/tight.js +10 -78
- package/lib/decoders/tightpng.js +5 -27
- package/lib/decoders/zrle.js +185 -0
- package/lib/deflator.js +5 -22
- package/lib/des.js +20 -36
- package/lib/display.js +59 -107
- package/lib/encodings.js +7 -8
- package/lib/inflator.js +2 -18
- package/lib/input/domkeytable.js +77 -48
- package/lib/input/fixedkeys.js +8 -3
- package/lib/input/gesturehandler.js +82 -152
- package/lib/input/keyboard.js +59 -90
- package/lib/input/keysym.js +14 -270
- package/lib/input/keysymdef.js +5 -7
- package/lib/input/util.js +44 -86
- package/lib/input/vkeys.js +0 -3
- package/lib/input/xtscancodes.js +1 -168
- package/lib/ra2.js +1033 -0
- package/lib/rfb.js +716 -922
- package/lib/util/browser.js +24 -29
- package/lib/util/cursor.js +21 -65
- package/lib/util/element.js +3 -5
- package/lib/util/events.js +25 -32
- package/lib/util/eventtarget.js +1 -13
- package/lib/util/int.js +2 -3
- package/lib/util/logging.js +3 -21
- package/lib/util/md5.js +83 -0
- package/lib/util/strings.js +3 -5
- package/lib/vendor/pako/lib/utils/common.js +10 -19
- package/lib/vendor/pako/lib/zlib/adler32.js +3 -7
- package/lib/vendor/pako/lib/zlib/constants.js +2 -5
- package/lib/vendor/pako/lib/zlib/crc32.js +5 -12
- package/lib/vendor/pako/lib/zlib/deflate.js +218 -622
- package/lib/vendor/pako/lib/zlib/gzheader.js +1 -13
- package/lib/vendor/pako/lib/zlib/inffast.js +60 -172
- package/lib/vendor/pako/lib/zlib/inflate.js +407 -874
- package/lib/vendor/pako/lib/zlib/inftrees.js +63 -169
- package/lib/vendor/pako/lib/zlib/messages.js +1 -11
- package/lib/vendor/pako/lib/zlib/trees.js +248 -590
- package/lib/vendor/pako/lib/zlib/zstream.js +2 -18
- package/lib/websock.js +33 -86
- package/package.json +2 -7
package/lib/decoders/tightpng.js
CHANGED
|
@@ -1,56 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
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 _tight = _interopRequireDefault(require("./tight.js"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
11
|
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); } }
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
21
|
-
|
|
22
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
23
|
-
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
14
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
24
15
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
25
|
-
|
|
26
16
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
27
|
-
|
|
28
17
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
29
|
-
|
|
30
18
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
31
|
-
|
|
32
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
33
|
-
|
|
19
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
34
20
|
var TightPNGDecoder = /*#__PURE__*/function (_TightDecoder) {
|
|
35
21
|
_inherits(TightPNGDecoder, _TightDecoder);
|
|
36
|
-
|
|
37
22
|
var _super = _createSuper(TightPNGDecoder);
|
|
38
|
-
|
|
39
23
|
function TightPNGDecoder() {
|
|
40
24
|
_classCallCheck(this, TightPNGDecoder);
|
|
41
|
-
|
|
42
25
|
return _super.apply(this, arguments);
|
|
43
26
|
}
|
|
44
|
-
|
|
45
27
|
_createClass(TightPNGDecoder, [{
|
|
46
28
|
key: "_pngRect",
|
|
47
29
|
value: function _pngRect(x, y, width, height, sock, display, depth) {
|
|
48
30
|
var data = this._readData(sock);
|
|
49
|
-
|
|
50
31
|
if (data === null) {
|
|
51
32
|
return false;
|
|
52
33
|
}
|
|
53
|
-
|
|
54
34
|
display.imageRect(x, y, width, height, "image/png", data);
|
|
55
35
|
return true;
|
|
56
36
|
}
|
|
@@ -60,8 +40,6 @@ var TightPNGDecoder = /*#__PURE__*/function (_TightDecoder) {
|
|
|
60
40
|
throw new Error("BasicCompression received in TightPNG rect");
|
|
61
41
|
}
|
|
62
42
|
}]);
|
|
63
|
-
|
|
64
43
|
return TightPNGDecoder;
|
|
65
44
|
}(_tight["default"]);
|
|
66
|
-
|
|
67
45
|
exports["default"] = TightPNGDecoder;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _inflator = _interopRequireDefault(require("../inflator.js"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10
|
+
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
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
12
|
+
var ZRLE_TILE_WIDTH = 64;
|
|
13
|
+
var ZRLE_TILE_HEIGHT = 64;
|
|
14
|
+
var ZRLEDecoder = /*#__PURE__*/function () {
|
|
15
|
+
function ZRLEDecoder() {
|
|
16
|
+
_classCallCheck(this, ZRLEDecoder);
|
|
17
|
+
this._length = 0;
|
|
18
|
+
this._inflator = new _inflator["default"]();
|
|
19
|
+
this._pixelBuffer = new Uint8Array(ZRLE_TILE_WIDTH * ZRLE_TILE_HEIGHT * 4);
|
|
20
|
+
this._tileBuffer = new Uint8Array(ZRLE_TILE_WIDTH * ZRLE_TILE_HEIGHT * 4);
|
|
21
|
+
}
|
|
22
|
+
_createClass(ZRLEDecoder, [{
|
|
23
|
+
key: "decodeRect",
|
|
24
|
+
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
25
|
+
if (this._length === 0) {
|
|
26
|
+
if (sock.rQwait("ZLib data length", 4)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
this._length = sock.rQshift32();
|
|
30
|
+
}
|
|
31
|
+
if (sock.rQwait("Zlib data", this._length)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
var data = sock.rQshiftBytes(this._length);
|
|
35
|
+
this._inflator.setInput(data);
|
|
36
|
+
for (var ty = y; ty < y + height; ty += ZRLE_TILE_HEIGHT) {
|
|
37
|
+
var th = Math.min(ZRLE_TILE_HEIGHT, y + height - ty);
|
|
38
|
+
for (var tx = x; tx < x + width; tx += ZRLE_TILE_WIDTH) {
|
|
39
|
+
var tw = Math.min(ZRLE_TILE_WIDTH, x + width - tx);
|
|
40
|
+
var tileSize = tw * th;
|
|
41
|
+
var subencoding = this._inflator.inflate(1)[0];
|
|
42
|
+
if (subencoding === 0) {
|
|
43
|
+
// raw data
|
|
44
|
+
var _data = this._readPixels(tileSize);
|
|
45
|
+
display.blitImage(tx, ty, tw, th, _data, 0, false);
|
|
46
|
+
} else if (subencoding === 1) {
|
|
47
|
+
// solid
|
|
48
|
+
var background = this._readPixels(1);
|
|
49
|
+
display.fillRect(tx, ty, tw, th, [background[0], background[1], background[2]]);
|
|
50
|
+
} else if (subencoding >= 2 && subencoding <= 16) {
|
|
51
|
+
var _data2 = this._decodePaletteTile(subencoding, tileSize, tw, th);
|
|
52
|
+
display.blitImage(tx, ty, tw, th, _data2, 0, false);
|
|
53
|
+
} else if (subencoding === 128) {
|
|
54
|
+
var _data3 = this._decodeRLETile(tileSize);
|
|
55
|
+
display.blitImage(tx, ty, tw, th, _data3, 0, false);
|
|
56
|
+
} else if (subencoding >= 130 && subencoding <= 255) {
|
|
57
|
+
var _data4 = this._decodeRLEPaletteTile(subencoding - 128, tileSize);
|
|
58
|
+
display.blitImage(tx, ty, tw, th, _data4, 0, false);
|
|
59
|
+
} else {
|
|
60
|
+
throw new Error('Unknown subencoding: ' + subencoding);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
this._length = 0;
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
key: "_getBitsPerPixelInPalette",
|
|
69
|
+
value: function _getBitsPerPixelInPalette(paletteSize) {
|
|
70
|
+
if (paletteSize <= 2) {
|
|
71
|
+
return 1;
|
|
72
|
+
} else if (paletteSize <= 4) {
|
|
73
|
+
return 2;
|
|
74
|
+
} else if (paletteSize <= 16) {
|
|
75
|
+
return 4;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}, {
|
|
79
|
+
key: "_readPixels",
|
|
80
|
+
value: function _readPixels(pixels) {
|
|
81
|
+
var data = this._pixelBuffer;
|
|
82
|
+
var buffer = this._inflator.inflate(3 * pixels);
|
|
83
|
+
for (var i = 0, j = 0; i < pixels * 4; i += 4, j += 3) {
|
|
84
|
+
data[i] = buffer[j];
|
|
85
|
+
data[i + 1] = buffer[j + 1];
|
|
86
|
+
data[i + 2] = buffer[j + 2];
|
|
87
|
+
data[i + 3] = 255; // Add the Alpha
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return data;
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
key: "_decodePaletteTile",
|
|
94
|
+
value: function _decodePaletteTile(paletteSize, tileSize, tilew, tileh) {
|
|
95
|
+
var data = this._tileBuffer;
|
|
96
|
+
var palette = this._readPixels(paletteSize);
|
|
97
|
+
var bitsPerPixel = this._getBitsPerPixelInPalette(paletteSize);
|
|
98
|
+
var mask = (1 << bitsPerPixel) - 1;
|
|
99
|
+
var offset = 0;
|
|
100
|
+
var encoded = this._inflator.inflate(1)[0];
|
|
101
|
+
for (var y = 0; y < tileh; y++) {
|
|
102
|
+
var shift = 8 - bitsPerPixel;
|
|
103
|
+
for (var x = 0; x < tilew; x++) {
|
|
104
|
+
if (shift < 0) {
|
|
105
|
+
shift = 8 - bitsPerPixel;
|
|
106
|
+
encoded = this._inflator.inflate(1)[0];
|
|
107
|
+
}
|
|
108
|
+
var indexInPalette = encoded >> shift & mask;
|
|
109
|
+
data[offset] = palette[indexInPalette * 4];
|
|
110
|
+
data[offset + 1] = palette[indexInPalette * 4 + 1];
|
|
111
|
+
data[offset + 2] = palette[indexInPalette * 4 + 2];
|
|
112
|
+
data[offset + 3] = palette[indexInPalette * 4 + 3];
|
|
113
|
+
offset += 4;
|
|
114
|
+
shift -= bitsPerPixel;
|
|
115
|
+
}
|
|
116
|
+
if (shift < 8 - bitsPerPixel && y < tileh - 1) {
|
|
117
|
+
encoded = this._inflator.inflate(1)[0];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return data;
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "_decodeRLETile",
|
|
124
|
+
value: function _decodeRLETile(tileSize) {
|
|
125
|
+
var data = this._tileBuffer;
|
|
126
|
+
var i = 0;
|
|
127
|
+
while (i < tileSize) {
|
|
128
|
+
var pixel = this._readPixels(1);
|
|
129
|
+
var length = this._readRLELength();
|
|
130
|
+
for (var j = 0; j < length; j++) {
|
|
131
|
+
data[i * 4] = pixel[0];
|
|
132
|
+
data[i * 4 + 1] = pixel[1];
|
|
133
|
+
data[i * 4 + 2] = pixel[2];
|
|
134
|
+
data[i * 4 + 3] = pixel[3];
|
|
135
|
+
i++;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return data;
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: "_decodeRLEPaletteTile",
|
|
142
|
+
value: function _decodeRLEPaletteTile(paletteSize, tileSize) {
|
|
143
|
+
var data = this._tileBuffer;
|
|
144
|
+
|
|
145
|
+
// palette
|
|
146
|
+
var palette = this._readPixels(paletteSize);
|
|
147
|
+
var offset = 0;
|
|
148
|
+
while (offset < tileSize) {
|
|
149
|
+
var indexInPalette = this._inflator.inflate(1)[0];
|
|
150
|
+
var length = 1;
|
|
151
|
+
if (indexInPalette >= 128) {
|
|
152
|
+
indexInPalette -= 128;
|
|
153
|
+
length = this._readRLELength();
|
|
154
|
+
}
|
|
155
|
+
if (indexInPalette > paletteSize) {
|
|
156
|
+
throw new Error('Too big index in palette: ' + indexInPalette + ', palette size: ' + paletteSize);
|
|
157
|
+
}
|
|
158
|
+
if (offset + length > tileSize) {
|
|
159
|
+
throw new Error('Too big rle length in palette mode: ' + length + ', allowed length is: ' + (tileSize - offset));
|
|
160
|
+
}
|
|
161
|
+
for (var j = 0; j < length; j++) {
|
|
162
|
+
data[offset * 4] = palette[indexInPalette * 4];
|
|
163
|
+
data[offset * 4 + 1] = palette[indexInPalette * 4 + 1];
|
|
164
|
+
data[offset * 4 + 2] = palette[indexInPalette * 4 + 2];
|
|
165
|
+
data[offset * 4 + 3] = palette[indexInPalette * 4 + 3];
|
|
166
|
+
offset++;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return data;
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
key: "_readRLELength",
|
|
173
|
+
value: function _readRLELength() {
|
|
174
|
+
var length = 0;
|
|
175
|
+
var current = 0;
|
|
176
|
+
do {
|
|
177
|
+
current = this._inflator.inflate(1)[0];
|
|
178
|
+
length += current;
|
|
179
|
+
} while (current === 255);
|
|
180
|
+
return length + 1;
|
|
181
|
+
}
|
|
182
|
+
}]);
|
|
183
|
+
return ZRLEDecoder;
|
|
184
|
+
}();
|
|
185
|
+
exports["default"] = ZRLEDecoder;
|
package/lib/deflator.js
CHANGED
|
@@ -4,30 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _deflate2 = require("../lib/vendor/pako/lib/zlib/deflate.js");
|
|
9
|
-
|
|
10
8
|
var _zstream = _interopRequireDefault(require("../lib/vendor/pako/lib/zlib/zstream.js"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
11
|
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); } }
|
|
17
|
-
|
|
18
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
19
|
-
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
13
|
var Deflator = /*#__PURE__*/function () {
|
|
21
14
|
function Deflator() {
|
|
22
15
|
_classCallCheck(this, Deflator);
|
|
23
|
-
|
|
24
16
|
this.strm = new _zstream["default"]();
|
|
25
17
|
this.chunkSize = 1024 * 10 * 10;
|
|
26
18
|
this.outputBuffer = new Uint8Array(this.chunkSize);
|
|
27
19
|
this.windowBits = 5;
|
|
28
20
|
(0, _deflate2.deflateInit)(this.strm, this.windowBits);
|
|
29
21
|
}
|
|
30
|
-
|
|
31
22
|
_createClass(Deflator, [{
|
|
32
23
|
key: "deflate",
|
|
33
24
|
value: function deflate(inData) {
|
|
@@ -42,16 +33,14 @@ var Deflator = /*#__PURE__*/function () {
|
|
|
42
33
|
|
|
43
34
|
var lastRet = (0, _deflate2.deflate)(this.strm, _deflate2.Z_FULL_FLUSH);
|
|
44
35
|
var outData = new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
|
|
45
|
-
|
|
46
36
|
if (lastRet < 0) {
|
|
47
37
|
throw new Error("zlib deflate failed");
|
|
48
38
|
}
|
|
49
|
-
|
|
50
39
|
if (this.strm.avail_in > 0) {
|
|
51
40
|
// Read chunks until done
|
|
41
|
+
|
|
52
42
|
var chunks = [outData];
|
|
53
43
|
var totalLen = outData.length;
|
|
54
|
-
|
|
55
44
|
do {
|
|
56
45
|
/* eslint-disable camelcase */
|
|
57
46
|
this.strm.output = new Uint8Array(this.chunkSize);
|
|
@@ -60,30 +49,26 @@ var Deflator = /*#__PURE__*/function () {
|
|
|
60
49
|
/* eslint-enable camelcase */
|
|
61
50
|
|
|
62
51
|
lastRet = (0, _deflate2.deflate)(this.strm, _deflate2.Z_FULL_FLUSH);
|
|
63
|
-
|
|
64
52
|
if (lastRet < 0) {
|
|
65
53
|
throw new Error("zlib deflate failed");
|
|
66
54
|
}
|
|
67
|
-
|
|
68
55
|
var chunk = new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
|
|
69
56
|
totalLen += chunk.length;
|
|
70
57
|
chunks.push(chunk);
|
|
71
|
-
} while (this.strm.avail_in > 0);
|
|
58
|
+
} while (this.strm.avail_in > 0);
|
|
72
59
|
|
|
60
|
+
// Combine chunks into a single data
|
|
73
61
|
|
|
74
62
|
var newData = new Uint8Array(totalLen);
|
|
75
63
|
var offset = 0;
|
|
76
|
-
|
|
77
64
|
for (var i = 0; i < chunks.length; i++) {
|
|
78
65
|
newData.set(chunks[i], offset);
|
|
79
66
|
offset += chunks[i].length;
|
|
80
67
|
}
|
|
81
|
-
|
|
82
68
|
outData = newData;
|
|
83
69
|
}
|
|
84
|
-
/* eslint-disable camelcase */
|
|
85
|
-
|
|
86
70
|
|
|
71
|
+
/* eslint-disable camelcase */
|
|
87
72
|
this.strm.input = null;
|
|
88
73
|
this.strm.avail_in = 0;
|
|
89
74
|
this.strm.next_in = 0;
|
|
@@ -92,8 +77,6 @@ var Deflator = /*#__PURE__*/function () {
|
|
|
92
77
|
return outData;
|
|
93
78
|
}
|
|
94
79
|
}]);
|
|
95
|
-
|
|
96
80
|
return Deflator;
|
|
97
81
|
}();
|
|
98
|
-
|
|
99
82
|
exports["default"] = Deflator;
|
package/lib/des.js
CHANGED
|
@@ -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
|
* Ported from Flashlight VNC ActionScript implementation:
|
|
16
12
|
* http://www.wizhelp.com/flashlight-vnc/
|
|
@@ -89,9 +85,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
89
85
|
*/
|
|
90
86
|
|
|
91
87
|
/* eslint-disable comma-spacing */
|
|
88
|
+
|
|
92
89
|
// Tables, permutations, S-boxes, etc.
|
|
93
90
|
var PC2 = [13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9, 22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1, 40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47, 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31],
|
|
94
|
-
|
|
91
|
+
totrot = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
|
|
95
92
|
var z = 0x0;
|
|
96
93
|
var a, b, c, d, e, f;
|
|
97
94
|
a = 1 << 16;
|
|
@@ -150,51 +147,43 @@ d = 1 << 6;
|
|
|
150
147
|
e = 1 << 12;
|
|
151
148
|
f = d | e;
|
|
152
149
|
var SP8 = [b | f, z | e, a | z, c | f, b | z, b | f, z | d, b | z, a | d, c | z, c | f, a | e, c | e, a | f, z | e, z | d, c | z, b | d, b | e, z | f, a | e, a | d, c | d, c | e, z | f, z | z, z | z, c | d, b | d, b | e, a | f, a | z, a | f, a | z, c | e, z | e, z | d, c | d, z | e, a | f, b | e, z | d, b | d, c | z, c | d, b | z, a | z, b | f, z | z, c | f, a | d, b | d, c | z, b | e, b | f, z | z, c | f, a | e, a | e, z | f, z | f, a | d, b | z, c | e];
|
|
153
|
-
/* eslint-enable comma-spacing */
|
|
154
150
|
|
|
151
|
+
/* eslint-enable comma-spacing */
|
|
155
152
|
var DES = /*#__PURE__*/function () {
|
|
156
153
|
function DES(password) {
|
|
157
154
|
_classCallCheck(this, DES);
|
|
155
|
+
this.keys = [];
|
|
158
156
|
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
// Set the key.
|
|
161
158
|
var pc1m = [],
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
pcr = [],
|
|
160
|
+
kn = [];
|
|
165
161
|
for (var j = 0, l = 56; j < 56; ++j, l -= 8) {
|
|
166
162
|
l += l < -5 ? 65 : l < -3 ? 31 : l < -1 ? 63 : l === 27 ? 35 : 0; // PC1
|
|
167
|
-
|
|
168
163
|
var m = l & 0x7;
|
|
169
164
|
pc1m[j] = (password[l >>> 3] & 1 << m) !== 0 ? 1 : 0;
|
|
170
165
|
}
|
|
171
|
-
|
|
172
166
|
for (var i = 0; i < 16; ++i) {
|
|
173
167
|
var _m = i << 1;
|
|
174
|
-
|
|
175
168
|
var n = _m + 1;
|
|
176
169
|
kn[_m] = kn[n] = 0;
|
|
177
|
-
|
|
178
170
|
for (var o = 28; o < 59; o += 28) {
|
|
179
171
|
for (var _j = o - 28; _j < o; ++_j) {
|
|
180
172
|
var _l = _j + totrot[i];
|
|
181
|
-
|
|
182
173
|
pcr[_j] = _l < o ? pc1m[_l] : pc1m[_l - 28];
|
|
183
174
|
}
|
|
184
175
|
}
|
|
185
|
-
|
|
186
176
|
for (var _j2 = 0; _j2 < 24; ++_j2) {
|
|
187
177
|
if (pcr[PC2[_j2]] !== 0) {
|
|
188
178
|
kn[_m] |= 1 << 23 - _j2;
|
|
189
179
|
}
|
|
190
|
-
|
|
191
180
|
if (pcr[PC2[_j2 + 24]] !== 0) {
|
|
192
181
|
kn[n] |= 1 << 23 - _j2;
|
|
193
182
|
}
|
|
194
183
|
}
|
|
195
|
-
}
|
|
196
|
-
|
|
184
|
+
}
|
|
197
185
|
|
|
186
|
+
// cookey
|
|
198
187
|
for (var _i = 0, rawi = 0, KnLi = 0; _i < 16; ++_i) {
|
|
199
188
|
var raw0 = kn[rawi++];
|
|
200
189
|
var raw1 = kn[rawi++];
|
|
@@ -209,19 +198,19 @@ var DES = /*#__PURE__*/function () {
|
|
|
209
198
|
this.keys[KnLi] |= raw1 & 0x0000003f;
|
|
210
199
|
++KnLi;
|
|
211
200
|
}
|
|
212
|
-
}
|
|
213
|
-
|
|
201
|
+
}
|
|
214
202
|
|
|
203
|
+
// Encrypt 8 bytes of text
|
|
215
204
|
_createClass(DES, [{
|
|
216
205
|
key: "enc8",
|
|
217
206
|
value: function enc8(text) {
|
|
218
207
|
var b = text.slice();
|
|
219
208
|
var i = 0,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
// Squash 8 bytes to 2 ints
|
|
209
|
+
l,
|
|
210
|
+
r,
|
|
211
|
+
x; // left, right, accumulator
|
|
224
212
|
|
|
213
|
+
// Squash 8 bytes to 2 ints
|
|
225
214
|
l = b[i++] << 24 | b[i++] << 16 | b[i++] << 8 | b[i++];
|
|
226
215
|
r = b[i++] << 24 | b[i++] << 16 | b[i++] << 8 | b[i++];
|
|
227
216
|
x = (l >>> 4 ^ r) & 0x0f0f0f0f;
|
|
@@ -241,7 +230,6 @@ var DES = /*#__PURE__*/function () {
|
|
|
241
230
|
l ^= x;
|
|
242
231
|
r ^= x;
|
|
243
232
|
l = l << 1 | l >>> 31 & 1;
|
|
244
|
-
|
|
245
233
|
for (var _i2 = 0, keysi = 0; _i2 < 8; ++_i2) {
|
|
246
234
|
x = r << 28 | r >>> 4;
|
|
247
235
|
x ^= this.keys[keysi++];
|
|
@@ -268,7 +256,6 @@ var DES = /*#__PURE__*/function () {
|
|
|
268
256
|
fval |= SP2[x >>> 24 & 0x3f];
|
|
269
257
|
r ^= fval;
|
|
270
258
|
}
|
|
271
|
-
|
|
272
259
|
r = r << 31 | r >>> 1;
|
|
273
260
|
x = (l ^ r) & 0xaaaaaaaa;
|
|
274
261
|
l ^= x;
|
|
@@ -285,30 +272,27 @@ var DES = /*#__PURE__*/function () {
|
|
|
285
272
|
r ^= x << 16;
|
|
286
273
|
x = (r >>> 4 ^ l) & 0x0f0f0f0f;
|
|
287
274
|
l ^= x;
|
|
288
|
-
r ^= x << 4;
|
|
275
|
+
r ^= x << 4;
|
|
289
276
|
|
|
277
|
+
// Spread ints to bytes
|
|
290
278
|
x = [r, l];
|
|
291
|
-
|
|
292
279
|
for (i = 0; i < 8; i++) {
|
|
293
280
|
b[i] = (x[i >>> 2] >>> 8 * (3 - i % 4)) % 256;
|
|
294
|
-
|
|
295
281
|
if (b[i] < 0) {
|
|
296
282
|
b[i] += 256;
|
|
297
283
|
} // unsigned
|
|
298
|
-
|
|
299
284
|
}
|
|
300
285
|
|
|
301
286
|
return b;
|
|
302
|
-
}
|
|
287
|
+
}
|
|
303
288
|
|
|
289
|
+
// Encrypt 16 bytes of text using passwd as key
|
|
304
290
|
}, {
|
|
305
291
|
key: "encrypt",
|
|
306
292
|
value: function encrypt(t) {
|
|
307
293
|
return this.enc8(t.slice(0, 8)).concat(this.enc8(t.slice(8, 16)));
|
|
308
294
|
}
|
|
309
295
|
}]);
|
|
310
|
-
|
|
311
296
|
return DES;
|
|
312
297
|
}();
|
|
313
|
-
|
|
314
298
|
exports["default"] = DES;
|