pdfjs-dist 2.2.228 → 2.6.347

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.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (229) hide show
  1. package/README.md +4 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +8816 -19300
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +22 -1
  6. package/build/pdf.worker.entry.js +5 -3
  7. package/build/pdf.worker.js +27185 -35746
  8. package/build/pdf.worker.js.map +1 -1
  9. package/build/pdf.worker.min.js +22 -1
  10. package/es5/build/pdf.js +26665 -0
  11. package/es5/build/pdf.js.map +1 -0
  12. package/es5/build/pdf.min.js +22 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +61231 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/build/pdf.worker.min.js +22 -0
  17. package/es5/image_decoders/pdf.image_decoders.js +12529 -0
  18. package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
  19. package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
  20. package/es5/web/images/annotation-check.svg +11 -0
  21. package/es5/web/images/annotation-comment.svg +16 -0
  22. package/es5/web/images/annotation-help.svg +26 -0
  23. package/es5/web/images/annotation-insert.svg +10 -0
  24. package/es5/web/images/annotation-key.svg +11 -0
  25. package/es5/web/images/annotation-newparagraph.svg +11 -0
  26. package/es5/web/images/annotation-noicon.svg +7 -0
  27. package/es5/web/images/annotation-note.svg +42 -0
  28. package/es5/web/images/annotation-paragraph.svg +16 -0
  29. package/es5/web/images/loading-icon.gif +0 -0
  30. package/es5/web/images/shadow.png +0 -0
  31. package/es5/web/pdf_viewer.css +406 -0
  32. package/es5/web/pdf_viewer.js +7886 -0
  33. package/es5/web/pdf_viewer.js.map +1 -0
  34. package/image_decoders/pdf.image_decoders.js +1498 -4832
  35. package/image_decoders/pdf.image_decoders.js.map +1 -1
  36. package/image_decoders/pdf.image_decoders.min.js +22 -1
  37. package/lib/README.md +7 -0
  38. package/lib/core/annotation.js +1144 -927
  39. package/lib/core/arithmetic_decoder.js +81 -97
  40. package/lib/core/bidi.js +54 -46
  41. package/lib/core/ccitt.js +88 -81
  42. package/lib/core/ccitt_stream.js +15 -14
  43. package/lib/core/cff_parser.js +747 -716
  44. package/lib/core/charsets.js +4 -4
  45. package/lib/core/chunked_stream.js +462 -553
  46. package/lib/core/cmap.js +231 -277
  47. package/lib/core/colorspace.js +715 -857
  48. package/lib/core/core_utils.js +57 -52
  49. package/lib/core/crypto.js +416 -437
  50. package/lib/core/document.js +629 -670
  51. package/lib/core/encodings.js +15 -15
  52. package/lib/core/evaluator.js +3229 -2800
  53. package/lib/core/font_renderer.js +135 -178
  54. package/lib/core/fonts.js +602 -534
  55. package/lib/core/function.js +355 -279
  56. package/lib/core/glyphlist.js +4527 -4526
  57. package/lib/core/image.js +442 -439
  58. package/lib/core/image_utils.js +221 -61
  59. package/lib/core/jbig2.js +325 -316
  60. package/lib/core/jbig2_stream.js +18 -17
  61. package/lib/core/jpeg_stream.js +21 -26
  62. package/lib/core/jpg.js +289 -233
  63. package/lib/core/jpx.js +161 -143
  64. package/lib/core/jpx_stream.js +28 -28
  65. package/lib/core/metrics.js +2928 -2928
  66. package/lib/core/murmurhash3.js +87 -102
  67. package/lib/core/obj.js +1343 -1300
  68. package/lib/core/operator_list.js +90 -67
  69. package/lib/core/parser.js +990 -987
  70. package/lib/core/pattern.js +105 -77
  71. package/lib/core/pdf_manager.js +149 -316
  72. package/lib/core/primitives.js +156 -104
  73. package/lib/core/ps_parser.js +175 -214
  74. package/lib/core/standard_fonts.js +237 -236
  75. package/lib/core/stream.js +94 -74
  76. package/lib/core/type1_parser.js +89 -69
  77. package/lib/core/unicode.js +1654 -1654
  78. package/lib/core/worker.js +275 -290
  79. package/lib/core/worker_stream.js +101 -210
  80. package/lib/core/writer.js +242 -0
  81. package/lib/display/annotation_layer.js +772 -1041
  82. package/lib/display/annotation_storage.js +89 -0
  83. package/lib/display/api.js +1575 -1868
  84. package/lib/display/api_compatibility.js +12 -17
  85. package/lib/display/canvas.js +370 -222
  86. package/lib/display/content_disposition.js +40 -59
  87. package/lib/display/display_utils.js +341 -536
  88. package/lib/display/fetch_stream.js +188 -304
  89. package/lib/display/font_loader.js +282 -414
  90. package/lib/display/metadata.js +81 -99
  91. package/lib/display/network.js +362 -511
  92. package/lib/display/network_utils.js +25 -18
  93. package/lib/display/node_stream.js +283 -465
  94. package/lib/display/node_utils.js +87 -0
  95. package/lib/display/optional_content_config.js +184 -0
  96. package/lib/display/pattern_helper.js +93 -44
  97. package/lib/display/svg.js +1163 -1401
  98. package/lib/display/text_layer.js +154 -137
  99. package/lib/display/transport_stream.js +237 -375
  100. package/lib/display/webgl.js +70 -83
  101. package/lib/display/worker_options.js +3 -3
  102. package/lib/display/xml_parser.js +303 -392
  103. package/lib/examples/node/domstubs.js +37 -37
  104. package/lib/pdf.js +220 -58
  105. package/lib/pdf.worker.js +14 -6
  106. package/lib/shared/compatibility.js +3 -246
  107. package/lib/shared/is_node.js +7 -6
  108. package/lib/shared/message_handler.js +327 -332
  109. package/lib/shared/util.js +271 -306
  110. package/lib/test/unit/annotation_spec.js +1902 -763
  111. package/lib/test/unit/annotation_storage_spec.js +83 -0
  112. package/lib/test/unit/api_spec.js +790 -592
  113. package/lib/test/unit/bidi_spec.js +7 -7
  114. package/lib/test/unit/cff_parser_spec.js +73 -72
  115. package/lib/test/unit/clitests_helper.js +7 -9
  116. package/lib/test/unit/cmap_spec.js +86 -88
  117. package/lib/test/unit/colorspace_spec.js +346 -154
  118. package/lib/test/unit/core_utils_spec.js +125 -105
  119. package/lib/test/unit/crypto_spec.js +232 -185
  120. package/lib/test/unit/custom_spec.js +150 -24
  121. package/lib/test/unit/display_svg_spec.js +34 -39
  122. package/lib/test/unit/display_utils_spec.js +139 -149
  123. package/lib/test/unit/document_spec.js +128 -17
  124. package/lib/test/unit/encodings_spec.js +12 -34
  125. package/lib/test/unit/evaluator_spec.js +112 -91
  126. package/lib/test/unit/fetch_stream_spec.js +31 -29
  127. package/lib/test/unit/function_spec.js +206 -204
  128. package/lib/test/unit/jasmine-boot.js +48 -32
  129. package/lib/test/unit/message_handler_spec.js +173 -159
  130. package/lib/test/unit/metadata_spec.js +71 -71
  131. package/lib/test/unit/murmurhash3_spec.js +12 -12
  132. package/lib/test/unit/network_spec.js +13 -11
  133. package/lib/test/unit/network_utils_spec.js +158 -144
  134. package/lib/test/unit/node_stream_spec.js +76 -90
  135. package/lib/test/unit/parser_spec.js +108 -114
  136. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  137. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  138. package/lib/test/unit/pdf_history_spec.js +32 -32
  139. package/lib/test/unit/primitives_spec.js +337 -156
  140. package/lib/test/unit/stream_spec.js +16 -14
  141. package/lib/test/unit/test_utils.js +91 -304
  142. package/lib/test/unit/testreporter.js +33 -22
  143. package/lib/test/unit/type1_parser_spec.js +42 -42
  144. package/lib/test/unit/ui_utils_spec.js +299 -461
  145. package/lib/test/unit/unicode_spec.js +42 -42
  146. package/lib/test/unit/util_spec.js +129 -149
  147. package/lib/test/unit/writer_spec.js +84 -0
  148. package/lib/web/annotation_layer_builder.js +78 -111
  149. package/lib/web/app.js +1542 -1267
  150. package/lib/web/app_options.js +76 -91
  151. package/lib/web/base_tree_viewer.js +100 -0
  152. package/lib/web/base_viewer.js +869 -834
  153. package/lib/web/chromecom.js +165 -252
  154. package/lib/web/debugger.js +149 -205
  155. package/lib/web/download_manager.js +34 -58
  156. package/lib/web/firefox_print_service.js +62 -34
  157. package/lib/web/firefoxcom.js +206 -374
  158. package/lib/web/genericcom.js +26 -108
  159. package/lib/web/genericl10n.js +24 -153
  160. package/lib/web/grab_to_pan.js +30 -30
  161. package/lib/web/interfaces.js +80 -254
  162. package/lib/web/overlay_manager.js +70 -246
  163. package/lib/web/password_prompt.js +38 -64
  164. package/lib/web/pdf_attachment_viewer.js +150 -126
  165. package/lib/web/pdf_cursor_tools.js +75 -102
  166. package/lib/web/pdf_document_properties.js +229 -383
  167. package/lib/web/pdf_find_bar.js +136 -170
  168. package/lib/web/pdf_find_controller.js +492 -548
  169. package/lib/web/pdf_find_utils.js +13 -13
  170. package/lib/web/pdf_history.js +397 -406
  171. package/lib/web/pdf_layer_viewer.js +208 -0
  172. package/lib/web/pdf_link_service.js +304 -348
  173. package/lib/web/pdf_outline_viewer.js +119 -212
  174. package/lib/web/pdf_page_view.js +474 -513
  175. package/lib/web/pdf_presentation_mode.js +308 -357
  176. package/lib/web/pdf_print_service.js +96 -110
  177. package/lib/web/pdf_rendering_queue.js +87 -108
  178. package/lib/web/pdf_sidebar.js +286 -302
  179. package/lib/web/pdf_sidebar_resizer.js +92 -119
  180. package/lib/web/pdf_single_page_viewer.js +77 -126
  181. package/lib/web/pdf_thumbnail_view.js +289 -297
  182. package/lib/web/pdf_thumbnail_viewer.js +202 -206
  183. package/lib/web/pdf_viewer.component.js +20 -21
  184. package/lib/web/pdf_viewer.js +55 -115
  185. package/lib/web/preferences.js +69 -273
  186. package/lib/web/secondary_toolbar.js +164 -196
  187. package/lib/web/text_layer_builder.js +284 -319
  188. package/lib/web/toolbar.js +217 -210
  189. package/lib/web/ui_utils.js +274 -421
  190. package/lib/web/view_history.js +52 -226
  191. package/lib/web/viewer_compatibility.js +21 -6
  192. package/package.json +4 -9
  193. package/types/display/annotation_layer.d.ts +61 -0
  194. package/types/display/annotation_storage.d.ts +36 -0
  195. package/types/display/api.d.ts +1107 -0
  196. package/types/display/api_compatibility.d.ts +1 -0
  197. package/types/display/canvas.d.ts +4 -0
  198. package/types/display/content_disposition.d.ts +7 -0
  199. package/types/display/display_utils.d.ts +243 -0
  200. package/types/display/fetch_stream.d.ts +67 -0
  201. package/types/display/font_loader.d.ts +19 -0
  202. package/types/display/metadata.d.ts +9 -0
  203. package/types/display/network.d.ts +80 -0
  204. package/types/display/network_utils.d.ts +14 -0
  205. package/types/display/node_stream.d.ts +72 -0
  206. package/types/display/node_utils.d.ts +6 -0
  207. package/types/display/optional_content_config.d.ts +12 -0
  208. package/types/display/pattern_helper.d.ts +5 -0
  209. package/types/display/svg.d.ts +2 -0
  210. package/types/display/text_layer.d.ts +83 -0
  211. package/types/display/transport_stream.d.ts +57 -0
  212. package/types/display/webgl.d.ts +20 -0
  213. package/types/display/worker_options.d.ts +27 -0
  214. package/types/display/xml_parser.d.ts +35 -0
  215. package/types/pdf.d.ts +33 -0
  216. package/types/shared/compatibility.d.ts +1 -0
  217. package/types/shared/is_node.d.ts +1 -0
  218. package/types/shared/message_handler.d.ts +62 -0
  219. package/types/shared/util.d.ts +421 -0
  220. package/web/images/shadow.png +0 -0
  221. package/web/pdf_viewer.css +29 -27
  222. package/web/pdf_viewer.js +3524 -4746
  223. package/web/pdf_viewer.js.map +1 -1
  224. package/webpack.js +6 -5
  225. package/external/streams/streams-lib.js +0 -3962
  226. package/external/url/url-lib.js +0 -627
  227. package/lib/shared/streams_polyfill.js +0 -43
  228. package/lib/shared/url_polyfill.js +0 -56
  229. package/web/images/texture.png +0 -0
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2019 Mozilla Foundation
5
+ * Copyright 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -26,29 +26,11 @@ Object.defineProperty(exports, "__esModule", {
26
26
  });
