pdfjs-dist 2.6.347 → 2.7.570

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 (158) hide show
  1. package/README.md +3 -3
  2. package/bower.json +1 -1
  3. package/build/pdf.js +2050 -1087
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +1 -1
  6. package/build/pdf.worker.js +18219 -10436
  7. package/build/pdf.worker.js.map +1 -1
  8. package/build/pdf.worker.min.js +1 -1
  9. package/es5/build/pdf.d.ts +1 -0
  10. package/es5/build/pdf.js +6623 -6654
  11. package/es5/build/pdf.js.map +1 -1
  12. package/es5/build/pdf.min.js +1 -1
  13. package/es5/build/pdf.worker.js +20815 -13888
  14. package/es5/build/pdf.worker.js.map +1 -1
  15. package/es5/build/pdf.worker.min.js +1 -1
  16. package/es5/image_decoders/pdf.image_decoders.js +3817 -4946
  17. package/es5/image_decoders/pdf.image_decoders.js.map +1 -1
  18. package/es5/image_decoders/pdf.image_decoders.min.js +1 -1
  19. package/es5/web/pdf_viewer.css +18 -15
  20. package/es5/web/pdf_viewer.js +1094 -514
  21. package/es5/web/pdf_viewer.js.map +1 -1
  22. package/image_decoders/pdf.image_decoders.js +774 -168
  23. package/image_decoders/pdf.image_decoders.js.map +1 -1
  24. package/image_decoders/pdf.image_decoders.min.js +1 -1
  25. package/lib/core/annotation.js +556 -108
  26. package/lib/core/cff_parser.js +7 -1
  27. package/lib/core/charsets.js +1 -1
  28. package/lib/core/cmap.js +20 -1
  29. package/lib/core/core_utils.js +162 -3
  30. package/lib/core/crypto.js +1 -1
  31. package/lib/core/default_appearance.js +132 -0
  32. package/lib/core/document.js +115 -9
  33. package/lib/core/encodings.js +1 -1
  34. package/lib/core/evaluator.js +168 -74
  35. package/lib/core/fonts.js +97 -11
  36. package/lib/core/function.js +5 -10
  37. package/lib/core/glyphlist.js +11 -4529
  38. package/lib/core/image_utils.js +30 -1
  39. package/lib/core/jpg.js +1 -1
  40. package/lib/core/jpx.js +5 -5
  41. package/lib/core/murmurhash3.js +1 -1
  42. package/lib/core/obj.js +123 -39
  43. package/lib/core/pattern.js +4 -4
  44. package/lib/core/primitives.js +24 -5
  45. package/lib/core/standard_fonts.js +1 -1
  46. package/lib/core/stream.js +5 -1
  47. package/lib/core/unicode.js +15 -1387
  48. package/lib/core/worker.js +58 -17
  49. package/lib/core/writer.js +68 -4
  50. package/lib/display/annotation_layer.js +712 -119
  51. package/lib/display/annotation_storage.js +21 -4
  52. package/lib/display/api.js +88 -18
  53. package/lib/display/canvas.js +414 -375
  54. package/lib/display/display_utils.js +11 -4
  55. package/lib/display/fetch_stream.js +3 -3
  56. package/lib/display/font_loader.js +2 -3
  57. package/lib/display/metadata.js +54 -20
  58. package/lib/display/node_stream.js +1 -1
  59. package/lib/display/optional_content_config.js +1 -1
  60. package/lib/display/pattern_helper.js +109 -113
  61. package/lib/display/svg.js +5 -5
  62. package/lib/display/text_layer.js +54 -54
  63. package/lib/display/transport_stream.js +4 -4
  64. package/lib/display/webgl.js +65 -68
  65. package/lib/examples/node/domstubs.js +9 -4
  66. package/lib/pdf.js +2 -2
  67. package/lib/pdf.sandbox.js +311 -0
  68. package/lib/pdf.worker.js +2 -2
  69. package/lib/shared/scripting_utils.js +84 -0
  70. package/lib/shared/util.js +129 -14
  71. package/lib/{display → shared}/xml_parser.js +112 -4
  72. package/lib/test/unit/annotation_spec.js +831 -109
  73. package/lib/test/unit/annotation_storage_spec.js +28 -10
  74. package/lib/test/unit/api_spec.js +190 -160
  75. package/lib/test/unit/bidi_spec.js +6 -6
  76. package/lib/test/unit/cff_parser_spec.js +73 -73
  77. package/lib/test/unit/clitests_helper.js +2 -0
  78. package/lib/test/unit/cmap_spec.js +48 -74
  79. package/lib/test/unit/core_utils_spec.js +34 -0
  80. package/lib/test/unit/crypto_spec.js +162 -199
  81. package/lib/test/unit/custom_spec.js +7 -18
  82. package/lib/test/unit/default_appearance_spec.js +54 -0
  83. package/lib/test/unit/display_svg_spec.js +24 -19
  84. package/lib/test/unit/display_utils_spec.js +1 -1
  85. package/lib/test/unit/document_spec.js +187 -20
  86. package/lib/test/unit/evaluator_spec.js +30 -30
  87. package/lib/test/unit/function_spec.js +165 -165
  88. package/lib/test/unit/jasmine-boot.js +52 -53
  89. package/lib/test/unit/metadata_spec.js +2 -2
  90. package/lib/test/unit/murmurhash3_spec.js +29 -16
  91. package/lib/test/unit/network_spec.js +21 -21
  92. package/lib/test/unit/pdf_find_controller_spec.js +131 -69
  93. package/lib/test/unit/pdf_find_utils_spec.js +10 -10
  94. package/lib/test/unit/scripting_spec.js +1104 -0
  95. package/lib/test/unit/stream_spec.js +8 -8
  96. package/lib/test/unit/test_utils.js +16 -19
  97. package/lib/test/unit/testreporter.js +11 -4
  98. package/lib/test/unit/type1_parser_spec.js +23 -23
  99. package/lib/test/unit/ui_utils_spec.js +78 -35
  100. package/lib/test/unit/unicode_spec.js +7 -7
  101. package/lib/test/unit/util_spec.js +26 -3
  102. package/lib/test/unit/writer_spec.js +16 -1
  103. package/lib/test/unit/xml_spec.js +117 -0
  104. package/lib/web/annotation_layer_builder.js +18 -6
  105. package/lib/web/app.js +579 -161
  106. package/lib/web/app_options.js +14 -0
  107. package/lib/web/base_tree_viewer.js +50 -0
  108. package/lib/web/base_viewer.js +350 -14
  109. package/lib/web/chromecom.js +9 -1
  110. package/lib/web/debugger.js +1 -2
  111. package/lib/web/download_manager.js +0 -15
  112. package/lib/web/firefox_print_service.js +6 -4
  113. package/lib/web/firefoxcom.js +84 -69
  114. package/lib/web/generic_scripting.js +55 -0
  115. package/lib/web/genericcom.js +9 -1
  116. package/lib/web/grab_to_pan.js +1 -1
  117. package/lib/web/interfaces.js +9 -3
  118. package/lib/web/pdf_attachment_viewer.js +1 -3
  119. package/lib/web/pdf_cursor_tools.js +20 -13
  120. package/lib/web/pdf_document_properties.js +48 -61
  121. package/lib/web/pdf_find_bar.js +1 -3
  122. package/lib/web/pdf_find_controller.js +58 -12
  123. package/lib/web/pdf_history.js +43 -21
  124. package/lib/web/pdf_layer_viewer.js +1 -9
  125. package/lib/web/pdf_link_service.js +108 -78
  126. package/lib/web/pdf_outline_viewer.js +166 -10
  127. package/lib/web/pdf_page_view.js +14 -14
  128. package/lib/web/pdf_presentation_mode.js +21 -31
  129. package/lib/web/pdf_rendering_queue.js +8 -1
  130. package/lib/web/pdf_sidebar.js +62 -107
  131. package/lib/web/pdf_sidebar_resizer.js +11 -21
  132. package/lib/web/pdf_single_page_viewer.js +8 -0
  133. package/lib/web/pdf_thumbnail_view.js +26 -26
  134. package/lib/web/pdf_thumbnail_viewer.js +13 -2
  135. package/lib/web/pdf_viewer.component.js +2 -2
  136. package/lib/web/pdf_viewer.js +3 -1
  137. package/lib/web/preferences.js +33 -44
  138. package/lib/web/text_layer_builder.js +2 -9
  139. package/lib/web/ui_utils.js +78 -46
  140. package/lib/web/viewer_compatibility.js +1 -2
  141. package/package.json +4 -1
  142. package/types/display/annotation_layer.d.ts +18 -3
  143. package/types/display/api.d.ts +110 -54
  144. package/types/display/canvas.d.ts +1 -1
  145. package/types/display/display_utils.d.ts +96 -95
  146. package/types/display/fetch_stream.d.ts +2 -2
  147. package/types/display/metadata.d.ts +4 -0
  148. package/types/display/pattern_helper.d.ts +1 -1
  149. package/types/display/text_layer.d.ts +7 -7
  150. package/types/display/transport_stream.d.ts +1 -1
  151. package/types/shared/scripting_utils.d.ts +12 -0
  152. package/types/shared/util.d.ts +281 -250
  153. package/types/shared/xml_parser.d.ts +64 -0
  154. package/web/pdf_viewer.css +18 -15
  155. package/web/pdf_viewer.js +809 -408
  156. package/web/pdf_viewer.js.map +1 -1
  157. package/webpack.js +1 -1
  158. package/types/display/xml_parser.d.ts +0 -35
