@pdfme/pdf-lib 1.17.3 → 1.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1475) hide show
  1. package/README.md +43 -23
  2. package/cjs/api/PDFDocument.d.ts +11 -11
  3. package/cjs/api/PDFDocument.d.ts.map +1 -1
  4. package/cjs/api/PDFDocument.js +368 -539
  5. package/cjs/api/PDFDocument.js.map +1 -1
  6. package/cjs/api/PDFDocumentOptions.d.ts +3 -2
  7. package/cjs/api/PDFDocumentOptions.d.ts.map +1 -1
  8. package/cjs/api/PDFEmbeddedFile.d.ts +4 -4
  9. package/cjs/api/PDFEmbeddedFile.d.ts.map +1 -1
  10. package/cjs/api/PDFEmbeddedFile.js +48 -63
  11. package/cjs/api/PDFEmbeddedFile.js.map +1 -1
  12. package/cjs/api/PDFEmbeddedPage.d.ts +3 -3
  13. package/cjs/api/PDFEmbeddedPage.d.ts.map +1 -1
  14. package/cjs/api/PDFEmbeddedPage.js +34 -47
  15. package/cjs/api/PDFEmbeddedPage.js.map +1 -1
  16. package/cjs/api/PDFFont.d.ts +3 -3
  17. package/cjs/api/PDFFont.d.ts.map +1 -1
  18. package/cjs/api/PDFFont.js +46 -58
  19. package/cjs/api/PDFFont.js.map +1 -1
  20. package/cjs/api/PDFImage.d.ts +3 -3
  21. package/cjs/api/PDFImage.d.ts.map +1 -1
  22. package/cjs/api/PDFImage.js +49 -63
  23. package/cjs/api/PDFImage.js.map +1 -1
  24. package/cjs/api/PDFJavaScript.d.ts +4 -4
  25. package/cjs/api/PDFJavaScript.d.ts.map +1 -1
  26. package/cjs/api/PDFJavaScript.js +37 -52
  27. package/cjs/api/PDFJavaScript.js.map +1 -1
  28. package/cjs/api/PDFPage.d.ts +21 -9
  29. package/cjs/api/PDFPage.d.ts.map +1 -1
  30. package/cjs/api/PDFPage.js +447 -426
  31. package/cjs/api/PDFPage.js.map +1 -1
  32. package/cjs/api/PDFPageOptions.d.ts +29 -12
  33. package/cjs/api/PDFPageOptions.d.ts.map +1 -1
  34. package/cjs/api/PDFPageOptions.js.map +1 -1
  35. package/cjs/api/colors.d.ts +4 -0
  36. package/cjs/api/colors.d.ts.map +1 -1
  37. package/cjs/api/colors.js +52 -43
  38. package/cjs/api/colors.js.map +1 -1
  39. package/cjs/api/errors.js +73 -130
  40. package/cjs/api/errors.js.map +1 -1
  41. package/cjs/api/form/PDFButton.d.ts +8 -8
  42. package/cjs/api/form/PDFButton.d.ts.map +1 -1
  43. package/cjs/api/form/PDFButton.js +68 -72
  44. package/cjs/api/form/PDFButton.js.map +1 -1
  45. package/cjs/api/form/PDFCheckBox.d.ts +5 -5
  46. package/cjs/api/form/PDFCheckBox.d.ts.map +1 -1
  47. package/cjs/api/form/PDFCheckBox.js +64 -69
  48. package/cjs/api/form/PDFCheckBox.js.map +1 -1
  49. package/cjs/api/form/PDFDropdown.d.ts +6 -6
  50. package/cjs/api/form/PDFDropdown.d.ts.map +1 -1
  51. package/cjs/api/form/PDFDropdown.js +126 -132
  52. package/cjs/api/form/PDFDropdown.js.map +1 -1
  53. package/cjs/api/form/PDFField.d.ts +6 -6
  54. package/cjs/api/form/PDFField.d.ts.map +1 -1
  55. package/cjs/api/form/PDFField.js +118 -123
  56. package/cjs/api/form/PDFField.js.map +1 -1
  57. package/cjs/api/form/PDFForm.d.ts +11 -11
  58. package/cjs/api/form/PDFForm.d.ts.map +1 -1
  59. package/cjs/api/form/PDFForm.js +218 -217
  60. package/cjs/api/form/PDFForm.js.map +1 -1
  61. package/cjs/api/form/PDFOptionList.d.ts +6 -6
  62. package/cjs/api/form/PDFOptionList.d.ts.map +1 -1
  63. package/cjs/api/form/PDFOptionList.js +115 -121
  64. package/cjs/api/form/PDFOptionList.js.map +1 -1
  65. package/cjs/api/form/PDFRadioGroup.d.ts +5 -5
  66. package/cjs/api/form/PDFRadioGroup.d.ts.map +1 -1
  67. package/cjs/api/form/PDFRadioGroup.js +98 -101
  68. package/cjs/api/form/PDFRadioGroup.js.map +1 -1
  69. package/cjs/api/form/PDFSignature.d.ts +3 -3
  70. package/cjs/api/form/PDFSignature.d.ts.map +1 -1
  71. package/cjs/api/form/PDFSignature.js +25 -28
  72. package/cjs/api/form/PDFSignature.js.map +1 -1
  73. package/cjs/api/form/PDFTextField.d.ts +8 -8
  74. package/cjs/api/form/PDFTextField.d.ts.map +1 -1
  75. package/cjs/api/form/PDFTextField.js +136 -141
  76. package/cjs/api/form/PDFTextField.js.map +1 -1
  77. package/cjs/api/form/appearances.d.ts +11 -11
  78. package/cjs/api/form/appearances.d.ts.map +1 -1
  79. package/cjs/api/form/appearances.js +297 -219
  80. package/cjs/api/form/appearances.js.map +1 -1
  81. package/cjs/api/form/index.d.ts +10 -10
  82. package/cjs/api/form/index.d.ts.map +1 -1
  83. package/cjs/api/form/index.js +12 -11
  84. package/cjs/api/form/index.js.map +1 -1
  85. package/cjs/api/image/index.d.ts +1 -1
  86. package/cjs/api/image/index.d.ts.map +1 -1
  87. package/cjs/api/image/index.js +2 -2
  88. package/cjs/api/image/index.js.map +1 -1
  89. package/cjs/api/index.d.ts +20 -20
  90. package/cjs/api/index.d.ts.map +1 -1
  91. package/cjs/api/index.js +21 -20
  92. package/cjs/api/index.js.map +1 -1
  93. package/cjs/api/objects.d.ts +1 -1
  94. package/cjs/api/objects.d.ts.map +1 -1
  95. package/cjs/api/objects.js +7 -10
  96. package/cjs/api/objects.js.map +1 -1
  97. package/cjs/api/operations.d.ts +20 -4
  98. package/cjs/api/operations.d.ts.map +1 -1
  99. package/cjs/api/operations.js +383 -347
  100. package/cjs/api/operations.js.map +1 -1
  101. package/cjs/api/operators.d.ts +6 -1
  102. package/cjs/api/operators.d.ts.map +1 -1
  103. package/cjs/api/operators.js +169 -183
  104. package/cjs/api/operators.js.map +1 -1
  105. package/cjs/api/rotations.d.ts +1 -1
  106. package/cjs/api/rotations.d.ts.map +1 -1
  107. package/cjs/api/rotations.js +31 -30
  108. package/cjs/api/rotations.js.map +1 -1
  109. package/cjs/api/svg.d.ts +71 -0
  110. package/cjs/api/svg.d.ts.map +1 -0
  111. package/cjs/api/svg.js +654 -0
  112. package/cjs/api/svg.js.map +1 -0
  113. package/cjs/api/svgPath.d.ts +1 -1
  114. package/cjs/api/svgPath.d.ts.map +1 -1
  115. package/cjs/api/svgPath.js +115 -118
  116. package/cjs/api/svgPath.js.map +1 -1
  117. package/cjs/api/text/index.d.ts +2 -2
  118. package/cjs/api/text/index.d.ts.map +1 -1
  119. package/cjs/api/text/index.js +3 -3
  120. package/cjs/api/text/index.js.map +1 -1
  121. package/cjs/api/text/layout.d.ts +3 -3
  122. package/cjs/api/text/layout.d.ts.map +1 -1
  123. package/cjs/api/text/layout.js +87 -88
  124. package/cjs/api/text/layout.js.map +1 -1
  125. package/cjs/core/PDFContext.d.ts +17 -16
  126. package/cjs/core/PDFContext.d.ts.map +1 -1
  127. package/cjs/core/PDFContext.js +93 -101
  128. package/cjs/core/PDFContext.js.map +1 -1
  129. package/cjs/core/PDFObjectCopier.d.ts +2 -2
  130. package/cjs/core/PDFObjectCopier.d.ts.map +1 -1
  131. package/cjs/core/PDFObjectCopier.js +58 -62
  132. package/cjs/core/PDFObjectCopier.js.map +1 -1
  133. package/cjs/core/acroform/PDFAcroButton.d.ts +7 -7
  134. package/cjs/core/acroform/PDFAcroButton.d.ts.map +1 -1
  135. package/cjs/core/acroform/PDFAcroButton.js +42 -47
  136. package/cjs/core/acroform/PDFAcroButton.js.map +1 -1
  137. package/cjs/core/acroform/PDFAcroCheckBox.d.ts +5 -5
  138. package/cjs/core/acroform/PDFAcroCheckBox.d.ts.map +1 -1
  139. package/cjs/core/acroform/PDFAcroCheckBox.js +28 -35
  140. package/cjs/core/acroform/PDFAcroCheckBox.js.map +1 -1
  141. package/cjs/core/acroform/PDFAcroChoice.d.ts +4 -4
  142. package/cjs/core/acroform/PDFAcroChoice.d.ts.map +1 -1
  143. package/cjs/core/acroform/PDFAcroChoice.js +47 -60
  144. package/cjs/core/acroform/PDFAcroChoice.js.map +1 -1
  145. package/cjs/core/acroform/PDFAcroComboBox.d.ts +4 -4
  146. package/cjs/core/acroform/PDFAcroComboBox.d.ts.map +1 -1
  147. package/cjs/core/acroform/PDFAcroComboBox.js +15 -22
  148. package/cjs/core/acroform/PDFAcroComboBox.js.map +1 -1
  149. package/cjs/core/acroform/PDFAcroField.d.ts +8 -8
  150. package/cjs/core/acroform/PDFAcroField.d.ts.map +1 -1
  151. package/cjs/core/acroform/PDFAcroField.js +80 -81
  152. package/cjs/core/acroform/PDFAcroField.js.map +1 -1
  153. package/cjs/core/acroform/PDFAcroForm.d.ts +5 -5
  154. package/cjs/core/acroform/PDFAcroForm.d.ts.map +1 -1
  155. package/cjs/core/acroform/PDFAcroForm.js +46 -47
  156. package/cjs/core/acroform/PDFAcroForm.js.map +1 -1
  157. package/cjs/core/acroform/PDFAcroListBox.d.ts +4 -4
  158. package/cjs/core/acroform/PDFAcroListBox.d.ts.map +1 -1
  159. package/cjs/core/acroform/PDFAcroListBox.js +13 -20
  160. package/cjs/core/acroform/PDFAcroListBox.js.map +1 -1
  161. package/cjs/core/acroform/PDFAcroNonTerminal.d.ts +4 -4
  162. package/cjs/core/acroform/PDFAcroNonTerminal.d.ts.map +1 -1
  163. package/cjs/core/acroform/PDFAcroNonTerminal.js +18 -25
  164. package/cjs/core/acroform/PDFAcroNonTerminal.js.map +1 -1
  165. package/cjs/core/acroform/PDFAcroPushButton.d.ts +4 -4
  166. package/cjs/core/acroform/PDFAcroPushButton.d.ts.map +1 -1
  167. package/cjs/core/acroform/PDFAcroPushButton.js +15 -22
  168. package/cjs/core/acroform/PDFAcroPushButton.js.map +1 -1
  169. package/cjs/core/acroform/PDFAcroRadioButton.d.ts +5 -5
  170. package/cjs/core/acroform/PDFAcroRadioButton.d.ts.map +1 -1
  171. package/cjs/core/acroform/PDFAcroRadioButton.js +33 -40
  172. package/cjs/core/acroform/PDFAcroRadioButton.js.map +1 -1
  173. package/cjs/core/acroform/PDFAcroSignature.d.ts +3 -3
  174. package/cjs/core/acroform/PDFAcroSignature.d.ts.map +1 -1
  175. package/cjs/core/acroform/PDFAcroSignature.js +5 -12
  176. package/cjs/core/acroform/PDFAcroSignature.js.map +1 -1
  177. package/cjs/core/acroform/PDFAcroTerminal.d.ts +5 -5
  178. package/cjs/core/acroform/PDFAcroTerminal.d.ts.map +1 -1
  179. package/cjs/core/acroform/PDFAcroTerminal.js +28 -35
  180. package/cjs/core/acroform/PDFAcroTerminal.js.map +1 -1
  181. package/cjs/core/acroform/PDFAcroText.d.ts +7 -7
  182. package/cjs/core/acroform/PDFAcroText.d.ts.map +1 -1
  183. package/cjs/core/acroform/PDFAcroText.js +40 -45
  184. package/cjs/core/acroform/PDFAcroText.js.map +1 -1
  185. package/cjs/core/acroform/flags.js +1 -1
  186. package/cjs/core/acroform/flags.js.map +1 -1
  187. package/cjs/core/acroform/index.d.ts +15 -15
  188. package/cjs/core/acroform/index.d.ts.map +1 -1
  189. package/cjs/core/acroform/index.js +17 -16
  190. package/cjs/core/acroform/index.js.map +1 -1
  191. package/cjs/core/acroform/utils.d.ts +4 -4
  192. package/cjs/core/acroform/utils.d.ts.map +1 -1
  193. package/cjs/core/acroform/utils.js +48 -48
  194. package/cjs/core/acroform/utils.js.map +1 -1
  195. package/cjs/core/annotation/AppearanceCharacteristics.d.ts +5 -5
  196. package/cjs/core/annotation/AppearanceCharacteristics.d.ts.map +1 -1
  197. package/cjs/core/annotation/AppearanceCharacteristics.js +61 -64
  198. package/cjs/core/annotation/AppearanceCharacteristics.js.map +1 -1
  199. package/cjs/core/annotation/BorderStyle.d.ts +2 -2
  200. package/cjs/core/annotation/BorderStyle.d.ts.map +1 -1
  201. package/cjs/core/annotation/BorderStyle.js +15 -16
  202. package/cjs/core/annotation/BorderStyle.js.map +1 -1
  203. package/cjs/core/annotation/PDFAnnotation.d.ts +6 -6
  204. package/cjs/core/annotation/PDFAnnotation.d.ts.map +1 -1
  205. package/cjs/core/annotation/PDFAnnotation.js +76 -77
  206. package/cjs/core/annotation/PDFAnnotation.js.map +1 -1
  207. package/cjs/core/annotation/PDFWidgetAnnotation.d.ts +9 -9
  208. package/cjs/core/annotation/PDFWidgetAnnotation.d.ts.map +1 -1
  209. package/cjs/core/annotation/PDFWidgetAnnotation.js +60 -67
  210. package/cjs/core/annotation/PDFWidgetAnnotation.js.map +1 -1
  211. package/cjs/core/annotation/flags.js +1 -1
  212. package/cjs/core/annotation/flags.js.map +1 -1
  213. package/cjs/core/annotation/index.d.ts +4 -4
  214. package/cjs/core/annotation/index.d.ts.map +1 -1
  215. package/cjs/core/annotation/index.js +6 -5
  216. package/cjs/core/annotation/index.js.map +1 -1
  217. package/cjs/core/crypto.d.ts +96 -0
  218. package/cjs/core/crypto.d.ts.map +1 -0
  219. package/cjs/core/crypto.js +1619 -0
  220. package/cjs/core/crypto.js.map +1 -0
  221. package/cjs/core/document/PDFCrossRefSection.d.ts +1 -1
  222. package/cjs/core/document/PDFCrossRefSection.d.ts.map +1 -1
  223. package/cjs/core/document/PDFCrossRefSection.js +62 -65
  224. package/cjs/core/document/PDFCrossRefSection.js.map +1 -1
  225. package/cjs/core/document/PDFHeader.js +18 -21
  226. package/cjs/core/document/PDFHeader.js.map +1 -1
  227. package/cjs/core/document/PDFTrailer.js +16 -19
  228. package/cjs/core/document/PDFTrailer.js.map +1 -1
  229. package/cjs/core/document/PDFTrailerDict.d.ts +1 -1
  230. package/cjs/core/document/PDFTrailerDict.d.ts.map +1 -1
  231. package/cjs/core/document/PDFTrailerDict.js +14 -15
  232. package/cjs/core/document/PDFTrailerDict.js.map +1 -1
  233. package/cjs/core/embedders/CMap.d.ts +1 -1
  234. package/cjs/core/embedders/CMap.d.ts.map +1 -1
  235. package/cjs/core/embedders/CMap.js +41 -28
  236. package/cjs/core/embedders/CMap.js.map +1 -1
  237. package/cjs/core/embedders/CustomFontEmbedder.d.ts +5 -5
  238. package/cjs/core/embedders/CustomFontEmbedder.d.ts.map +1 -1
  239. package/cjs/core/embedders/CustomFontEmbedder.js +126 -183
  240. package/cjs/core/embedders/CustomFontEmbedder.js.map +1 -1
  241. package/cjs/core/embedders/CustomFontSubsetEmbedder.d.ts +3 -3
  242. package/cjs/core/embedders/CustomFontSubsetEmbedder.d.ts.map +1 -1
  243. package/cjs/core/embedders/CustomFontSubsetEmbedder.js +39 -52
  244. package/cjs/core/embedders/CustomFontSubsetEmbedder.js.map +1 -1
  245. package/cjs/core/embedders/FileEmbedder.d.ts +2 -2
  246. package/cjs/core/embedders/FileEmbedder.d.ts.map +1 -1
  247. package/cjs/core/embedders/FileEmbedder.js +39 -48
  248. package/cjs/core/embedders/FileEmbedder.js.map +1 -1
  249. package/cjs/core/embedders/FontFlags.d.ts +1 -1
  250. package/cjs/core/embedders/FontFlags.d.ts.map +1 -1
  251. package/cjs/core/embedders/FontFlags.js +7 -6
  252. package/cjs/core/embedders/FontFlags.js.map +1 -1
  253. package/cjs/core/embedders/JavaScriptEmbedder.d.ts +2 -2
  254. package/cjs/core/embedders/JavaScriptEmbedder.d.ts.map +1 -1
  255. package/cjs/core/embedders/JavaScriptEmbedder.js +20 -27
  256. package/cjs/core/embedders/JavaScriptEmbedder.js.map +1 -1
  257. package/cjs/core/embedders/JpegEmbedder.d.ts +2 -2
  258. package/cjs/core/embedders/JpegEmbedder.d.ts.map +1 -1
  259. package/cjs/core/embedders/JpegEmbedder.js +62 -74
  260. package/cjs/core/embedders/JpegEmbedder.js.map +1 -1
  261. package/cjs/core/embedders/PDFPageEmbedder.d.ts +4 -4
  262. package/cjs/core/embedders/PDFPageEmbedder.d.ts.map +1 -1
  263. package/cjs/core/embedders/PDFPageEmbedder.js +53 -63
  264. package/cjs/core/embedders/PDFPageEmbedder.js.map +1 -1
  265. package/cjs/core/embedders/PngEmbedder.d.ts +2 -2
  266. package/cjs/core/embedders/PngEmbedder.d.ts.map +1 -1
  267. package/cjs/core/embedders/PngEmbedder.js +29 -42
  268. package/cjs/core/embedders/PngEmbedder.js.map +1 -1
  269. package/cjs/core/embedders/StandardFontEmbedder.d.ts +3 -3
  270. package/cjs/core/embedders/StandardFontEmbedder.d.ts.map +1 -1
  271. package/cjs/core/embedders/StandardFontEmbedder.js +46 -50
  272. package/cjs/core/embedders/StandardFontEmbedder.js.map +1 -1
  273. package/cjs/core/errors.d.ts +1 -1
  274. package/cjs/core/errors.d.ts.map +1 -1
  275. package/cjs/core/errors.js +147 -260
  276. package/cjs/core/errors.js.map +1 -1
  277. package/cjs/core/index.d.ts +47 -47
  278. package/cjs/core/index.d.ts.map +1 -1
  279. package/cjs/core/index.js +48 -47
  280. package/cjs/core/index.js.map +1 -1
  281. package/cjs/core/interactive/ViewerPreferences.d.ts +6 -6
  282. package/cjs/core/interactive/ViewerPreferences.d.ts.map +1 -1
  283. package/cjs/core/interactive/ViewerPreferences.js +135 -138
  284. package/cjs/core/interactive/ViewerPreferences.js.map +1 -1
  285. package/cjs/core/objects/PDFArray.d.ts +12 -12
  286. package/cjs/core/objects/PDFArray.d.ts.map +1 -1
  287. package/cjs/core/objects/PDFArray.js +72 -81
  288. package/cjs/core/objects/PDFArray.js.map +1 -1
  289. package/cjs/core/objects/PDFBool.d.ts +1 -1
  290. package/cjs/core/objects/PDFBool.d.ts.map +1 -1
  291. package/cjs/core/objects/PDFBool.js +22 -26
  292. package/cjs/core/objects/PDFBool.js.map +1 -1
  293. package/cjs/core/objects/PDFDict.d.ts +12 -11
  294. package/cjs/core/objects/PDFDict.d.ts.map +1 -1
  295. package/cjs/core/objects/PDFDict.js +74 -86
  296. package/cjs/core/objects/PDFDict.js.map +1 -1
  297. package/cjs/core/objects/PDFHexString.d.ts +1 -1
  298. package/cjs/core/objects/PDFHexString.d.ts.map +1 -1
  299. package/cjs/core/objects/PDFHexString.js +49 -52
  300. package/cjs/core/objects/PDFHexString.js.map +1 -1
  301. package/cjs/core/objects/PDFInvalidObject.d.ts +1 -1
  302. package/cjs/core/objects/PDFInvalidObject.d.ts.map +1 -1
  303. package/cjs/core/objects/PDFInvalidObject.js +19 -22
  304. package/cjs/core/objects/PDFInvalidObject.js.map +1 -1
  305. package/cjs/core/objects/PDFName.d.ts +1 -1
  306. package/cjs/core/objects/PDFName.d.ts.map +1 -1
  307. package/cjs/core/objects/PDFName.js +84 -92
  308. package/cjs/core/objects/PDFName.js.map +1 -1
  309. package/cjs/core/objects/PDFNull.d.ts +1 -1
  310. package/cjs/core/objects/PDFNull.d.ts.map +1 -1
  311. package/cjs/core/objects/PDFNull.js +15 -20
  312. package/cjs/core/objects/PDFNull.js.map +1 -1
  313. package/cjs/core/objects/PDFNumber.d.ts +1 -1
  314. package/cjs/core/objects/PDFNumber.d.ts.map +1 -1
  315. package/cjs/core/objects/PDFNumber.js +23 -26
  316. package/cjs/core/objects/PDFNumber.js.map +1 -1
  317. package/cjs/core/objects/PDFObject.d.ts +1 -1
  318. package/cjs/core/objects/PDFObject.d.ts.map +1 -1
  319. package/cjs/core/objects/PDFObject.js +11 -14
  320. package/cjs/core/objects/PDFObject.js.map +1 -1
  321. package/cjs/core/objects/PDFRawStream.d.ts +6 -4
  322. package/cjs/core/objects/PDFRawStream.d.ts.map +1 -1
  323. package/cjs/core/objects/PDFRawStream.js +21 -25
  324. package/cjs/core/objects/PDFRawStream.js.map +1 -1
  325. package/cjs/core/objects/PDFRef.d.ts +1 -1
  326. package/cjs/core/objects/PDFRef.d.ts.map +1 -1
  327. package/cjs/core/objects/PDFRef.js +31 -36
  328. package/cjs/core/objects/PDFRef.js.map +1 -1
  329. package/cjs/core/objects/PDFStream.d.ts +3 -3
  330. package/cjs/core/objects/PDFStream.d.ts.map +1 -1
  331. package/cjs/core/objects/PDFStream.js +32 -35
  332. package/cjs/core/objects/PDFStream.js.map +1 -1
  333. package/cjs/core/objects/PDFString.d.ts +1 -1
  334. package/cjs/core/objects/PDFString.d.ts.map +1 -1
  335. package/cjs/core/objects/PDFString.js +55 -58
  336. package/cjs/core/objects/PDFString.js.map +1 -1
  337. package/cjs/core/operators/PDFOperator.d.ts +7 -7
  338. package/cjs/core/operators/PDFOperator.d.ts.map +1 -1
  339. package/cjs/core/operators/PDFOperator.js +29 -32
  340. package/cjs/core/operators/PDFOperator.js.map +1 -1
  341. package/cjs/core/parser/BaseParser.d.ts +1 -1
  342. package/cjs/core/parser/BaseParser.d.ts.map +1 -1
  343. package/cjs/core/parser/BaseParser.js +40 -42
  344. package/cjs/core/parser/BaseParser.js.map +1 -1
  345. package/cjs/core/parser/ByteStream.d.ts +1 -1
  346. package/cjs/core/parser/ByteStream.d.ts.map +1 -1
  347. package/cjs/core/parser/ByteStream.js +30 -33
  348. package/cjs/core/parser/ByteStream.js.map +1 -1
  349. package/cjs/core/parser/PDFObjectParser.d.ts +22 -20
  350. package/cjs/core/parser/PDFObjectParser.d.ts.map +1 -1
  351. package/cjs/core/parser/PDFObjectParser.js +96 -88
  352. package/cjs/core/parser/PDFObjectParser.js.map +1 -1
  353. package/cjs/core/parser/PDFObjectStreamParser.d.ts +2 -2
  354. package/cjs/core/parser/PDFObjectStreamParser.d.ts.map +1 -1
  355. package/cjs/core/parser/PDFObjectStreamParser.js +41 -61
  356. package/cjs/core/parser/PDFObjectStreamParser.js.map +1 -1
  357. package/cjs/core/parser/PDFParser.d.ts +5 -4
  358. package/cjs/core/parser/PDFParser.d.ts.map +1 -1
  359. package/cjs/core/parser/PDFParser.js +157 -219
  360. package/cjs/core/parser/PDFParser.js.map +1 -1
  361. package/cjs/core/parser/PDFXRefStreamParser.d.ts +2 -2
  362. package/cjs/core/parser/PDFXRefStreamParser.d.ts.map +1 -1
  363. package/cjs/core/parser/PDFXRefStreamParser.js +38 -41
  364. package/cjs/core/parser/PDFXRefStreamParser.js.map +1 -1
  365. package/cjs/core/streams/Ascii85Stream.d.ts +2 -2
  366. package/cjs/core/streams/Ascii85Stream.d.ts.map +1 -1
  367. package/cjs/core/streams/Ascii85Stream.js +21 -26
  368. package/cjs/core/streams/Ascii85Stream.js.map +1 -1
  369. package/cjs/core/streams/AsciiHexStream.d.ts +2 -2
  370. package/cjs/core/streams/AsciiHexStream.d.ts.map +1 -1
  371. package/cjs/core/streams/AsciiHexStream.js +19 -22
  372. package/cjs/core/streams/AsciiHexStream.js.map +1 -1
  373. package/cjs/core/streams/DecodeStream.d.ts +1 -1
  374. package/cjs/core/streams/DecodeStream.d.ts.map +1 -1
  375. package/cjs/core/streams/DecodeStream.js +54 -61
  376. package/cjs/core/streams/DecodeStream.js.map +1 -1
  377. package/cjs/core/streams/DecryptStream.d.ts +13 -0
  378. package/cjs/core/streams/DecryptStream.d.ts.map +1 -0
  379. package/cjs/core/streams/DecryptStream.js +37 -0
  380. package/cjs/core/streams/DecryptStream.js.map +1 -0
  381. package/cjs/core/streams/FlateStream.d.ts +2 -2
  382. package/cjs/core/streams/FlateStream.d.ts.map +1 -1
  383. package/cjs/core/streams/FlateStream.js +81 -84
  384. package/cjs/core/streams/FlateStream.js.map +1 -1
  385. package/cjs/core/streams/LZWStream.d.ts +3 -3
  386. package/cjs/core/streams/LZWStream.d.ts.map +1 -1
  387. package/cjs/core/streams/LZWStream.js +42 -45
  388. package/cjs/core/streams/LZWStream.js.map +1 -1
  389. package/cjs/core/streams/RunLengthStream.d.ts +2 -2
  390. package/cjs/core/streams/RunLengthStream.d.ts.map +1 -1
  391. package/cjs/core/streams/RunLengthStream.js +16 -19
  392. package/cjs/core/streams/RunLengthStream.js.map +1 -1
  393. package/cjs/core/streams/Stream.js +45 -56
  394. package/cjs/core/streams/Stream.js.map +1 -1
  395. package/cjs/core/streams/decode.d.ts +3 -3
  396. package/cjs/core/streams/decode.d.ts.map +1 -1
  397. package/cjs/core/streams/decode.js +24 -21
  398. package/cjs/core/streams/decode.js.map +1 -1
  399. package/cjs/core/structures/PDFCatalog.d.ts +5 -5
  400. package/cjs/core/structures/PDFCatalog.d.ts.map +1 -1
  401. package/cjs/core/structures/PDFCatalog.js +40 -47
  402. package/cjs/core/structures/PDFCatalog.js.map +1 -1
  403. package/cjs/core/structures/PDFContentStream.d.ts +4 -4
  404. package/cjs/core/structures/PDFContentStream.d.ts.map +1 -1
  405. package/cjs/core/structures/PDFContentStream.js +31 -43
  406. package/cjs/core/structures/PDFContentStream.js.map +1 -1
  407. package/cjs/core/structures/PDFCrossRefStream.d.ts +4 -4
  408. package/cjs/core/structures/PDFCrossRefStream.d.ts.map +1 -1
  409. package/cjs/core/structures/PDFCrossRefStream.js +92 -100
  410. package/cjs/core/structures/PDFCrossRefStream.js.map +1 -1
  411. package/cjs/core/structures/PDFFlateStream.d.ts +3 -3
  412. package/cjs/core/structures/PDFFlateStream.d.ts.map +1 -1
  413. package/cjs/core/structures/PDFFlateStream.js +21 -24
  414. package/cjs/core/structures/PDFFlateStream.js.map +1 -1
  415. package/cjs/core/structures/PDFObjectStream.d.ts +4 -4
  416. package/cjs/core/structures/PDFObjectStream.d.ts.map +1 -1
  417. package/cjs/core/structures/PDFObjectStream.js +49 -56
  418. package/cjs/core/structures/PDFObjectStream.js.map +1 -1
  419. package/cjs/core/structures/PDFPageLeaf.d.ts +9 -9
  420. package/cjs/core/structures/PDFPageLeaf.d.ts.map +1 -1
  421. package/cjs/core/structures/PDFPageLeaf.js +126 -133
  422. package/cjs/core/structures/PDFPageLeaf.js.map +1 -1
  423. package/cjs/core/structures/PDFPageTree.d.ts +6 -6
  424. package/cjs/core/structures/PDFPageTree.d.ts.map +1 -1
  425. package/cjs/core/structures/PDFPageTree.js +67 -75
  426. package/cjs/core/structures/PDFPageTree.js.map +1 -1
  427. package/cjs/core/syntax/Delimiters.js +2 -2
  428. package/cjs/core/syntax/Delimiters.js.map +1 -1
  429. package/cjs/core/syntax/Irregular.js +5 -5
  430. package/cjs/core/syntax/Irregular.js.map +1 -1
  431. package/cjs/core/syntax/Keywords.d.ts +1 -1
  432. package/cjs/core/syntax/Keywords.d.ts.map +1 -1
  433. package/cjs/core/syntax/Keywords.js +14 -14
  434. package/cjs/core/syntax/Keywords.js.map +1 -1
  435. package/cjs/core/syntax/Numeric.js +3 -3
  436. package/cjs/core/syntax/Numeric.js.map +1 -1
  437. package/cjs/core/syntax/Whitespace.js +2 -2
  438. package/cjs/core/syntax/Whitespace.js.map +1 -1
  439. package/cjs/core/writers/PDFStreamWriter.d.ts +6 -6
  440. package/cjs/core/writers/PDFStreamWriter.d.ts.map +1 -1
  441. package/cjs/core/writers/PDFStreamWriter.js +74 -107
  442. package/cjs/core/writers/PDFStreamWriter.js.map +1 -1
  443. package/cjs/core/writers/PDFWriter.d.ts +12 -9
  444. package/cjs/core/writers/PDFWriter.d.ts.map +1 -1
  445. package/cjs/core/writers/PDFWriter.js +87 -127
  446. package/cjs/core/writers/PDFWriter.js.map +1 -1
  447. package/cjs/index.d.ts +4 -4
  448. package/cjs/index.d.ts.map +1 -1
  449. package/cjs/index.js +5 -5
  450. package/cjs/index.js.map +1 -1
  451. package/cjs/types/index.d.ts +25 -1
  452. package/cjs/types/index.d.ts.map +1 -1
  453. package/cjs/types/matrix.d.ts +8 -1
  454. package/cjs/types/matrix.d.ts.map +1 -1
  455. package/cjs/utils/Cache.js +10 -11
  456. package/cjs/utils/Cache.js.map +1 -1
  457. package/cjs/utils/arrays.d.ts +2 -1
  458. package/cjs/utils/arrays.d.ts.map +1 -1
  459. package/cjs/utils/arrays.js +83 -64
  460. package/cjs/utils/arrays.js.map +1 -1
  461. package/cjs/utils/async.d.ts.map +1 -1
  462. package/cjs/utils/async.js +4 -5
  463. package/cjs/utils/async.js.map +1 -1
  464. package/cjs/utils/base64.d.ts.map +1 -1
  465. package/cjs/utils/base64.js +29 -26
  466. package/cjs/utils/base64.js.map +1 -1
  467. package/cjs/utils/elements/Arc.d.ts +23 -0
  468. package/cjs/utils/elements/Arc.d.ts.map +1 -0
  469. package/cjs/utils/elements/Arc.js +78 -0
  470. package/cjs/utils/elements/Arc.js.map +1 -0
  471. package/cjs/utils/elements/Circle.d.ts +15 -0
  472. package/cjs/utils/elements/Circle.d.ts.map +1 -0
  473. package/cjs/utils/elements/Circle.js +41 -0
  474. package/cjs/utils/elements/Circle.js.map +1 -0
  475. package/cjs/utils/elements/Ellipse.d.ts +21 -0
  476. package/cjs/utils/elements/Ellipse.d.ts.map +1 -0
  477. package/cjs/utils/elements/Ellipse.js +91 -0
  478. package/cjs/utils/elements/Ellipse.js.map +1 -0
  479. package/cjs/utils/elements/GraphElement.d.ts +7 -0
  480. package/cjs/utils/elements/GraphElement.d.ts.map +1 -0
  481. package/cjs/utils/elements/GraphElement.js +11 -0
  482. package/cjs/utils/elements/GraphElement.js.map +1 -0
  483. package/cjs/utils/elements/Line.d.ts +24 -0
  484. package/cjs/utils/elements/Line.d.ts.map +1 -0
  485. package/cjs/utils/elements/Line.js +72 -0
  486. package/cjs/utils/elements/Line.js.map +1 -0
  487. package/cjs/utils/elements/Plot.d.ts +12 -0
  488. package/cjs/utils/elements/Plot.d.ts.map +1 -0
  489. package/cjs/utils/elements/Plot.js +46 -0
  490. package/cjs/utils/elements/Plot.js.map +1 -0
  491. package/cjs/utils/elements/Point.d.ts +19 -0
  492. package/cjs/utils/elements/Point.d.ts.map +1 -0
  493. package/cjs/utils/elements/Point.js +32 -0
  494. package/cjs/utils/elements/Point.js.map +1 -0
  495. package/cjs/utils/elements/Rectangle.d.ts +22 -0
  496. package/cjs/utils/elements/Rectangle.d.ts.map +1 -0
  497. package/cjs/utils/elements/Rectangle.js +58 -0
  498. package/cjs/utils/elements/Rectangle.js.map +1 -0
  499. package/cjs/utils/elements/Segment.d.ts +20 -0
  500. package/cjs/utils/elements/Segment.d.ts.map +1 -0
  501. package/cjs/utils/elements/Segment.js +80 -0
  502. package/cjs/utils/elements/Segment.js.map +1 -0
  503. package/cjs/utils/elements/index.d.ts +10 -0
  504. package/cjs/utils/elements/index.d.ts.map +1 -0
  505. package/cjs/utils/elements/index.js +25 -0
  506. package/cjs/utils/elements/index.js.map +1 -0
  507. package/cjs/utils/errors.js +2 -1
  508. package/cjs/utils/errors.js.map +1 -1
  509. package/cjs/utils/index.d.ts +11 -11
  510. package/cjs/utils/index.d.ts.map +1 -1
  511. package/cjs/utils/index.js +13 -12
  512. package/cjs/utils/index.js.map +1 -1
  513. package/cjs/utils/intersections.d.ts +10 -0
  514. package/cjs/utils/intersections.d.ts.map +1 -0
  515. package/cjs/utils/intersections.js +255 -0
  516. package/cjs/utils/intersections.js.map +1 -0
  517. package/cjs/utils/maths.d.ts +46 -0
  518. package/cjs/utils/maths.d.ts.map +1 -0
  519. package/cjs/utils/maths.js +89 -0
  520. package/cjs/utils/maths.js.map +1 -0
  521. package/cjs/utils/numbers.js +12 -9
  522. package/cjs/utils/numbers.js.map +1 -1
  523. package/cjs/utils/objects.js +8 -7
  524. package/cjs/utils/objects.js.map +1 -1
  525. package/cjs/utils/pdfDocEncoding.js +52 -51
  526. package/cjs/utils/pdfDocEncoding.js.map +1 -1
  527. package/cjs/utils/png.js +22 -23
  528. package/cjs/utils/png.js.map +1 -1
  529. package/cjs/utils/rng.js +7 -8
  530. package/cjs/utils/rng.js.map +1 -1
  531. package/cjs/utils/strings.d.ts +1 -0
  532. package/cjs/utils/strings.d.ts.map +1 -1
  533. package/cjs/utils/strings.js +84 -70
  534. package/cjs/utils/strings.js.map +1 -1
  535. package/cjs/utils/unicode.js +51 -64
  536. package/cjs/utils/unicode.js.map +1 -1
  537. package/cjs/utils/validators.js +84 -67
  538. package/cjs/utils/validators.js.map +1 -1
  539. package/dist/pdf-lib.esm.js +11480 -7021
  540. package/dist/pdf-lib.esm.js.map +1 -1
  541. package/dist/pdf-lib.esm.min.js +1 -15
  542. package/dist/pdf-lib.esm.min.js.map +1 -1
  543. package/dist/pdf-lib.js +11481 -7019
  544. package/dist/pdf-lib.js.map +1 -1
  545. package/dist/pdf-lib.min.js +1 -15
  546. package/dist/pdf-lib.min.js.map +1 -1
  547. package/es/api/Embeddable.js +1 -0
  548. package/es/api/PDFDocument.d.ts +11 -11
  549. package/es/api/PDFDocument.d.ts.map +1 -1
  550. package/es/api/PDFDocument.js +346 -519
  551. package/es/api/PDFDocument.js.map +1 -1
  552. package/es/api/PDFDocumentOptions.d.ts +3 -2
  553. package/es/api/PDFDocumentOptions.d.ts.map +1 -1
  554. package/es/api/PDFEmbeddedFile.d.ts +4 -4
  555. package/es/api/PDFEmbeddedFile.d.ts.map +1 -1
  556. package/es/api/PDFEmbeddedFile.js +48 -64
  557. package/es/api/PDFEmbeddedFile.js.map +1 -1
  558. package/es/api/PDFEmbeddedPage.d.ts +3 -3
  559. package/es/api/PDFEmbeddedPage.d.ts.map +1 -1
  560. package/es/api/PDFEmbeddedPage.js +29 -44
  561. package/es/api/PDFEmbeddedPage.js.map +1 -1
  562. package/es/api/PDFFont.d.ts +3 -3
  563. package/es/api/PDFFont.d.ts.map +1 -1
  564. package/es/api/PDFFont.js +36 -50
  565. package/es/api/PDFFont.js.map +1 -1
  566. package/es/api/PDFImage.d.ts +3 -3
  567. package/es/api/PDFImage.d.ts.map +1 -1
  568. package/es/api/PDFImage.js +42 -58
  569. package/es/api/PDFImage.js.map +1 -1
  570. package/es/api/PDFJavaScript.d.ts +4 -4
  571. package/es/api/PDFJavaScript.d.ts.map +1 -1
  572. package/es/api/PDFJavaScript.js +37 -53
  573. package/es/api/PDFJavaScript.js.map +1 -1
  574. package/es/api/PDFPage.d.ts +21 -9
  575. package/es/api/PDFPage.d.ts.map +1 -1
  576. package/es/api/PDFPage.js +279 -260
  577. package/es/api/PDFPage.js.map +1 -1
  578. package/es/api/PDFPageOptions.d.ts +29 -12
  579. package/es/api/PDFPageOptions.d.ts.map +1 -1
  580. package/es/api/PDFPageOptions.js.map +1 -1
  581. package/es/api/colors.d.ts +4 -0
  582. package/es/api/colors.d.ts.map +1 -1
  583. package/es/api/colors.js +34 -34
  584. package/es/api/colors.js.map +1 -1
  585. package/es/api/errors.js +73 -144
  586. package/es/api/errors.js.map +1 -1
  587. package/es/api/form/PDFButton.d.ts +8 -8
  588. package/es/api/form/PDFButton.d.ts.map +1 -1
  589. package/es/api/form/PDFButton.js +56 -62
  590. package/es/api/form/PDFButton.js.map +1 -1
  591. package/es/api/form/PDFCheckBox.d.ts +5 -5
  592. package/es/api/form/PDFCheckBox.d.ts.map +1 -1
  593. package/es/api/form/PDFCheckBox.js +55 -62
  594. package/es/api/form/PDFCheckBox.js.map +1 -1
  595. package/es/api/form/PDFDropdown.d.ts +6 -6
  596. package/es/api/form/PDFDropdown.d.ts.map +1 -1
  597. package/es/api/form/PDFDropdown.js +110 -118
  598. package/es/api/form/PDFDropdown.js.map +1 -1
  599. package/es/api/form/PDFField.d.ts +6 -6
  600. package/es/api/form/PDFField.d.ts.map +1 -1
  601. package/es/api/form/PDFField.js +98 -106
  602. package/es/api/form/PDFField.js.map +1 -1
  603. package/es/api/form/PDFForm.d.ts +11 -11
  604. package/es/api/form/PDFForm.d.ts.map +1 -1
  605. package/es/api/form/PDFForm.js +195 -196
  606. package/es/api/form/PDFForm.js.map +1 -1
  607. package/es/api/form/PDFOptionList.d.ts +6 -6
  608. package/es/api/form/PDFOptionList.d.ts.map +1 -1
  609. package/es/api/form/PDFOptionList.js +98 -106
  610. package/es/api/form/PDFOptionList.js.map +1 -1
  611. package/es/api/form/PDFRadioGroup.d.ts +5 -5
  612. package/es/api/form/PDFRadioGroup.d.ts.map +1 -1
  613. package/es/api/form/PDFRadioGroup.js +86 -91
  614. package/es/api/form/PDFRadioGroup.js.map +1 -1
  615. package/es/api/form/PDFSignature.d.ts +3 -3
  616. package/es/api/form/PDFSignature.d.ts.map +1 -1
  617. package/es/api/form/PDFSignature.js +23 -28
  618. package/es/api/form/PDFSignature.js.map +1 -1
  619. package/es/api/form/PDFTextField.d.ts +8 -8
  620. package/es/api/form/PDFTextField.d.ts.map +1 -1
  621. package/es/api/form/PDFTextField.js +121 -128
  622. package/es/api/form/PDFTextField.js.map +1 -1
  623. package/es/api/form/appearances.d.ts +11 -11
  624. package/es/api/form/appearances.d.ts.map +1 -1
  625. package/es/api/form/appearances.js +285 -214
  626. package/es/api/form/appearances.js.map +1 -1
  627. package/es/api/form/index.d.ts +10 -10
  628. package/es/api/form/index.d.ts.map +1 -1
  629. package/es/api/form/index.js +10 -10
  630. package/es/api/form/index.js.map +1 -1
  631. package/es/api/image/index.d.ts +1 -1
  632. package/es/api/image/index.d.ts.map +1 -1
  633. package/es/api/image/index.js +1 -1
  634. package/es/api/image/index.js.map +1 -1
  635. package/es/api/index.d.ts +20 -20
  636. package/es/api/index.d.ts.map +1 -1
  637. package/es/api/index.js +19 -19
  638. package/es/api/index.js.map +1 -1
  639. package/es/api/objects.d.ts +1 -1
  640. package/es/api/objects.d.ts.map +1 -1
  641. package/es/api/objects.js +4 -10
  642. package/es/api/objects.js.map +1 -1
  643. package/es/api/operations.d.ts +20 -4
  644. package/es/api/operations.d.ts.map +1 -1
  645. package/es/api/operations.js +229 -210
  646. package/es/api/operations.js.map +1 -1
  647. package/es/api/operators.d.ts +6 -1
  648. package/es/api/operators.d.ts.map +1 -1
  649. package/es/api/operators.js +114 -182
  650. package/es/api/operators.js.map +1 -1
  651. package/es/api/rotations.d.ts +1 -1
  652. package/es/api/rotations.d.ts.map +1 -1
  653. package/es/api/rotations.js +20 -28
  654. package/es/api/rotations.js.map +1 -1
  655. package/es/api/sizes.js +1 -1
  656. package/es/api/sizes.js.map +1 -1
  657. package/es/api/svg.d.ts +71 -0
  658. package/es/api/svg.d.ts.map +1 -0
  659. package/es/api/svg.js +650 -0
  660. package/es/api/svg.js.map +1 -0
  661. package/es/api/svgPath.d.ts +1 -1
  662. package/es/api/svgPath.d.ts.map +1 -1
  663. package/es/api/svgPath.js +104 -108
  664. package/es/api/svgPath.js.map +1 -1
  665. package/es/api/text/index.d.ts +2 -2
  666. package/es/api/text/index.d.ts.map +1 -1
  667. package/es/api/text/index.js +2 -2
  668. package/es/api/text/index.js.map +1 -1
  669. package/es/api/text/layout.d.ts +3 -3
  670. package/es/api/text/layout.d.ts.map +1 -1
  671. package/es/api/text/layout.js +84 -88
  672. package/es/api/text/layout.js.map +1 -1
  673. package/es/core/PDFContext.d.ts +17 -16
  674. package/es/core/PDFContext.d.ts.map +1 -1
  675. package/es/core/PDFContext.js +90 -99
  676. package/es/core/PDFContext.js.map +1 -1
  677. package/es/core/PDFObjectCopier.d.ts +2 -2
  678. package/es/core/PDFObjectCopier.d.ts.map +1 -1
  679. package/es/core/PDFObjectCopier.js +57 -61
  680. package/es/core/PDFObjectCopier.js.map +1 -1
  681. package/es/core/acroform/PDFAcroButton.d.ts +7 -7
  682. package/es/core/acroform/PDFAcroButton.d.ts.map +1 -1
  683. package/es/core/acroform/PDFAcroButton.js +41 -47
  684. package/es/core/acroform/PDFAcroButton.js.map +1 -1
  685. package/es/core/acroform/PDFAcroCheckBox.d.ts +5 -5
  686. package/es/core/acroform/PDFAcroCheckBox.d.ts.map +1 -1
  687. package/es/core/acroform/PDFAcroCheckBox.js +27 -35
  688. package/es/core/acroform/PDFAcroCheckBox.js.map +1 -1
  689. package/es/core/acroform/PDFAcroChoice.d.ts +4 -4
  690. package/es/core/acroform/PDFAcroChoice.d.ts.map +1 -1
  691. package/es/core/acroform/PDFAcroChoice.js +46 -60
  692. package/es/core/acroform/PDFAcroChoice.js.map +1 -1
  693. package/es/core/acroform/PDFAcroComboBox.d.ts +4 -4
  694. package/es/core/acroform/PDFAcroComboBox.d.ts.map +1 -1
  695. package/es/core/acroform/PDFAcroComboBox.js +14 -22
  696. package/es/core/acroform/PDFAcroComboBox.js.map +1 -1
  697. package/es/core/acroform/PDFAcroField.d.ts +8 -8
  698. package/es/core/acroform/PDFAcroField.d.ts.map +1 -1
  699. package/es/core/acroform/PDFAcroField.js +79 -80
  700. package/es/core/acroform/PDFAcroField.js.map +1 -1
  701. package/es/core/acroform/PDFAcroForm.d.ts +5 -5
  702. package/es/core/acroform/PDFAcroForm.d.ts.map +1 -1
  703. package/es/core/acroform/PDFAcroForm.js +43 -44
  704. package/es/core/acroform/PDFAcroForm.js.map +1 -1
  705. package/es/core/acroform/PDFAcroListBox.d.ts +4 -4
  706. package/es/core/acroform/PDFAcroListBox.d.ts.map +1 -1
  707. package/es/core/acroform/PDFAcroListBox.js +12 -20
  708. package/es/core/acroform/PDFAcroListBox.js.map +1 -1
  709. package/es/core/acroform/PDFAcroNonTerminal.d.ts +4 -4
  710. package/es/core/acroform/PDFAcroNonTerminal.d.ts.map +1 -1
  711. package/es/core/acroform/PDFAcroNonTerminal.js +17 -25
  712. package/es/core/acroform/PDFAcroNonTerminal.js.map +1 -1
  713. package/es/core/acroform/PDFAcroPushButton.d.ts +4 -4
  714. package/es/core/acroform/PDFAcroPushButton.d.ts.map +1 -1
  715. package/es/core/acroform/PDFAcroPushButton.js +14 -22
  716. package/es/core/acroform/PDFAcroPushButton.js.map +1 -1
  717. package/es/core/acroform/PDFAcroRadioButton.d.ts +5 -5
  718. package/es/core/acroform/PDFAcroRadioButton.d.ts.map +1 -1
  719. package/es/core/acroform/PDFAcroRadioButton.js +32 -40
  720. package/es/core/acroform/PDFAcroRadioButton.js.map +1 -1
  721. package/es/core/acroform/PDFAcroSignature.d.ts +3 -3
  722. package/es/core/acroform/PDFAcroSignature.d.ts.map +1 -1
  723. package/es/core/acroform/PDFAcroSignature.js +4 -12
  724. package/es/core/acroform/PDFAcroSignature.js.map +1 -1
  725. package/es/core/acroform/PDFAcroTerminal.d.ts +5 -5
  726. package/es/core/acroform/PDFAcroTerminal.d.ts.map +1 -1
  727. package/es/core/acroform/PDFAcroTerminal.js +27 -35
  728. package/es/core/acroform/PDFAcroTerminal.js.map +1 -1
  729. package/es/core/acroform/PDFAcroText.d.ts +7 -7
  730. package/es/core/acroform/PDFAcroText.d.ts.map +1 -1
  731. package/es/core/acroform/PDFAcroText.js +39 -45
  732. package/es/core/acroform/PDFAcroText.js.map +1 -1
  733. package/es/core/acroform/flags.js +1 -1
  734. package/es/core/acroform/flags.js.map +1 -1
  735. package/es/core/acroform/index.d.ts +15 -15
  736. package/es/core/acroform/index.d.ts.map +1 -1
  737. package/es/core/acroform/index.js +15 -15
  738. package/es/core/acroform/index.js.map +1 -1
  739. package/es/core/acroform/utils.d.ts +4 -4
  740. package/es/core/acroform/utils.d.ts.map +1 -1
  741. package/es/core/acroform/utils.js +44 -46
  742. package/es/core/acroform/utils.js.map +1 -1
  743. package/es/core/annotation/AppearanceCharacteristics.d.ts +5 -5
  744. package/es/core/annotation/AppearanceCharacteristics.d.ts.map +1 -1
  745. package/es/core/annotation/AppearanceCharacteristics.js +60 -63
  746. package/es/core/annotation/AppearanceCharacteristics.js.map +1 -1
  747. package/es/core/annotation/BorderStyle.d.ts +2 -2
  748. package/es/core/annotation/BorderStyle.d.ts.map +1 -1
  749. package/es/core/annotation/BorderStyle.js +14 -15
  750. package/es/core/annotation/BorderStyle.js.map +1 -1
  751. package/es/core/annotation/PDFAnnotation.d.ts +6 -6
  752. package/es/core/annotation/PDFAnnotation.d.ts.map +1 -1
  753. package/es/core/annotation/PDFAnnotation.js +75 -76
  754. package/es/core/annotation/PDFAnnotation.js.map +1 -1
  755. package/es/core/annotation/PDFWidgetAnnotation.d.ts +9 -9
  756. package/es/core/annotation/PDFWidgetAnnotation.d.ts.map +1 -1
  757. package/es/core/annotation/PDFWidgetAnnotation.js +59 -67
  758. package/es/core/annotation/PDFWidgetAnnotation.js.map +1 -1
  759. package/es/core/annotation/flags.js +1 -1
  760. package/es/core/annotation/flags.js.map +1 -1
  761. package/es/core/annotation/index.d.ts +4 -4
  762. package/es/core/annotation/index.d.ts.map +1 -1
  763. package/es/core/annotation/index.js +4 -4
  764. package/es/core/annotation/index.js.map +1 -1
  765. package/es/core/crypto.d.ts +96 -0
  766. package/es/core/crypto.d.ts.map +1 -0
  767. package/es/core/crypto.js +1605 -0
  768. package/es/core/crypto.js.map +1 -0
  769. package/es/core/document/PDFCrossRefSection.d.ts +1 -1
  770. package/es/core/document/PDFCrossRefSection.d.ts.map +1 -1
  771. package/es/core/document/PDFCrossRefSection.js +55 -58
  772. package/es/core/document/PDFCrossRefSection.js.map +1 -1
  773. package/es/core/document/PDFHeader.js +15 -18
  774. package/es/core/document/PDFHeader.js.map +1 -1
  775. package/es/core/document/PDFTrailer.js +14 -17
  776. package/es/core/document/PDFTrailer.js.map +1 -1
  777. package/es/core/document/PDFTrailerDict.d.ts +1 -1
  778. package/es/core/document/PDFTrailerDict.d.ts.map +1 -1
  779. package/es/core/document/PDFTrailerDict.js +13 -14
  780. package/es/core/document/PDFTrailerDict.js.map +1 -1
  781. package/es/core/embedders/CMap.d.ts +1 -1
  782. package/es/core/embedders/CMap.d.ts.map +1 -1
  783. package/es/core/embedders/CMap.js +38 -26
  784. package/es/core/embedders/CMap.js.map +1 -1
  785. package/es/core/embedders/CustomFontEmbedder.d.ts +5 -5
  786. package/es/core/embedders/CustomFontEmbedder.d.ts.map +1 -1
  787. package/es/core/embedders/CustomFontEmbedder.js +124 -182
  788. package/es/core/embedders/CustomFontEmbedder.js.map +1 -1
  789. package/es/core/embedders/CustomFontSubsetEmbedder.d.ts +3 -3
  790. package/es/core/embedders/CustomFontSubsetEmbedder.d.ts.map +1 -1
  791. package/es/core/embedders/CustomFontSubsetEmbedder.js +37 -51
  792. package/es/core/embedders/CustomFontSubsetEmbedder.js.map +1 -1
  793. package/es/core/embedders/FileEmbedder.d.ts +2 -2
  794. package/es/core/embedders/FileEmbedder.d.ts.map +1 -1
  795. package/es/core/embedders/FileEmbedder.js +38 -48
  796. package/es/core/embedders/FileEmbedder.js.map +1 -1
  797. package/es/core/embedders/FontFlags.d.ts +1 -1
  798. package/es/core/embedders/FontFlags.d.ts.map +1 -1
  799. package/es/core/embedders/FontFlags.js +6 -6
  800. package/es/core/embedders/FontFlags.js.map +1 -1
  801. package/es/core/embedders/JavaScriptEmbedder.d.ts +2 -2
  802. package/es/core/embedders/JavaScriptEmbedder.d.ts.map +1 -1
  803. package/es/core/embedders/JavaScriptEmbedder.js +19 -27
  804. package/es/core/embedders/JavaScriptEmbedder.js.map +1 -1
  805. package/es/core/embedders/JpegEmbedder.d.ts +2 -2
  806. package/es/core/embedders/JpegEmbedder.d.ts.map +1 -1
  807. package/es/core/embedders/JpegEmbedder.js +62 -74
  808. package/es/core/embedders/JpegEmbedder.js.map +1 -1
  809. package/es/core/embedders/PDFPageEmbedder.d.ts +4 -4
  810. package/es/core/embedders/PDFPageEmbedder.d.ts.map +1 -1
  811. package/es/core/embedders/PDFPageEmbedder.js +51 -62
  812. package/es/core/embedders/PDFPageEmbedder.js.map +1 -1
  813. package/es/core/embedders/PngEmbedder.d.ts +2 -2
  814. package/es/core/embedders/PngEmbedder.d.ts.map +1 -1
  815. package/es/core/embedders/PngEmbedder.js +29 -42
  816. package/es/core/embedders/PngEmbedder.js.map +1 -1
  817. package/es/core/embedders/StandardFontEmbedder.d.ts +3 -3
  818. package/es/core/embedders/StandardFontEmbedder.d.ts.map +1 -1
  819. package/es/core/embedders/StandardFontEmbedder.js +43 -47
  820. package/es/core/embedders/StandardFontEmbedder.js.map +1 -1
  821. package/es/core/errors.d.ts +1 -1
  822. package/es/core/errors.d.ts.map +1 -1
  823. package/es/core/errors.js +175 -316
  824. package/es/core/errors.js.map +1 -1
  825. package/es/core/index.d.ts +47 -47
  826. package/es/core/index.d.ts.map +1 -1
  827. package/es/core/index.js +47 -47
  828. package/es/core/index.js.map +1 -1
  829. package/es/core/interactive/ViewerPreferences.d.ts +6 -6
  830. package/es/core/interactive/ViewerPreferences.d.ts.map +1 -1
  831. package/es/core/interactive/ViewerPreferences.js +127 -130
  832. package/es/core/interactive/ViewerPreferences.js.map +1 -1
  833. package/es/core/objects/PDFArray.d.ts +12 -12
  834. package/es/core/objects/PDFArray.d.ts.map +1 -1
  835. package/es/core/objects/PDFArray.js +71 -81
  836. package/es/core/objects/PDFArray.js.map +1 -1
  837. package/es/core/objects/PDFBool.d.ts +1 -1
  838. package/es/core/objects/PDFBool.d.ts.map +1 -1
  839. package/es/core/objects/PDFBool.js +21 -26
  840. package/es/core/objects/PDFBool.js.map +1 -1
  841. package/es/core/objects/PDFDict.d.ts +12 -11
  842. package/es/core/objects/PDFDict.d.ts.map +1 -1
  843. package/es/core/objects/PDFDict.js +73 -86
  844. package/es/core/objects/PDFDict.js.map +1 -1
  845. package/es/core/objects/PDFHexString.d.ts +1 -1
  846. package/es/core/objects/PDFHexString.d.ts.map +1 -1
  847. package/es/core/objects/PDFHexString.js +44 -48
  848. package/es/core/objects/PDFHexString.js.map +1 -1
  849. package/es/core/objects/PDFInvalidObject.d.ts +1 -1
  850. package/es/core/objects/PDFInvalidObject.d.ts.map +1 -1
  851. package/es/core/objects/PDFInvalidObject.js +18 -22
  852. package/es/core/objects/PDFInvalidObject.js.map +1 -1
  853. package/es/core/objects/PDFName.d.ts +1 -1
  854. package/es/core/objects/PDFName.d.ts.map +1 -1
  855. package/es/core/objects/PDFName.js +82 -91
  856. package/es/core/objects/PDFName.js.map +1 -1
  857. package/es/core/objects/PDFNull.d.ts +1 -1
  858. package/es/core/objects/PDFNull.d.ts.map +1 -1
  859. package/es/core/objects/PDFNull.js +14 -20
  860. package/es/core/objects/PDFNull.js.map +1 -1
  861. package/es/core/objects/PDFNumber.d.ts +1 -1
  862. package/es/core/objects/PDFNumber.d.ts.map +1 -1
  863. package/es/core/objects/PDFNumber.js +21 -25
  864. package/es/core/objects/PDFNumber.js.map +1 -1
  865. package/es/core/objects/PDFObject.d.ts +1 -1
  866. package/es/core/objects/PDFObject.d.ts.map +1 -1
  867. package/es/core/objects/PDFObject.js +11 -14
  868. package/es/core/objects/PDFObject.js.map +1 -1
  869. package/es/core/objects/PDFRawStream.d.ts +6 -4
  870. package/es/core/objects/PDFRawStream.d.ts.map +1 -1
  871. package/es/core/objects/PDFRawStream.js +19 -24
  872. package/es/core/objects/PDFRawStream.js.map +1 -1
  873. package/es/core/objects/PDFRef.d.ts +1 -1
  874. package/es/core/objects/PDFRef.d.ts.map +1 -1
  875. package/es/core/objects/PDFRef.js +29 -35
  876. package/es/core/objects/PDFRef.js.map +1 -1
  877. package/es/core/objects/PDFStream.d.ts +3 -3
  878. package/es/core/objects/PDFStream.d.ts.map +1 -1
  879. package/es/core/objects/PDFStream.js +31 -35
  880. package/es/core/objects/PDFStream.js.map +1 -1
  881. package/es/core/objects/PDFString.d.ts +1 -1
  882. package/es/core/objects/PDFString.d.ts.map +1 -1
  883. package/es/core/objects/PDFString.js +50 -54
  884. package/es/core/objects/PDFString.js.map +1 -1
  885. package/es/core/operators/PDFOperator.d.ts +7 -7
  886. package/es/core/operators/PDFOperator.d.ts.map +1 -1
  887. package/es/core/operators/PDFOperator.js +26 -29
  888. package/es/core/operators/PDFOperator.js.map +1 -1
  889. package/es/core/parser/BaseParser.d.ts +1 -1
  890. package/es/core/parser/BaseParser.d.ts.map +1 -1
  891. package/es/core/parser/BaseParser.js +36 -38
  892. package/es/core/parser/BaseParser.js.map +1 -1
  893. package/es/core/parser/ByteStream.d.ts +1 -1
  894. package/es/core/parser/ByteStream.d.ts.map +1 -1
  895. package/es/core/parser/ByteStream.js +29 -32
  896. package/es/core/parser/ByteStream.js.map +1 -1
  897. package/es/core/parser/PDFObjectParser.d.ts +22 -20
  898. package/es/core/parser/PDFObjectParser.d.ts.map +1 -1
  899. package/es/core/parser/PDFObjectParser.js +92 -85
  900. package/es/core/parser/PDFObjectParser.js.map +1 -1
  901. package/es/core/parser/PDFObjectStreamParser.d.ts +2 -2
  902. package/es/core/parser/PDFObjectStreamParser.d.ts.map +1 -1
  903. package/es/core/parser/PDFObjectStreamParser.js +40 -61
  904. package/es/core/parser/PDFObjectStreamParser.js.map +1 -1
  905. package/es/core/parser/PDFParser.d.ts +5 -4
  906. package/es/core/parser/PDFParser.d.ts.map +1 -1
  907. package/es/core/parser/PDFParser.js +156 -219
  908. package/es/core/parser/PDFParser.js.map +1 -1
  909. package/es/core/parser/PDFXRefStreamParser.d.ts +2 -2
  910. package/es/core/parser/PDFXRefStreamParser.d.ts.map +1 -1
  911. package/es/core/parser/PDFXRefStreamParser.js +37 -40
  912. package/es/core/parser/PDFXRefStreamParser.js.map +1 -1
  913. package/es/core/streams/Ascii85Stream.d.ts +2 -2
  914. package/es/core/streams/Ascii85Stream.d.ts.map +1 -1
  915. package/es/core/streams/Ascii85Stream.js +20 -26
  916. package/es/core/streams/Ascii85Stream.js.map +1 -1
  917. package/es/core/streams/AsciiHexStream.d.ts +2 -2
  918. package/es/core/streams/AsciiHexStream.d.ts.map +1 -1
  919. package/es/core/streams/AsciiHexStream.js +18 -22
  920. package/es/core/streams/AsciiHexStream.js.map +1 -1
  921. package/es/core/streams/DecodeStream.d.ts +1 -1
  922. package/es/core/streams/DecodeStream.d.ts.map +1 -1
  923. package/es/core/streams/DecodeStream.js +53 -60
  924. package/es/core/streams/DecodeStream.js.map +1 -1
  925. package/es/core/streams/DecryptStream.d.ts +13 -0
  926. package/es/core/streams/DecryptStream.d.ts.map +1 -0
  927. package/es/core/streams/DecryptStream.js +34 -0
  928. package/es/core/streams/DecryptStream.js.map +1 -0
  929. package/es/core/streams/FlateStream.d.ts +2 -2
  930. package/es/core/streams/FlateStream.d.ts.map +1 -1
  931. package/es/core/streams/FlateStream.js +80 -84
  932. package/es/core/streams/FlateStream.js.map +1 -1
  933. package/es/core/streams/LZWStream.d.ts +3 -3
  934. package/es/core/streams/LZWStream.d.ts.map +1 -1
  935. package/es/core/streams/LZWStream.js +41 -45
  936. package/es/core/streams/LZWStream.js.map +1 -1
  937. package/es/core/streams/RunLengthStream.d.ts +2 -2
  938. package/es/core/streams/RunLengthStream.d.ts.map +1 -1
  939. package/es/core/streams/RunLengthStream.js +15 -19
  940. package/es/core/streams/RunLengthStream.js.map +1 -1
  941. package/es/core/streams/Stream.js +45 -56
  942. package/es/core/streams/Stream.js.map +1 -1
  943. package/es/core/streams/decode.d.ts +3 -3
  944. package/es/core/streams/decode.d.ts.map +1 -1
  945. package/es/core/streams/decode.js +22 -20
  946. package/es/core/streams/decode.js.map +1 -1
  947. package/es/core/structures/PDFCatalog.d.ts +5 -5
  948. package/es/core/structures/PDFCatalog.d.ts.map +1 -1
  949. package/es/core/structures/PDFCatalog.js +39 -47
  950. package/es/core/structures/PDFCatalog.js.map +1 -1
  951. package/es/core/structures/PDFContentStream.d.ts +4 -4
  952. package/es/core/structures/PDFContentStream.d.ts.map +1 -1
  953. package/es/core/structures/PDFContentStream.js +30 -43
  954. package/es/core/structures/PDFContentStream.js.map +1 -1
  955. package/es/core/structures/PDFCrossRefStream.d.ts +4 -4
  956. package/es/core/structures/PDFCrossRefStream.d.ts.map +1 -1
  957. package/es/core/structures/PDFCrossRefStream.js +91 -100
  958. package/es/core/structures/PDFCrossRefStream.js.map +1 -1
  959. package/es/core/structures/PDFFlateStream.d.ts +3 -3
  960. package/es/core/structures/PDFFlateStream.d.ts.map +1 -1
  961. package/es/core/structures/PDFFlateStream.js +19 -23
  962. package/es/core/structures/PDFFlateStream.js.map +1 -1
  963. package/es/core/structures/PDFObjectStream.d.ts +4 -4
  964. package/es/core/structures/PDFObjectStream.d.ts.map +1 -1
  965. package/es/core/structures/PDFObjectStream.js +46 -54
  966. package/es/core/structures/PDFObjectStream.js.map +1 -1
  967. package/es/core/structures/PDFPageLeaf.d.ts +9 -9
  968. package/es/core/structures/PDFPageLeaf.d.ts.map +1 -1
  969. package/es/core/structures/PDFPageLeaf.js +125 -133
  970. package/es/core/structures/PDFPageLeaf.js.map +1 -1
  971. package/es/core/structures/PDFPageTree.d.ts +6 -6
  972. package/es/core/structures/PDFPageTree.d.ts.map +1 -1
  973. package/es/core/structures/PDFPageTree.js +66 -75
  974. package/es/core/structures/PDFPageTree.js.map +1 -1
  975. package/es/core/syntax/Delimiters.js +2 -2
  976. package/es/core/syntax/Delimiters.js.map +1 -1
  977. package/es/core/syntax/Irregular.js +5 -5
  978. package/es/core/syntax/Irregular.js.map +1 -1
  979. package/es/core/syntax/Keywords.d.ts +1 -1
  980. package/es/core/syntax/Keywords.d.ts.map +1 -1
  981. package/es/core/syntax/Keywords.js +14 -15
  982. package/es/core/syntax/Keywords.js.map +1 -1
  983. package/es/core/syntax/Numeric.js +5 -5
  984. package/es/core/syntax/Numeric.js.map +1 -1
  985. package/es/core/syntax/Whitespace.js +2 -2
  986. package/es/core/syntax/Whitespace.js.map +1 -1
  987. package/es/core/writers/PDFStreamWriter.d.ts +6 -6
  988. package/es/core/writers/PDFStreamWriter.d.ts.map +1 -1
  989. package/es/core/writers/PDFStreamWriter.js +73 -107
  990. package/es/core/writers/PDFStreamWriter.js.map +1 -1
  991. package/es/core/writers/PDFWriter.d.ts +12 -9
  992. package/es/core/writers/PDFWriter.d.ts.map +1 -1
  993. package/es/core/writers/PDFWriter.js +86 -127
  994. package/es/core/writers/PDFWriter.js.map +1 -1
  995. package/es/index.d.ts +4 -4
  996. package/es/index.d.ts.map +1 -1
  997. package/es/index.js +4 -4
  998. package/es/index.js.map +1 -1
  999. package/es/package.json +3 -0
  1000. package/es/types/fontkit.js +1 -0
  1001. package/es/types/index.d.ts +25 -1
  1002. package/es/types/index.d.ts.map +1 -1
  1003. package/es/types/index.js +1 -0
  1004. package/es/types/matrix.d.ts +8 -1
  1005. package/es/types/matrix.d.ts.map +1 -1
  1006. package/es/types/matrix.js +1 -1
  1007. package/es/types/matrix.js.map +1 -1
  1008. package/es/utils/Cache.js +10 -11
  1009. package/es/utils/Cache.js.map +1 -1
  1010. package/es/utils/arrays.d.ts +2 -1
  1011. package/es/utils/arrays.d.ts.map +1 -1
  1012. package/es/utils/arrays.js +65 -60
  1013. package/es/utils/arrays.js.map +1 -1
  1014. package/es/utils/async.d.ts.map +1 -1
  1015. package/es/utils/async.js +3 -5
  1016. package/es/utils/async.js.map +1 -1
  1017. package/es/utils/base64.d.ts.map +1 -1
  1018. package/es/utils/base64.js +24 -24
  1019. package/es/utils/base64.js.map +1 -1
  1020. package/es/utils/elements/Arc.d.ts +23 -0
  1021. package/es/utils/elements/Arc.d.ts.map +1 -0
  1022. package/es/utils/elements/Arc.js +74 -0
  1023. package/es/utils/elements/Arc.js.map +1 -0
  1024. package/es/utils/elements/Circle.d.ts +15 -0
  1025. package/es/utils/elements/Circle.d.ts.map +1 -0
  1026. package/es/utils/elements/Circle.js +37 -0
  1027. package/es/utils/elements/Circle.js.map +1 -0
  1028. package/es/utils/elements/Ellipse.d.ts +21 -0
  1029. package/es/utils/elements/Ellipse.d.ts.map +1 -0
  1030. package/es/utils/elements/Ellipse.js +87 -0
  1031. package/es/utils/elements/Ellipse.js.map +1 -0
  1032. package/es/utils/elements/GraphElement.d.ts +7 -0
  1033. package/es/utils/elements/GraphElement.d.ts.map +1 -0
  1034. package/es/utils/elements/GraphElement.js +8 -0
  1035. package/es/utils/elements/GraphElement.js.map +1 -0
  1036. package/es/utils/elements/Line.d.ts +24 -0
  1037. package/es/utils/elements/Line.d.ts.map +1 -0
  1038. package/es/utils/elements/Line.js +68 -0
  1039. package/es/utils/elements/Line.js.map +1 -0
  1040. package/es/utils/elements/Plot.d.ts +12 -0
  1041. package/es/utils/elements/Plot.d.ts.map +1 -0
  1042. package/es/utils/elements/Plot.js +42 -0
  1043. package/es/utils/elements/Plot.js.map +1 -0
  1044. package/es/utils/elements/Point.d.ts +19 -0
  1045. package/es/utils/elements/Point.d.ts.map +1 -0
  1046. package/es/utils/elements/Point.js +28 -0
  1047. package/es/utils/elements/Point.js.map +1 -0
  1048. package/es/utils/elements/Rectangle.d.ts +22 -0
  1049. package/es/utils/elements/Rectangle.d.ts.map +1 -0
  1050. package/es/utils/elements/Rectangle.js +54 -0
  1051. package/es/utils/elements/Rectangle.js.map +1 -0
  1052. package/es/utils/elements/Segment.d.ts +20 -0
  1053. package/es/utils/elements/Segment.d.ts.map +1 -0
  1054. package/es/utils/elements/Segment.js +76 -0
  1055. package/es/utils/elements/Segment.js.map +1 -0
  1056. package/es/utils/elements/index.d.ts +10 -0
  1057. package/es/utils/elements/index.d.ts.map +1 -0
  1058. package/es/utils/elements/index.js +10 -0
  1059. package/es/utils/elements/index.js.map +1 -0
  1060. package/es/utils/errors.js +1 -1
  1061. package/es/utils/errors.js.map +1 -1
  1062. package/es/utils/index.d.ts +11 -11
  1063. package/es/utils/index.d.ts.map +1 -1
  1064. package/es/utils/index.js +11 -11
  1065. package/es/utils/index.js.map +1 -1
  1066. package/es/utils/intersections.d.ts +10 -0
  1067. package/es/utils/intersections.d.ts.map +1 -0
  1068. package/es/utils/intersections.js +245 -0
  1069. package/es/utils/intersections.js.map +1 -0
  1070. package/es/utils/maths.d.ts +46 -0
  1071. package/es/utils/maths.d.ts.map +1 -0
  1072. package/es/utils/maths.js +69 -0
  1073. package/es/utils/maths.js.map +1 -0
  1074. package/es/utils/numbers.js +9 -9
  1075. package/es/utils/numbers.js.map +1 -1
  1076. package/es/utils/objects.js +4 -6
  1077. package/es/utils/objects.js.map +1 -1
  1078. package/es/utils/pdfDocEncoding.js +7 -7
  1079. package/es/utils/pdfDocEncoding.js.map +1 -1
  1080. package/es/utils/png.js +20 -22
  1081. package/es/utils/png.js.map +1 -1
  1082. package/es/utils/rng.js +7 -9
  1083. package/es/utils/rng.js.map +1 -1
  1084. package/es/utils/strings.d.ts +1 -0
  1085. package/es/utils/strings.d.ts.map +1 -1
  1086. package/es/utils/strings.js +62 -68
  1087. package/es/utils/strings.js.map +1 -1
  1088. package/es/utils/unicode.js +42 -63
  1089. package/es/utils/unicode.js.map +1 -1
  1090. package/es/utils/validators.js +38 -38
  1091. package/es/utils/validators.js.map +1 -1
  1092. package/package.json +29 -20
  1093. package/src/api/PDFDocument.ts +48 -21
  1094. package/src/api/PDFDocumentOptions.ts +3 -2
  1095. package/src/api/PDFEmbeddedFile.ts +4 -4
  1096. package/src/api/PDFEmbeddedPage.ts +4 -4
  1097. package/src/api/PDFFont.ts +4 -4
  1098. package/src/api/PDFImage.ts +4 -4
  1099. package/src/api/PDFJavaScript.ts +4 -4
  1100. package/src/api/PDFPage.ts +66 -19
  1101. package/src/api/PDFPageOptions.ts +28 -12
  1102. package/src/api/colors.ts +12 -2
  1103. package/src/api/form/PDFButton.ts +11 -11
  1104. package/src/api/form/PDFCheckBox.ts +8 -8
  1105. package/src/api/form/PDFDropdown.ts +9 -9
  1106. package/src/api/form/PDFField.ts +7 -7
  1107. package/src/api/form/PDFForm.ts +46 -38
  1108. package/src/api/form/PDFOptionList.ts +9 -9
  1109. package/src/api/form/PDFRadioGroup.ts +8 -8
  1110. package/src/api/form/PDFSignature.ts +4 -4
  1111. package/src/api/form/PDFTextField.ts +13 -13
  1112. package/src/api/form/appearances.ts +40 -48
  1113. package/src/api/form/index.ts +10 -10
  1114. package/src/api/image/index.ts +1 -1
  1115. package/src/api/index.ts +20 -20
  1116. package/src/api/objects.ts +1 -1
  1117. package/src/api/operations.ts +55 -12
  1118. package/src/api/operators.ts +10 -3
  1119. package/src/api/rotations.ts +1 -1
  1120. package/src/api/svg.ts +937 -0
  1121. package/src/api/svgPath.ts +2 -4
  1122. package/src/api/text/index.ts +2 -2
  1123. package/src/api/text/layout.ts +5 -5
  1124. package/src/core/PDFContext.ts +20 -19
  1125. package/src/core/PDFObjectCopier.ts +8 -8
  1126. package/src/core/acroform/PDFAcroButton.ts +8 -8
  1127. package/src/core/acroform/PDFAcroCheckBox.ts +6 -6
  1128. package/src/core/acroform/PDFAcroChoice.ts +7 -10
  1129. package/src/core/acroform/PDFAcroComboBox.ts +5 -5
  1130. package/src/core/acroform/PDFAcroField.ts +12 -11
  1131. package/src/core/acroform/PDFAcroForm.ts +8 -11
  1132. package/src/core/acroform/PDFAcroListBox.ts +4 -4
  1133. package/src/core/acroform/PDFAcroNonTerminal.ts +5 -5
  1134. package/src/core/acroform/PDFAcroPushButton.ts +5 -5
  1135. package/src/core/acroform/PDFAcroRadioButton.ts +7 -7
  1136. package/src/core/acroform/PDFAcroSignature.ts +3 -3
  1137. package/src/core/acroform/PDFAcroTerminal.ts +6 -6
  1138. package/src/core/acroform/PDFAcroText.ts +8 -8
  1139. package/src/core/acroform/index.ts +15 -15
  1140. package/src/core/acroform/utils.ts +20 -20
  1141. package/src/core/annotation/AppearanceCharacteristics.ts +6 -6
  1142. package/src/core/annotation/BorderStyle.ts +3 -3
  1143. package/src/core/annotation/PDFAnnotation.ts +6 -6
  1144. package/src/core/annotation/PDFWidgetAnnotation.ts +9 -9
  1145. package/src/core/annotation/index.ts +4 -4
  1146. package/src/core/crypto.ts +1989 -0
  1147. package/src/core/document/PDFCrossRefSection.ts +3 -3
  1148. package/src/core/document/PDFHeader.ts +2 -2
  1149. package/src/core/document/PDFTrailer.ts +2 -2
  1150. package/src/core/document/PDFTrailerDict.ts +2 -2
  1151. package/src/core/embedders/CMap.ts +3 -3
  1152. package/src/core/embedders/CustomFontEmbedder.ts +9 -9
  1153. package/src/core/embedders/CustomFontSubsetEmbedder.ts +11 -4
  1154. package/src/core/embedders/FileEmbedder.ts +4 -4
  1155. package/src/core/embedders/FontFlags.ts +1 -1
  1156. package/src/core/embedders/JavaScriptEmbedder.ts +3 -3
  1157. package/src/core/embedders/JpegEmbedder.ts +2 -2
  1158. package/src/core/embedders/PDFPageEmbedder.ts +13 -13
  1159. package/src/core/embedders/PngEmbedder.ts +3 -3
  1160. package/src/core/embedders/StandardFontEmbedder.ts +4 -4
  1161. package/src/core/errors.ts +2 -2
  1162. package/src/core/index.ts +47 -47
  1163. package/src/core/interactive/ViewerPreferences.ts +7 -7
  1164. package/src/core/objects/PDFArray.ts +14 -14
  1165. package/src/core/objects/PDFBool.ts +3 -3
  1166. package/src/core/objects/PDFDict.ts +14 -12
  1167. package/src/core/objects/PDFHexString.ts +4 -4
  1168. package/src/core/objects/PDFInvalidObject.ts +1 -1
  1169. package/src/core/objects/PDFName.ts +5 -5
  1170. package/src/core/objects/PDFNull.ts +2 -2
  1171. package/src/core/objects/PDFNumber.ts +2 -2
  1172. package/src/core/objects/PDFObject.ts +2 -2
  1173. package/src/core/objects/PDFRawStream.ts +17 -7
  1174. package/src/core/objects/PDFRef.ts +3 -3
  1175. package/src/core/objects/PDFStream.ts +7 -7
  1176. package/src/core/objects/PDFString.ts +4 -4
  1177. package/src/core/operators/PDFOperator.ts +10 -10
  1178. package/src/core/parser/BaseParser.ts +6 -6
  1179. package/src/core/parser/ByteStream.ts +4 -4
  1180. package/src/core/parser/PDFObjectParser.ts +78 -41
  1181. package/src/core/parser/PDFObjectStreamParser.ts +9 -9
  1182. package/src/core/parser/PDFParser.ts +37 -22
  1183. package/src/core/parser/PDFXRefStreamParser.ts +9 -9
  1184. package/src/core/streams/Ascii85Stream.ts +2 -2
  1185. package/src/core/streams/AsciiHexStream.ts +2 -2
  1186. package/src/core/streams/DecodeStream.ts +2 -2
  1187. package/src/core/streams/DecryptStream.ts +56 -0
  1188. package/src/core/streams/FlateStream.ts +2 -2
  1189. package/src/core/streams/LZWStream.ts +3 -3
  1190. package/src/core/streams/RunLengthStream.ts +2 -2
  1191. package/src/core/streams/decode.ts +22 -17
  1192. package/src/core/structures/PDFCatalog.ts +6 -6
  1193. package/src/core/structures/PDFContentStream.ts +5 -5
  1194. package/src/core/structures/PDFCrossRefStream.ts +6 -6
  1195. package/src/core/structures/PDFFlateStream.ts +5 -5
  1196. package/src/core/structures/PDFObjectStream.ts +8 -8
  1197. package/src/core/structures/PDFPageLeaf.ts +9 -9
  1198. package/src/core/structures/PDFPageTree.ts +8 -8
  1199. package/src/core/syntax/Delimiters.ts +1 -1
  1200. package/src/core/syntax/Irregular.ts +3 -3
  1201. package/src/core/syntax/Keywords.ts +1 -1
  1202. package/src/core/syntax/Numeric.ts +1 -1
  1203. package/src/core/syntax/Whitespace.ts +1 -1
  1204. package/src/core/writers/PDFStreamWriter.ts +13 -13
  1205. package/src/core/writers/PDFWriter.ts +13 -19
  1206. package/src/index.ts +4 -4
  1207. package/src/types/index.ts +38 -1
  1208. package/src/utils/arrays.ts +14 -2
  1209. package/src/utils/base64.ts +2 -1
  1210. package/src/utils/elements/Arc.ts +107 -0
  1211. package/src/utils/elements/Circle.ts +55 -0
  1212. package/src/utils/elements/Ellipse.ts +135 -0
  1213. package/src/utils/elements/GraphElement.ts +14 -0
  1214. package/src/utils/elements/Line.ts +85 -0
  1215. package/src/utils/elements/Plot.ts +50 -0
  1216. package/src/utils/elements/Point.ts +37 -0
  1217. package/src/utils/elements/Rectangle.ts +65 -0
  1218. package/src/utils/elements/Segment.ts +92 -0
  1219. package/src/utils/elements/index.ts +9 -0
  1220. package/src/utils/index.ts +11 -11
  1221. package/src/utils/intersections.ts +282 -0
  1222. package/src/utils/maths.ts +108 -0
  1223. package/src/utils/pdfDocEncoding.ts +1 -1
  1224. package/src/utils/strings.ts +8 -1
  1225. package/src/utils/unicode.ts +1 -1
  1226. package/src/utils/validators.ts +1 -1
  1227. package/ts3.4/cjs/api/PDFDocument.d.ts +11 -11
  1228. package/ts3.4/cjs/api/PDFDocumentOptions.d.ts +3 -2
  1229. package/ts3.4/cjs/api/PDFEmbeddedFile.d.ts +4 -4
  1230. package/ts3.4/cjs/api/PDFEmbeddedPage.d.ts +3 -3
  1231. package/ts3.4/cjs/api/PDFFont.d.ts +3 -3
  1232. package/ts3.4/cjs/api/PDFImage.d.ts +3 -3
  1233. package/ts3.4/cjs/api/PDFJavaScript.d.ts +4 -4
  1234. package/ts3.4/cjs/api/PDFPage.d.ts +21 -9
  1235. package/ts3.4/cjs/api/PDFPageOptions.d.ts +29 -12
  1236. package/ts3.4/cjs/api/colors.d.ts +4 -0
  1237. package/ts3.4/cjs/api/form/PDFButton.d.ts +8 -8
  1238. package/ts3.4/cjs/api/form/PDFCheckBox.d.ts +5 -5
  1239. package/ts3.4/cjs/api/form/PDFDropdown.d.ts +6 -6
  1240. package/ts3.4/cjs/api/form/PDFField.d.ts +6 -6
  1241. package/ts3.4/cjs/api/form/PDFForm.d.ts +11 -11
  1242. package/ts3.4/cjs/api/form/PDFOptionList.d.ts +6 -6
  1243. package/ts3.4/cjs/api/form/PDFRadioGroup.d.ts +5 -5
  1244. package/ts3.4/cjs/api/form/PDFSignature.d.ts +3 -3
  1245. package/ts3.4/cjs/api/form/PDFTextField.d.ts +8 -8
  1246. package/ts3.4/cjs/api/form/appearances.d.ts +11 -11
  1247. package/ts3.4/cjs/api/form/index.d.ts +10 -10
  1248. package/ts3.4/cjs/api/image/index.d.ts +1 -1
  1249. package/ts3.4/cjs/api/index.d.ts +20 -20
  1250. package/ts3.4/cjs/api/objects.d.ts +1 -1
  1251. package/ts3.4/cjs/api/operations.d.ts +20 -4
  1252. package/ts3.4/cjs/api/operators.d.ts +6 -1
  1253. package/ts3.4/cjs/api/rotations.d.ts +1 -1
  1254. package/ts3.4/cjs/api/svg.d.ts +71 -0
  1255. package/ts3.4/cjs/api/svgPath.d.ts +1 -1
  1256. package/ts3.4/cjs/api/text/index.d.ts +2 -2
  1257. package/ts3.4/cjs/api/text/layout.d.ts +3 -3
  1258. package/ts3.4/cjs/core/PDFContext.d.ts +17 -16
  1259. package/ts3.4/cjs/core/PDFObjectCopier.d.ts +2 -2
  1260. package/ts3.4/cjs/core/acroform/PDFAcroButton.d.ts +7 -7
  1261. package/ts3.4/cjs/core/acroform/PDFAcroCheckBox.d.ts +5 -5
  1262. package/ts3.4/cjs/core/acroform/PDFAcroChoice.d.ts +4 -4
  1263. package/ts3.4/cjs/core/acroform/PDFAcroComboBox.d.ts +4 -4
  1264. package/ts3.4/cjs/core/acroform/PDFAcroField.d.ts +8 -8
  1265. package/ts3.4/cjs/core/acroform/PDFAcroForm.d.ts +5 -5
  1266. package/ts3.4/cjs/core/acroform/PDFAcroListBox.d.ts +4 -4
  1267. package/ts3.4/cjs/core/acroform/PDFAcroNonTerminal.d.ts +4 -4
  1268. package/ts3.4/cjs/core/acroform/PDFAcroPushButton.d.ts +4 -4
  1269. package/ts3.4/cjs/core/acroform/PDFAcroRadioButton.d.ts +5 -5
  1270. package/ts3.4/cjs/core/acroform/PDFAcroSignature.d.ts +3 -3
  1271. package/ts3.4/cjs/core/acroform/PDFAcroTerminal.d.ts +5 -5
  1272. package/ts3.4/cjs/core/acroform/PDFAcroText.d.ts +7 -7
  1273. package/ts3.4/cjs/core/acroform/index.d.ts +15 -15
  1274. package/ts3.4/cjs/core/acroform/utils.d.ts +4 -4
  1275. package/ts3.4/cjs/core/annotation/AppearanceCharacteristics.d.ts +5 -5
  1276. package/ts3.4/cjs/core/annotation/BorderStyle.d.ts +2 -2
  1277. package/ts3.4/cjs/core/annotation/PDFAnnotation.d.ts +6 -6
  1278. package/ts3.4/cjs/core/annotation/PDFWidgetAnnotation.d.ts +9 -9
  1279. package/ts3.4/cjs/core/annotation/index.d.ts +4 -4
  1280. package/ts3.4/cjs/core/crypto.d.ts +96 -0
  1281. package/ts3.4/cjs/core/document/PDFCrossRefSection.d.ts +1 -1
  1282. package/ts3.4/cjs/core/document/PDFTrailerDict.d.ts +1 -1
  1283. package/ts3.4/cjs/core/embedders/CMap.d.ts +1 -1
  1284. package/ts3.4/cjs/core/embedders/CustomFontEmbedder.d.ts +5 -5
  1285. package/ts3.4/cjs/core/embedders/CustomFontSubsetEmbedder.d.ts +3 -3
  1286. package/ts3.4/cjs/core/embedders/FileEmbedder.d.ts +2 -2
  1287. package/ts3.4/cjs/core/embedders/FontFlags.d.ts +1 -1
  1288. package/ts3.4/cjs/core/embedders/JavaScriptEmbedder.d.ts +2 -2
  1289. package/ts3.4/cjs/core/embedders/JpegEmbedder.d.ts +2 -2
  1290. package/ts3.4/cjs/core/embedders/PDFPageEmbedder.d.ts +4 -4
  1291. package/ts3.4/cjs/core/embedders/PngEmbedder.d.ts +2 -2
  1292. package/ts3.4/cjs/core/embedders/StandardFontEmbedder.d.ts +3 -3
  1293. package/ts3.4/cjs/core/errors.d.ts +1 -1
  1294. package/ts3.4/cjs/core/index.d.ts +47 -47
  1295. package/ts3.4/cjs/core/interactive/ViewerPreferences.d.ts +6 -6
  1296. package/ts3.4/cjs/core/objects/PDFArray.d.ts +12 -12
  1297. package/ts3.4/cjs/core/objects/PDFBool.d.ts +1 -1
  1298. package/ts3.4/cjs/core/objects/PDFDict.d.ts +12 -11
  1299. package/ts3.4/cjs/core/objects/PDFHexString.d.ts +1 -1
  1300. package/ts3.4/cjs/core/objects/PDFInvalidObject.d.ts +1 -1
  1301. package/ts3.4/cjs/core/objects/PDFName.d.ts +1 -1
  1302. package/ts3.4/cjs/core/objects/PDFNull.d.ts +1 -1
  1303. package/ts3.4/cjs/core/objects/PDFNumber.d.ts +1 -1
  1304. package/ts3.4/cjs/core/objects/PDFObject.d.ts +1 -1
  1305. package/ts3.4/cjs/core/objects/PDFRawStream.d.ts +6 -4
  1306. package/ts3.4/cjs/core/objects/PDFRef.d.ts +1 -1
  1307. package/ts3.4/cjs/core/objects/PDFStream.d.ts +3 -3
  1308. package/ts3.4/cjs/core/objects/PDFString.d.ts +1 -1
  1309. package/ts3.4/cjs/core/operators/PDFOperator.d.ts +7 -7
  1310. package/ts3.4/cjs/core/parser/BaseParser.d.ts +1 -1
  1311. package/ts3.4/cjs/core/parser/ByteStream.d.ts +1 -1
  1312. package/ts3.4/cjs/core/parser/PDFObjectParser.d.ts +22 -20
  1313. package/ts3.4/cjs/core/parser/PDFObjectStreamParser.d.ts +2 -2
  1314. package/ts3.4/cjs/core/parser/PDFParser.d.ts +5 -4
  1315. package/ts3.4/cjs/core/parser/PDFXRefStreamParser.d.ts +2 -2
  1316. package/ts3.4/cjs/core/streams/Ascii85Stream.d.ts +2 -2
  1317. package/ts3.4/cjs/core/streams/AsciiHexStream.d.ts +2 -2
  1318. package/ts3.4/cjs/core/streams/DecodeStream.d.ts +1 -1
  1319. package/ts3.4/cjs/core/streams/DecryptStream.d.ts +13 -0
  1320. package/ts3.4/cjs/core/streams/FlateStream.d.ts +2 -2
  1321. package/ts3.4/cjs/core/streams/LZWStream.d.ts +3 -3
  1322. package/ts3.4/cjs/core/streams/RunLengthStream.d.ts +2 -2
  1323. package/ts3.4/cjs/core/streams/decode.d.ts +3 -3
  1324. package/ts3.4/cjs/core/structures/PDFCatalog.d.ts +5 -5
  1325. package/ts3.4/cjs/core/structures/PDFContentStream.d.ts +4 -4
  1326. package/ts3.4/cjs/core/structures/PDFCrossRefStream.d.ts +4 -4
  1327. package/ts3.4/cjs/core/structures/PDFFlateStream.d.ts +3 -3
  1328. package/ts3.4/cjs/core/structures/PDFObjectStream.d.ts +4 -4
  1329. package/ts3.4/cjs/core/structures/PDFPageLeaf.d.ts +9 -9
  1330. package/ts3.4/cjs/core/structures/PDFPageTree.d.ts +6 -6
  1331. package/ts3.4/cjs/core/syntax/Keywords.d.ts +1 -1
  1332. package/ts3.4/cjs/core/writers/PDFStreamWriter.d.ts +6 -6
  1333. package/ts3.4/cjs/core/writers/PDFWriter.d.ts +8 -8
  1334. package/ts3.4/cjs/index.d.ts +4 -4
  1335. package/ts3.4/cjs/types/index.d.ts +25 -1
  1336. package/ts3.4/cjs/utils/arrays.d.ts +2 -1
  1337. package/ts3.4/cjs/utils/elements/Arc.d.ts +23 -0
  1338. package/ts3.4/cjs/utils/elements/Circle.d.ts +15 -0
  1339. package/ts3.4/cjs/utils/elements/Ellipse.d.ts +21 -0
  1340. package/ts3.4/cjs/utils/elements/GraphElement.d.ts +7 -0
  1341. package/ts3.4/cjs/utils/elements/Line.d.ts +24 -0
  1342. package/ts3.4/cjs/utils/elements/Plot.d.ts +12 -0
  1343. package/ts3.4/cjs/utils/elements/Point.d.ts +19 -0
  1344. package/ts3.4/cjs/utils/elements/Rectangle.d.ts +22 -0
  1345. package/ts3.4/cjs/utils/elements/Segment.d.ts +20 -0
  1346. package/ts3.4/cjs/utils/elements/index.d.ts +10 -0
  1347. package/ts3.4/cjs/utils/index.d.ts +11 -11
  1348. package/ts3.4/cjs/utils/intersections.d.ts +10 -0
  1349. package/ts3.4/cjs/utils/maths.d.ts +46 -0
  1350. package/ts3.4/cjs/utils/strings.d.ts +1 -0
  1351. package/ts3.4/es/api/PDFDocument.d.ts +11 -11
  1352. package/ts3.4/es/api/PDFDocumentOptions.d.ts +3 -2
  1353. package/ts3.4/es/api/PDFEmbeddedFile.d.ts +4 -4
  1354. package/ts3.4/es/api/PDFEmbeddedPage.d.ts +3 -3
  1355. package/ts3.4/es/api/PDFFont.d.ts +3 -3
  1356. package/ts3.4/es/api/PDFImage.d.ts +3 -3
  1357. package/ts3.4/es/api/PDFJavaScript.d.ts +4 -4
  1358. package/ts3.4/es/api/PDFPage.d.ts +21 -9
  1359. package/ts3.4/es/api/PDFPageOptions.d.ts +29 -12
  1360. package/ts3.4/es/api/colors.d.ts +4 -0
  1361. package/ts3.4/es/api/form/PDFButton.d.ts +8 -8
  1362. package/ts3.4/es/api/form/PDFCheckBox.d.ts +5 -5
  1363. package/ts3.4/es/api/form/PDFDropdown.d.ts +6 -6
  1364. package/ts3.4/es/api/form/PDFField.d.ts +6 -6
  1365. package/ts3.4/es/api/form/PDFForm.d.ts +11 -11
  1366. package/ts3.4/es/api/form/PDFOptionList.d.ts +6 -6
  1367. package/ts3.4/es/api/form/PDFRadioGroup.d.ts +5 -5
  1368. package/ts3.4/es/api/form/PDFSignature.d.ts +3 -3
  1369. package/ts3.4/es/api/form/PDFTextField.d.ts +8 -8
  1370. package/ts3.4/es/api/form/appearances.d.ts +11 -11
  1371. package/ts3.4/es/api/form/index.d.ts +10 -10
  1372. package/ts3.4/es/api/image/index.d.ts +1 -1
  1373. package/ts3.4/es/api/index.d.ts +20 -20
  1374. package/ts3.4/es/api/objects.d.ts +1 -1
  1375. package/ts3.4/es/api/operations.d.ts +20 -4
  1376. package/ts3.4/es/api/operators.d.ts +6 -1
  1377. package/ts3.4/es/api/rotations.d.ts +1 -1
  1378. package/ts3.4/es/api/svg.d.ts +71 -0
  1379. package/ts3.4/es/api/svgPath.d.ts +1 -1
  1380. package/ts3.4/es/api/text/index.d.ts +2 -2
  1381. package/ts3.4/es/api/text/layout.d.ts +3 -3
  1382. package/ts3.4/es/core/PDFContext.d.ts +17 -16
  1383. package/ts3.4/es/core/PDFObjectCopier.d.ts +2 -2
  1384. package/ts3.4/es/core/acroform/PDFAcroButton.d.ts +7 -7
  1385. package/ts3.4/es/core/acroform/PDFAcroCheckBox.d.ts +5 -5
  1386. package/ts3.4/es/core/acroform/PDFAcroChoice.d.ts +4 -4
  1387. package/ts3.4/es/core/acroform/PDFAcroComboBox.d.ts +4 -4
  1388. package/ts3.4/es/core/acroform/PDFAcroField.d.ts +8 -8
  1389. package/ts3.4/es/core/acroform/PDFAcroForm.d.ts +5 -5
  1390. package/ts3.4/es/core/acroform/PDFAcroListBox.d.ts +4 -4
  1391. package/ts3.4/es/core/acroform/PDFAcroNonTerminal.d.ts +4 -4
  1392. package/ts3.4/es/core/acroform/PDFAcroPushButton.d.ts +4 -4
  1393. package/ts3.4/es/core/acroform/PDFAcroRadioButton.d.ts +5 -5
  1394. package/ts3.4/es/core/acroform/PDFAcroSignature.d.ts +3 -3
  1395. package/ts3.4/es/core/acroform/PDFAcroTerminal.d.ts +5 -5
  1396. package/ts3.4/es/core/acroform/PDFAcroText.d.ts +7 -7
  1397. package/ts3.4/es/core/acroform/index.d.ts +15 -15
  1398. package/ts3.4/es/core/acroform/utils.d.ts +4 -4
  1399. package/ts3.4/es/core/annotation/AppearanceCharacteristics.d.ts +5 -5
  1400. package/ts3.4/es/core/annotation/BorderStyle.d.ts +2 -2
  1401. package/ts3.4/es/core/annotation/PDFAnnotation.d.ts +6 -6
  1402. package/ts3.4/es/core/annotation/PDFWidgetAnnotation.d.ts +9 -9
  1403. package/ts3.4/es/core/annotation/index.d.ts +4 -4
  1404. package/ts3.4/es/core/crypto.d.ts +96 -0
  1405. package/ts3.4/es/core/document/PDFCrossRefSection.d.ts +1 -1
  1406. package/ts3.4/es/core/document/PDFTrailerDict.d.ts +1 -1
  1407. package/ts3.4/es/core/embedders/CMap.d.ts +1 -1
  1408. package/ts3.4/es/core/embedders/CustomFontEmbedder.d.ts +5 -5
  1409. package/ts3.4/es/core/embedders/CustomFontSubsetEmbedder.d.ts +3 -3
  1410. package/ts3.4/es/core/embedders/FileEmbedder.d.ts +2 -2
  1411. package/ts3.4/es/core/embedders/FontFlags.d.ts +1 -1
  1412. package/ts3.4/es/core/embedders/JavaScriptEmbedder.d.ts +2 -2
  1413. package/ts3.4/es/core/embedders/JpegEmbedder.d.ts +2 -2
  1414. package/ts3.4/es/core/embedders/PDFPageEmbedder.d.ts +4 -4
  1415. package/ts3.4/es/core/embedders/PngEmbedder.d.ts +2 -2
  1416. package/ts3.4/es/core/embedders/StandardFontEmbedder.d.ts +3 -3
  1417. package/ts3.4/es/core/errors.d.ts +1 -1
  1418. package/ts3.4/es/core/index.d.ts +47 -47
  1419. package/ts3.4/es/core/interactive/ViewerPreferences.d.ts +6 -6
  1420. package/ts3.4/es/core/objects/PDFArray.d.ts +12 -12
  1421. package/ts3.4/es/core/objects/PDFBool.d.ts +1 -1
  1422. package/ts3.4/es/core/objects/PDFDict.d.ts +12 -11
  1423. package/ts3.4/es/core/objects/PDFHexString.d.ts +1 -1
  1424. package/ts3.4/es/core/objects/PDFInvalidObject.d.ts +1 -1
  1425. package/ts3.4/es/core/objects/PDFName.d.ts +1 -1
  1426. package/ts3.4/es/core/objects/PDFNull.d.ts +1 -1
  1427. package/ts3.4/es/core/objects/PDFNumber.d.ts +1 -1
  1428. package/ts3.4/es/core/objects/PDFObject.d.ts +1 -1
  1429. package/ts3.4/es/core/objects/PDFRawStream.d.ts +6 -4
  1430. package/ts3.4/es/core/objects/PDFRef.d.ts +1 -1
  1431. package/ts3.4/es/core/objects/PDFStream.d.ts +3 -3
  1432. package/ts3.4/es/core/objects/PDFString.d.ts +1 -1
  1433. package/ts3.4/es/core/operators/PDFOperator.d.ts +7 -7
  1434. package/ts3.4/es/core/parser/BaseParser.d.ts +1 -1
  1435. package/ts3.4/es/core/parser/ByteStream.d.ts +1 -1
  1436. package/ts3.4/es/core/parser/PDFObjectParser.d.ts +22 -20
  1437. package/ts3.4/es/core/parser/PDFObjectStreamParser.d.ts +2 -2
  1438. package/ts3.4/es/core/parser/PDFParser.d.ts +5 -4
  1439. package/ts3.4/es/core/parser/PDFXRefStreamParser.d.ts +2 -2
  1440. package/ts3.4/es/core/streams/Ascii85Stream.d.ts +2 -2
  1441. package/ts3.4/es/core/streams/AsciiHexStream.d.ts +2 -2
  1442. package/ts3.4/es/core/streams/DecodeStream.d.ts +1 -1
  1443. package/ts3.4/es/core/streams/DecryptStream.d.ts +13 -0
  1444. package/ts3.4/es/core/streams/FlateStream.d.ts +2 -2
  1445. package/ts3.4/es/core/streams/LZWStream.d.ts +3 -3
  1446. package/ts3.4/es/core/streams/RunLengthStream.d.ts +2 -2
  1447. package/ts3.4/es/core/streams/decode.d.ts +3 -3
  1448. package/ts3.4/es/core/structures/PDFCatalog.d.ts +5 -5
  1449. package/ts3.4/es/core/structures/PDFContentStream.d.ts +4 -4
  1450. package/ts3.4/es/core/structures/PDFCrossRefStream.d.ts +4 -4
  1451. package/ts3.4/es/core/structures/PDFFlateStream.d.ts +3 -3
  1452. package/ts3.4/es/core/structures/PDFObjectStream.d.ts +4 -4
  1453. package/ts3.4/es/core/structures/PDFPageLeaf.d.ts +9 -9
  1454. package/ts3.4/es/core/structures/PDFPageTree.d.ts +6 -6
  1455. package/ts3.4/es/core/syntax/Keywords.d.ts +1 -1
  1456. package/ts3.4/es/core/writers/PDFStreamWriter.d.ts +6 -6
  1457. package/ts3.4/es/core/writers/PDFWriter.d.ts +8 -8
  1458. package/ts3.4/es/index.d.ts +4 -4
  1459. package/ts3.4/es/types/index.d.ts +25 -1
  1460. package/ts3.4/es/utils/arrays.d.ts +2 -1
  1461. package/ts3.4/es/utils/elements/Arc.d.ts +23 -0
  1462. package/ts3.4/es/utils/elements/Circle.d.ts +15 -0
  1463. package/ts3.4/es/utils/elements/Ellipse.d.ts +21 -0
  1464. package/ts3.4/es/utils/elements/GraphElement.d.ts +7 -0
  1465. package/ts3.4/es/utils/elements/Line.d.ts +24 -0
  1466. package/ts3.4/es/utils/elements/Plot.d.ts +12 -0
  1467. package/ts3.4/es/utils/elements/Point.d.ts +19 -0
  1468. package/ts3.4/es/utils/elements/Rectangle.d.ts +22 -0
  1469. package/ts3.4/es/utils/elements/Segment.d.ts +20 -0
  1470. package/ts3.4/es/utils/elements/index.d.ts +10 -0
  1471. package/ts3.4/es/utils/index.d.ts +11 -11
  1472. package/ts3.4/es/utils/intersections.d.ts +10 -0
  1473. package/ts3.4/es/utils/maths.d.ts +46 -0
  1474. package/ts3.4/es/utils/strings.d.ts +1 -0
  1475. package/yarn.lock +0 -4408