27
27
  exports.calculateSHA512 = exports.calculateSHA384 = exports.calculateSHA256 = exports.calculateMD5 = exports.PDF20 = exports.PDF17 = exports.CipherTransformFactory = exports.ARCFourCipher = exports.AES256Cipher = exports.AES128Cipher = void 0;
28
28
 
29
- var _util = require("../shared/util");
29
+ var _util = require("../shared/util.js");
30
30
 
31
- var _primitives = require("./primitives");
31
+ var _primitives = require("./primitives.js");
32
32
 
33
- var _stream = require("./stream");
34
-
35
- function _typeof(obj) { 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); }
36
-
37
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
38
-
39
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
40
-
41
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
42
-
43
- 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); }
44
-
45
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
46
-
47
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
48
-
49
- 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); } }
50
-
51
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
33
+ var _stream = require("./stream.js");
52
34
 
53
35
  var ARCFourCipher = function ARCFourCipherClosure() {
54
36
  function ARCFourCipher(key) {
@@ -66,7 +48,7 @@ var ARCFourCipher = function ARCFourCipherClosure() {
66
48
 
67
49
  for (i = 0; i < 256; ++i) {
68
50
  tmp = s[i];
69
- j = j + tmp + key[i % keyLength] & 0xFF;
51
+ j = j + tmp + key[i % keyLength] & 0xff;
70
52
  s[i] = s[j];
71
53
  s[j] = tmp;
72
54
  }
@@ -86,13 +68,13 @@ var ARCFourCipher = function ARCFourCipherClosure() {
86
68
  var output = new Uint8Array(n);
87
69
 
88
70
  for (i = 0; i < n; ++i) {
89
- a = a + 1 & 0xFF;
71
+ a = a + 1 & 0xff;
90
72
  tmp = s[a];
91
- b = b + tmp & 0xFF;
73
+ b = b + tmp & 0xff;
92
74
  tmp2 = s[b];
93
75
  s[a] = tmp2;
94
76
  s[b] = tmp;
95
- output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
77
+ output[i] = data[i] ^ s[tmp + tmp2 & 0xff];
96
78
  }
97
79
 
98
80
  this.a = a;
@@ -101,6 +83,7 @@ var ARCFourCipher = function ARCFourCipherClosure() {
101
83
  }
102
84
  };
103
85
  ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
86
+ ARCFourCipher.prototype.encrypt = ARCFourCipher.prototype.encryptBlock;
104
87
  return ARCFourCipher;
105
88
  }();
106
89
 
@@ -130,11 +113,11 @@ var calculateMD5 = function calculateMD5Closure() {
130
113
  padded[i++] = 0;
131
114
  }
132
115
 
133
- padded[i++] = length << 3 & 0xFF;
134
- padded[i++] = length >> 5 & 0xFF;
135
- padded[i++] = length >> 13 & 0xFF;
136
- padded[i++] = length >> 21 & 0xFF;
137
- padded[i++] = length >>> 29 & 0xFF;
116
+ padded[i++] = length << 3 & 0xff;
117
+ padded[i++] = length >> 5 & 0xff;
118
+ padded[i++] = length >> 13 & 0xff;
119
+ padded[i++] = length >> 21 & 0xff;
120
+ padded[i++] = length >>> 29 & 0xff;
138
121
  padded[i++] = 0;
139
122
  padded[i++] = 0;
140
123
  padded[i++] = 0;
@@ -250,7 +233,7 @@ var Word64 = function Word64Closure() {
250
233
  var lowAdd = (this.low >>> 0) + (word.low >>> 0);
251
234
  var highAdd = (this.high >>> 0) + (word.high >>> 0);
252
235
 
253
- if (lowAdd > 0xFFFFFFFF) {
236
+ if (lowAdd > 0xffffffff) {
254
237
  highAdd += 1;
255
238
  }
256
239
 
@@ -258,14 +241,14 @@ var Word64 = function Word64Closure() {
258
241
  this.high = highAdd | 0;
259
242
  },
260
243
  copyTo: function Word64_copyTo(bytes, offset) {
261
- bytes[offset] = this.high >>> 24 & 0xFF;
262
- bytes[offset + 1] = this.high >> 16 & 0xFF;
263
- bytes[offset + 2] = this.high >> 8 & 0xFF;
264
- bytes[offset + 3] = this.high & 0xFF;
265
- bytes[offset + 4] = this.low >>> 24 & 0xFF;
266
- bytes[offset + 5] = this.low >> 16 & 0xFF;
267
- bytes[offset + 6] = this.low >> 8 & 0xFF;
268
- bytes[offset + 7] = this.low & 0xFF;
244
+ bytes[offset] = this.high >>> 24 & 0xff;
245
+ bytes[offset + 1] = this.high >> 16 & 0xff;
246
+ bytes[offset + 2] = this.high >> 8 & 0xff;
247
+ bytes[offset + 3] = this.high & 0xff;
248
+ bytes[offset + 4] = this.low >>> 24 & 0xff;
249
+ bytes[offset + 5] = this.low >> 16 & 0xff;
250
+ bytes[offset + 6] = this.low >> 8 & 0xff;
251
+ bytes[offset + 7] = this.low & 0xff;
269
252
  },
270
253
  assign: function Word64_assign(word) {
271
254
  this.high = word.high;
@@ -333,11 +316,11 @@ var calculateSHA256 = function calculateSHA256Closure() {
333
316
  padded[i++] = 0;
334
317
  padded[i++] = 0;
335
318
  padded[i++] = 0;
336
- padded[i++] = length >>> 29 & 0xFF;
337
- padded[i++] = length >> 21 & 0xFF;
338
- padded[i++] = length >> 13 & 0xFF;
339
- padded[i++] = length >> 5 & 0xFF;
340
- padded[i++] = length << 3 & 0xFF;
319
+ padded[i++] = length >>> 29 & 0xff;
320
+ padded[i++] = length >> 21 & 0xff;
321
+ padded[i++] = length >> 13 & 0xff;
322
+ padded[i++] = length >> 5 & 0xff;
323
+ padded[i++] = length << 3 & 0xff;
341
324
  var w = new Uint32Array(64);
342
325
 
343
326
  for (i = 0; i < paddedLength;) {
@@ -509,11 +492,11 @@ var calculateSHA512 = function calculateSHA512Closure() {
509
492
  padded[i++] = 0;
510
493
  padded[i++] = 0;
511
494
  padded[i++] = 0;
512
- padded[i++] = length >>> 29 & 0xFF;
513
- padded[i++] = length >> 21 & 0xFF;
514
- padded[i++] = length >> 13 & 0xFF;
515
- padded[i++] = length >> 5 & 0xFF;
516
- padded[i++] = length << 3 & 0xFF;
495
+ padded[i++] = length >>> 29 & 0xff;
496
+ padded[i++] = length >> 21 & 0xff;
497
+ padded[i++] = length >> 13 & 0xff;
498
+ padded[i++] = length >> 5 & 0xff;
499
+ padded[i++] = length << 3 & 0xff;
517
500
  var w = new Array(80);
518
501
 
519
502
  for (i = 0; i < 80; i++) {
@@ -640,19 +623,18 @@ var NullCipher = function NullCipherClosure() {
640
623
  NullCipher.prototype = {
641
624
  decryptBlock: function NullCipher_decryptBlock(data) {
642
625
  return data;
626
+ },
627
+ encrypt: function NullCipher_encrypt(data) {
628
+ return data;
643
629
  }
644
630
  };
645
631
  return NullCipher;
646
632
  }();
647
633
 
648
- var AESBaseCipher =
649
- /*#__PURE__*/
650
- function () {
651
- function AESBaseCipher() {
652
- _classCallCheck(this, AESBaseCipher);
653
-
634
+ class AESBaseCipher {
635
+ constructor() {
654
636
  if (this.constructor === AESBaseCipher) {
655
- (0, _util.unreachable)('Cannot initialize AESBaseCipher.');
637
+ (0, _util.unreachable)("Cannot initialize AESBaseCipher.");
656
638
  }
657
639
 
658
640
  this._s = new Uint8Array([0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]);
@@ -660,7 +642,7 @@ function () {
660
642
  this._mix = new Uint32Array([0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]);
661
643
  this._mixCol = new Uint8Array(256);
662
644
 
663
- for (var i = 0; i < 256; i++) {
645
+ for (let i = 0; i < 256; i++) {
664
646
  if (i < 128) {
665
647
  this._mixCol[i] = i << 1;
666
648
  } else {
@@ -672,63 +654,20 @@ function () {
672
654
  this.bufferPosition = 0;
673
655
  }
674
656
 
675
- _createClass(AESBaseCipher, [{
676
- key: "_expandKey",
677
- value: function _expandKey(cipherKey) {
678
- (0, _util.unreachable)('Cannot call `_expandKey` on the base class');
679
- }
680
- }, {
681
- key: "_decrypt",
682
- value: function _decrypt(input, key) {
683
- var t, u, v;
684
- var state = new Uint8Array(16);
685
- state.set(input);
686
-
687
- for (var j = 0, k = this._keySize; j < 16; ++j, ++k) {
688
- state[j] ^= key[k];
689
- }
690
-
691
- for (var i = this._cyclesOfRepetition - 1; i >= 1; --i) {
692
- t = state[13];
693
- state[13] = state[9];
694
- state[9] = state[5];
695
- state[5] = state[1];
696
- state[1] = t;
697
- t = state[14];
698
- u = state[10];
699
- state[14] = state[6];
700
- state[10] = state[2];
701
- state[6] = t;
702
- state[2] = u;
703
- t = state[15];
704
- u = state[11];
705
- v = state[7];
706
- state[15] = state[3];
707
- state[11] = t;
708
- state[7] = u;
709
- state[3] = v;
710
-
711
- for (var _j = 0; _j < 16; ++_j) {
712
- state[_j] = this._inv_s[state[_j]];
713
- }
657
+ _expandKey(cipherKey) {
658
+ (0, _util.unreachable)("Cannot call `_expandKey` on the base class");
659
+ }
714
660
 
715
- for (var _j2 = 0, _k = i * 16; _j2 < 16; ++_j2, ++_k) {
716
- state[_j2] ^= key[_k];
717
- }
661
+ _decrypt(input, key) {
662
+ let t, u, v;
663
+ const state = new Uint8Array(16);
664
+ state.set(input);
718
665
 
719
- for (var _j3 = 0; _j3 < 16; _j3 += 4) {
720
- var s0 = this._mix[state[_j3]];
721
- var s1 = this._mix[state[_j3 + 1]];
722
- var s2 = this._mix[state[_j3 + 2]];
723
- var s3 = this._mix[state[_j3 + 3]];
724
- t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
725
- state[_j3] = t >>> 24 & 0xFF;
726
- state[_j3 + 1] = t >> 16 & 0xFF;
727
- state[_j3 + 2] = t >> 8 & 0xFF;
728
- state[_j3 + 3] = t & 0xFF;
729
- }
730
- }
666
+ for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
667
+ state[j] ^= key[k];
668
+ }
731
669
 
670
+ for (let i = this._cyclesOfRepetition - 1; i >= 1; --i) {
732
671
  t = state[13];
733
672
  state[13] = state[9];
734
673
  state[9] = state[5];
@@ -748,68 +687,67 @@ function () {
748
687
  state[7] = u;
749
688
  state[3] = v;
750
689
 
751
- for (var _j4 = 0; _j4 < 16; ++_j4) {
752
- state[_j4] = this._inv_s[state[_j4]];
753
- state[_j4] ^= key[_j4];
690
+ for (let j = 0; j < 16; ++j) {
691
+ state[j] = this._inv_s[state[j]];
754
692
  }
755
693
 
756
- return state;
757
- }
758
- }, {
759
- key: "_encrypt",
760
- value: function _encrypt(input, key) {
761
- var s = this._s;
762
- var t, u, v;
763
- var state = new Uint8Array(16);
764
- state.set(input);
694
+ for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
695
+ state[j] ^= key[k];
696
+ }
765
697
 
766
- for (var j = 0; j < 16; ++j) {
767
- state[j] ^= key[j];
698
+ for (let j = 0; j < 16; j += 4) {
699
+ const s0 = this._mix[state[j]];
700
+ const s1 = this._mix[state[j + 1]];
701
+ const s2 = this._mix[state[j + 2]];
702
+ const s3 = this._mix[state[j + 3]];
703
+ t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
704
+ state[j] = t >>> 24 & 0xff;
705
+ state[j + 1] = t >> 16 & 0xff;
706
+ state[j + 2] = t >> 8 & 0xff;
707
+ state[j + 3] = t & 0xff;
768
708
  }
709
+ }
769
710
 
770
- for (var i = 1; i < this._cyclesOfRepetition; i++) {
771
- for (var _j5 = 0; _j5 < 16; ++_j5) {
772
- state[_j5] = s[state[_j5]];
773
- }
711
+ t = state[13];
712
+ state[13] = state[9];
713
+ state[9] = state[5];
714
+ state[5] = state[1];
715
+ state[1] = t;
716
+ t = state[14];
717
+ u = state[10];
718
+ state[14] = state[6];
719
+ state[10] = state[2];
720
+ state[6] = t;
721
+ state[2] = u;
722
+ t = state[15];
723
+ u = state[11];
724
+ v = state[7];
725
+ state[15] = state[3];
726
+ state[11] = t;
727
+ state[7] = u;
728
+ state[3] = v;
729
+
730
+ for (let j = 0; j < 16; ++j) {
731
+ state[j] = this._inv_s[state[j]];
732
+ state[j] ^= key[j];
733
+ }
734
+
735
+ return state;
736
+ }
774
737
 
775
- v = state[1];
776
- state[1] = state[5];
777
- state[5] = state[9];
778
- state[9] = state[13];
779
- state[13] = v;
780
- v = state[2];
781
- u = state[6];
782
- state[2] = state[10];
783
- state[6] = state[14];
784
- state[10] = v;
785
- state[14] = u;
786
- v = state[3];
787
- u = state[7];
788
- t = state[11];
789
- state[3] = state[15];
790
- state[7] = v;
791
- state[11] = u;
792
- state[15] = t;
793
-
794
- for (var _j6 = 0; _j6 < 16; _j6 += 4) {
795
- var s0 = state[_j6 + 0];
796
- var s1 = state[_j6 + 1];
797
- var s2 = state[_j6 + 2];
798
- var s3 = state[_j6 + 3];
799
- t = s0 ^ s1 ^ s2 ^ s3;
800
- state[_j6 + 0] ^= t ^ this._mixCol[s0 ^ s1];
801
- state[_j6 + 1] ^= t ^ this._mixCol[s1 ^ s2];
802
- state[_j6 + 2] ^= t ^ this._mixCol[s2 ^ s3];
803
- state[_j6 + 3] ^= t ^ this._mixCol[s3 ^ s0];
804
- }
738
+ _encrypt(input, key) {
739
+ const s = this._s;
740
+ let t, u, v;
741
+ const state = new Uint8Array(16);
742
+ state.set(input);
805
743
 
806
- for (var _j7 = 0, k = i * 16; _j7 < 16; ++_j7, ++k) {
807
- state[_j7] ^= key[k];
808
- }
809
- }
744
+ for (let j = 0; j < 16; ++j) {
745
+ state[j] ^= key[j];
746
+ }
810
747
 
811
- for (var _j8 = 0; _j8 < 16; ++_j8) {
812
- state[_j8] = s[state[_j8]];
748
+ for (let i = 1; i < this._cyclesOfRepetition; i++) {
749
+ for (let j = 0; j < 16; ++j) {
750
+ state[j] = s[state[j]];
813
751
  }
814
752
 
815
753
  v = state[1];
@@ -831,285 +769,293 @@ function () {
831
769
  state[11] = u;
832
770
  state[15] = t;
833
771
 
834
- for (var _j9 = 0, _k2 = this._keySize; _j9 < 16; ++_j9, ++_k2) {
835
- state[_j9] ^= key[_k2];
772
+ for (let j = 0; j < 16; j += 4) {
773
+ const s0 = state[j + 0];
774
+ const s1 = state[j + 1];
775
+ const s2 = state[j + 2];
776
+ const s3 = state[j + 3];
777
+ t = s0 ^ s1 ^ s2 ^ s3;
778
+ state[j + 0] ^= t ^ this._mixCol[s0 ^ s1];
779
+ state[j + 1] ^= t ^ this._mixCol[s1 ^ s2];
780
+ state[j + 2] ^= t ^ this._mixCol[s2 ^ s3];
781
+ state[j + 3] ^= t ^ this._mixCol[s3 ^ s0];
836
782
  }
837
783
 
838
- return state;
784
+ for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
785
+ state[j] ^= key[k];
786
+ }
839
787
  }
840
- }, {
841
- key: "_decryptBlock2",
842
- value: function _decryptBlock2(data, finalize) {
843
- var sourceLength = data.length;
844
- var buffer = this.buffer,
845
- bufferLength = this.bufferPosition;
846
- var result = [],
847
- iv = this.iv;
848
788
 
849
- for (var i = 0; i < sourceLength; ++i) {
850
- buffer[bufferLength] = data[i];
851
- ++bufferLength;
789
+ for (let j = 0; j < 16; ++j) {
790
+ state[j] = s[state[j]];
791
+ }
852
792
 
853
- if (bufferLength < 16) {
854
- continue;
855
- }
793
+ v = state[1];
794
+ state[1] = state[5];
795
+ state[5] = state[9];
796
+ state[9] = state[13];
797
+ state[13] = v;
798
+ v = state[2];
799
+ u = state[6];
800
+ state[2] = state[10];
801
+ state[6] = state[14];
802
+ state[10] = v;
803
+ state[14] = u;
804
+ v = state[3];
805
+ u = state[7];
806
+ t = state[11];
807
+ state[3] = state[15];
808
+ state[7] = v;
809
+ state[11] = u;
810
+ state[15] = t;
856
811
 
857
- var plain = this._decrypt(buffer, this._key);
812
+ for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
813
+ state[j] ^= key[k];
814
+ }
858
815
 
859
- for (var j = 0; j < 16; ++j) {
860
- plain[j] ^= iv[j];
861
- }
816
+ return state;
817
+ }
818
+
819
+ _decryptBlock2(data, finalize) {
820
+ const sourceLength = data.length;
821
+ let buffer = this.buffer,
822
+ bufferLength = this.bufferPosition;
823
+ const result = [];
824
+ let iv = this.iv;
825
+
826
+ for (let i = 0; i < sourceLength; ++i) {
827
+ buffer[bufferLength] = data[i];
828
+ ++bufferLength;
862
829
 
863
- iv = buffer;
864
- result.push(plain);
865
- buffer = new Uint8Array(16);
866
- bufferLength = 0;
830
+ if (bufferLength < 16) {
831
+ continue;
867
832
  }
868
833
 
869
- this.buffer = buffer;
870
- this.bufferLength = bufferLength;
871
- this.iv = iv;
834
+ const plain = this._decrypt(buffer, this._key);
872
835
 
873
- if (result.length === 0) {
874
- return new Uint8Array(0);
836
+ for (let j = 0; j < 16; ++j) {
837
+ plain[j] ^= iv[j];
875
838
  }
876
839
 
877
- var outputLength = 16 * result.length;
840
+ iv = buffer;
841
+ result.push(plain);
842
+ buffer = new Uint8Array(16);
843
+ bufferLength = 0;
844
+ }
845
+
846
+ this.buffer = buffer;
847
+ this.bufferLength = bufferLength;
848
+ this.iv = iv;
878
849
 
879
- if (finalize) {
880
- var lastBlock = result[result.length - 1];
881
- var psLen = lastBlock[15];
850
+ if (result.length === 0) {
851
+ return new Uint8Array(0);
852
+ }
882
853
 
883
- if (psLen <= 16) {
884
- for (var _i = 15, ii = 16 - psLen; _i >= ii; --_i) {
885
- if (lastBlock[_i] !== psLen) {
886
- psLen = 0;
887
- break;
888
- }
889
- }
854
+ let outputLength = 16 * result.length;
890
855
 
891
- outputLength -= psLen;
892
- result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
893
- }
894
- }
856
+ if (finalize) {
857
+ const lastBlock = result[result.length - 1];
858
+ let psLen = lastBlock[15];
895
859
 
896
- var output = new Uint8Array(outputLength);
860
+ if (psLen <= 16) {
861
+ for (let i = 15, ii = 16 - psLen; i >= ii; --i) {
862
+ if (lastBlock[i] !== psLen) {
863
+ psLen = 0;
864
+ break;
865
+ }
866
+ }
897
867
 
898
- for (var _i2 = 0, _j10 = 0, _ii = result.length; _i2 < _ii; ++_i2, _j10 += 16) {
899
- output.set(result[_i2], _j10);
868
+ outputLength -= psLen;
869
+ result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
900
870
  }
871
+ }
901
872
 
902
- return output;
873
+ const output = new Uint8Array(outputLength);
874
+
875
+ for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
876
+ output.set(result[i], j);
903
877
  }
904
- }, {
905
- key: "decryptBlock",
906
- value: function decryptBlock(data, finalize) {
907
- var iv = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
908
- var sourceLength = data.length;
909
- var buffer = this.buffer,
910
- bufferLength = this.bufferPosition;
911
878
 
912
- if (iv) {
913
- this.iv = iv;
914
- } else {
915
- for (var i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
916
- buffer[bufferLength] = data[i];
917
- }
879
+ return output;
880
+ }
918
881
 
919
- if (bufferLength < 16) {
920
- this.bufferLength = bufferLength;
921
- return new Uint8Array(0);
922
- }
882
+ decryptBlock(data, finalize, iv = null) {
883
+ const sourceLength = data.length;
884
+ const buffer = this.buffer;
885
+ let bufferLength = this.bufferPosition;
923
886
 
924
- this.iv = buffer;
925
- data = data.subarray(16);
887
+ if (iv) {
888
+ this.iv = iv;
889
+ } else {
890
+ for (let i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
891
+ buffer[bufferLength] = data[i];
926
892
  }
927
893
 
928
- this.buffer = new Uint8Array(16);
929
- this.bufferLength = 0;
930
- this.decryptBlock = this._decryptBlock2;
931
- return this.decryptBlock(data, finalize);
932
- }
933
- }, {
934
- key: "encrypt",
935
- value: function encrypt(data, iv) {
936
- var sourceLength = data.length;
937
- var buffer = this.buffer,
938
- bufferLength = this.bufferPosition;
939
- var result = [];
940
-
941
- if (!iv) {
942
- iv = new Uint8Array(16);
894
+ if (bufferLength < 16) {
895
+ this.bufferLength = bufferLength;
896
+ return new Uint8Array(0);
943
897
  }
944
898
 
945
- for (var i = 0; i < sourceLength; ++i) {
946
- buffer[bufferLength] = data[i];
947
- ++bufferLength;
899
+ this.iv = buffer;
900
+ data = data.subarray(16);
901
+ }
948
902
 
949
- if (bufferLength < 16) {
950
- continue;
951
- }
903
+ this.buffer = new Uint8Array(16);
904
+ this.bufferLength = 0;
905
+ this.decryptBlock = this._decryptBlock2;
906
+ return this.decryptBlock(data, finalize);
907
+ }
952
908
 
953
- for (var j = 0; j < 16; ++j) {
954
- buffer[j] ^= iv[j];
955
- }
909
+ encrypt(data, iv) {
910
+ const sourceLength = data.length;
911
+ let buffer = this.buffer,
912
+ bufferLength = this.bufferPosition;
913
+ const result = [];
956
914
 
957
- var cipher = this._encrypt(buffer, this._key);
915
+ if (!iv) {
916
+ iv = new Uint8Array(16);
917
+ }
958
918
 
959
- iv = cipher;
960
- result.push(cipher);
961
- buffer = new Uint8Array(16);
962
- bufferLength = 0;
963
- }
919
+ for (let i = 0; i < sourceLength; ++i) {
920
+ buffer[bufferLength] = data[i];
921
+ ++bufferLength;
964
922
 
965
- this.buffer = buffer;
966
- this.bufferLength = bufferLength;
967
- this.iv = iv;
923
+ if (bufferLength < 16) {
924
+ continue;
925
+ }
968
926
 
969
- if (result.length === 0) {
970
- return new Uint8Array(0);
927
+ for (let j = 0; j < 16; ++j) {
928
+ buffer[j] ^= iv[j];
971
929
  }
972
930
 
973
- var outputLength = 16 * result.length;
974
- var output = new Uint8Array(outputLength);
931
+ const cipher = this._encrypt(buffer, this._key);
975
932
 
976
- for (var _i3 = 0, _j11 = 0, ii = result.length; _i3 < ii; ++_i3, _j11 += 16) {
977
- output.set(result[_i3], _j11);
978
- }
933
+ iv = cipher;
934
+ result.push(cipher);
935
+ buffer = new Uint8Array(16);
936
+ bufferLength = 0;
937
+ }
979
938
 
980
- return output;
939
+ this.buffer = buffer;
940
+ this.bufferLength = bufferLength;
941
+ this.iv = iv;
942
+
943
+ if (result.length === 0) {
944
+ return new Uint8Array(0);
981
945
  }
982
- }]);
983
946
 
984
- return AESBaseCipher;
985
- }();
947
+ const outputLength = 16 * result.length;
948
+ const output = new Uint8Array(outputLength);
986
949
 
987
- var AES128Cipher =
988
- /*#__PURE__*/
989
- function (_AESBaseCipher) {
990
- _inherits(AES128Cipher, _AESBaseCipher);
950
+ for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
951
+ output.set(result[i], j);
952
+ }
991
953
 
992
- function AES128Cipher(key) {
993
- var _this;
954
+ return output;
955
+ }
994
956
 
995
- _classCallCheck(this, AES128Cipher);
957
+ }
996
958
 
997
- _this = _possibleConstructorReturn(this, _getPrototypeOf(AES128Cipher).call(this));
998
- _this._cyclesOfRepetition = 10;
999
- _this._keySize = 160;
1000
- _this._rcon = new Uint8Array([0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d]);
1001
- _this._key = _this._expandKey(key);
1002
- return _this;
959
+ class AES128Cipher extends AESBaseCipher {
960
+ constructor(key) {
961
+ super();
962
+ this._cyclesOfRepetition = 10;
963
+ this._keySize = 160;
964
+ this._rcon = new Uint8Array([0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d]);
965
+ this._key = this._expandKey(key);
1003
966
  }
1004
967
 
1005
- _createClass(AES128Cipher, [{
1006
- key: "_expandKey",
1007
- value: function _expandKey(cipherKey) {
1008
- var b = 176;
1009
- var s = this._s;
1010
- var rcon = this._rcon;
1011
- var result = new Uint8Array(b);
1012
- result.set(cipherKey);
1013
-
1014
- for (var j = 16, i = 1; j < b; ++i) {
1015
- var t1 = result[j - 3];
1016
- var t2 = result[j - 2];
1017
- var t3 = result[j - 1];
1018
- var t4 = result[j - 4];
1019
- t1 = s[t1];
1020
- t2 = s[t2];
1021
- t3 = s[t3];
1022
- t4 = s[t4];
1023
- t1 = t1 ^ rcon[i];
1024
-
1025
- for (var n = 0; n < 4; ++n) {
1026
- result[j] = t1 ^= result[j - 16];
1027
- j++;
1028
- result[j] = t2 ^= result[j - 16];
1029
- j++;
1030
- result[j] = t3 ^= result[j - 16];
1031
- j++;
1032
- result[j] = t4 ^= result[j - 16];
1033
- j++;
1034
- }
968
+ _expandKey(cipherKey) {
969
+ const b = 176;
970
+ const s = this._s;
971
+ const rcon = this._rcon;
972
+ const result = new Uint8Array(b);
973
+ result.set(cipherKey);
974
+
975
+ for (let j = 16, i = 1; j < b; ++i) {
976
+ let t1 = result[j - 3];
977
+ let t2 = result[j - 2];
978
+ let t3 = result[j - 1];
979
+ let t4 = result[j - 4];
980
+ t1 = s[t1];
981
+ t2 = s[t2];
982
+ t3 = s[t3];
983
+ t4 = s[t4];
984
+ t1 = t1 ^ rcon[i];
985
+
986
+ for (let n = 0; n < 4; ++n) {
987
+ result[j] = t1 ^= result[j - 16];
988
+ j++;
989
+ result[j] = t2 ^= result[j - 16];
990
+ j++;
991
+ result[j] = t3 ^= result[j - 16];
992
+ j++;
993
+ result[j] = t4 ^= result[j - 16];
994
+ j++;
1035
995
  }
1036
-
1037
- return result;
1038
996
  }
1039
- }]);
1040
-
1041
- return AES128Cipher;
1042
- }(AESBaseCipher);
1043
997
 
1044
- exports.AES128Cipher = AES128Cipher;
1045
-
1046
- var AES256Cipher =
1047
- /*#__PURE__*/
1048
- function (_AESBaseCipher2) {
1049
- _inherits(AES256Cipher, _AESBaseCipher2);
998
+ return result;
999
+ }
1050
1000
 
1051
- function AES256Cipher(key) {
1052
- var _this2;
1001
+ }
1053
1002
 
1054
- _classCallCheck(this, AES256Cipher);
1003
+ exports.AES128Cipher = AES128Cipher;
1055
1004
 
1056
- _this2 = _possibleConstructorReturn(this, _getPrototypeOf(AES256Cipher).call(this));
1057
- _this2._cyclesOfRepetition = 14;
1058
- _this2._keySize = 224;
1059
- _this2._key = _this2._expandKey(key);
1060
- return _this2;
1005
+ class AES256Cipher extends AESBaseCipher {
1006
+ constructor(key) {
1007
+ super();
1008
+ this._cyclesOfRepetition = 14;
1009
+ this._keySize = 224;
1010
+ this._key = this._expandKey(key);
1061
1011
  }
1062
1012
 
1063
- _createClass(AES256Cipher, [{
1064
- key: "_expandKey",
1065
- value: function _expandKey(cipherKey) {
1066
- var b = 240;
1067
- var s = this._s;
1068
- var result = new Uint8Array(b);
1069
- result.set(cipherKey);
1070
- var r = 1;
1071
- var t1, t2, t3, t4;
1072
-
1073
- for (var j = 32, i = 1; j < b; ++i) {
1074
- if (j % 32 === 16) {
1075
- t1 = s[t1];
1076
- t2 = s[t2];
1077
- t3 = s[t3];
1078
- t4 = s[t4];
1079
- } else if (j % 32 === 0) {
1080
- t1 = result[j - 3];
1081
- t2 = result[j - 2];
1082
- t3 = result[j - 1];
1083
- t4 = result[j - 4];
1084
- t1 = s[t1];
1085
- t2 = s[t2];
1086
- t3 = s[t3];
1087
- t4 = s[t4];
1088
- t1 = t1 ^ r;
1089
-
1090
- if ((r <<= 1) >= 256) {
1091
- r = (r ^ 0x1b) & 0xFF;
1092
- }
1093
- }
1013
+ _expandKey(cipherKey) {
1014
+ const b = 240;
1015
+ const s = this._s;
1016
+ const result = new Uint8Array(b);
1017
+ result.set(cipherKey);
1018
+ let r = 1;
1019
+ let t1, t2, t3, t4;
1094
1020
 
1095
- for (var n = 0; n < 4; ++n) {
1096
- result[j] = t1 ^= result[j - 32];
1097
- j++;
1098
- result[j] = t2 ^= result[j - 32];
1099
- j++;
1100
- result[j] = t3 ^= result[j - 32];
1101
- j++;
1102
- result[j] = t4 ^= result[j - 32];
1103
- j++;
1021
+ for (let j = 32, i = 1; j < b; ++i) {
1022
+ if (j % 32 === 16) {
1023
+ t1 = s[t1];
1024
+ t2 = s[t2];
1025
+ t3 = s[t3];
1026
+ t4 = s[t4];
1027
+ } else if (j % 32 === 0) {
1028
+ t1 = result[j - 3];
1029
+ t2 = result[j - 2];
1030
+ t3 = result[j - 1];
1031
+ t4 = result[j - 4];
1032
+ t1 = s[t1];
1033
+ t2 = s[t2];
1034
+ t3 = s[t3];
1035
+ t4 = s[t4];
1036
+ t1 = t1 ^ r;
1037
+
1038
+ if ((r <<= 1) >= 256) {
1039
+ r = (r ^ 0x1b) & 0xff;
1104
1040
  }
1105
1041
  }
1106
1042
 
1107
- return result;
1043
+ for (let n = 0; n < 4; ++n) {
1044
+ result[j] = t1 ^= result[j - 32];
1045
+ j++;
1046
+ result[j] = t2 ^= result[j - 32];
1047
+ j++;
1048
+ result[j] = t3 ^= result[j - 32];
1049
+ j++;
1050
+ result[j] = t4 ^= result[j - 32];
1051
+ j++;
1052
+ }
1108
1053
  }
1109
- }]);
1110
1054
 
1111
- return AES256Cipher;
1112
- }(AESBaseCipher);
1055
+ return result;
1056
+ }
1057
+
1058
+ }
1113
1059
 
1114
1060
  exports.AES256Cipher = AES256Cipher;
1115
1061
 
@@ -1293,6 +1239,39 @@ var CipherTransform = function CipherTransformClosure() {
1293
1239
  var data = (0, _util.stringToBytes)(s);
1294
1240
  data = cipher.decryptBlock(data, true);
1295
1241
  return (0, _util.bytesToString)(data);
1242
+ },
1243
+ encryptString: function CipherTransform_encryptString(s) {
1244
+ const cipher = new this.StringCipherConstructor();
1245
+
1246
+ if (cipher instanceof AESBaseCipher) {
1247
+ const strLen = s.length;
1248
+ const pad = 16 - strLen % 16;
1249
+
1250
+ if (pad !== 16) {
1251
+ s = s.padEnd(16 * Math.ceil(strLen / 16), String.fromCharCode(pad));
1252
+ }
1253
+
1254
+ const iv = new Uint8Array(16);
1255
+
1256
+ if (typeof crypto !== "undefined") {
1257
+ crypto.getRandomValues(iv);
1258
+ } else {
1259
+ for (let i = 0; i < 16; i++) {
1260
+ iv[i] = Math.floor(256 * Math.random());
1261
+ }
1262
+ }
1263
+
1264
+ let data = (0, _util.stringToBytes)(s);
1265
+ data = cipher.encrypt(data, iv);
1266
+ const buf = new Uint8Array(16 + data.length);
1267
+ buf.set(iv);
1268
+ buf.set(data, 16);
1269
+ return (0, _util.bytesToString)(buf);
1270
+ }
1271
+
1272
+ let data = (0, _util.stringToBytes)(s);
1273
+ data = cipher.encrypt(data);
1274
+ return (0, _util.bytesToString)(data);
1296
1275
  }
1297
1276
  };
1298
1277
  return CipherTransform;
@@ -1351,20 +1330,20 @@ var CipherTransformFactory = function CipherTransformFactoryClosure() {
1351
1330
  hashData[i++] = ownerPassword[j];
1352
1331
  }
1353
1332
 
1354
- hashData[i++] = flags & 0xFF;
1355
- hashData[i++] = flags >> 8 & 0xFF;
1356
- hashData[i++] = flags >> 16 & 0xFF;
1357
- hashData[i++] = flags >>> 24 & 0xFF;
1333
+ hashData[i++] = flags & 0xff;
1334
+ hashData[i++] = flags >> 8 & 0xff;
1335
+ hashData[i++] = flags >> 16 & 0xff;
1336
+ hashData[i++] = flags >>> 24 & 0xff;
1358
1337
 
1359
1338
  for (j = 0, n = fileId.length; j < n; ++j) {
1360
1339
  hashData[i++] = fileId[j];
1361
1340
  }
1362
1341
 
1363
1342
  if (revision >= 4 && !encryptMetadata) {
1364
- hashData[i++] = 0xFF;
1365
- hashData[i++] = 0xFF;
1366
- hashData[i++] = 0xFF;
1367
- hashData[i++] = 0xFF;
1343
+ hashData[i++] = 0xff;
1344
+ hashData[i++] = 0xff;
1345
+ hashData[i++] = 0xff;
1346
+ hashData[i++] = 0xff;
1368
1347
  }
1369
1348
 
1370
1349
  var hash = calculateMD5(hashData, 0, i);
@@ -1471,36 +1450,36 @@ var CipherTransformFactory = function CipherTransformFactoryClosure() {
1471
1450
  return userPassword;
1472
1451
  }
1473
1452
 
1474
- var identityName = _primitives.Name.get('Identity');
1453
+ var identityName = _primitives.Name.get("Identity");
1475
1454
 
1476
1455
  function CipherTransformFactory(dict, fileId, password) {
1477
- var filter = dict.get('Filter');
1456
+ var filter = dict.get("Filter");
1478
1457
 
1479
- if (!(0, _primitives.isName)(filter, 'Standard')) {
1480
- throw new _util.FormatError('unknown encryption method');
1458
+ if (!(0, _primitives.isName)(filter, "Standard")) {
1459
+ throw new _util.FormatError("unknown encryption method");
1481
1460
  }
1482
1461
 
1483
1462
  this.dict = dict;
1484
- var algorithm = dict.get('V');
1463
+ var algorithm = dict.get("V");
1485
1464
 
1486
1465
  if (!Number.isInteger(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
1487
- throw new _util.FormatError('unsupported encryption algorithm');
1466
+ throw new _util.FormatError("unsupported encryption algorithm");
1488
1467
  }
1489
1468
 
1490
1469
  this.algorithm = algorithm;
1491
- var keyLength = dict.get('Length');
1470
+ var keyLength = dict.get("Length");
1492
1471
 
1493
1472
  if (!keyLength) {
1494
1473
  if (algorithm <= 3) {
1495
1474
  keyLength = 40;
1496
1475
  } else {
1497
- var cfDict = dict.get('CF');
1498
- var streamCryptoName = dict.get('StmF');
1476
+ var cfDict = dict.get("CF");
1477
+ var streamCryptoName = dict.get("StmF");
1499
1478
 
1500
1479
  if ((0, _primitives.isDict)(cfDict) && (0, _primitives.isName)(streamCryptoName)) {
1501
1480
  cfDict.suppressEncryption = true;
1502
1481
  var handlerDict = cfDict.get(streamCryptoName.name);
1503
- keyLength = handlerDict && handlerDict.get('Length') || 128;
1482
+ keyLength = handlerDict && handlerDict.get("Length") || 128;
1504
1483
 
1505
1484
  if (keyLength < 40) {
1506
1485
  keyLength <<= 3;
@@ -1510,14 +1489,14 @@ var CipherTransformFactory = function CipherTransformFactoryClosure() {
1510
1489
  }
1511
1490
 
1512
1491
  if (!Number.isInteger(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
1513
- throw new _util.FormatError('invalid key length');
1492
+ throw new _util.FormatError("invalid key length");
1514
1493
  }
1515
1494
 
1516
- var ownerPassword = (0, _util.stringToBytes)(dict.get('O')).subarray(0, 32);
1517
- var userPassword = (0, _util.stringToBytes)(dict.get('U')).subarray(0, 32);
1518
- var flags = dict.get('P');
1519
- var revision = dict.get('R');
1520
- var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
1495
+ var ownerPassword = (0, _util.stringToBytes)(dict.get("O")).subarray(0, 32);
1496
+ var userPassword = (0, _util.stringToBytes)(dict.get("U")).subarray(0, 32);
1497
+ var flags = dict.get("P");
1498
+ var revision = dict.get("R");
1499
+ var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get("EncryptMetadata") !== false;
1521
1500
  this.encryptMetadata = encryptMetadata;
1522
1501
  var fileIdBytes = (0, _util.stringToBytes)(fileId);
1523
1502
  var passwordBytes;
@@ -1527,7 +1506,7 @@ var CipherTransformFactory = function CipherTransformFactoryClosure() {
1527
1506
  try {
1528
1507
  password = (0, _util.utf8StringToString)(password);
1529
1508
  } catch (ex) {
1530
- (0, _util.warn)('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
1509
+ (0, _util.warn)("CipherTransformFactory: " + "Unable to convert UTF8 encoded password.");
1531
1510
  }
1532
1511
  }
1533
1512
 
@@ -1539,41 +1518,41 @@ var CipherTransformFactory = function CipherTransformFactoryClosure() {
1539
1518
  if (algorithm !== 5) {
1540
1519
  encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
1541
1520
  } else {
1542
- var ownerValidationSalt = (0, _util.stringToBytes)(dict.get('O')).subarray(32, 40);
1543
- var ownerKeySalt = (0, _util.stringToBytes)(dict.get('O')).subarray(40, 48);
1544
- var uBytes = (0, _util.stringToBytes)(dict.get('U')).subarray(0, 48);
1545
- var userValidationSalt = (0, _util.stringToBytes)(dict.get('U')).subarray(32, 40);
1546
- var userKeySalt = (0, _util.stringToBytes)(dict.get('U')).subarray(40, 48);
1547
- var ownerEncryption = (0, _util.stringToBytes)(dict.get('OE'));
1548
- var userEncryption = (0, _util.stringToBytes)(dict.get('UE'));
1549
- var perms = (0, _util.stringToBytes)(dict.get('Perms'));
1521
+ var ownerValidationSalt = (0, _util.stringToBytes)(dict.get("O")).subarray(32, 40);
1522
+ var ownerKeySalt = (0, _util.stringToBytes)(dict.get("O")).subarray(40, 48);
1523
+ var uBytes = (0, _util.stringToBytes)(dict.get("U")).subarray(0, 48);
1524
+ var userValidationSalt = (0, _util.stringToBytes)(dict.get("U")).subarray(32, 40);
1525
+ var userKeySalt = (0, _util.stringToBytes)(dict.get("U")).subarray(40, 48);
1526
+ var ownerEncryption = (0, _util.stringToBytes)(dict.get("OE"));
1527
+ var userEncryption = (0, _util.stringToBytes)(dict.get("UE"));
1528
+ var perms = (0, _util.stringToBytes)(dict.get("Perms"));
1550
1529
  encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
1551
1530
  }
1552
1531
 
1553
1532
  if (!encryptionKey && !password) {
1554
- throw new _util.PasswordException('No password given', _util.PasswordResponses.NEED_PASSWORD);
1533
+ throw new _util.PasswordException("No password given", _util.PasswordResponses.NEED_PASSWORD);
1555
1534
  } else if (!encryptionKey && password) {
1556
1535
  var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
1557
1536
  encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
1558
1537
  }
1559
1538
 
1560
1539
  if (!encryptionKey) {
1561
- throw new _util.PasswordException('Incorrect Password', _util.PasswordResponses.INCORRECT_PASSWORD);
1540
+ throw new _util.PasswordException("Incorrect Password", _util.PasswordResponses.INCORRECT_PASSWORD);
1562
1541
  }
1563
1542
 
1564
1543
  this.encryptionKey = encryptionKey;
1565
1544
 
1566
1545
  if (algorithm >= 4) {
1567
- var cf = dict.get('CF');
1546
+ var cf = dict.get("CF");
1568
1547
 
1569
1548
  if ((0, _primitives.isDict)(cf)) {
1570
1549
  cf.suppressEncryption = true;
1571
1550
  }
1572
1551
 
1573
1552
  this.cf = cf;
1574
- this.stmf = dict.get('StmF') || identityName;
1575
- this.strf = dict.get('StrF') || identityName;
1576
- this.eff = dict.get('EFF') || this.stmf;
1553
+ this.stmf = dict.get("StmF") || identityName;
1554
+ this.strf = dict.get("StrF") || identityName;
1555
+ this.eff = dict.get("EFF") || this.stmf;
1577
1556
  }
1578
1557
  }
1579
1558
 
@@ -1586,16 +1565,16 @@ var CipherTransformFactory = function CipherTransformFactoryClosure() {
1586
1565
  key[i] = encryptionKey[i];
1587
1566
  }
1588
1567
 
1589
- key[i++] = num & 0xFF;
1590
- key[i++] = num >> 8 & 0xFF;
1591
- key[i++] = num >> 16 & 0xFF;
1592
- key[i++] = gen & 0xFF;
1593
- key[i++] = gen >> 8 & 0xFF;
1568
+ key[i++] = num & 0xff;
1569
+ key[i++] = num >> 8 & 0xff;
1570
+ key[i++] = num >> 16 & 0xff;
1571
+ key[i++] = gen & 0xff;
1572
+ key[i++] = gen >> 8 & 0xff;
1594
1573
 
1595
1574
  if (isAes) {
1596
1575
  key[i++] = 0x73;
1597
1576
  key[i++] = 0x41;
1598
- key[i++] = 0x6C;
1577
+ key[i++] = 0x6c;
1599
1578
  key[i++] = 0x54;
1600
1579
  }
1601
1580
 
@@ -1605,41 +1584,41 @@ var CipherTransformFactory = function CipherTransformFactoryClosure() {
1605
1584
 
1606
1585
  function buildCipherConstructor(cf, name, num, gen, key) {
1607
1586
  if (!(0, _primitives.isName)(name)) {
1608
- throw new _util.FormatError('Invalid crypt filter name.');
1587
+ throw new _util.FormatError("Invalid crypt filter name.");
1609
1588
  }
1610
1589
 
1611
1590
  var cryptFilter = cf.get(name.name);
1612
1591
  var cfm;
1613
1592
 
1614
1593
  if (cryptFilter !== null && cryptFilter !== undefined) {
1615
- cfm = cryptFilter.get('CFM');
1594
+ cfm = cryptFilter.get("CFM");
1616
1595
  }
1617
1596
 
1618
- if (!cfm || cfm.name === 'None') {
1597
+ if (!cfm || cfm.name === "None") {
1619
1598
  return function cipherTransformFactoryBuildCipherConstructorNone() {
1620
1599
  return new NullCipher();
1621
1600
  };
1622
1601
  }
1623
1602
 
1624
- if (cfm.name === 'V2') {
1603
+ if (cfm.name === "V2") {
1625
1604
  return function cipherTransformFactoryBuildCipherConstructorV2() {
1626
1605
  return new ARCFourCipher(buildObjectKey(num, gen, key, false));
1627
1606
  };
1628
1607
  }
1629
1608
 
1630
- if (cfm.name === 'AESV2') {
1609
+ if (cfm.name === "AESV2") {
1631
1610
  return function cipherTransformFactoryBuildCipherConstructorAESV2() {
1632
1611
  return new AES128Cipher(buildObjectKey(num, gen, key, true));
1633
1612
  };
1634
1613
  }
1635
1614
 
1636
- if (cfm.name === 'AESV3') {
1615
+ if (cfm.name === "AESV3") {
1637
1616
  return function cipherTransformFactoryBuildCipherConstructorAESV3() {
1638
1617
  return new AES256Cipher(key);
1639
1618
  };
1640
1619
  }
1641
1620
 
1642
- throw new _util.FormatError('Unknown crypto method');
1621
+ throw new _util.FormatError("Unknown crypto method");
1643
1622
  }
1644
1623
 
1645
1624
  CipherTransformFactory.prototype = {