@@ -29,17 +29,15 @@ var _util = require("../../shared/util.js");
29
29
 
30
30
  describe("crypto", function () {
31
31
  function hex2binary(s) {
32
- var digits = "0123456789ABCDEF";
32
+ const digits = "0123456789ABCDEF";
33
33
  s = s.toUpperCase();
34
- var n = s.length >> 1,
35
- i,
36
- j;
37
- var result = new Uint8Array(n);
34
+ const n = s.length >> 1;
35
+ const result = new Uint8Array(n);
38
36
 
39
- for (i = 0, j = 0; i < n; ++i) {
40
- var d1 = s.charAt(j++);
41
- var d2 = s.charAt(j++);
42
- var value = digits.indexOf(d1) << 4 | digits.indexOf(d2);
37
+ for (let i = 0, j = 0; i < n; ++i) {
38
+ const d1 = s.charAt(j++);
39
+ const d2 = s.charAt(j++);
40
+ const value = digits.indexOf(d1) << 4 | digits.indexOf(d2);
43
41
  result[i] = value;
44
42
  }
45
43
 
@@ -48,189 +46,167 @@ describe("crypto", function () {
48
46
 
49
47
  describe("calculateMD5", function () {
50
48
  it("should pass RFC 1321 test #1", function () {
51
- var input, result, expected;
52
- input = (0, _util.stringToBytes)("");
53
- result = (0, _crypto.calculateMD5)(input, 0, input.length);
54
- expected = hex2binary("d41d8cd98f00b204e9800998ecf8427e");
49
+ const input = (0, _util.stringToBytes)("");
50
+ const result = (0, _crypto.calculateMD5)(input, 0, input.length);
51
+ const expected = hex2binary("d41d8cd98f00b204e9800998ecf8427e");
55
52
  expect(result).toEqual(expected);
56
53
  });
57
54
  it("should pass RFC 1321 test #2", function () {
58
- var input, result, expected;
59
- input = (0, _util.stringToBytes)("a");
60
- result = (0, _crypto.calculateMD5)(input, 0, input.length);
61
- expected = hex2binary("0cc175b9c0f1b6a831c399e269772661");
55
+ const input = (0, _util.stringToBytes)("a");
56
+ const result = (0, _crypto.calculateMD5)(input, 0, input.length);
57
+ const expected = hex2binary("0cc175b9c0f1b6a831c399e269772661");
62
58
  expect(result).toEqual(expected);
63
59
  });
64
60
  it("should pass RFC 1321 test #3", function () {
65
- var input, result, expected;
66
- input = (0, _util.stringToBytes)("abc");
67
- result = (0, _crypto.calculateMD5)(input, 0, input.length);
68
- expected = hex2binary("900150983cd24fb0d6963f7d28e17f72");
61
+ const input = (0, _util.stringToBytes)("abc");
62
+ const result = (0, _crypto.calculateMD5)(input, 0, input.length);
63
+ const expected = hex2binary("900150983cd24fb0d6963f7d28e17f72");
69
64
  expect(result).toEqual(expected);
70
65
  });
71
66
  it("should pass RFC 1321 test #4", function () {
72
- var input, result, expected;
73
- input = (0, _util.stringToBytes)("message digest");
74
- result = (0, _crypto.calculateMD5)(input, 0, input.length);
75
- expected = hex2binary("f96b697d7cb7938d525a2f31aaf161d0");
67
+ const input = (0, _util.stringToBytes)("message digest");
68
+ const result = (0, _crypto.calculateMD5)(input, 0, input.length);
69
+ const expected = hex2binary("f96b697d7cb7938d525a2f31aaf161d0");
76
70
  expect(result).toEqual(expected);
77
71
  });
78
72
  it("should pass RFC 1321 test #5", function () {
79
- var input, result, expected;
80
- input = (0, _util.stringToBytes)("abcdefghijklmnopqrstuvwxyz");
81
- result = (0, _crypto.calculateMD5)(input, 0, input.length);
82
- expected = hex2binary("c3fcd3d76192e4007dfb496cca67e13b");
73
+ const input = (0, _util.stringToBytes)("abcdefghijklmnopqrstuvwxyz");
74
+ const result = (0, _crypto.calculateMD5)(input, 0, input.length);
75
+ const expected = hex2binary("c3fcd3d76192e4007dfb496cca67e13b");
83
76
  expect(result).toEqual(expected);
84
77
  });
85
78
  it("should pass RFC 1321 test #6", function () {
86
- var input, result, expected;
87
- input = (0, _util.stringToBytes)("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
88
- result = (0, _crypto.calculateMD5)(input, 0, input.length);
89
- expected = hex2binary("d174ab98d277d9f5a5611c2c9f419d9f");
79
+ const input = (0, _util.stringToBytes)("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
80
+ const result = (0, _crypto.calculateMD5)(input, 0, input.length);
81
+ const expected = hex2binary("d174ab98d277d9f5a5611c2c9f419d9f");
90
82
  expect(result).toEqual(expected);
91
83
  });
92
84
  it("should pass RFC 1321 test #7", function () {
93
- var input, result, expected;
94
- input = (0, _util.stringToBytes)("123456789012345678901234567890123456789012345678" + "90123456789012345678901234567890");
95
- result = (0, _crypto.calculateMD5)(input, 0, input.length);
96
- expected = hex2binary("57edf4a22be3c955ac49da2e2107b67a");
85
+ const input = (0, _util.stringToBytes)("123456789012345678901234567890123456789012345678" + "90123456789012345678901234567890");
86
+ const result = (0, _crypto.calculateMD5)(input, 0, input.length);
87
+ const expected = hex2binary("57edf4a22be3c955ac49da2e2107b67a");
97
88
  expect(result).toEqual(expected);
98
89
  });
99
90
  });
100
91
  describe("ARCFourCipher", function () {
101
92
  it("should pass test #1", function () {
102
- var key, input, result, expected, cipher;
103
- key = hex2binary("0123456789abcdef");
104
- input = hex2binary("0123456789abcdef");
105
- cipher = new _crypto.ARCFourCipher(key);
106
- result = cipher.encryptBlock(input);
107
- expected = hex2binary("75b7878099e0c596");
93
+ const key = hex2binary("0123456789abcdef");
94
+ const input = hex2binary("0123456789abcdef");
95
+ const cipher = new _crypto.ARCFourCipher(key);
96
+ const result = cipher.encryptBlock(input);
97
+ const expected = hex2binary("75b7878099e0c596");
108
98
  expect(result).toEqual(expected);
109
99
  });
110
100
  it("should pass test #2", function () {
111
- var key, input, result, expected, cipher;
112
- key = hex2binary("0123456789abcdef");
113
- input = hex2binary("0000000000000000");
114
- cipher = new _crypto.ARCFourCipher(key);
115
- result = cipher.encryptBlock(input);
116
- expected = hex2binary("7494c2e7104b0879");
101
+ const key = hex2binary("0123456789abcdef");
102
+ const input = hex2binary("0000000000000000");
103
+ const cipher = new _crypto.ARCFourCipher(key);
104
+ const result = cipher.encryptBlock(input);
105
+ const expected = hex2binary("7494c2e7104b0879");
117
106
  expect(result).toEqual(expected);
118
107
  });
119
108
  it("should pass test #3", function () {
120
- var key, input, result, expected, cipher;
121
- key = hex2binary("0000000000000000");
122
- input = hex2binary("0000000000000000");
123
- cipher = new _crypto.ARCFourCipher(key);
124
- result = cipher.encryptBlock(input);
125
- expected = hex2binary("de188941a3375d3a");
109
+ const key = hex2binary("0000000000000000");
110
+ const input = hex2binary("0000000000000000");
111
+ const cipher = new _crypto.ARCFourCipher(key);
112
+ const result = cipher.encryptBlock(input);
113
+ const expected = hex2binary("de188941a3375d3a");
126
114
  expect(result).toEqual(expected);
127
115
  });
128
116
  it("should pass test #4", function () {
129
- var key, input, result, expected, cipher;
130
- key = hex2binary("ef012345");
131
- input = hex2binary("00000000000000000000");
132
- cipher = new _crypto.ARCFourCipher(key);
133
- result = cipher.encryptBlock(input);
134
- expected = hex2binary("d6a141a7ec3c38dfbd61");
117
+ const key = hex2binary("ef012345");
118
+ const input = hex2binary("00000000000000000000");
119
+ const cipher = new _crypto.ARCFourCipher(key);
120
+ const result = cipher.encryptBlock(input);
121
+ const expected = hex2binary("d6a141a7ec3c38dfbd61");
135
122
  expect(result).toEqual(expected);
136
123
  });
137
124
  it("should pass test #5", function () {
138
- var key, input, result, expected, cipher;
139
- key = hex2binary("0123456789abcdef");
140
- input = hex2binary("010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "101010101010101010101");
141
- cipher = new _crypto.ARCFourCipher(key);
142
- result = cipher.encryptBlock(input);
143
- expected = hex2binary("7595c3e6114a09780c4ad452338e1ffd9a1be9498f813d76" + "533449b6778dcad8c78a8d2ba9ac66085d0e53d59c26c2d1c490c1ebbe0ce66d1b6b" + "1b13b6b919b847c25a91447a95e75e4ef16779cde8bf0a95850e32af9689444fd377" + "108f98fdcbd4e726567500990bcc7e0ca3c4aaa304a387d20f3b8fbbcd42a1bd311d" + "7a4303dda5ab078896ae80c18b0af66dff319616eb784e495ad2ce90d7f772a81747" + "b65f62093b1e0db9e5ba532fafec47508323e671327df9444432cb7367cec82f5d44" + "c0d00b67d650a075cd4b70dedd77eb9b10231b6b5b741347396d62897421d43df9b4" + "2e446e358e9c11a9b2184ecbef0cd8e7a877ef968f1390ec9b3d35a5585cb009290e" + "2fcde7b5ec66d9084be44055a619d9dd7fc3166f9487f7cb272912426445998514c1" + "5d53a18c864ce3a2b7555793988126520eacf2e3066e230c91bee4dd5304f5fd0405" + "b35bd99c73135d3d9bc335ee049ef69b3867bf2d7bd1eaa595d8bfc0066ff8d31509" + "eb0c6caa006c807a623ef84c3d33c195d23ee320c40de0558157c822d4b8c569d849" + "aed59d4e0fd7f379586b4b7ff684ed6a189f7486d49b9c4bad9ba24b96abf924372c" + "8a8fffb10d55354900a77a3db5f205e1b99fcd8660863a159ad4abe40fa48934163d" + "dde542a6585540fd683cbfd8c00f12129a284deacc4cdefe58be7137541c047126c8" + "d49e2755ab181ab7e940b0c0");
125
+ const key = hex2binary("0123456789abcdef");
126
+ const input = hex2binary("010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "101010101010101010101");
127
+ const cipher = new _crypto.ARCFourCipher(key);
128
+ const result = cipher.encryptBlock(input);
129
+ const expected = hex2binary("7595c3e6114a09780c4ad452338e1ffd9a1be9498f813d76" + "533449b6778dcad8c78a8d2ba9ac66085d0e53d59c26c2d1c490c1ebbe0ce66d1b6b" + "1b13b6b919b847c25a91447a95e75e4ef16779cde8bf0a95850e32af9689444fd377" + "108f98fdcbd4e726567500990bcc7e0ca3c4aaa304a387d20f3b8fbbcd42a1bd311d" + "7a4303dda5ab078896ae80c18b0af66dff319616eb784e495ad2ce90d7f772a81747" + "b65f62093b1e0db9e5ba532fafec47508323e671327df9444432cb7367cec82f5d44" + "c0d00b67d650a075cd4b70dedd77eb9b10231b6b5b741347396d62897421d43df9b4" + "2e446e358e9c11a9b2184ecbef0cd8e7a877ef968f1390ec9b3d35a5585cb009290e" + "2fcde7b5ec66d9084be44055a619d9dd7fc3166f9487f7cb272912426445998514c1" + "5d53a18c864ce3a2b7555793988126520eacf2e3066e230c91bee4dd5304f5fd0405" + "b35bd99c73135d3d9bc335ee049ef69b3867bf2d7bd1eaa595d8bfc0066ff8d31509" + "eb0c6caa006c807a623ef84c3d33c195d23ee320c40de0558157c822d4b8c569d849" + "aed59d4e0fd7f379586b4b7ff684ed6a189f7486d49b9c4bad9ba24b96abf924372c" + "8a8fffb10d55354900a77a3db5f205e1b99fcd8660863a159ad4abe40fa48934163d" + "dde542a6585540fd683cbfd8c00f12129a284deacc4cdefe58be7137541c047126c8" + "d49e2755ab181ab7e940b0c0");
144
130
  expect(result).toEqual(expected);
145
131
  });
146
132
  it("should pass test #6", function () {
147
- var key, input, result, expected, cipher;
148
- key = hex2binary("fb029e3031323334");
149
- input = hex2binary("aaaa0300000008004500004e661a00008011be640a0001220af" + "fffff00890089003a000080a601100001000000000000204543454a4548454346434" + "550464545494546464343414341434143414341414100002000011bd0b604");
150
- cipher = new _crypto.ARCFourCipher(key);
151
- result = cipher.encryptBlock(input);
152
- expected = hex2binary("f69c5806bd6ce84626bcbefb9474650aad1f7909b0f64d5f" + "58a503a258b7ed22eb0ea64930d3a056a55742fcce141d485f8aa836dea18df42c53" + "80805ad0c61a5d6f58f41040b24b7d1a693856ed0d4398e7aee3bf0e2a2ca8f7");
133
+ const key = hex2binary("fb029e3031323334");
134
+ const input = hex2binary("aaaa0300000008004500004e661a00008011be640a0001220af" + "fffff00890089003a000080a601100001000000000000204543454a4548454346434" + "550464545494546464343414341434143414341414100002000011bd0b604");
135
+ const cipher = new _crypto.ARCFourCipher(key);
136
+ const result = cipher.encryptBlock(input);
137
+ const expected = hex2binary("f69c5806bd6ce84626bcbefb9474650aad1f7909b0f64d5f" + "58a503a258b7ed22eb0ea64930d3a056a55742fcce141d485f8aa836dea18df42c53" + "80805ad0c61a5d6f58f41040b24b7d1a693856ed0d4398e7aee3bf0e2a2ca8f7");
153
138
  expect(result).toEqual(expected);
154
139
  });
155
140
  it("should pass test #7", function () {
156
- var key, input, result, expected, cipher;
157
- key = hex2binary("0123456789abcdef");
158
- input = hex2binary("123456789abcdef0123456789abcdef0123456789abcdef012345678");
159
- cipher = new _crypto.ARCFourCipher(key);
160
- result = cipher.encryptBlock(input);
161
- expected = hex2binary("66a0949f8af7d6891f7f832ba833c00c892ebe30143ce28740011ecf");
141
+ const key = hex2binary("0123456789abcdef");
142
+ const input = hex2binary("123456789abcdef0123456789abcdef0123456789abcdef012345678");
143
+ const cipher = new _crypto.ARCFourCipher(key);
144
+ const result = cipher.encryptBlock(input);
145
+ const expected = hex2binary("66a0949f8af7d6891f7f832ba833c00c892ebe30143ce28740011ecf");
162
146
  expect(result).toEqual(expected);
163
147
  });
164
148
  });
165
149
  describe("calculateSHA256", function () {
166
150
  it("should properly hash abc", function () {
167
- var input, result, expected;
168
- input = (0, _util.stringToBytes)("abc");
169
- result = (0, _crypto.calculateSHA256)(input, 0, input.length);
170
- expected = hex2binary("BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD");
151
+ const input = (0, _util.stringToBytes)("abc");
152
+ const result = (0, _crypto.calculateSHA256)(input, 0, input.length);
153
+ const expected = hex2binary("BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD");
171
154
  expect(result).toEqual(expected);
172
155
  });
173
156
  it("should properly hash a multiblock input", function () {
174
- var input, result, expected;
175
- input = (0, _util.stringToBytes)("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
176
- result = (0, _crypto.calculateSHA256)(input, 0, input.length);
177
- expected = hex2binary("248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167F6ECEDD419DB06C1");
157
+ const input = (0, _util.stringToBytes)("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
158
+ const result = (0, _crypto.calculateSHA256)(input, 0, input.length);
159
+ const expected = hex2binary("248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167F6ECEDD419DB06C1");
178
160
  expect(result).toEqual(expected);
179
161
  });
180
162
  });
181
163
  describe("calculateSHA384", function () {
182
164
  it("should properly hash abc", function () {
183
- var input, result, expected;
184
- input = (0, _util.stringToBytes)("abc");
185
- result = (0, _crypto.calculateSHA384)(input, 0, input.length);
186
- expected = hex2binary("CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED163" + "1A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7");
165
+ const input = (0, _util.stringToBytes)("abc");
166
+ const result = (0, _crypto.calculateSHA384)(input, 0, input.length);
167
+ const expected = hex2binary("CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED163" + "1A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7");
187
168
  expect(result).toEqual(expected);
188
169
  });
189
170
  it("should properly hash a multiblock input", function () {
190
- var input, result, expected;
191
- input = (0, _util.stringToBytes)("abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" + "ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs" + "mnopqrstnopqrstu");
192
- result = (0, _crypto.calculateSHA384)(input, 0, input.length);
193
- expected = hex2binary("09330C33F71147E83D192FC782CD1B4753111B173B3B05D2" + "2FA08086E3B0F712FCC7C71A557E2DB966C3E9FA91746039");
171
+ const input = (0, _util.stringToBytes)("abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" + "ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs" + "mnopqrstnopqrstu");
172
+ const result = (0, _crypto.calculateSHA384)(input, 0, input.length);
173
+ const expected = hex2binary("09330C33F71147E83D192FC782CD1B4753111B173B3B05D2" + "2FA08086E3B0F712FCC7C71A557E2DB966C3E9FA91746039");
194
174
  expect(result).toEqual(expected);
195
175
  });
196
176
  });
197
177
  describe("calculateSHA512", function () {
198
178
  it("should properly hash abc", function () {
199
- var input, result, expected;
200
- input = (0, _util.stringToBytes)("abc");
201
- result = (0, _crypto.calculateSHA512)(input, 0, input.length);
202
- expected = hex2binary("DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA2" + "0A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD" + "454D4423643CE80E2A9AC94FA54CA49F");
179
+ const input = (0, _util.stringToBytes)("abc");
180
+ const result = (0, _crypto.calculateSHA512)(input, 0, input.length);
181
+ const expected = hex2binary("DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA2" + "0A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD" + "454D4423643CE80E2A9AC94FA54CA49F");
203
182
  expect(result).toEqual(expected);
204
183
  });
205
184
  it("should properly hash a multiblock input", function () {
206
- var input, result, expected;
207
- input = (0, _util.stringToBytes)("abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" + "ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs" + "mnopqrstnopqrstu");
208
- result = (0, _crypto.calculateSHA512)(input, 0, input.length);
209
- expected = hex2binary("8E959B75DAE313DA8CF4F72814FC143F8F7779C6EB9F7FA1" + "7299AEADB6889018501D289E4900F7E4331B99DEC4B5433A" + "C7D329EEB6DD26545E96E55B874BE909");
185
+ const input = (0, _util.stringToBytes)("abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" + "ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs" + "mnopqrstnopqrstu");
186
+ const result = (0, _crypto.calculateSHA512)(input, 0, input.length);
187
+ const expected = hex2binary("8E959B75DAE313DA8CF4F72814FC143F8F7779C6EB9F7FA1" + "7299AEADB6889018501D289E4900F7E4331B99DEC4B5433A" + "C7D329EEB6DD26545E96E55B874BE909");
210
188
  expect(result).toEqual(expected);
211
189
  });
212
190
  });
213
191
  describe("AES128", function () {
214
192
  describe("Encryption", function () {
215
193
  it("should be able to encrypt a block", function () {
216
- var input, key, result, expected, iv, cipher;
217
- input = hex2binary("00112233445566778899aabbccddeeff");
218
- key = hex2binary("000102030405060708090a0b0c0d0e0f");
219
- iv = hex2binary("00000000000000000000000000000000");
220
- cipher = new _crypto.AES128Cipher(key);
221
- result = cipher.encrypt(input, iv);
222
- expected = hex2binary("69c4e0d86a7b0430d8cdb78070b4c55a");
194
+ const input = hex2binary("00112233445566778899aabbccddeeff");
195
+ const key = hex2binary("000102030405060708090a0b0c0d0e0f");
196
+ const iv = hex2binary("00000000000000000000000000000000");
197
+ const cipher = new _crypto.AES128Cipher(key);
198
+ const result = cipher.encrypt(input, iv);
199
+ const expected = hex2binary("69c4e0d86a7b0430d8cdb78070b4c55a");
223
200
  expect(result).toEqual(expected);
224
201
  });
225
202
  });
226
203
  describe("Decryption", function () {
227
204
  it("should be able to decrypt a block with IV in stream", function () {
228
- var input, key, result, expected, cipher;
229
- input = hex2binary("0000000000000000000000000000000069c4e0d86a7b0430d" + "8cdb78070b4c55a");
230
- key = hex2binary("000102030405060708090a0b0c0d0e0f");
231
- cipher = new _crypto.AES128Cipher(key);
232
- result = cipher.decryptBlock(input);
233
- expected = hex2binary("00112233445566778899aabbccddeeff");
205
+ const input = hex2binary("0000000000000000000000000000000069c4e0d86a7b0430d" + "8cdb78070b4c55a");
206
+ const key = hex2binary("000102030405060708090a0b0c0d0e0f");
207
+ const cipher = new _crypto.AES128Cipher(key);
208
+ const result = cipher.decryptBlock(input);
209
+ const expected = hex2binary("00112233445566778899aabbccddeeff");
234
210
  expect(result).toEqual(expected);
235
211
  });
236
212
  });
@@ -238,130 +214,117 @@ describe("crypto", function () {
238
214
  describe("AES256", function () {
239
215
  describe("Encryption", function () {
240
216
  it("should be able to encrypt a block", function () {
241
- var input, key, result, expected, iv, cipher;
242
- input = hex2binary("00112233445566778899aabbccddeeff");
243
- key = hex2binary("000102030405060708090a0b0c0d0e0f101112131415161718" + "191a1b1c1d1e1f");
244
- iv = hex2binary("00000000000000000000000000000000");
245
- cipher = new _crypto.AES256Cipher(key);
246
- result = cipher.encrypt(input, iv);
247
- expected = hex2binary("8ea2b7ca516745bfeafc49904b496089");
217
+ const input = hex2binary("00112233445566778899aabbccddeeff");
218
+ const key = hex2binary("000102030405060708090a0b0c0d0e0f101112131415161718" + "191a1b1c1d1e1f");
219
+ const iv = hex2binary("00000000000000000000000000000000");
220
+ const cipher = new _crypto.AES256Cipher(key);
221
+ const result = cipher.encrypt(input, iv);
222
+ const expected = hex2binary("8ea2b7ca516745bfeafc49904b496089");
248
223
  expect(result).toEqual(expected);
249
224
  });
250
225
  });
251
226
  describe("Decryption", function () {
252
227
  it("should be able to decrypt a block with specified iv", function () {
253
- var input, key, result, expected, cipher, iv;
254
- input = hex2binary("8ea2b7ca516745bfeafc49904b496089");
255
- key = hex2binary("000102030405060708090a0b0c0d0e0f101112131415161718" + "191a1b1c1d1e1f");
256
- iv = hex2binary("00000000000000000000000000000000");
257
- cipher = new _crypto.AES256Cipher(key);
258
- result = cipher.decryptBlock(input, false, iv);
259
- expected = hex2binary("00112233445566778899aabbccddeeff");
228
+ const input = hex2binary("8ea2b7ca516745bfeafc49904b496089");
229
+ const key = hex2binary("000102030405060708090a0b0c0d0e0f101112131415161718" + "191a1b1c1d1e1f");
230
+ const iv = hex2binary("00000000000000000000000000000000");
231
+ const cipher = new _crypto.AES256Cipher(key);
232
+ const result = cipher.decryptBlock(input, false, iv);
233
+ const expected = hex2binary("00112233445566778899aabbccddeeff");
260
234
  expect(result).toEqual(expected);
261
235
  });
262
236
  it("should be able to decrypt a block with IV in stream", function () {
263
- var input, key, result, expected, cipher;
264
- input = hex2binary("000000000000000000000000000000008ea2b7ca516745bf" + "eafc49904b496089");
265
- key = hex2binary("000102030405060708090a0b0c0d0e0f101112131415161718" + "191a1b1c1d1e1f");
266
- cipher = new _crypto.AES256Cipher(key);
267
- result = cipher.decryptBlock(input, false);
268
- expected = hex2binary("00112233445566778899aabbccddeeff");
237
+ const input = hex2binary("000000000000000000000000000000008ea2b7ca516745bf" + "eafc49904b496089");
238
+ const key = hex2binary("000102030405060708090a0b0c0d0e0f101112131415161718" + "191a1b1c1d1e1f");
239
+ const cipher = new _crypto.AES256Cipher(key);
240
+ const result = cipher.decryptBlock(input, false);
241
+ const expected = hex2binary("00112233445566778899aabbccddeeff");
269
242
  expect(result).toEqual(expected);
270
243
  });
271
244
  });
272
245
  });
273
246
  describe("PDF17Algorithm", function () {
274
247
  it("should correctly check a user key", function () {
275
- var password, userValidation, userPassword, alg, result;
276
- alg = new _crypto.PDF17();
277
- password = new Uint8Array([117, 115, 101, 114]);
278
- userValidation = new Uint8Array([117, 169, 4, 32, 159, 101, 22, 220]);
279
- userPassword = new Uint8Array([131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144, 241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187, 221]);
280
- result = alg.checkUserPassword(password, userValidation, userPassword);
248
+ const alg = new _crypto.PDF17();
249
+ const password = new Uint8Array([117, 115, 101, 114]);
250
+ const userValidation = new Uint8Array([117, 169, 4, 32, 159, 101, 22, 220]);
251
+ const userPassword = new Uint8Array([131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144, 241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187, 221]);
252
+ const result = alg.checkUserPassword(password, userValidation, userPassword);
281
253
  expect(result).toEqual(true);
282
254
  });
283
255
  it("should correctly check an owner key", function () {
284
- var password, ownerValidation, ownerPassword, alg, result, uBytes;
285
- alg = new _crypto.PDF17();
286
- password = new Uint8Array([111, 119, 110, 101, 114]);
287
- ownerValidation = new Uint8Array([243, 118, 71, 153, 128, 17, 101, 62]);
288
- ownerPassword = new Uint8Array([60, 98, 137, 35, 51, 101, 200, 152, 210, 178, 226, 228, 134, 205, 163, 24, 204, 126, 177, 36, 106, 50, 36, 125, 210, 172, 171, 120, 222, 108, 139, 115]);
289
- uBytes = new Uint8Array([131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144, 241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187, 221, 117, 169, 4, 32, 159, 101, 22, 220, 168, 94, 215, 192, 100, 38, 188, 40]);
290
- result = alg.checkOwnerPassword(password, ownerValidation, uBytes, ownerPassword);
256
+ const alg = new _crypto.PDF17();
257
+ const password = new Uint8Array([111, 119, 110, 101, 114]);
258
+ const ownerValidation = new Uint8Array([243, 118, 71, 153, 128, 17, 101, 62]);
259
+ const ownerPassword = new Uint8Array([60, 98, 137, 35, 51, 101, 200, 152, 210, 178, 226, 228, 134, 205, 163, 24, 204, 126, 177, 36, 106, 50, 36, 125, 210, 172, 171, 120, 222, 108, 139, 115]);
260
+ const uBytes = new Uint8Array([131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144, 241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187, 221, 117, 169, 4, 32, 159, 101, 22, 220, 168, 94, 215, 192, 100, 38, 188, 40]);
261
+ const result = alg.checkOwnerPassword(password, ownerValidation, uBytes, ownerPassword);
291
262
  expect(result).toEqual(true);
292
263
  });
293
264
  it("should generate a file encryption key from the user key", function () {
294
- var password, userKeySalt, expected, alg, result, userEncryption;
295
- alg = new _crypto.PDF17();
296
- password = new Uint8Array([117, 115, 101, 114]);
297
- userKeySalt = new Uint8Array([168, 94, 215, 192, 100, 38, 188, 40]);
298
- userEncryption = new Uint8Array([35, 150, 195, 169, 245, 51, 51, 255, 158, 158, 33, 242, 231, 75, 125, 190, 25, 126, 172, 114, 195, 244, 137, 245, 234, 165, 42, 74, 60, 38, 17, 17]);
299
- result = alg.getUserKey(password, userKeySalt, userEncryption);
300
- expected = new Uint8Array([63, 114, 136, 209, 87, 61, 12, 30, 249, 1, 186, 144, 254, 248, 163, 153, 151, 51, 133, 10, 80, 152, 206, 15, 72, 187, 231, 33, 224, 239, 13, 213]);
265
+ const alg = new _crypto.PDF17();
266
+ const password = new Uint8Array([117, 115, 101, 114]);
267
+ const userKeySalt = new Uint8Array([168, 94, 215, 192, 100, 38, 188, 40]);
268
+ const userEncryption = new Uint8Array([35, 150, 195, 169, 245, 51, 51, 255, 158, 158, 33, 242, 231, 75, 125, 190, 25, 126, 172, 114, 195, 244, 137, 245, 234, 165, 42, 74, 60, 38, 17, 17]);
269
+ const result = alg.getUserKey(password, userKeySalt, userEncryption);
270
+ const expected = new Uint8Array([63, 114, 136, 209, 87, 61, 12, 30, 249, 1, 186, 144, 254, 248, 163, 153, 151, 51, 133, 10, 80, 152, 206, 15, 72, 187, 231, 33, 224, 239, 13, 213]);
301
271
  expect(result).toEqual(expected);
302
272
  });
303
273
  it("should generate a file encryption key from the owner key", function () {
304
- var password, ownerKeySalt, expected, alg, result, ownerEncryption;
305
- var uBytes;
306
- alg = new _crypto.PDF17();
307
- password = new Uint8Array([111, 119, 110, 101, 114]);
308
- ownerKeySalt = new Uint8Array([200, 245, 242, 12, 218, 123, 24, 120]);
309
- ownerEncryption = new Uint8Array([213, 202, 14, 189, 110, 76, 70, 191, 6, 195, 10, 190, 157, 100, 144, 85, 8, 62, 123, 178, 156, 229, 50, 40, 229, 216, 54, 222, 34, 38, 106, 223]);
310
- uBytes = new Uint8Array([131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144, 241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187, 221, 117, 169, 4, 32, 159, 101, 22, 220, 168, 94, 215, 192, 100, 38, 188, 40]);
311
- result = alg.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
312
- expected = new Uint8Array([63, 114, 136, 209, 87, 61, 12, 30, 249, 1, 186, 144, 254, 248, 163, 153, 151, 51, 133, 10, 80, 152, 206, 15, 72, 187, 231, 33, 224, 239, 13, 213]);
274
+ const alg = new _crypto.PDF17();
275
+ const password = new Uint8Array([111, 119, 110, 101, 114]);
276
+ const ownerKeySalt = new Uint8Array([200, 245, 242, 12, 218, 123, 24, 120]);
277
+ const ownerEncryption = new Uint8Array([213, 202, 14, 189, 110, 76, 70, 191, 6, 195, 10, 190, 157, 100, 144, 85, 8, 62, 123, 178, 156, 229, 50, 40, 229, 216, 54, 222, 34, 38, 106, 223]);
278
+ const uBytes = new Uint8Array([131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144, 241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187, 221, 117, 169, 4, 32, 159, 101, 22, 220, 168, 94, 215, 192, 100, 38, 188, 40]);
279
+ const result = alg.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
280
+ const expected = new Uint8Array([63, 114, 136, 209, 87, 61, 12, 30, 249, 1, 186, 144, 254, 248, 163, 153, 151, 51, 133, 10, 80, 152, 206, 15, 72, 187, 231, 33, 224, 239, 13, 213]);
313
281
  expect(result).toEqual(expected);
314
282
  });
315
283
  });
316
284
  describe("PDF20Algorithm", function () {
317
285
  it("should correctly check a user key", function () {
318
- var password, userValidation, userPassword, alg, result;
319
- alg = new _crypto.PDF20();
320
- password = new Uint8Array([117, 115, 101, 114]);
321
- userValidation = new Uint8Array([83, 245, 146, 101, 198, 247, 34, 198]);
322
- userPassword = new Uint8Array([94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164, 150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95, 184]);
323
- result = alg.checkUserPassword(password, userValidation, userPassword);
286
+ const alg = new _crypto.PDF20();
287
+ const password = new Uint8Array([117, 115, 101, 114]);
288
+ const userValidation = new Uint8Array([83, 245, 146, 101, 198, 247, 34, 198]);
289
+ const userPassword = new Uint8Array([94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164, 150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95, 184]);
290
+ const result = alg.checkUserPassword(password, userValidation, userPassword);
324
291
  expect(result).toEqual(true);
325
292
  });
326
293
  it("should correctly check an owner key", function () {
327
- var password, ownerValidation, ownerPassword, alg, result, uBytes;
328
- alg = new _crypto.PDF20();
329
- password = new Uint8Array([111, 119, 110, 101, 114]);
330
- ownerValidation = new Uint8Array([142, 232, 169, 208, 202, 214, 5, 185]);
331
- ownerPassword = new Uint8Array([88, 232, 62, 54, 245, 26, 245, 209, 137, 123, 221, 72, 199, 49, 37, 217, 31, 74, 115, 167, 127, 158, 176, 77, 45, 163, 87, 47, 39, 90, 217, 141]);
332
- uBytes = new Uint8Array([94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164, 150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95, 184, 83, 245, 146, 101, 198, 247, 34, 198, 191, 11, 16, 94, 237, 216, 20, 175]);
333
- result = alg.checkOwnerPassword(password, ownerValidation, uBytes, ownerPassword);
294
+ const alg = new _crypto.PDF20();
295
+ const password = new Uint8Array([111, 119, 110, 101, 114]);
296
+ const ownerValidation = new Uint8Array([142, 232, 169, 208, 202, 214, 5, 185]);
297
+ const ownerPassword = new Uint8Array([88, 232, 62, 54, 245, 26, 245, 209, 137, 123, 221, 72, 199, 49, 37, 217, 31, 74, 115, 167, 127, 158, 176, 77, 45, 163, 87, 47, 39, 90, 217, 141]);
298
+ const uBytes = new Uint8Array([94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164, 150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95, 184, 83, 245, 146, 101, 198, 247, 34, 198, 191, 11, 16, 94, 237, 216, 20, 175]);
299
+ const result = alg.checkOwnerPassword(password, ownerValidation, uBytes, ownerPassword);
334
300
  expect(result).toEqual(true);
335
301
  });
336
302
  it("should generate a file encryption key from the user key", function () {
337
- var password, userKeySalt, expected, alg, result, userEncryption;
338
- alg = new _crypto.PDF20();
339
- password = new Uint8Array([117, 115, 101, 114]);
340
- userKeySalt = new Uint8Array([191, 11, 16, 94, 237, 216, 20, 175]);
341
- userEncryption = new Uint8Array([121, 208, 2, 181, 230, 89, 156, 60, 253, 143, 212, 28, 84, 180, 196, 177, 173, 128, 221, 107, 46, 20, 94, 186, 135, 51, 95, 24, 20, 223, 254, 36]);
342
- result = alg.getUserKey(password, userKeySalt, userEncryption);
343
- expected = new Uint8Array([42, 218, 213, 39, 73, 91, 72, 79, 67, 38, 248, 133, 18, 189, 61, 34, 107, 79, 29, 56, 59, 181, 213, 118, 113, 34, 65, 210, 87, 174, 22, 239]);
303
+ const alg = new _crypto.PDF20();
304
+ const password = new Uint8Array([117, 115, 101, 114]);
305
+ const userKeySalt = new Uint8Array([191, 11, 16, 94, 237, 216, 20, 175]);
306
+ const userEncryption = new Uint8Array([121, 208, 2, 181, 230, 89, 156, 60, 253, 143, 212, 28, 84, 180, 196, 177, 173, 128, 221, 107, 46, 20, 94, 186, 135, 51, 95, 24, 20, 223, 254, 36]);
307
+ const result = alg.getUserKey(password, userKeySalt, userEncryption);
308
+ const expected = new Uint8Array([42, 218, 213, 39, 73, 91, 72, 79, 67, 38, 248, 133, 18, 189, 61, 34, 107, 79, 29, 56, 59, 181, 213, 118, 113, 34, 65, 210, 87, 174, 22, 239]);
344
309
  expect(result).toEqual(expected);
345
310
  });
346
311
  it("should generate a file encryption key from the owner key", function () {
347
- var password, ownerKeySalt, expected, alg, result, ownerEncryption;
348
- var uBytes;
349
- alg = new _crypto.PDF20();
350
- password = new Uint8Array([111, 119, 110, 101, 114]);
351
- ownerKeySalt = new Uint8Array([29, 208, 185, 46, 11, 76, 135, 149]);
352
- ownerEncryption = new Uint8Array([209, 73, 224, 77, 103, 155, 201, 181, 190, 68, 223, 20, 62, 90, 56, 210, 5, 240, 178, 128, 238, 124, 68, 254, 253, 244, 62, 108, 208, 135, 10, 251]);
353
- uBytes = new Uint8Array([94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164, 150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95, 184, 83, 245, 146, 101, 198, 247, 34, 198, 191, 11, 16, 94, 237, 216, 20, 175]);
354
- result = alg.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
355
- expected = new Uint8Array([42, 218, 213, 39, 73, 91, 72, 79, 67, 38, 248, 133, 18, 189, 61, 34, 107, 79, 29, 56, 59, 181, 213, 118, 113, 34, 65, 210, 87, 174, 22, 239]);
312
+ const alg = new _crypto.PDF20();
313
+ const password = new Uint8Array([111, 119, 110, 101, 114]);
314
+ const ownerKeySalt = new Uint8Array([29, 208, 185, 46, 11, 76, 135, 149]);
315
+ const ownerEncryption = new Uint8Array([209, 73, 224, 77, 103, 155, 201, 181, 190, 68, 223, 20, 62, 90, 56, 210, 5, 240, 178, 128, 238, 124, 68, 254, 253, 244, 62, 108, 208, 135, 10, 251]);
316
+ const uBytes = new Uint8Array([94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164, 150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95, 184, 83, 245, 146, 101, 198, 247, 34, 198, 191, 11, 16, 94, 237, 216, 20, 175]);
317
+ const result = alg.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
318
+ const expected = new Uint8Array([42, 218, 213, 39, 73, 91, 72, 79, 67, 38, 248, 133, 18, 189, 61, 34, 107, 79, 29, 56, 59, 181, 213, 118, 113, 34, 65, 210, 87, 174, 22, 239]);
356
319
  expect(result).toEqual(expected);
357
320
  });
358
321
  });
359
322
  });
360
323
  describe("CipherTransformFactory", function () {
361
324
  function buildDict(map) {
362
- var dict = new _primitives.Dict();
325
+ const dict = new _primitives.Dict();
363
326
 
364
- for (var key in map) {
327
+ for (const key in map) {
365
328
  dict.set(key, map[key]);
366
329
  }
367
330
 
@@ -370,7 +333,7 @@ describe("CipherTransformFactory", function () {
370
333
 
371
334
  function ensurePasswordCorrect(done, dict, fileId, password) {
372
335
  try {
373
- var factory = new _crypto.CipherTransformFactory(dict, fileId, password);
336
+ const factory = new _crypto.CipherTransformFactory(dict, fileId, password);
374
337
  expect("createCipherTransform" in factory).toEqual(true);
375
338
  } catch (ex) {
376
339
  done.fail("Password should be accepted: " + ex);
@@ -414,8 +377,8 @@ describe("CipherTransformFactory", function () {
414
377
  expect(string).toEqual(decrypted);
415
378
  }
416
379
 
417
- var fileId1, fileId2, dict1, dict2, dict3;
418
- var aes256Dict, aes256IsoDict, aes256BlankDict, aes256IsoBlankDict;
380
+ let fileId1, fileId2, dict1, dict2, dict3;
381
+ let aes256Dict, aes256IsoDict, aes256BlankDict, aes256IsoBlankDict;
419
382
  beforeAll(function (done) {
420
383
  fileId1 = unescape("%F6%C6%AF%17%F3rR%8DRM%9A%80%D1%EF%DF%18");
421
384
  fileId2 = unescape("%3CL_%3AD%96%AF@%9A%9D%B3%3Cx%1Cv%AC");
@@ -21,15 +21,9 @@
21
21
  */
22
22
  "use strict";
23
23
 
24
- var _test_utils = require("./test_utils.js");
25
-
26
- var _display_utils = require("../../display/display_utils.js");
27
-
28
24
  var _api = require("../../display/api.js");
29
25
 
30
- var _is_node = require("../../shared/is_node.js");
31
-
32
- var _node_utils = require("../../display/node_utils.js");
26
+ var _test_utils = require("./test_utils.js");
33
27
 
34
28
  function getTopLeftPixel(canvasContext) {
35
29
  const imgData = canvasContext.getImageData(0, 0, 1, 1);
@@ -47,12 +41,7 @@ describe("custom canvas rendering", function () {
47
41
  let loadingTask;
48
42
  let page;
49
43
  beforeAll(function (done) {
50
- if (_is_node.isNodeJS) {
51
- CanvasFactory = new _node_utils.NodeCanvasFactory();
52
- } else {
53
- CanvasFactory = new _display_utils.DOMCanvasFactory();
54
- }
55
-
44
+ CanvasFactory = new _api.DefaultCanvasFactory();
56
45
  loadingTask = (0, _api.getDocument)(transparentGetDocumentParams);
57
46
  loadingTask.promise.then(function (doc) {
58
47
  return doc.getPage(1);
@@ -67,10 +56,10 @@ describe("custom canvas rendering", function () {
67
56
  loadingTask.destroy().then(done);
68
57
  });
69
58
  it("renders to canvas with a default white background", function (done) {
70
- var viewport = page.getViewport({
59
+ const viewport = page.getViewport({
71
60
  scale: 1
72
61
  });
73
- var canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
62
+ const canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
74
63
  const renderTask = page.render({
75
64
  canvasContext: canvasAndCtx.context,
76
65
  viewport
@@ -87,10 +76,10 @@ describe("custom canvas rendering", function () {
87
76
  }).catch(done.fail);
88
77
  });
89
78
  it("renders to canvas with a custom background", function (done) {
90
- var viewport = page.getViewport({
79
+ const viewport = page.getViewport({
91
80
  scale: 1
92
81
  });
93
- var canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
82
+ const canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
94
83
  const renderTask = page.render({
95
84
  canvasContext: canvasAndCtx.context,
96
85
  viewport,
@@ -163,7 +152,7 @@ describe("custom ownerDocument", function () {
163
152
  }]
164
153
  }
165
154
  };
166
- const CanvasFactory = _is_node.isNodeJS ? new _node_utils.NodeCanvasFactory() : new _display_utils.DOMCanvasFactory({
155
+ const CanvasFactory = new _api.DefaultCanvasFactory({
167
156
  ownerDocument
168
157
  });
169
158
  return {