@pdfme/pdf-lib 1.17.3 → 1.18.1

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