@@ -0,0 +1,1605 @@
1
+ /* Copyright 2012 Mozilla Foundation
2
+ *
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ import { arrayAsString, isArrayEqual } from '../utils/arrays.js';
16
+ import { stringAsByteArray } from '../utils/strings.js';
17
+ import PDFDict from './objects/PDFDict.js';
18
+ import PDFName from './objects/PDFName.js';
19
+ import DecryptStream from './streams/DecryptStream.js';
20
+ class ARCFourCipher {
21
+ constructor(key) {
22
+ this.a = 0;
23
+ this.b = 0;
24
+ const s = new Uint8Array(256);
25
+ const keyLength = key.length;
26
+ for (let i = 0; i < 256; ++i) {
27
+ s[i] = i;
28
+ }
29
+ for (let i = 0, j = 0; i < 256; ++i) {
30
+ const tmp = s[i];
31
+ j = (j + tmp + key[i % keyLength]) & 0xff;
32
+ s[i] = s[j];
33
+ s[j] = tmp;
34
+ }
35
+ this.s = s;
36
+ }
37
+ encryptBlock(data) {
38
+ let a = this.a, b = this.b;
39
+ const s = this.s;
40
+ const n = data.length;
41
+ const output = new Uint8Array(n);
42
+ for (let i = 0; i < n; ++i) {
43
+ a = (a + 1) & 0xff;
44
+ const tmp = s[a];
45
+ b = (b + tmp) & 0xff;
46
+ const tmp2 = s[b];
47
+ s[a] = tmp2;
48
+ s[b] = tmp;
49
+ output[i] = data[i] ^ s[(tmp + tmp2) & 0xff];
50
+ }
51
+ this.a = a;
52
+ this.b = b;
53
+ return output;
54
+ }
55
+ decryptBlock(data) {
56
+ return this.encryptBlock(data);
57
+ }
58
+ encrypt(data) {
59
+ return this.encryptBlock(data);
60
+ }
61
+ }
62
+ const calculateMD5 = (function calculateMD5Closure() {
63
+ const r = new Uint8Array([
64
+ 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5,
65
+ 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11,
66
+ 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10,
67
+ 15, 21,
68
+ ]);
69
+ const k = new Int32Array([
70
+ -680876936, -389564586, 606105819, -1044525330, -176418897, 1200080426,
71
+ -1473231341, -45705983, 1770035416, -1958414417, -42063, -1990404162,
72
+ 1804603682, -40341101, -1502002290, 1236535329, -165796510, -1069501632,
73
+ 643717713, -373897302, -701558691, 38016083, -660478335, -405537848,
74
+ 568446438, -1019803690, -187363961, 1163531501, -1444681467, -51403784,
75
+ 1735328473, -1926607734, -378558, -2022574463, 1839030562, -35309556,
76
+ -1530992060, 1272893353, -155497632, -1094730640, 681279174, -358537222,
77
+ -722521979, 76029189, -640364487, -421815835, 530742520, -995338651,
78
+ -198630844, 1126891415, -1416354905, -57434055, 1700485571, -1894986606,
79
+ -1051523, -2054922799, 1873313359, -30611744, -1560198380, 1309151649,
80
+ -145523070, -1120210379, 718787259, -343485551,
81
+ ]);
82
+ function hash(data, offset, length) {
83
+ let h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
84
+ // pre-processing
85
+ const paddedLength = (length + 72) & ~63; // data + 9 extra bytes
86
+ const padded = new Uint8Array(paddedLength);
87
+ let i, j;
88
+ for (i = 0; i < length; ++i) {
89
+ padded[i] = data[offset++];
90
+ }
91
+ padded[i++] = 0x80;
92
+ const n = paddedLength - 8;
93
+ while (i < n) {
94
+ padded[i++] = 0;
95
+ }
96
+ padded[i++] = (length << 3) & 0xff;
97
+ padded[i++] = (length >> 5) & 0xff;
98
+ padded[i++] = (length >> 13) & 0xff;
99
+ padded[i++] = (length >> 21) & 0xff;
100
+ padded[i++] = (length >>> 29) & 0xff;
101
+ padded[i++] = 0;
102
+ padded[i++] = 0;
103
+ padded[i++] = 0;
104
+ const w = new Int32Array(16);
105
+ for (i = 0; i < paddedLength;) {
106
+ for (j = 0; j < 16; ++j, i += 4) {
107
+ w[j] =
108
+ padded[i] |
109
+ (padded[i + 1] << 8) |
110
+ (padded[i + 2] << 16) |
111
+ (padded[i + 3] << 24);
112
+ }
113
+ let a = h0, b = h1, c = h2, d = h3, f, g;
114
+ for (j = 0; j < 64; ++j) {
115
+ if (j < 16) {
116
+ f = (b & c) | (~b & d);
117
+ g = j;
118
+ }
119
+ else if (j < 32) {
120
+ f = (d & b) | (~d & c);
121
+ g = (5 * j + 1) & 15;
122
+ }
123
+ else if (j < 48) {
124
+ f = b ^ c ^ d;
125
+ g = (3 * j + 5) & 15;
126
+ }
127
+ else {
128
+ f = c ^ (b | ~d);
129
+ g = (7 * j) & 15;
130
+ }
131
+ const tmp = d, rotateArg = (a + f + k[j] + w[g]) | 0, rotate = r[j];
132
+ d = c;
133
+ c = b;
134
+ b = (b + ((rotateArg << rotate) | (rotateArg >>> (32 - rotate)))) | 0;
135
+ a = tmp;
136
+ }
137
+ h0 = (h0 + a) | 0;
138
+ h1 = (h1 + b) | 0;
139
+ h2 = (h2 + c) | 0;
140
+ h3 = (h3 + d) | 0;
141
+ }
142
+ // prettier-ignore
143
+ return new Uint8Array([
144
+ h0 & 0xFF, (h0 >> 8) & 0xFF, (h0 >> 16) & 0xFF, (h0 >>> 24) & 0xFF,
145
+ h1 & 0xFF, (h1 >> 8) & 0xFF, (h1 >> 16) & 0xFF, (h1 >>> 24) & 0xFF,
146
+ h2 & 0xFF, (h2 >> 8) & 0xFF, (h2 >> 16) & 0xFF, (h2 >>> 24) & 0xFF,
147
+ h3 & 0xFF, (h3 >> 8) & 0xFF, (h3 >> 16) & 0xFF, (h3 >>> 24) & 0xFF
148
+ ]);
149
+ }
150
+ return hash;
151
+ })();
152
+ class Word64 {
153
+ constructor(highInteger, lowInteger) {
154
+ this.high = highInteger | 0;
155
+ this.low = lowInteger | 0;
156
+ }
157
+ and(word) {
158
+ this.high &= word.high;
159
+ this.low &= word.low;
160
+ }
161
+ xor(word) {
162
+ this.high ^= word.high;
163
+ this.low ^= word.low;
164
+ }
165
+ or(word) {
166
+ this.high |= word.high;
167
+ this.low |= word.low;
168
+ }
169
+ shiftRight(places) {
170
+ if (places >= 32) {
171
+ this.low = (this.high >>> (places - 32)) | 0;
172
+ this.high = 0;
173
+ }
174
+ else {
175
+ this.low = (this.low >>> places) | (this.high << (32 - places));
176
+ this.high = (this.high >>> places) | 0;
177
+ }
178
+ }
179
+ shiftLeft(places) {
180
+ if (places >= 32) {
181
+ this.high = this.low << (places - 32);
182
+ this.low = 0;
183
+ }
184
+ else {
185
+ this.high = (this.high << places) | (this.low >>> (32 - places));
186
+ this.low <<= places;
187
+ }
188
+ }
189
+ rotateRight(places) {
190
+ let low, high;
191
+ if (places & 32) {
192
+ high = this.low;
193
+ low = this.high;
194
+ }
195
+ else {
196
+ low = this.low;
197
+ high = this.high;
198
+ }
199
+ places &= 31;
200
+ this.low = (low >>> places) | (high << (32 - places));
201
+ this.high = (high >>> places) | (low << (32 - places));
202
+ }
203
+ not() {
204
+ this.high = ~this.high;
205
+ this.low = ~this.low;
206
+ }
207
+ add(word) {
208
+ const lowAdd = (this.low >>> 0) + (word.low >>> 0);
209
+ let highAdd = (this.high >>> 0) + (word.high >>> 0);
210
+ if (lowAdd > 0xffffffff) {
211
+ highAdd += 1;
212
+ }
213
+ this.low = lowAdd | 0;
214
+ this.high = highAdd | 0;
215
+ }
216
+ copyTo(bytes, offset) {
217
+ bytes[offset] = (this.high >>> 24) & 0xff;
218
+ bytes[offset + 1] = (this.high >> 16) & 0xff;
219
+ bytes[offset + 2] = (this.high >> 8) & 0xff;
220
+ bytes[offset + 3] = this.high & 0xff;
221
+ bytes[offset + 4] = (this.low >>> 24) & 0xff;
222
+ bytes[offset + 5] = (this.low >> 16) & 0xff;
223
+ bytes[offset + 6] = (this.low >> 8) & 0xff;
224
+ bytes[offset + 7] = this.low & 0xff;
225
+ }
226
+ assign(word) {
227
+ this.high = word.high;
228
+ this.low = word.low;
229
+ }
230
+ }
231
+ const calculateSHA256 = (function calculateSHA256Closure() {
232
+ function rotr(x, n) {
233
+ return (x >>> n) | (x << (32 - n));
234
+ }
235
+ function ch(x, y, z) {
236
+ return (x & y) ^ (~x & z);
237
+ }
238
+ function maj(x, y, z) {
239
+ return (x & y) ^ (x & z) ^ (y & z);
240
+ }
241
+ function sigma(x) {
242
+ return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
243
+ }
244
+ function sigmaPrime(x) {
245
+ return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
246
+ }
247
+ function littleSigma(x) {
248
+ return rotr(x, 7) ^ rotr(x, 18) ^ (x >>> 3);
249
+ }
250
+ function littleSigmaPrime(x) {
251
+ return rotr(x, 17) ^ rotr(x, 19) ^ (x >>> 10);
252
+ }
253
+ const k = [
254
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
255
+ 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
256
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
257
+ 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
258
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
259
+ 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
260
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
261
+ 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
262
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
263
+ 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
264
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
265
+ ];
266
+ function hash(data, offset, length) {
267
+ // initial hash values
268
+ let h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
269
+ // pre-processing
270
+ const paddedLength = Math.ceil((length + 9) / 64) * 64;
271
+ const padded = new Uint8Array(paddedLength);
272
+ let i, j;
273
+ for (i = 0; i < length; ++i) {
274
+ padded[i] = data[offset++];
275
+ }
276
+ padded[i++] = 0x80;
277
+ const n = paddedLength - 8;
278
+ while (i < n) {
279
+ padded[i++] = 0;
280
+ }
281
+ padded[i++] = 0;
282
+ padded[i++] = 0;
283
+ padded[i++] = 0;
284
+ padded[i++] = (length >>> 29) & 0xff;
285
+ padded[i++] = (length >> 21) & 0xff;
286
+ padded[i++] = (length >> 13) & 0xff;
287
+ padded[i++] = (length >> 5) & 0xff;
288
+ padded[i++] = (length << 3) & 0xff;
289
+ const w = new Uint32Array(64);
290
+ // for each 512 bit block
291
+ for (i = 0; i < paddedLength;) {
292
+ for (j = 0; j < 16; ++j) {
293
+ w[j] =
294
+ (padded[i] << 24) |
295
+ (padded[i + 1] << 16) |
296
+ (padded[i + 2] << 8) |
297
+ padded[i + 3];
298
+ i += 4;
299
+ }
300
+ for (j = 16; j < 64; ++j) {
301
+ w[j] =
302
+ (littleSigmaPrime(w[j - 2]) +
303
+ w[j - 7] +
304
+ littleSigma(w[j - 15]) +
305
+ w[j - 16]) |
306
+ 0;
307
+ }
308
+ let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
309
+ for (j = 0; j < 64; ++j) {
310
+ t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
311
+ t2 = sigma(a) + maj(a, b, c);
312
+ h = g;
313
+ g = f;
314
+ f = e;
315
+ e = (d + t1) | 0;
316
+ d = c;
317
+ c = b;
318
+ b = a;
319
+ a = (t1 + t2) | 0;
320
+ }
321
+ h0 = (h0 + a) | 0;
322
+ h1 = (h1 + b) | 0;
323
+ h2 = (h2 + c) | 0;
324
+ h3 = (h3 + d) | 0;
325
+ h4 = (h4 + e) | 0;
326
+ h5 = (h5 + f) | 0;
327
+ h6 = (h6 + g) | 0;
328
+ h7 = (h7 + h) | 0;
329
+ }
330
+ // prettier-ignore
331
+ return new Uint8Array([
332
+ (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, (h0) & 0xFF,
333
+ (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, (h1) & 0xFF,
334
+ (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, (h2) & 0xFF,
335
+ (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, (h3) & 0xFF,
336
+ (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, (h4) & 0xFF,
337
+ (h5 >> 24) & 0xFF, (h5 >> 16) & 0xFF, (h5 >> 8) & 0xFF, (h5) & 0xFF,
338
+ (h6 >> 24) & 0xFF, (h6 >> 16) & 0xFF, (h6 >> 8) & 0xFF, (h6) & 0xFF,
339
+ (h7 >> 24) & 0xFF, (h7 >> 16) & 0xFF, (h7 >> 8) & 0xFF, (h7) & 0xFF
340
+ ]);
341
+ }
342
+ return hash;
343
+ })();
344
+ const calculateSHA512 = (function calculateSHA512Closure() {
345
+ function ch(result, x, y, z, tmp) {
346
+ result.assign(x);
347
+ result.and(y);
348
+ tmp.assign(x);
349
+ tmp.not();
350
+ tmp.and(z);
351
+ result.xor(tmp);
352
+ }
353
+ function maj(result, x, y, z, tmp) {
354
+ result.assign(x);
355
+ result.and(y);
356
+ tmp.assign(x);
357
+ tmp.and(z);
358
+ result.xor(tmp);
359
+ tmp.assign(y);
360
+ tmp.and(z);
361
+ result.xor(tmp);
362
+ }
363
+ function sigma(result, x, tmp) {
364
+ result.assign(x);
365
+ result.rotateRight(28);
366
+ tmp.assign(x);
367
+ tmp.rotateRight(34);
368
+ result.xor(tmp);
369
+ tmp.assign(x);
370
+ tmp.rotateRight(39);
371
+ result.xor(tmp);
372
+ }
373
+ function sigmaPrime(result, x, tmp) {
374
+ result.assign(x);
375
+ result.rotateRight(14);
376
+ tmp.assign(x);
377
+ tmp.rotateRight(18);
378
+ result.xor(tmp);
379
+ tmp.assign(x);
380
+ tmp.rotateRight(41);
381
+ result.xor(tmp);
382
+ }
383
+ function littleSigma(result, x, tmp) {
384
+ result.assign(x);
385
+ result.rotateRight(1);
386
+ tmp.assign(x);
387
+ tmp.rotateRight(8);
388
+ result.xor(tmp);
389
+ tmp.assign(x);
390
+ tmp.shiftRight(7);
391
+ result.xor(tmp);
392
+ }
393
+ function littleSigmaPrime(result, x, tmp) {
394
+ result.assign(x);
395
+ result.rotateRight(19);
396
+ tmp.assign(x);
397
+ tmp.rotateRight(61);
398
+ result.xor(tmp);
399
+ tmp.assign(x);
400
+ tmp.shiftRight(6);
401
+ result.xor(tmp);
402
+ }
403
+ // prettier-ignore
404
+ const k = [
405
+ new Word64(0x428a2f98, 0xd728ae22), new Word64(0x71374491, 0x23ef65cd),
406
+ new Word64(0xb5c0fbcf, 0xec4d3b2f), new Word64(0xe9b5dba5, 0x8189dbbc),
407
+ new Word64(0x3956c25b, 0xf348b538), new Word64(0x59f111f1, 0xb605d019),
408
+ new Word64(0x923f82a4, 0xaf194f9b), new Word64(0xab1c5ed5, 0xda6d8118),
409
+ new Word64(0xd807aa98, 0xa3030242), new Word64(0x12835b01, 0x45706fbe),
410
+ new Word64(0x243185be, 0x4ee4b28c), new Word64(0x550c7dc3, 0xd5ffb4e2),
411
+ new Word64(0x72be5d74, 0xf27b896f), new Word64(0x80deb1fe, 0x3b1696b1),
412
+ new Word64(0x9bdc06a7, 0x25c71235), new Word64(0xc19bf174, 0xcf692694),
413
+ new Word64(0xe49b69c1, 0x9ef14ad2), new Word64(0xefbe4786, 0x384f25e3),
414
+ new Word64(0x0fc19dc6, 0x8b8cd5b5), new Word64(0x240ca1cc, 0x77ac9c65),
415
+ new Word64(0x2de92c6f, 0x592b0275), new Word64(0x4a7484aa, 0x6ea6e483),
416
+ new Word64(0x5cb0a9dc, 0xbd41fbd4), new Word64(0x76f988da, 0x831153b5),
417
+ new Word64(0x983e5152, 0xee66dfab), new Word64(0xa831c66d, 0x2db43210),
418
+ new Word64(0xb00327c8, 0x98fb213f), new Word64(0xbf597fc7, 0xbeef0ee4),
419
+ new Word64(0xc6e00bf3, 0x3da88fc2), new Word64(0xd5a79147, 0x930aa725),
420
+ new Word64(0x06ca6351, 0xe003826f), new Word64(0x14292967, 0x0a0e6e70),
421
+ new Word64(0x27b70a85, 0x46d22ffc), new Word64(0x2e1b2138, 0x5c26c926),
422
+ new Word64(0x4d2c6dfc, 0x5ac42aed), new Word64(0x53380d13, 0x9d95b3df),
423
+ new Word64(0x650a7354, 0x8baf63de), new Word64(0x766a0abb, 0x3c77b2a8),
424
+ new Word64(0x81c2c92e, 0x47edaee6), new Word64(0x92722c85, 0x1482353b),
425
+ new Word64(0xa2bfe8a1, 0x4cf10364), new Word64(0xa81a664b, 0xbc423001),
426
+ new Word64(0xc24b8b70, 0xd0f89791), new Word64(0xc76c51a3, 0x0654be30),
427
+ new Word64(0xd192e819, 0xd6ef5218), new Word64(0xd6990624, 0x5565a910),
428
+ new Word64(0xf40e3585, 0x5771202a), new Word64(0x106aa070, 0x32bbd1b8),
429
+ new Word64(0x19a4c116, 0xb8d2d0c8), new Word64(0x1e376c08, 0x5141ab53),
430
+ new Word64(0x2748774c, 0xdf8eeb99), new Word64(0x34b0bcb5, 0xe19b48a8),
431
+ new Word64(0x391c0cb3, 0xc5c95a63), new Word64(0x4ed8aa4a, 0xe3418acb),
432
+ new Word64(0x5b9cca4f, 0x7763e373), new Word64(0x682e6ff3, 0xd6b2b8a3),
433
+ new Word64(0x748f82ee, 0x5defb2fc), new Word64(0x78a5636f, 0x43172f60),
434
+ new Word64(0x84c87814, 0xa1f0ab72), new Word64(0x8cc70208, 0x1a6439ec),
435
+ new Word64(0x90befffa, 0x23631e28), new Word64(0xa4506ceb, 0xde82bde9),
436
+ new Word64(0xbef9a3f7, 0xb2c67915), new Word64(0xc67178f2, 0xe372532b),
437
+ new Word64(0xca273ece, 0xea26619c), new Word64(0xd186b8c7, 0x21c0c207),
438
+ new Word64(0xeada7dd6, 0xcde0eb1e), new Word64(0xf57d4f7f, 0xee6ed178),
439
+ new Word64(0x06f067aa, 0x72176fba), new Word64(0x0a637dc5, 0xa2c898a6),
440
+ new Word64(0x113f9804, 0xbef90dae), new Word64(0x1b710b35, 0x131c471b),
441
+ new Word64(0x28db77f5, 0x23047d84), new Word64(0x32caab7b, 0x40c72493),
442
+ new Word64(0x3c9ebe0a, 0x15c9bebc), new Word64(0x431d67c4, 0x9c100d4c),
443
+ new Word64(0x4cc5d4be, 0xcb3e42b6), new Word64(0x597f299c, 0xfc657e2a),
444
+ new Word64(0x5fcb6fab, 0x3ad6faec), new Word64(0x6c44198c, 0x4a475817)
445
+ ];
446
+ function hash(data, offset, length, mode384 = false) {
447
+ // initial hash values
448
+ let h0, h1, h2, h3, h4, h5, h6, h7;
449
+ if (!mode384) {
450
+ h0 = new Word64(0x6a09e667, 0xf3bcc908);
451
+ h1 = new Word64(0xbb67ae85, 0x84caa73b);
452
+ h2 = new Word64(0x3c6ef372, 0xfe94f82b);
453
+ h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
454
+ h4 = new Word64(0x510e527f, 0xade682d1);
455
+ h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
456
+ h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
457
+ h7 = new Word64(0x5be0cd19, 0x137e2179);
458
+ }
459
+ else {
460
+ // SHA384 is exactly the same
461
+ // except with different starting values and a trimmed result
462
+ h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
463
+ h1 = new Word64(0x629a292a, 0x367cd507);
464
+ h2 = new Word64(0x9159015a, 0x3070dd17);
465
+ h3 = new Word64(0x152fecd8, 0xf70e5939);
466
+ h4 = new Word64(0x67332667, 0xffc00b31);
467
+ h5 = new Word64(0x8eb44a87, 0x68581511);
468
+ h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
469
+ h7 = new Word64(0x47b5481d, 0xbefa4fa4);
470
+ }
471
+ // pre-processing
472
+ const paddedLength = Math.ceil((length + 17) / 128) * 128;
473
+ const padded = new Uint8Array(paddedLength);
474
+ let i, j;
475
+ for (i = 0; i < length; ++i) {
476
+ padded[i] = data[offset++];
477
+ }
478
+ padded[i++] = 0x80;
479
+ const n = paddedLength - 16;
480
+ while (i < n) {
481
+ padded[i++] = 0;
482
+ }
483
+ padded[i++] = 0;
484
+ padded[i++] = 0;
485
+ padded[i++] = 0;
486
+ padded[i++] = 0;
487
+ padded[i++] = 0;
488
+ padded[i++] = 0;
489
+ padded[i++] = 0;
490
+ padded[i++] = 0;
491
+ padded[i++] = 0;
492
+ padded[i++] = 0;
493
+ padded[i++] = 0;
494
+ padded[i++] = (length >>> 29) & 0xff;
495
+ padded[i++] = (length >> 21) & 0xff;
496
+ padded[i++] = (length >> 13) & 0xff;
497
+ padded[i++] = (length >> 5) & 0xff;
498
+ padded[i++] = (length << 3) & 0xff;
499
+ const w = new Array(80);
500
+ for (i = 0; i < 80; i++) {
501
+ w[i] = new Word64(0, 0);
502
+ }
503
+ let a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
504
+ let d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
505
+ let g = new Word64(0, 0), h = new Word64(0, 0);
506
+ const t1 = new Word64(0, 0), t2 = new Word64(0, 0);
507
+ const tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0);
508
+ let tmp3;
509
+ // for each 1024 bit block
510
+ for (i = 0; i < paddedLength;) {
511
+ for (j = 0; j < 16; ++j) {
512
+ w[j].high =
513
+ (padded[i] << 24) |
514
+ (padded[i + 1] << 16) |
515
+ (padded[i + 2] << 8) |
516
+ padded[i + 3];
517
+ w[j].low =
518
+ (padded[i + 4] << 24) |
519
+ (padded[i + 5] << 16) |
520
+ (padded[i + 6] << 8) |
521
+ padded[i + 7];
522
+ i += 8;
523
+ }
524
+ for (j = 16; j < 80; ++j) {
525
+ tmp3 = w[j];
526
+ littleSigmaPrime(tmp3, w[j - 2], tmp2);
527
+ tmp3.add(w[j - 7]);
528
+ littleSigma(tmp1, w[j - 15], tmp2);
529
+ tmp3.add(tmp1);
530
+ tmp3.add(w[j - 16]);
531
+ }
532
+ a.assign(h0);
533
+ b.assign(h1);
534
+ c.assign(h2);
535
+ d.assign(h3);
536
+ e.assign(h4);
537
+ f.assign(h5);
538
+ g.assign(h6);
539
+ h.assign(h7);
540
+ for (j = 0; j < 80; ++j) {
541
+ t1.assign(h);
542
+ sigmaPrime(tmp1, e, tmp2);
543
+ t1.add(tmp1);
544
+ ch(tmp1, e, f, g, tmp2);
545
+ t1.add(tmp1);
546
+ t1.add(k[j]);
547
+ t1.add(w[j]);
548
+ sigma(t2, a, tmp2);
549
+ maj(tmp1, a, b, c, tmp2);
550
+ t2.add(tmp1);
551
+ tmp3 = h;
552
+ h = g;
553
+ g = f;
554
+ f = e;
555
+ d.add(t1);
556
+ e = d;
557
+ d = c;
558
+ c = b;
559
+ b = a;
560
+ tmp3.assign(t1);
561
+ tmp3.add(t2);
562
+ a = tmp3;
563
+ }
564
+ h0.add(a);
565
+ h1.add(b);
566
+ h2.add(c);
567
+ h3.add(d);
568
+ h4.add(e);
569
+ h5.add(f);
570
+ h6.add(g);
571
+ h7.add(h);
572
+ }
573
+ let result;
574
+ if (!mode384) {
575
+ result = new Uint8Array(64);
576
+ h0.copyTo(result, 0);
577
+ h1.copyTo(result, 8);
578
+ h2.copyTo(result, 16);
579
+ h3.copyTo(result, 24);
580
+ h4.copyTo(result, 32);
581
+ h5.copyTo(result, 40);
582
+ h6.copyTo(result, 48);
583
+ h7.copyTo(result, 56);
584
+ }
585
+ else {
586
+ result = new Uint8Array(48);
587
+ h0.copyTo(result, 0);
588
+ h1.copyTo(result, 8);
589
+ h2.copyTo(result, 16);
590
+ h3.copyTo(result, 24);
591
+ h4.copyTo(result, 32);
592
+ h5.copyTo(result, 40);
593
+ }
594
+ return result;
595
+ }
596
+ return hash;
597
+ })();
598
+ function calculateSHA384(data, offset, length) {
599
+ return calculateSHA512(data, offset, length, /* mode384 = */ true);
600
+ }
601
+ class NullCipher {
602
+ decryptBlock(data) {
603
+ return data;
604
+ }
605
+ encrypt(data) {
606
+ return data;
607
+ }
608
+ }
609
+ class AESBaseCipher {
610
+ constructor() {
611
+ if (this.constructor === AESBaseCipher) {
612
+ throw new Error('Cannot initialize AESBaseCipher.');
613
+ }
614
+ this._s = new Uint8Array([
615
+ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b,
616
+ 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
617
+ 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26,
618
+ 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
619
+ 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2,
620
+ 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
621
+ 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed,
622
+ 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
623
+ 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f,
624
+ 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
625
+ 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec,
626
+ 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
627
+ 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14,
628
+ 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
629
+ 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d,
630
+ 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
631
+ 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f,
632
+ 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
633
+ 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11,
634
+ 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
635
+ 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f,
636
+ 0xb0, 0x54, 0xbb, 0x16,
637
+ ]);
638
+ this._inv_s = new Uint8Array([
639
+ 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e,
640
+ 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87,
641
+ 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32,
642
+ 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
643
+ 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49,
644
+ 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16,
645
+ 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50,
646
+ 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
647
+ 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05,
648
+ 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02,
649
+ 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41,
650
+ 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
651
+ 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8,
652
+ 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89,
653
+ 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b,
654
+ 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
655
+ 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59,
656
+ 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d,
657
+ 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d,
658
+ 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
659
+ 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63,
660
+ 0x55, 0x21, 0x0c, 0x7d,
661
+ ]);
662
+ this._mix = new Uint32Array([
663
+ 0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927,
664
+ 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45,
665
+ 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb,
666
+ 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381,
667
+ 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf,
668
+ 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66,
669
+ 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28,
670
+ 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012,
671
+ 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec,
672
+ 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e,
673
+ 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd,
674
+ 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7,
675
+ 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89,
676
+ 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b,
677
+ 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815,
678
+ 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f,
679
+ 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa,
680
+ 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8,
681
+ 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36,
682
+ 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c,
683
+ 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742,
684
+ 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea,
685
+ 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4,
686
+ 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e,
687
+ 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360,
688
+ 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502,
689
+ 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87,
690
+ 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd,
691
+ 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3,
692
+ 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621,
693
+ 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f,
694
+ 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55,
695
+ 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26,
696
+ 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844,
697
+ 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba,
698
+ 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480,
699
+ 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce,
700
+ 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67,
701
+ 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929,
702
+ 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713,
703
+ 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed,
704
+ 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f,
705
+ 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3,
706
+ ]);
707
+ this._mixCol = new Uint8Array(256);
708
+ for (let i = 0; i < 256; i++) {
709
+ if (i < 128) {
710
+ this._mixCol[i] = i << 1;
711
+ }
712
+ else {
713
+ this._mixCol[i] = (i << 1) ^ 0x1b;
714
+ }
715
+ }
716
+ this.buffer = new Uint8Array(16);
717
+ this.bufferPosition = 0;
718
+ }
719
+ _expandKey(_cipherKey) {
720
+ throw new Error('Cannot call `_expandKey` on the base class');
721
+ }
722
+ _decrypt(input, key) {
723
+ let t, u, v;
724
+ const state = new Uint8Array(16);
725
+ state.set(input);
726
+ // AddRoundKey
727
+ for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
728
+ state[j] ^= key[k];
729
+ }
730
+ for (let i = this._cyclesOfRepetition - 1; i >= 1; --i) {
731
+ // InvShiftRows
732
+ t = state[13];
733
+ state[13] = state[9];
734
+ state[9] = state[5];
735
+ state[5] = state[1];
736
+ state[1] = t;
737
+ t = state[14];
738
+ u = state[10];
739
+ state[14] = state[6];
740
+ state[10] = state[2];
741
+ state[6] = t;
742
+ state[2] = u;
743
+ t = state[15];
744
+ u = state[11];
745
+ v = state[7];
746
+ state[15] = state[3];
747
+ state[11] = t;
748
+ state[7] = u;
749
+ state[3] = v;
750
+ // InvSubBytes
751
+ for (let j = 0; j < 16; ++j) {
752
+ state[j] = this._inv_s[state[j]];
753
+ }
754
+ // AddRoundKey
755
+ for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
756
+ state[j] ^= key[k];
757
+ }
758
+ // InvMixColumns
759
+ for (let j = 0; j < 16; j += 4) {
760
+ const s0 = this._mix[state[j]];
761
+ const s1 = this._mix[state[j + 1]];
762
+ const s2 = this._mix[state[j + 2]];
763
+ const s3 = this._mix[state[j + 3]];
764
+ t =
765
+ s0 ^
766
+ (s1 >>> 8) ^
767
+ (s1 << 24) ^
768
+ (s2 >>> 16) ^
769
+ (s2 << 16) ^
770
+ (s3 >>> 24) ^
771
+ (s3 << 8);
772
+ state[j] = (t >>> 24) & 0xff;
773
+ state[j + 1] = (t >> 16) & 0xff;
774
+ state[j + 2] = (t >> 8) & 0xff;
775
+ state[j + 3] = t & 0xff;
776
+ }
777
+ }
778
+ // InvShiftRows
779
+ t = state[13];
780
+ state[13] = state[9];
781
+ state[9] = state[5];
782
+ state[5] = state[1];
783
+ state[1] = t;
784
+ t = state[14];
785
+ u = state[10];
786
+ state[14] = state[6];
787
+ state[10] = state[2];
788
+ state[6] = t;
789
+ state[2] = u;
790
+ t = state[15];
791
+ u = state[11];
792
+ v = state[7];
793
+ state[15] = state[3];
794
+ state[11] = t;
795
+ state[7] = u;
796
+ state[3] = v;
797
+ for (let j = 0; j < 16; ++j) {
798
+ // InvSubBytes
799
+ state[j] = this._inv_s[state[j]];
800
+ // AddRoundKey
801
+ state[j] ^= key[j];
802
+ }
803
+ return state;
804
+ }
805
+ _encrypt(input, key) {
806
+ const s = this._s;
807
+ let t, u, v;
808
+ const state = new Uint8Array(16);
809
+ state.set(input);
810
+ for (let j = 0; j < 16; ++j) {
811
+ // AddRoundKey
812
+ state[j] ^= key[j];
813
+ }
814
+ for (let i = 1; i < this._cyclesOfRepetition; i++) {
815
+ // SubBytes
816
+ for (let j = 0; j < 16; ++j) {
817
+ state[j] = s[state[j]];
818
+ }
819
+ // ShiftRows
820
+ v = state[1];
821
+ state[1] = state[5];
822
+ state[5] = state[9];
823
+ state[9] = state[13];
824
+ state[13] = v;
825
+ v = state[2];
826
+ u = state[6];
827
+ state[2] = state[10];
828
+ state[6] = state[14];
829
+ state[10] = v;
830
+ state[14] = u;
831
+ v = state[3];
832
+ u = state[7];
833
+ t = state[11];
834
+ state[3] = state[15];
835
+ state[7] = v;
836
+ state[11] = u;
837
+ state[15] = t;
838
+ // MixColumns
839
+ for (let j = 0; j < 16; j += 4) {
840
+ const s0 = state[j + 0];
841
+ const s1 = state[j + 1];
842
+ const s2 = state[j + 2];
843
+ const s3 = state[j + 3];
844
+ t = s0 ^ s1 ^ s2 ^ s3;
845
+ state[j + 0] ^= t ^ this._mixCol[s0 ^ s1];
846
+ state[j + 1] ^= t ^ this._mixCol[s1 ^ s2];
847
+ state[j + 2] ^= t ^ this._mixCol[s2 ^ s3];
848
+ state[j + 3] ^= t ^ this._mixCol[s3 ^ s0];
849
+ }
850
+ // AddRoundKey
851
+ for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
852
+ state[j] ^= key[k];
853
+ }
854
+ }
855
+ // SubBytes
856
+ for (let j = 0; j < 16; ++j) {
857
+ state[j] = s[state[j]];
858
+ }
859
+ // ShiftRows
860
+ v = state[1];
861
+ state[1] = state[5];
862
+ state[5] = state[9];
863
+ state[9] = state[13];
864
+ state[13] = v;
865
+ v = state[2];
866
+ u = state[6];
867
+ state[2] = state[10];
868
+ state[6] = state[14];
869
+ state[10] = v;
870
+ state[14] = u;
871
+ v = state[3];
872
+ u = state[7];
873
+ t = state[11];
874
+ state[3] = state[15];
875
+ state[7] = v;
876
+ state[11] = u;
877
+ state[15] = t;
878
+ // AddRoundKey
879
+ for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
880
+ state[j] ^= key[k];
881
+ }
882
+ return state;
883
+ }
884
+ _decryptBlock2(data, finalize) {
885
+ const sourceLength = data.length;
886
+ let buffer = this.buffer, bufferLength = this.bufferPosition;
887
+ const result = [];
888
+ let iv = this.iv;
889
+ for (let i = 0; i < sourceLength; ++i) {
890
+ buffer[bufferLength] = data[i];
891
+ ++bufferLength;
892
+ if (bufferLength < 16) {
893
+ continue;
894
+ }
895
+ // buffer is full, decrypting
896
+ const plain = this._decrypt(buffer, this._key);
897
+ // xor-ing the IV vector to get plain text
898
+ for (let j = 0; j < 16; ++j) {
899
+ plain[j] ^= iv[j];
900
+ }
901
+ iv = buffer;
902
+ result.push(plain);
903
+ buffer = new Uint8Array(16);
904
+ bufferLength = 0;
905
+ }
906
+ // saving incomplete buffer
907
+ this.buffer = buffer;
908
+ this.bufferLength = bufferLength;
909
+ this.iv = iv;
910
+ if (result.length === 0) {
911
+ return new Uint8Array(0);
912
+ }
913
+ // combining plain text blocks into one
914
+ let outputLength = 16 * result.length;
915
+ if (finalize) {
916
+ // undo a padding that is described in RFC 2898
917
+ const lastBlock = result[result.length - 1];
918
+ let psLen = lastBlock[15];
919
+ if (psLen <= 16) {
920
+ for (let i = 15, ii = 16 - psLen; i >= ii; --i) {
921
+ if (lastBlock[i] !== psLen) {
922
+ // Invalid padding, assume that the block has no padding.
923
+ psLen = 0;
924
+ break;
925
+ }
926
+ }
927
+ outputLength -= psLen;
928
+ result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
929
+ }
930
+ }
931
+ const output = new Uint8Array(outputLength);
932
+ for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
933
+ output.set(result[i], j);
934
+ }
935
+ return output;
936
+ }
937
+ decryptBlock(data, finalize, iv) {
938
+ const sourceLength = data.length;
939
+ const buffer = this.buffer;
940
+ let bufferLength = this.bufferPosition;
941
+ // If an IV is not supplied, wait for IV values. They are at the start
942
+ // of the stream.
943
+ if (iv) {
944
+ this.iv = iv;
945
+ }
946
+ else {
947
+ for (let i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
948
+ buffer[bufferLength] = data[i];
949
+ }
950
+ if (bufferLength < 16) {
951
+ // Need more data.
952
+ this.bufferLength = bufferLength;
953
+ return new Uint8Array(0);
954
+ }
955
+ this.iv = buffer;
956
+ data = data.subarray(16);
957
+ }
958
+ this.buffer = new Uint8Array(16);
959
+ this.bufferLength = 0;
960
+ // starting decryption
961
+ this.decryptBlock = this._decryptBlock2;
962
+ return this.decryptBlock(data, finalize);
963
+ }
964
+ encrypt(data, iv) {
965
+ const sourceLength = data.length;
966
+ let buffer = this.buffer, bufferLength = this.bufferPosition;
967
+ const result = [];
968
+ if (!iv) {
969
+ iv = new Uint8Array(16);
970
+ }
971
+ for (let i = 0; i < sourceLength; ++i) {
972
+ buffer[bufferLength] = data[i];
973
+ ++bufferLength;
974
+ if (bufferLength < 16) {
975
+ continue;
976
+ }
977
+ for (let j = 0; j < 16; ++j) {
978
+ buffer[j] ^= iv[j];
979
+ }
980
+ // buffer is full, encrypting
981
+ const cipher = this._encrypt(buffer, this._key);
982
+ iv = cipher;
983
+ result.push(cipher);
984
+ buffer = new Uint8Array(16);
985
+ bufferLength = 0;
986
+ }
987
+ // saving incomplete buffer
988
+ this.buffer = buffer;
989
+ this.bufferLength = bufferLength;
990
+ this.iv = iv;
991
+ if (result.length === 0) {
992
+ return new Uint8Array(0);
993
+ }
994
+ // combining plain text blocks into one
995
+ const outputLength = 16 * result.length;
996
+ const output = new Uint8Array(outputLength);
997
+ for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
998
+ output.set(result[i], j);
999
+ }
1000
+ return output;
1001
+ }
1002
+ }
1003
+ class AES128Cipher extends AESBaseCipher {
1004
+ constructor(key) {
1005
+ super();
1006
+ this._cyclesOfRepetition = 10;
1007
+ this._keySize = 160; // bits
1008
+ this._rcon = new Uint8Array([
1009
+ 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c,
1010
+ 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a,
1011
+ 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd,
1012
+ 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a,
1013
+ 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
1014
+ 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6,
1015
+ 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72,
1016
+ 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc,
1017
+ 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10,
1018
+ 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e,
1019
+ 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5,
1020
+ 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94,
1021
+ 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02,
1022
+ 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d,
1023
+ 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d,
1024
+ 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f,
1025
+ 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb,
1026
+ 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c,
1027
+ 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a,
1028
+ 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd,
1029
+ 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a,
1030
+ 0x74, 0xe8, 0xcb, 0x8d,
1031
+ ]);
1032
+ this._key = this._expandKey(key);
1033
+ }
1034
+ _expandKey(cipherKey) {
1035
+ const b = 176;
1036
+ const s = this._s;
1037
+ const rcon = this._rcon;
1038
+ const result = new Uint8Array(b);
1039
+ result.set(cipherKey);
1040
+ for (let j = 16, i = 1; j < b; ++i) {
1041
+ // RotWord
1042
+ let t1 = result[j - 3];
1043
+ let t2 = result[j - 2];
1044
+ let t3 = result[j - 1];
1045
+ let t4 = result[j - 4];
1046
+ // SubWord
1047
+ t1 = s[t1];
1048
+ t2 = s[t2];
1049
+ t3 = s[t3];
1050
+ t4 = s[t4];
1051
+ // Rcon
1052
+ t1 ^= rcon[i];
1053
+ for (let n = 0; n < 4; ++n) {
1054
+ result[j] = t1 ^= result[j - 16];
1055
+ j++;
1056
+ result[j] = t2 ^= result[j - 16];
1057
+ j++;
1058
+ result[j] = t3 ^= result[j - 16];
1059
+ j++;
1060
+ result[j] = t4 ^= result[j - 16];
1061
+ j++;
1062
+ }
1063
+ }
1064
+ return result;
1065
+ }
1066
+ }
1067
+ class AES256Cipher extends AESBaseCipher {
1068
+ constructor(key) {
1069
+ super();
1070
+ this._cyclesOfRepetition = 14;
1071
+ this._keySize = 224; // bits
1072
+ this._key = this._expandKey(key);
1073
+ }
1074
+ _expandKey(cipherKey) {
1075
+ const b = 240;
1076
+ const s = this._s;
1077
+ const result = new Uint8Array(b);
1078
+ result.set(cipherKey);
1079
+ let r = 1;
1080
+ let t1 = 0, t2 = 0, t3 = 0, t4 = 0;
1081
+ for (let j = 32, i = 1; j < b; ++i) {
1082
+ if (j % 32 === 16) {
1083
+ t1 = s[t1];
1084
+ t2 = s[t2];
1085
+ t3 = s[t3];
1086
+ t4 = s[t4];
1087
+ }
1088
+ else if (j % 32 === 0) {
1089
+ // RotWord
1090
+ t1 = result[j - 3];
1091
+ t2 = result[j - 2];
1092
+ t3 = result[j - 1];
1093
+ t4 = result[j - 4];
1094
+ // SubWord
1095
+ t1 = s[t1];
1096
+ t2 = s[t2];
1097
+ t3 = s[t3];
1098
+ t4 = s[t4];
1099
+ // Rcon
1100
+ t1 ^= r;
1101
+ if ((r <<= 1) >= 256) {
1102
+ r = (r ^ 0x1b) & 0xff;
1103
+ }
1104
+ }
1105
+ for (let n = 0; n < 4; ++n) {
1106
+ result[j] = t1 ^= result[j - 32];
1107
+ j++;
1108
+ result[j] = t2 ^= result[j - 32];
1109
+ j++;
1110
+ result[j] = t3 ^= result[j - 32];
1111
+ j++;
1112
+ result[j] = t4 ^= result[j - 32];
1113
+ j++;
1114
+ }
1115
+ }
1116
+ return result;
1117
+ }
1118
+ }
1119
+ class PDF17 {
1120
+ checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
1121
+ const hashData = new Uint8Array(password.length + 56);
1122
+ hashData.set(password, 0);
1123
+ hashData.set(ownerValidationSalt, password.length);
1124
+ hashData.set(userBytes, password.length + ownerValidationSalt.length);
1125
+ const result = calculateSHA256(hashData, 0, hashData.length);
1126
+ return isArrayEqual(result, ownerPassword);
1127
+ }
1128
+ checkUserPassword(password, userValidationSalt, userPassword) {
1129
+ const hashData = new Uint8Array(password.length + 8);
1130
+ hashData.set(password, 0);
1131
+ hashData.set(userValidationSalt, password.length);
1132
+ const result = calculateSHA256(hashData, 0, hashData.length);
1133
+ return isArrayEqual(result, userPassword);
1134
+ }
1135
+ getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
1136
+ const hashData = new Uint8Array(password.length + 56);
1137
+ hashData.set(password, 0);
1138
+ hashData.set(ownerKeySalt, password.length);
1139
+ hashData.set(userBytes, password.length + ownerKeySalt.length);
1140
+ const key = calculateSHA256(hashData, 0, hashData.length);
1141
+ const cipher = new AES256Cipher(key);
1142
+ return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
1143
+ }
1144
+ getUserKey(password, userKeySalt, userEncryption) {
1145
+ const hashData = new Uint8Array(password.length + 8);
1146
+ hashData.set(password, 0);
1147
+ hashData.set(userKeySalt, password.length);
1148
+ // `key` is the decryption key for the UE string.
1149
+ const key = calculateSHA256(hashData, 0, hashData.length);
1150
+ const cipher = new AES256Cipher(key);
1151
+ return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
1152
+ }
1153
+ }
1154
+ class PDF20 {
1155
+ calculatePDF20Hash(password, input, userBytes) {
1156
+ // This refers to Algorithm 2.B as defined in ISO 32000-2.
1157
+ let k = calculateSHA256(input, 0, input.length).subarray(0, 32);
1158
+ let e = new Uint8Array([0]);
1159
+ let i = 0;
1160
+ while (i < 64 || e[e.length - 1] > i - 32) {
1161
+ const combinedLength = password.length + k.length + userBytes.length, combinedArray = new Uint8Array(combinedLength);
1162
+ let writeOffset = 0;
1163
+ combinedArray.set(password, writeOffset);
1164
+ writeOffset += password.length;
1165
+ combinedArray.set(k, writeOffset);
1166
+ writeOffset += k.length;
1167
+ combinedArray.set(userBytes, writeOffset);
1168
+ const k1 = new Uint8Array(combinedLength * 64);
1169
+ for (let j = 0, pos = 0; j < 64; j++, pos += combinedLength) {
1170
+ k1.set(combinedArray, pos);
1171
+ }
1172
+ // AES128 CBC NO PADDING with first 16 bytes of k as the key
1173
+ // and the second 16 as the iv.
1174
+ const cipher = new AES128Cipher(k.subarray(0, 16));
1175
+ e = cipher.encrypt(k1, k.subarray(16, 32));
1176
+ // Now we have to take the first 16 bytes of an unsigned big endian
1177
+ // integer and compute the remainder modulo 3. That is a fairly large
1178
+ // number and JavaScript isn't going to handle that well.
1179
+ // The number is e0 + 256 * e1 + 256^2 * e2... and 256 % 3 === 1, hence
1180
+ // the powers of 256 are === 1 modulo 3 and finally the number modulo 3
1181
+ // is equal to the remainder modulo 3 of the sum of the e_n.
1182
+ const remainder = e.slice(0, 16).reduce((a, b) => a + b, 0) % 3;
1183
+ if (remainder === 0) {
1184
+ k = calculateSHA256(e, 0, e.length);
1185
+ }
1186
+ else if (remainder === 1) {
1187
+ k = calculateSHA384(e, 0, e.length);
1188
+ }
1189
+ else if (remainder === 2) {
1190
+ k = calculateSHA512(e, 0, e.length);
1191
+ }
1192
+ i++;
1193
+ }
1194
+ return k.subarray(0, 32);
1195
+ }
1196
+ hash(password, concatBytes, userBytes) {
1197
+ return this.calculatePDF20Hash(password, concatBytes, userBytes);
1198
+ }
1199
+ checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
1200
+ const hashData = new Uint8Array(password.length + 56);
1201
+ hashData.set(password, 0);
1202
+ hashData.set(ownerValidationSalt, password.length);
1203
+ hashData.set(userBytes, password.length + ownerValidationSalt.length);
1204
+ const result = this.calculatePDF20Hash(password, hashData, userBytes);
1205
+ return isArrayEqual(result, ownerPassword);
1206
+ }
1207
+ checkUserPassword(password, userValidationSalt, userPassword) {
1208
+ const hashData = new Uint8Array(password.length + 8);
1209
+ hashData.set(password, 0);
1210
+ hashData.set(userValidationSalt, password.length);
1211
+ const result = this.calculatePDF20Hash(password, hashData, new Uint8Array());
1212
+ return isArrayEqual(result, userPassword);
1213
+ }
1214
+ getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
1215
+ const hashData = new Uint8Array(password.length + 56);
1216
+ hashData.set(password, 0);
1217
+ hashData.set(ownerKeySalt, password.length);
1218
+ hashData.set(userBytes, password.length + ownerKeySalt.length);
1219
+ const key = this.calculatePDF20Hash(password, hashData, userBytes);
1220
+ const cipher = new AES256Cipher(key);
1221
+ return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
1222
+ }
1223
+ getUserKey(password, userKeySalt, userEncryption) {
1224
+ const hashData = new Uint8Array(password.length + 8);
1225
+ hashData.set(password, 0);
1226
+ hashData.set(userKeySalt, password.length);
1227
+ // `key` is the decryption key for the UE string.
1228
+ const key = this.calculatePDF20Hash(password, hashData, new Uint8Array());
1229
+ const cipher = new AES256Cipher(key);
1230
+ return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
1231
+ }
1232
+ }
1233
+ class CipherTransform {
1234
+ constructor(stringCipherConstructor, streamCipherConstructor) {
1235
+ this.StringCipherConstructor = stringCipherConstructor;
1236
+ this.StreamCipherConstructor = streamCipherConstructor;
1237
+ }
1238
+ createStream(stream, length) {
1239
+ const cipher = this.StreamCipherConstructor();
1240
+ return new DecryptStream(stream, function cipherTransformDecryptStream(data, finalize) {
1241
+ return cipher.decryptBlock(data, finalize);
1242
+ }, length);
1243
+ }
1244
+ decryptString(s) {
1245
+ const cipher = this.StringCipherConstructor();
1246
+ let data = stringAsByteArray(s);
1247
+ data = cipher.decryptBlock(data, true);
1248
+ return arrayAsString(data);
1249
+ }
1250
+ decryptBytes(d) {
1251
+ const cipher = this.StringCipherConstructor();
1252
+ return cipher.decryptBlock(d, true);
1253
+ }
1254
+ encryptString(s) {
1255
+ const cipher = this.StringCipherConstructor();
1256
+ if (cipher instanceof AESBaseCipher) {
1257
+ // Append some chars equal to "16 - (M mod 16)"
1258
+ // where M is the string length (see section 7.6.2 in PDF specification)
1259
+ // to have a final string where the length is a multiple of 16.
1260
+ // Special note:
1261
+ // "Note that the pad is present when M is evenly divisible by 16;
1262
+ // it contains 16 bytes of 0x10."
1263
+ const strLen = s.length;
1264
+ const pad = 16 - (strLen % 16);
1265
+ s += String.fromCharCode(pad).repeat(pad);
1266
+ // Generate an initialization vector
1267
+ const iv = new Uint8Array(16);
1268
+ if (typeof crypto !== 'undefined') {
1269
+ crypto.getRandomValues(iv);
1270
+ }
1271
+ else {
1272
+ for (let i = 0; i < 16; i++) {
1273
+ iv[i] = Math.floor(256 * Math.random());
1274
+ }
1275
+ }
1276
+ let data = stringAsByteArray(s);
1277
+ data = cipher.encrypt(data, iv);
1278
+ const buf = new Uint8Array(16 + data.length);
1279
+ buf.set(iv);
1280
+ buf.set(data, 16);
1281
+ return arrayAsString(buf);
1282
+ }
1283
+ let data = stringAsByteArray(s);
1284
+ data = cipher.encrypt(data);
1285
+ return arrayAsString(data);
1286
+ }
1287
+ }
1288
+ // eslint-disable-next-line no-shadow
1289
+ class CipherTransformFactory {
1290
+ constructor(dict, fileIdBytes, password) {
1291
+ var _a;
1292
+ this.defaultPasswordBytes = new Uint8Array([
1293
+ 0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e, 0x56,
1294
+ 0xff, 0xfa, 0x01, 0x08, 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80,
1295
+ 0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a,
1296
+ ]);
1297
+ this.identityName = PDFName.of('Identity');
1298
+ const filter = dict.get(PDFName.of('Filter'));
1299
+ if (filter.asString() !== '/Standard') {
1300
+ throw new Error('unknown encryption method');
1301
+ }
1302
+ this.filterName = filter.asString();
1303
+ this.dict = dict;
1304
+ const algorithm = dict.get(PDFName.of('V')).asNumber();
1305
+ if (!Number.isInteger(algorithm) ||
1306
+ (algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5)) {
1307
+ throw new Error('unsupported encryption algorithm');
1308
+ }
1309
+ this.algorithm = algorithm;
1310
+ let keyLength = dict.get(PDFName.of('Length')).asNumber();
1311
+ if (!keyLength) {
1312
+ // Spec asks to rely on encryption dictionary's Length entry, however
1313
+ // some PDFs don't have it. Trying to recover.
1314
+ if (algorithm <= 3) {
1315
+ // For 1 and 2 it's fixed to 40-bit, for 3 40-bit is a minimal value.
1316
+ keyLength = 40;
1317
+ }
1318
+ else {
1319
+ // Trying to find default handler -- it usually has Length.
1320
+ const cfDict = dict.get(PDFName.of('CF'));
1321
+ const streamCryptoName = dict.get(PDFName.of('StmF'));
1322
+ if (cfDict instanceof PDFDict && streamCryptoName instanceof PDFName) {
1323
+ cfDict.suppressEncryption = true;
1324
+ const handlerDict = cfDict.get(PDFName.of(streamCryptoName.asString()));
1325
+ let keyLen = null;
1326
+ if (handlerDict) {
1327
+ keyLen = handlerDict.get(PDFName.of('Length'));
1328
+ }
1329
+ keyLength = (keyLen && keyLen.asNumber()) || 128;
1330
+ if (keyLength < 40) {
1331
+ // Sometimes it's incorrect value of bits, generators specify
1332
+ // bytes.
1333
+ keyLength <<= 3;
1334
+ }
1335
+ }
1336
+ }
1337
+ }
1338
+ if (!Number.isInteger(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
1339
+ throw new Error('invalid key length');
1340
+ }
1341
+ const oPdfStr = dict.get(PDFName.of('O')).asBytes();
1342
+ const uPdfStr = dict.get(PDFName.of('U')).asBytes();
1343
+ // prepare keys
1344
+ const ownerPassword = oPdfStr.subarray(0, 32);
1345
+ const userPassword = uPdfStr.subarray(0, 32);
1346
+ const flags = dict.get(PDFName.of('P')).asNumber();
1347
+ const revision = dict.get(PDFName.of('R')).asNumber();
1348
+ // meaningful when V is 4 or 5
1349
+ const encryptMetadata = (algorithm === 4 || algorithm === 5) &&
1350
+ ((_a = dict.get(PDFName.of('EncryptMetadata'))) === null || _a === void 0 ? void 0 : _a.asBoolean()) !==
1351
+ false;
1352
+ this.encryptMetadata = encryptMetadata;
1353
+ let passwordBytes;
1354
+ if (password) {
1355
+ if (revision === 6) {
1356
+ try {
1357
+ password = unescape(encodeURIComponent(password));
1358
+ }
1359
+ catch (ex) {
1360
+ console.warn('CipherTransformFactory: ' +
1361
+ 'Unable to convert UTF8 encoded password.');
1362
+ }
1363
+ }
1364
+ passwordBytes = stringAsByteArray(password);
1365
+ }
1366
+ let encryptionKey;
1367
+ if (algorithm !== 5) {
1368
+ encryptionKey = this.prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
1369
+ }
1370
+ else {
1371
+ const ownerValidationSalt = oPdfStr.subarray(32, 40);
1372
+ const ownerKeySalt = oPdfStr.subarray(40, 48);
1373
+ const uBytes = uPdfStr.subarray(0, 48);
1374
+ const userValidationSalt = uPdfStr.subarray(32, 40);
1375
+ const userKeySalt = uPdfStr.subarray(40, 48);
1376
+ const ownerEncryption = dict.get(PDFName.of('OE')).asBytes();
1377
+ const userEncryption = dict.get(PDFName.of('UE')).asBytes();
1378
+ const perms = dict.get(PDFName.of('Perms')).asBytes();
1379
+ encryptionKey = this.createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
1380
+ }
1381
+ if (!encryptionKey && !password) {
1382
+ throw new Error('NEEDS PASSWORD');
1383
+ }
1384
+ else if (!encryptionKey && password) {
1385
+ // Attempting use the password as an owner password
1386
+ const decodedPassword = this.decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
1387
+ encryptionKey = this.prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
1388
+ }
1389
+ if (!encryptionKey) {
1390
+ throw new Error('Password incorrect');
1391
+ }
1392
+ this.encryptionKey = encryptionKey;
1393
+ if (algorithm >= 4) {
1394
+ const cf = dict.get(PDFName.of('CF'));
1395
+ if (cf instanceof PDFDict) {
1396
+ // The 'CF' dictionary itself should not be encrypted, and by setting
1397
+ // `suppressEncryption` we can prevent an infinite loop inside of
1398
+ // `XRef_fetchUncompressed` if the dictionary contains indirect
1399
+ // objects (fixes issue7665.pdf).
1400
+ cf.suppressEncryption = true;
1401
+ }
1402
+ this.cf = cf;
1403
+ this.stmf =
1404
+ dict.get(PDFName.of('StmF')) || this.identityName;
1405
+ this.strf =
1406
+ dict.get(PDFName.of('StrF')) || this.identityName;
1407
+ this.eff = dict.get(PDFName.of('EFF')) || this.stmf;
1408
+ }
1409
+ }
1410
+ createCipherTransform(num, gen) {
1411
+ if (this.algorithm === 4 || this.algorithm === 5) {
1412
+ return new CipherTransform(this.buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey), this.buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey));
1413
+ }
1414
+ // algorithms 1 and 2
1415
+ const key = this.buildObjectKey(num, gen, this.encryptionKey,
1416
+ /* isAes = */ false);
1417
+ const cipherConstructor = function buildCipherCipherConstructor() {
1418
+ return new ARCFourCipher(key);
1419
+ };
1420
+ return new CipherTransform(cipherConstructor, cipherConstructor);
1421
+ }
1422
+ createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, _perms) {
1423
+ if (password) {
1424
+ const passwordLength = Math.min(127, password.length);
1425
+ password = password.subarray(0, passwordLength);
1426
+ }
1427
+ else {
1428
+ password = new Uint8Array();
1429
+ }
1430
+ let pdfAlgorithm;
1431
+ if (revision === 6) {
1432
+ pdfAlgorithm = new PDF20();
1433
+ }
1434
+ else {
1435
+ pdfAlgorithm = new PDF17();
1436
+ }
1437
+ if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
1438
+ return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
1439
+ }
1440
+ else if (password.length &&
1441
+ pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
1442
+ return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
1443
+ }
1444
+ return null;
1445
+ }
1446
+ prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
1447
+ const hashDataSize = 40 + ownerPassword.length + fileId.length;
1448
+ const hashData = new Uint8Array(hashDataSize);
1449
+ let i = 0, j, n;
1450
+ if (password) {
1451
+ n = Math.min(32, password.length);
1452
+ for (; i < n; ++i) {
1453
+ hashData[i] = password[i];
1454
+ }
1455
+ }
1456
+ j = 0;
1457
+ while (i < 32) {
1458
+ hashData[i++] = this.defaultPasswordBytes[j++];
1459
+ }
1460
+ // as now the padded password in the hashData[0..i]
1461
+ for (j = 0, n = ownerPassword.length; j < n; ++j) {
1462
+ hashData[i++] = ownerPassword[j];
1463
+ }
1464
+ hashData[i++] = flags & 0xff;
1465
+ hashData[i++] = (flags >> 8) & 0xff;
1466
+ hashData[i++] = (flags >> 16) & 0xff;
1467
+ hashData[i++] = (flags >>> 24) & 0xff;
1468
+ for (j = 0, n = fileId.length; j < n; ++j) {
1469
+ hashData[i++] = fileId[j];
1470
+ }
1471
+ if (revision >= 4 && !encryptMetadata) {
1472
+ hashData[i++] = 0xff;
1473
+ hashData[i++] = 0xff;
1474
+ hashData[i++] = 0xff;
1475
+ hashData[i++] = 0xff;
1476
+ }
1477
+ let hash = calculateMD5(hashData, 0, i);
1478
+ const keyLengthInBytes = keyLength >> 3;
1479
+ if (revision >= 3) {
1480
+ for (j = 0; j < 50; ++j) {
1481
+ hash = calculateMD5(hash, 0, keyLengthInBytes);
1482
+ }
1483
+ }
1484
+ const encryptionKey = hash.subarray(0, keyLengthInBytes);
1485
+ let cipher, checkData;
1486
+ if (revision >= 3) {
1487
+ for (i = 0; i < 32; ++i) {
1488
+ hashData[i] = this.defaultPasswordBytes[i];
1489
+ }
1490
+ for (j = 0, n = fileId.length; j < n; ++j) {
1491
+ hashData[i++] = fileId[j];
1492
+ }
1493
+ cipher = new ARCFourCipher(encryptionKey);
1494
+ checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
1495
+ n = encryptionKey.length;
1496
+ const derivedKey = new Uint8Array(n);
1497
+ for (j = 1; j <= 19; ++j) {
1498
+ for (let k = 0; k < n; ++k) {
1499
+ derivedKey[k] = encryptionKey[k] ^ j;
1500
+ }
1501
+ cipher = new ARCFourCipher(derivedKey);
1502
+ checkData = cipher.encryptBlock(checkData);
1503
+ }
1504
+ for (j = 0, n = checkData.length; j < n; ++j) {
1505
+ if (userPassword[j] !== checkData[j]) {
1506
+ return null;
1507
+ }
1508
+ }
1509
+ }
1510
+ else {
1511
+ cipher = new ARCFourCipher(encryptionKey);
1512
+ checkData = cipher.encryptBlock(this.defaultPasswordBytes);
1513
+ for (j = 0, n = checkData.length; j < n; ++j) {
1514
+ if (userPassword[j] !== checkData[j]) {
1515
+ return null;
1516
+ }
1517
+ }
1518
+ }
1519
+ return encryptionKey;
1520
+ }
1521
+ decodeUserPassword(password, ownerPassword, revision, keyLength) {
1522
+ const hashData = new Uint8Array(32);
1523
+ let i = 0;
1524
+ const n = Math.min(32, password.length);
1525
+ for (; i < n; ++i) {
1526
+ hashData[i] = password[i];
1527
+ }
1528
+ let j = 0;
1529
+ while (i < 32) {
1530
+ hashData[i++] = this.defaultPasswordBytes[j++];
1531
+ }
1532
+ let hash = calculateMD5(hashData, 0, i);
1533
+ const keyLengthInBytes = keyLength >> 3;
1534
+ if (revision >= 3) {
1535
+ for (j = 0; j < 50; ++j) {
1536
+ hash = calculateMD5(hash, 0, hash.length);
1537
+ }
1538
+ }
1539
+ let cipher, userPassword;
1540
+ if (revision >= 3) {
1541
+ userPassword = ownerPassword;
1542
+ const derivedKey = new Uint8Array(keyLengthInBytes);
1543
+ for (j = 19; j >= 0; j--) {
1544
+ for (let k = 0; k < keyLengthInBytes; ++k) {
1545
+ derivedKey[k] = hash[k] ^ j;
1546
+ }
1547
+ cipher = new ARCFourCipher(derivedKey);
1548
+ userPassword = cipher.encryptBlock(userPassword);
1549
+ }
1550
+ }
1551
+ else {
1552
+ cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
1553
+ userPassword = cipher.encryptBlock(ownerPassword);
1554
+ }
1555
+ return userPassword;
1556
+ }
1557
+ buildObjectKey(num, gen, encryptionKey, isAes = false) {
1558
+ const key = new Uint8Array(encryptionKey.length + 9);
1559
+ const n = encryptionKey.length;
1560
+ let i;
1561
+ for (i = 0; i < n; ++i) {
1562
+ key[i] = encryptionKey[i];
1563
+ }
1564
+ key[i++] = num & 0xff;
1565
+ key[i++] = (num >> 8) & 0xff;
1566
+ key[i++] = (num >> 16) & 0xff;
1567
+ key[i++] = gen & 0xff;
1568
+ key[i++] = (gen >> 8) & 0xff;
1569
+ if (isAes) {
1570
+ key[i++] = 0x73;
1571
+ key[i++] = 0x41;
1572
+ key[i++] = 0x6c;
1573
+ key[i++] = 0x54;
1574
+ }
1575
+ const hash = calculateMD5(key, 0, i);
1576
+ return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
1577
+ }
1578
+ buildCipherConstructor(cf, name, num, gen, key) {
1579
+ if (!(name instanceof PDFName)) {
1580
+ throw new Error('Invalid crypt filter name.');
1581
+ }
1582
+ const cryptFilter = cf.get(PDFName.of(name.asString().replace('/', '')));
1583
+ let cfm;
1584
+ if (cryptFilter !== null && cryptFilter !== undefined) {
1585
+ cfm = cryptFilter.get(PDFName.of('CFM'));
1586
+ }
1587
+ if (!cfm || cfm.asString() === '/None') {
1588
+ return function cipherTransformFactoryBuildCipherConstructorNone() {
1589
+ return new NullCipher();
1590
+ };
1591
+ }
1592
+ if (cfm.asString() === '/V2') {
1593
+ return () => new ARCFourCipher(this.buildObjectKey(num, gen, key, /* isAes = */ false));
1594
+ }
1595
+ if (cfm.asString() === '/AESV2') {
1596
+ return () => new AES128Cipher(this.buildObjectKey(num, gen, key, /* isAes = */ true));
1597
+ }
1598
+ if (cfm.asString() === '/AESV3') {
1599
+ return () => new AES256Cipher(key);
1600
+ }
1601
+ throw new Error('Unknown crypto method');
1602
+ }
1603
+ }
1604
+ export { AES128Cipher, AES256Cipher, ARCFourCipher, calculateMD5, calculateSHA256, calculateSHA384, calculateSHA512, CipherTransformFactory, CipherTransform, PDF17, PDF20, };
1605
+ //# sourceMappingURL=crypto.js.map