ooxml-core 0.9.0 → 0.11.0

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 (320) hide show
  1. package/README.md +14 -13
  2. package/dist/automation/docx.d.ts +13 -0
  3. package/dist/automation/docx.d.ts.map +1 -0
  4. package/dist/automation/index.cjs +36838 -0
  5. package/dist/automation/index.d.ts +6 -0
  6. package/dist/automation/index.d.ts.map +1 -0
  7. package/dist/automation/index.mjs +36824 -0
  8. package/dist/automation/node.cjs +103 -0
  9. package/dist/automation/node.d.ts +16 -0
  10. package/dist/automation/node.d.ts.map +1 -0
  11. package/dist/automation/node.mjs +101 -0
  12. package/dist/automation/visio.d.ts +30 -0
  13. package/dist/automation/visio.d.ts.map +1 -0
  14. package/dist/automation/xlsx.d.ts +25 -0
  15. package/dist/automation/xlsx.d.ts.map +1 -0
  16. package/dist/crypto/aes-ecb.d.ts +13 -0
  17. package/dist/crypto/aes-ecb.d.ts.map +1 -0
  18. package/dist/crypto/decrypt.d.ts +63 -0
  19. package/dist/crypto/decrypt.d.ts.map +1 -0
  20. package/dist/crypto/detect.d.ts +56 -0
  21. package/dist/crypto/detect.d.ts.map +1 -0
  22. package/dist/crypto/encrypt.d.ts +27 -0
  23. package/dist/crypto/encrypt.d.ts.map +1 -0
  24. package/dist/crypto/encryption-info-write.d.ts +46 -0
  25. package/dist/crypto/encryption-info-write.d.ts.map +1 -0
  26. package/dist/crypto/encryption-info.d.ts +22 -0
  27. package/dist/crypto/encryption-info.d.ts.map +1 -0
  28. package/dist/crypto/errors.d.ts +39 -0
  29. package/dist/crypto/errors.d.ts.map +1 -0
  30. package/dist/crypto/index.cjs +1805 -0
  31. package/dist/crypto/index.d.ts +26 -0
  32. package/dist/crypto/index.d.ts.map +1 -0
  33. package/dist/crypto/index.mjs +1774 -0
  34. package/dist/crypto/key-derivation.d.ts +73 -0
  35. package/dist/crypto/key-derivation.d.ts.map +1 -0
  36. package/dist/crypto/types.d.ts +104 -0
  37. package/dist/crypto/types.d.ts.map +1 -0
  38. package/dist/docx/embedded.cjs +2 -0
  39. package/dist/docx/embedded.mjs +2 -0
  40. package/dist/docx/index.cjs +2 -0
  41. package/dist/docx/index.mjs +2 -0
  42. package/dist/docx/load/detect.d.ts +14 -2
  43. package/dist/docx/load/detect.d.ts.map +1 -1
  44. package/dist/docx/load/index.cjs +8995 -7728
  45. package/dist/docx/load/index.d.ts +3 -1
  46. package/dist/docx/load/index.d.ts.map +1 -1
  47. package/dist/docx/load/index.mjs +8990 -7729
  48. package/dist/docx/load/legacy-doc.d.ts.map +1 -1
  49. package/dist/index.cjs +749 -19
  50. package/dist/index.mjs +749 -19
  51. package/dist/opc/index.cjs +797 -1
  52. package/dist/opc/index.d.ts +2 -0
  53. package/dist/opc/index.d.ts.map +1 -1
  54. package/dist/opc/index.mjs +784 -3
  55. package/dist/opc/properties/app.d.ts +10 -0
  56. package/dist/opc/properties/app.d.ts.map +1 -0
  57. package/dist/opc/properties/core.d.ts +13 -0
  58. package/dist/opc/properties/core.d.ts.map +1 -0
  59. package/dist/opc/properties/custom.d.ts +15 -0
  60. package/dist/opc/properties/custom.d.ts.map +1 -0
  61. package/dist/opc/properties/index.d.ts +5 -0
  62. package/dist/opc/properties/index.d.ts.map +1 -0
  63. package/dist/opc/properties/types.d.ts +114 -0
  64. package/dist/opc/properties/types.d.ts.map +1 -0
  65. package/dist/opc/relationship-types.d.ts +1 -0
  66. package/dist/opc/relationship-types.d.ts.map +1 -1
  67. package/dist/opc/safe-href.d.ts +34 -0
  68. package/dist/opc/safe-href.d.ts.map +1 -1
  69. package/dist/opc/signature/constants.d.ts +42 -0
  70. package/dist/opc/signature/constants.d.ts.map +1 -0
  71. package/dist/opc/signature/detection.d.ts +97 -0
  72. package/dist/opc/signature/detection.d.ts.map +1 -0
  73. package/dist/opc/signature/digest.d.ts +16 -0
  74. package/dist/opc/signature/digest.d.ts.map +1 -0
  75. package/dist/opc/signature/index.d.ts +8 -0
  76. package/dist/opc/signature/index.d.ts.map +1 -0
  77. package/dist/opc/signature/inspection-status.d.ts +24 -0
  78. package/dist/opc/signature/inspection-status.d.ts.map +1 -0
  79. package/dist/opc/signature/reference-utils.d.ts +12 -0
  80. package/dist/opc/signature/reference-utils.d.ts.map +1 -0
  81. package/dist/opc/signature/types.d.ts +90 -0
  82. package/dist/opc/signature/types.d.ts.map +1 -0
  83. package/dist/opc/signature/xml-utils.d.ts +35 -0
  84. package/dist/opc/signature/xml-utils.d.ts.map +1 -0
  85. package/dist/pptx/automation/index.cjs +149047 -0
  86. package/dist/pptx/automation/index.d.ts +1474 -0
  87. package/dist/pptx/automation/index.d.ts.map +1 -0
  88. package/dist/pptx/automation/index.mjs +148926 -0
  89. package/dist/pptx/chunks/{index-CojJtI77.d.ts → index-BWRd8p4y.d.ts} +10 -12
  90. package/dist/pptx/chunks/index-BWRd8p4y.d.ts.map +1 -0
  91. package/dist/pptx/chunks/index-LoCVDu8Z.d.ts +9644 -0
  92. package/dist/pptx/chunks/index-LoCVDu8Z.d.ts.map +1 -0
  93. package/dist/pptx/chunks/{signature-inspection-status-Bh2oap7B.d.ts → inspection-status-B2E-jSpG.d.ts} +8 -8
  94. package/dist/pptx/chunks/inspection-status-B2E-jSpG.d.ts.map +1 -0
  95. package/dist/pptx/chunks/{text-operations-IlJiffp7.d.ts → text-operations-2tKzrY5o.d.ts} +7381 -7381
  96. package/dist/pptx/chunks/text-operations-2tKzrY5o.d.ts.map +1 -0
  97. package/dist/pptx/cli/index.cjs +1409 -895
  98. package/dist/pptx/cli/index.d.ts +1 -1
  99. package/dist/pptx/cli/index.mjs +1409 -895
  100. package/dist/pptx/converter/index.d.ts +1 -1
  101. package/dist/pptx/index.cjs +1933 -1391
  102. package/dist/pptx/index.d.ts +5 -9692
  103. package/dist/pptx/index.mjs +1933 -1391
  104. package/dist/pptx/signature-node/index.cjs +5 -5
  105. package/dist/pptx/signature-node/index.d.ts +1 -1
  106. package/dist/pptx/signature-node/index.mjs +5 -5
  107. package/dist/visio/edit-geometry-admission.d.ts +1 -1
  108. package/dist/visio/edit-geometry-admission.d.ts.map +1 -1
  109. package/dist/visio/edit-geometry.d.ts +1 -1
  110. package/dist/visio/edit-geometry.d.ts.map +1 -1
  111. package/dist/visio/edit-master-index.d.ts +10 -0
  112. package/dist/visio/edit-master-index.d.ts.map +1 -0
  113. package/dist/visio/edit-master-move.d.ts +12 -0
  114. package/dist/visio/edit-master-move.d.ts.map +1 -0
  115. package/dist/visio/edit-master-scope.d.ts +7 -0
  116. package/dist/visio/edit-master-scope.d.ts.map +1 -0
  117. package/dist/visio/edit-recalculate-index.d.ts +2 -0
  118. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  119. package/dist/visio/edit-scope.d.ts +1 -1
  120. package/dist/visio/edit-scope.d.ts.map +1 -1
  121. package/dist/visio/edit.d.ts.map +1 -1
  122. package/dist/visio/formula-arithmetic.d.ts +8 -0
  123. package/dist/visio/formula-arithmetic.d.ts.map +1 -0
  124. package/dist/visio/formula-evaluate.d.ts.map +1 -1
  125. package/dist/visio/formula-master.d.ts +13 -0
  126. package/dist/visio/formula-master.d.ts.map +1 -0
  127. package/dist/visio/formula-numeric-functions.d.ts +8 -0
  128. package/dist/visio/formula-numeric-functions.d.ts.map +1 -0
  129. package/dist/visio/formula.d.ts +1 -1
  130. package/dist/visio/formula.d.ts.map +1 -1
  131. package/dist/visio/index.cjs +687 -71
  132. package/dist/visio/index.mjs +687 -71
  133. package/dist/xlsx/edit/annotations.d.ts +5 -1
  134. package/dist/xlsx/edit/annotations.d.ts.map +1 -1
  135. package/dist/xlsx/edit/cell-values.d.ts +7 -2
  136. package/dist/xlsx/edit/cell-values.d.ts.map +1 -1
  137. package/dist/xlsx/edit/clipboard.d.ts.map +1 -1
  138. package/dist/xlsx/edit/doc-properties.d.ts +14 -0
  139. package/dist/xlsx/edit/doc-properties.d.ts.map +1 -0
  140. package/dist/xlsx/edit/fill-series.d.ts.map +1 -1
  141. package/dist/xlsx/edit/find.d.ts +2 -1
  142. package/dist/xlsx/edit/find.d.ts.map +1 -1
  143. package/dist/xlsx/edit/format-lines.d.ts +22 -0
  144. package/dist/xlsx/edit/format-lines.d.ts.map +1 -0
  145. package/dist/xlsx/edit/format.d.ts +2 -1
  146. package/dist/xlsx/edit/format.d.ts.map +1 -1
  147. package/dist/xlsx/edit/history-refs.d.ts +51 -0
  148. package/dist/xlsx/edit/history-refs.d.ts.map +1 -0
  149. package/dist/xlsx/edit/history.d.ts +40 -5
  150. package/dist/xlsx/edit/history.d.ts.map +1 -1
  151. package/dist/xlsx/edit/index.d.ts +3 -0
  152. package/dist/xlsx/edit/index.d.ts.map +1 -1
  153. package/dist/xlsx/edit/input-text.d.ts +13 -0
  154. package/dist/xlsx/edit/input-text.d.ts.map +1 -0
  155. package/dist/xlsx/edit/merge.d.ts +10 -2
  156. package/dist/xlsx/edit/merge.d.ts.map +1 -1
  157. package/dist/xlsx/edit/session.d.ts.map +1 -1
  158. package/dist/xlsx/edit/sheets.d.ts.map +1 -1
  159. package/dist/xlsx/edit/shift-formulas.d.ts +2 -1
  160. package/dist/xlsx/edit/shift-formulas.d.ts.map +1 -1
  161. package/dist/xlsx/edit/shift-preserved.d.ts +17 -0
  162. package/dist/xlsx/edit/shift-preserved.d.ts.map +1 -0
  163. package/dist/xlsx/edit/shift-sheet.d.ts +2 -2
  164. package/dist/xlsx/edit/shift-sheet.d.ts.map +1 -1
  165. package/dist/xlsx/edit/structure.d.ts.map +1 -1
  166. package/dist/xlsx/edit/types.d.ts +7 -0
  167. package/dist/xlsx/edit/types.d.ts.map +1 -1
  168. package/dist/xlsx/edit/validation-list.d.ts +24 -0
  169. package/dist/xlsx/edit/validation-list.d.ts.map +1 -0
  170. package/dist/xlsx/edit/validation.d.ts +2 -1
  171. package/dist/xlsx/edit/validation.d.ts.map +1 -1
  172. package/dist/xlsx/formula/area-index.d.ts +18 -0
  173. package/dist/xlsx/formula/area-index.d.ts.map +1 -0
  174. package/dist/xlsx/formula/array-context.d.ts.map +1 -1
  175. package/dist/xlsx/formula/ast.d.ts +5 -1
  176. package/dist/xlsx/formula/ast.d.ts.map +1 -1
  177. package/dist/xlsx/formula/call.d.ts.map +1 -1
  178. package/dist/xlsx/formula/coerce.d.ts.map +1 -1
  179. package/dist/xlsx/formula/context.d.ts +5 -0
  180. package/dist/xlsx/formula/context.d.ts.map +1 -1
  181. package/dist/xlsx/formula/date-serial.d.ts +11 -4
  182. package/dist/xlsx/formula/date-serial.d.ts.map +1 -1
  183. package/dist/xlsx/formula/engine-core.d.ts +6 -0
  184. package/dist/xlsx/formula/engine-core.d.ts.map +1 -1
  185. package/dist/xlsx/formula/engine-host.d.ts +35 -3
  186. package/dist/xlsx/formula/engine-host.d.ts.map +1 -1
  187. package/dist/xlsx/formula/engine-util.d.ts.map +1 -1
  188. package/dist/xlsx/formula/engine.d.ts.map +1 -1
  189. package/dist/xlsx/formula/evaluator.d.ts.map +1 -1
  190. package/dist/xlsx/formula/functions/array-shape.d.ts.map +1 -1
  191. package/dist/xlsx/formula/functions/array.d.ts.map +1 -1
  192. package/dist/xlsx/formula/functions/criteria-index.d.ts +12 -0
  193. package/dist/xlsx/formula/functions/criteria-index.d.ts.map +1 -0
  194. package/dist/xlsx/formula/functions/criteria.d.ts +24 -16
  195. package/dist/xlsx/formula/functions/criteria.d.ts.map +1 -1
  196. package/dist/xlsx/formula/functions/date-calc.d.ts +4 -0
  197. package/dist/xlsx/formula/functions/date-calc.d.ts.map +1 -1
  198. package/dist/xlsx/formula/functions/depreciation.d.ts.map +1 -1
  199. package/dist/xlsx/formula/functions/financial.d.ts.map +1 -1
  200. package/dist/xlsx/formula/functions/helpers.d.ts.map +1 -1
  201. package/dist/xlsx/formula/functions/logical.d.ts.map +1 -1
  202. package/dist/xlsx/formula/functions/lookup-core.d.ts +14 -2
  203. package/dist/xlsx/formula/functions/lookup-core.d.ts.map +1 -1
  204. package/dist/xlsx/formula/functions/lookup.d.ts.map +1 -1
  205. package/dist/xlsx/formula/functions/math-mod.d.ts +8 -0
  206. package/dist/xlsx/formula/functions/math-mod.d.ts.map +1 -0
  207. package/dist/xlsx/formula/functions/math-sum.d.ts.map +1 -1
  208. package/dist/xlsx/formula/functions/math.d.ts.map +1 -1
  209. package/dist/xlsx/formula/functions/statistical-count.d.ts.map +1 -1
  210. package/dist/xlsx/formula/functions/statistical.d.ts.map +1 -1
  211. package/dist/xlsx/formula/functions/stats-core.d.ts +6 -0
  212. package/dist/xlsx/formula/functions/stats-core.d.ts.map +1 -1
  213. package/dist/xlsx/formula/functions/text-case.d.ts +14 -0
  214. package/dist/xlsx/formula/functions/text-case.d.ts.map +1 -0
  215. package/dist/xlsx/formula/functions/text.d.ts.map +1 -1
  216. package/dist/xlsx/formula/functions/workdays.d.ts.map +1 -1
  217. package/dist/xlsx/formula/graph-index.d.ts +15 -0
  218. package/dist/xlsx/formula/graph-index.d.ts.map +1 -0
  219. package/dist/xlsx/formula/graph.d.ts +13 -18
  220. package/dist/xlsx/formula/graph.d.ts.map +1 -1
  221. package/dist/xlsx/formula/operators.d.ts +9 -0
  222. package/dist/xlsx/formula/operators.d.ts.map +1 -1
  223. package/dist/xlsx/formula/parser.d.ts +2 -0
  224. package/dist/xlsx/formula/parser.d.ts.map +1 -1
  225. package/dist/xlsx/formula/references.d.ts +4 -1
  226. package/dist/xlsx/formula/references.d.ts.map +1 -1
  227. package/dist/xlsx/formula/text-number.d.ts.map +1 -1
  228. package/dist/xlsx/formula/transform.d.ts.map +1 -1
  229. package/dist/xlsx/formula/values.d.ts +44 -3
  230. package/dist/xlsx/formula/values.d.ts.map +1 -1
  231. package/dist/xlsx/index.cjs +4698 -1322
  232. package/dist/xlsx/index.mjs +4688 -1323
  233. package/dist/xlsx/layout/anchors.d.ts +47 -0
  234. package/dist/xlsx/layout/anchors.d.ts.map +1 -0
  235. package/dist/xlsx/layout/cf-evaluator.d.ts +1 -2
  236. package/dist/xlsx/layout/cf-evaluator.d.ts.map +1 -1
  237. package/dist/xlsx/layout/cf-helpers.d.ts +8 -1
  238. package/dist/xlsx/layout/cf-helpers.d.ts.map +1 -1
  239. package/dist/xlsx/layout/index.d.ts +1 -0
  240. package/dist/xlsx/layout/index.d.ts.map +1 -1
  241. package/dist/xlsx/load/csv.d.ts +24 -3
  242. package/dist/xlsx/load/csv.d.ts.map +1 -1
  243. package/dist/xlsx/load/detect.d.ts +39 -7
  244. package/dist/xlsx/load/detect.d.ts.map +1 -1
  245. package/dist/xlsx/load/errors.d.ts +10 -0
  246. package/dist/xlsx/load/errors.d.ts.map +1 -0
  247. package/dist/xlsx/load/index.cjs +16220 -12163
  248. package/dist/xlsx/load/index.d.ts +5 -2
  249. package/dist/xlsx/load/index.d.ts.map +1 -1
  250. package/dist/xlsx/load/index.mjs +16213 -12164
  251. package/dist/xlsx/load/text-decode.d.ts +7 -0
  252. package/dist/xlsx/load/text-decode.d.ts.map +1 -0
  253. package/dist/xlsx/model.d.ts +121 -17
  254. package/dist/xlsx/model.d.ts.map +1 -1
  255. package/dist/xlsx/numfmt/date.d.ts +7 -0
  256. package/dist/xlsx/numfmt/date.d.ts.map +1 -1
  257. package/dist/xlsx/numfmt/format.d.ts.map +1 -1
  258. package/dist/xlsx/numfmt/fraction.d.ts +5 -1
  259. package/dist/xlsx/numfmt/fraction.d.ts.map +1 -1
  260. package/dist/xlsx/numfmt/input-date.d.ts.map +1 -1
  261. package/dist/xlsx/numfmt/input.d.ts.map +1 -1
  262. package/dist/xlsx/numfmt/number.d.ts.map +1 -1
  263. package/dist/xlsx/read/conditional.d.ts.map +1 -1
  264. package/dist/xlsx/read/drawing.d.ts +2 -2
  265. package/dist/xlsx/read/drawing.d.ts.map +1 -1
  266. package/dist/xlsx/read/load.d.ts.map +1 -1
  267. package/dist/xlsx/read/package.d.ts +18 -2
  268. package/dist/xlsx/read/package.d.ts.map +1 -1
  269. package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
  270. package/dist/xlsx/read/sheet-props.d.ts +15 -1
  271. package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
  272. package/dist/xlsx/read/smart-art.d.ts +12 -0
  273. package/dist/xlsx/read/smart-art.d.ts.map +1 -0
  274. package/dist/xlsx/read/styles.d.ts.map +1 -1
  275. package/dist/xlsx/read/workbook-part.d.ts +5 -2
  276. package/dist/xlsx/read/workbook-part.d.ts.map +1 -1
  277. package/dist/xlsx/read/worksheet.d.ts.map +1 -1
  278. package/dist/xlsx/write/attr-merge.d.ts +10 -0
  279. package/dist/xlsx/write/attr-merge.d.ts.map +1 -0
  280. package/dist/xlsx/write/carried-refs.d.ts +61 -0
  281. package/dist/xlsx/write/carried-refs.d.ts.map +1 -0
  282. package/dist/xlsx/write/comments.d.ts +12 -2
  283. package/dist/xlsx/write/comments.d.ts.map +1 -1
  284. package/dist/xlsx/write/conditional.d.ts.map +1 -1
  285. package/dist/xlsx/write/doc-props.d.ts +30 -0
  286. package/dist/xlsx/write/doc-props.d.ts.map +1 -0
  287. package/dist/xlsx/write/drawing.d.ts +5 -0
  288. package/dist/xlsx/write/drawing.d.ts.map +1 -1
  289. package/dist/xlsx/write/metadata.d.ts +23 -0
  290. package/dist/xlsx/write/metadata.d.ts.map +1 -0
  291. package/dist/xlsx/write/package-writer.d.ts +6 -0
  292. package/dist/xlsx/write/package-writer.d.ts.map +1 -1
  293. package/dist/xlsx/write/page-setup.d.ts +8 -0
  294. package/dist/xlsx/write/page-setup.d.ts.map +1 -0
  295. package/dist/xlsx/write/save.d.ts.map +1 -1
  296. package/dist/xlsx/write/sheet-data.d.ts +8 -0
  297. package/dist/xlsx/write/sheet-data.d.ts.map +1 -1
  298. package/dist/xlsx/write/sheet-parts.d.ts +6 -0
  299. package/dist/xlsx/write/sheet-parts.d.ts.map +1 -1
  300. package/dist/xlsx/write/sheet-props.d.ts +0 -6
  301. package/dist/xlsx/write/sheet-props.d.ts.map +1 -1
  302. package/dist/xlsx/write/styles.d.ts.map +1 -1
  303. package/dist/xlsx/write/table-patch.d.ts +12 -0
  304. package/dist/xlsx/write/table-patch.d.ts.map +1 -0
  305. package/dist/xlsx/write/tables.d.ts +9 -0
  306. package/dist/xlsx/write/tables.d.ts.map +1 -1
  307. package/dist/xlsx/write/vml-ids.d.ts +29 -0
  308. package/dist/xlsx/write/vml-ids.d.ts.map +1 -0
  309. package/dist/xlsx/write/workbook-part.d.ts +1 -4
  310. package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
  311. package/dist/xlsx/write/worksheet.d.ts.map +1 -1
  312. package/dist/xml/index.cjs +4 -0
  313. package/dist/xml/index.mjs +4 -0
  314. package/dist/xml/namespaces.d.ts +4 -0
  315. package/dist/xml/namespaces.d.ts.map +1 -1
  316. package/package.json +26 -3
  317. package/dist/pptx/chunks/index-CojJtI77.d.ts.map +0 -1
  318. package/dist/pptx/chunks/signature-inspection-status-Bh2oap7B.d.ts.map +0 -1
  319. package/dist/pptx/chunks/text-operations-IlJiffp7.d.ts.map +0 -1
  320. package/dist/pptx/index.d.ts.map +0 -1
@@ -0,0 +1,103 @@
1
+ 'use strict';
2
+
3
+ var promises = require('fs/promises');
4
+ var path = require('path');
5
+ var crypto = require('crypto');
6
+
7
+ // src/automation/node.ts
8
+ function createFileOperations(rootDir = process.cwd()) {
9
+ const pending = /* @__PURE__ */ new Map();
10
+ const maxBytes = 64 * 1024 * 1024;
11
+ async function pathFor(file, extensions) {
12
+ const root = await promises.realpath(path.resolve(rootDir));
13
+ const path$1 = path.resolve(root, file);
14
+ const parent = await promises.realpath(path.dirname(path$1));
15
+ let actual = path.resolve(parent, path.basename(path$1));
16
+ const inside = (target) => {
17
+ const rel = path.relative(root, target);
18
+ if (rel === ".." || rel.startsWith("../") || rel.startsWith("..\\") || path.isAbsolute(rel))
19
+ throw new Error("Path is outside the configured root");
20
+ };
21
+ inside(actual);
22
+ try {
23
+ actual = await promises.realpath(actual);
24
+ inside(actual);
25
+ } catch (error) {
26
+ if (error.code !== "ENOENT") throw error;
27
+ }
28
+ if (!extensions.includes(path.extname(actual).toLowerCase()))
29
+ throw new Error("Unsupported file extension");
30
+ return actual;
31
+ }
32
+ async function read(path) {
33
+ const handle = await promises.open(path, "r");
34
+ try {
35
+ if ((await handle.stat()).size > maxBytes) throw new Error("File exceeds 64 MiB");
36
+ const bytes = await handle.readFile();
37
+ if (bytes.length > maxBytes) throw new Error("File exceeds 64 MiB");
38
+ return new Uint8Array(bytes);
39
+ } finally {
40
+ await handle.close();
41
+ }
42
+ }
43
+ async function write(path, bytes, replace) {
44
+ if (bytes.length > maxBytes) throw new Error("Output exceeds 64 MiB");
45
+ const temp = `${path}.${crypto.randomUUID()}.tmp`;
46
+ const handle = await promises.open(temp, "wx", 384);
47
+ try {
48
+ await handle.writeFile(bytes);
49
+ await handle.sync();
50
+ } catch (error) {
51
+ await handle.close();
52
+ await promises.unlink(temp).catch(() => {
53
+ });
54
+ throw error;
55
+ }
56
+ await handle.close();
57
+ try {
58
+ if (replace) await promises.rename(temp, path);
59
+ else await promises.link(temp, path);
60
+ } finally {
61
+ await promises.unlink(temp).catch(() => {
62
+ });
63
+ }
64
+ }
65
+ async function serial(path, action) {
66
+ if (process.platform === "win32") path = path.toLowerCase();
67
+ const before = pending.get(path) ?? Promise.resolve();
68
+ const current = before.catch(() => {
69
+ }).then(action);
70
+ pending.set(path, current);
71
+ try {
72
+ return await current;
73
+ } finally {
74
+ if (pending.get(path) === current) pending.delete(path);
75
+ }
76
+ }
77
+ return {
78
+ async inspect(file, extensions, inspect) {
79
+ const path = await pathFor(file, extensions);
80
+ return serial(path, async () => inspect(await read(path)));
81
+ },
82
+ async create(file, extensions, create) {
83
+ const path = await pathFor(file, extensions);
84
+ return serial(path, async () => {
85
+ await write(path, await create(), false);
86
+ return { filePath: path, saved: true };
87
+ });
88
+ },
89
+ async edit(file, extensions, edit, outputPath) {
90
+ const path$1 = await pathFor(file, extensions);
91
+ const output = outputPath ? await pathFor(outputPath, extensions) : path$1;
92
+ if (path.extname(output).toLowerCase() !== path.extname(path$1).toLowerCase())
93
+ throw new Error("Save-as must keep the source file extension");
94
+ return serial(path$1, async () => {
95
+ const { bytes, ...result } = await edit(await read(path$1));
96
+ await write(output, bytes, output === path$1);
97
+ return { ...result, filePath: output, saved: true };
98
+ });
99
+ }
100
+ };
101
+ }
102
+
103
+ exports.createFileOperations = createFileOperations;
@@ -0,0 +1,16 @@
1
+ export interface ByteEditResult {
2
+ bytes: Uint8Array;
3
+ }
4
+ /** Local filesystem boundary used by the repository-owned MCP adapters. */
5
+ export declare function createFileOperations(rootDir?: string): {
6
+ inspect<T>(file: string, extensions: readonly string[], inspect: (bytes: Uint8Array) => Promise<T>): Promise<T>;
7
+ create(file: string, extensions: readonly string[], create: () => Promise<Uint8Array>): Promise<{
8
+ filePath: string;
9
+ saved: boolean;
10
+ }>;
11
+ edit<T extends ByteEditResult>(file: string, extensions: readonly string[], edit: (bytes: Uint8Array) => Promise<T>, outputPath?: string): Promise<Omit<T, "bytes"> & {
12
+ filePath: string;
13
+ saved: boolean;
14
+ }>;
15
+ };
16
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/automation/node.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,UAAU,CAAC;CAClB;AAED,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,OAAO,SAAgB;YAmE5C,CAAC,QACR,MAAM,cACA,SAAS,MAAM,EAAE,WACpB,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC;iBAKxB,MAAM,cAAc,SAAS,MAAM,EAAE,UAAU,MAAM,OAAO,CAAC,UAAU,CAAC;;;;SAOhF,CAAC,SAAS,cAAc,QAC5B,MAAM,cACA,SAAS,MAAM,EAAE,QACvB,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,eAC1B,MAAM;;;;EAarB"}
@@ -0,0 +1,101 @@
1
+ import { realpath, open, unlink, rename, link } from 'fs/promises';
2
+ import { extname, resolve, dirname, basename, relative, isAbsolute } from 'path';
3
+ import { randomUUID } from 'crypto';
4
+
5
+ // src/automation/node.ts
6
+ function createFileOperations(rootDir = process.cwd()) {
7
+ const pending = /* @__PURE__ */ new Map();
8
+ const maxBytes = 64 * 1024 * 1024;
9
+ async function pathFor(file, extensions) {
10
+ const root = await realpath(resolve(rootDir));
11
+ const path = resolve(root, file);
12
+ const parent = await realpath(dirname(path));
13
+ let actual = resolve(parent, basename(path));
14
+ const inside = (target) => {
15
+ const rel = relative(root, target);
16
+ if (rel === ".." || rel.startsWith("../") || rel.startsWith("..\\") || isAbsolute(rel))
17
+ throw new Error("Path is outside the configured root");
18
+ };
19
+ inside(actual);
20
+ try {
21
+ actual = await realpath(actual);
22
+ inside(actual);
23
+ } catch (error) {
24
+ if (error.code !== "ENOENT") throw error;
25
+ }
26
+ if (!extensions.includes(extname(actual).toLowerCase()))
27
+ throw new Error("Unsupported file extension");
28
+ return actual;
29
+ }
30
+ async function read(path) {
31
+ const handle = await open(path, "r");
32
+ try {
33
+ if ((await handle.stat()).size > maxBytes) throw new Error("File exceeds 64 MiB");
34
+ const bytes = await handle.readFile();
35
+ if (bytes.length > maxBytes) throw new Error("File exceeds 64 MiB");
36
+ return new Uint8Array(bytes);
37
+ } finally {
38
+ await handle.close();
39
+ }
40
+ }
41
+ async function write(path, bytes, replace) {
42
+ if (bytes.length > maxBytes) throw new Error("Output exceeds 64 MiB");
43
+ const temp = `${path}.${randomUUID()}.tmp`;
44
+ const handle = await open(temp, "wx", 384);
45
+ try {
46
+ await handle.writeFile(bytes);
47
+ await handle.sync();
48
+ } catch (error) {
49
+ await handle.close();
50
+ await unlink(temp).catch(() => {
51
+ });
52
+ throw error;
53
+ }
54
+ await handle.close();
55
+ try {
56
+ if (replace) await rename(temp, path);
57
+ else await link(temp, path);
58
+ } finally {
59
+ await unlink(temp).catch(() => {
60
+ });
61
+ }
62
+ }
63
+ async function serial(path, action) {
64
+ if (process.platform === "win32") path = path.toLowerCase();
65
+ const before = pending.get(path) ?? Promise.resolve();
66
+ const current = before.catch(() => {
67
+ }).then(action);
68
+ pending.set(path, current);
69
+ try {
70
+ return await current;
71
+ } finally {
72
+ if (pending.get(path) === current) pending.delete(path);
73
+ }
74
+ }
75
+ return {
76
+ async inspect(file, extensions, inspect) {
77
+ const path = await pathFor(file, extensions);
78
+ return serial(path, async () => inspect(await read(path)));
79
+ },
80
+ async create(file, extensions, create) {
81
+ const path = await pathFor(file, extensions);
82
+ return serial(path, async () => {
83
+ await write(path, await create(), false);
84
+ return { filePath: path, saved: true };
85
+ });
86
+ },
87
+ async edit(file, extensions, edit, outputPath) {
88
+ const path = await pathFor(file, extensions);
89
+ const output = outputPath ? await pathFor(outputPath, extensions) : path;
90
+ if (extname(output).toLowerCase() !== extname(path).toLowerCase())
91
+ throw new Error("Save-as must keep the source file extension");
92
+ return serial(path, async () => {
93
+ const { bytes, ...result } = await edit(await read(path));
94
+ await write(output, bytes, output === path);
95
+ return { ...result, filePath: output, saved: true };
96
+ });
97
+ }
98
+ };
99
+ }
100
+
101
+ export { createFileOperations };
@@ -0,0 +1,30 @@
1
+ import type { VisioShape } from '../visio/model.js';
2
+ /** JSON-safe scene inspection without embedding binary images in tool responses. */
3
+ export interface VisioShapeSummary {
4
+ id: string;
5
+ name: string;
6
+ kind: VisioShape['kind'];
7
+ width: number;
8
+ height: number;
9
+ transform: VisioShape['transform'];
10
+ text: string;
11
+ hidden: boolean;
12
+ shapeData: VisioShape['shapeData'];
13
+ hyperlinks: VisioShape['hyperlinks'];
14
+ children: VisioShapeSummary[];
15
+ }
16
+ export declare function inspectVisio(bytes: Uint8Array): Promise<{
17
+ pages: {
18
+ id: string;
19
+ name: string;
20
+ width: number;
21
+ height: number;
22
+ isBackground: boolean;
23
+ backgroundPageId: string | undefined;
24
+ shapes: VisioShapeSummary[];
25
+ connectors: import("../visio/model.js").VisioConnection[];
26
+ layers: import("../visio/model.js").VisioLayer[] | undefined;
27
+ }[];
28
+ diagnostics: import("../visio/model.js").VisioDiagnostic[];
29
+ }>;
30
+ //# sourceMappingURL=visio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visio.d.ts","sourceRoot":"","sources":["../../src/automation/visio.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,oFAAoF;AACpF,MAAM,WAAW,iBAAiB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACnC,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IACrC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAkBD,wBAAsB,YAAY,CAAC,KAAK,EAAE,UAAU;;;;;;;;;;;;;GAgBnD"}
@@ -0,0 +1,25 @@
1
+ export declare function inspectXlsx(bytes: Uint8Array): Promise<{
2
+ sheets: {
3
+ index: number;
4
+ name: string;
5
+ }[];
6
+ properties: import("../xlsx/model.js").WorkbookProperties;
7
+ warnings: string[];
8
+ }>;
9
+ export declare function createXlsx(names: readonly string[]): Promise<Uint8Array>;
10
+ export declare function readXlsxRange(bytes: Uint8Array, sheetIndex: number, reference: string): Promise<{
11
+ cells: {
12
+ address: string;
13
+ value: string | number | boolean | import("../xlsx/model.js").CellError | null;
14
+ formula: string | undefined;
15
+ }[];
16
+ warnings: string[];
17
+ }>;
18
+ export declare function setXlsxCells(bytes: Uint8Array, sheetIndex: number, cells: readonly {
19
+ address: string;
20
+ input: string;
21
+ }[]): Promise<{
22
+ bytes: Uint8Array<ArrayBufferLike>;
23
+ warnings: string[];
24
+ }>;
25
+ //# sourceMappingURL=xlsx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xlsx.d.ts","sourceRoot":"","sources":["../../src/automation/xlsx.ts"],"names":[],"mappings":"AAOA,wBAAsB,WAAW,CAAC,KAAK,EAAE,UAAU;;;;;;;GAOlD;AAED,wBAAsB,UAAU,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAW9E;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;GAoB3F;AAED,wBAAsB,YAAY,CACjC,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE;;;GAgBpD"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * AES-ECB over Web Crypto, which only offers CBC: the ECMA-376 Standard scheme ([MS-OFFCRYPTO]
3
+ * 2.3.4.7-2.3.4.9) encrypts the password verifier and the package with AES in ECB mode.
4
+ *
5
+ * Decryption runs one CBC pass with a zero IV and then undoes the chaining (block i was XORed
6
+ * with ciphertext block i - 1). Encryption encrypts each block on its own (CBC with a zero IV over
7
+ * one block is ECB), in parallel batches.
8
+ */
9
+ /** AES-ECB decryption of block-aligned `data` (a trailing partial block is zero-padded). */
10
+ export declare function aesEcbDecrypt(key: Uint8Array, data: Uint8Array): Promise<Uint8Array>;
11
+ /** AES-ECB encryption of `data`, zero-padded to the block size. */
12
+ export declare function aesEcbEncrypt(key: Uint8Array, data: Uint8Array): Promise<Uint8Array>;
13
+ //# sourceMappingURL=aes-ecb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aes-ecb.d.ts","sourceRoot":"","sources":["../../src/crypto/aes-ecb.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,4FAA4F;AAC5F,wBAAsB,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAM1F;AAED,mEAAmE;AACnE,wBAAsB,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAwB1F"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * OOXML package decryption: password verification and package decryption for the agile
3
+ * (Office 2010+) and Standard (Office 2007) encryption schemes.
4
+ *
5
+ * Moved from `src/pptx/core/utils/ooxml-crypto-decrypt.ts` (see PROVENANCE.md).
6
+ */
7
+ import type { EncryptionInfo, StandardEncryptionInfo } from './types.js';
8
+ /**
9
+ * Verify the password against agile encryption info and return the
10
+ * decryption key if valid.
11
+ *
12
+ * @param info - Parsed agile encryption info.
13
+ * @param password - The password to verify.
14
+ * @returns The document encryption key, or null if the password is wrong.
15
+ */
16
+ export declare function verifyAgilePassword(info: EncryptionInfo, password: string): Promise<Uint8Array | null>;
17
+ /**
18
+ * Verify the password against standard encryption info and return the
19
+ * decryption key if valid.
20
+ *
21
+ * @param info - Parsed standard encryption info.
22
+ * @param password - The password to verify.
23
+ * @returns The encryption key, or null if the password is wrong.
24
+ */
25
+ export declare function verifyStandardPassword(info: StandardEncryptionInfo, password: string): Promise<Uint8Array | null>;
26
+ /**
27
+ * Verify the data integrity HMAC of an agile-encrypted package.
28
+ *
29
+ * [MS-OFFCRYPTO] 2.3.7.1 -- The data integrity is verified by:
30
+ * 1. Decrypting the HMAC key from dataIntegrity.encryptedHmacKey
31
+ * 2. Decrypting the HMAC value from dataIntegrity.encryptedHmacValue
32
+ * 3. Computing HMAC of the encrypted package data (after the 8-byte size prefix)
33
+ * 4. Comparing the computed HMAC with the decrypted HMAC value
34
+ *
35
+ * @param info - Parsed agile encryption info.
36
+ * @param key - The document encryption key.
37
+ * @param encryptedPackage - Raw bytes of the EncryptedPackage stream.
38
+ * @throws DataIntegrityError if the data integrity check fails.
39
+ */
40
+ export declare function verifyAgileDataIntegrity(info: EncryptionInfo, key: Uint8Array, encryptedPackage: Uint8Array): Promise<void>;
41
+ /**
42
+ * Decrypt the EncryptedPackage stream using the agile encryption key.
43
+ *
44
+ * The encrypted package uses segment-based encryption:
45
+ * each 4096-byte segment is encrypted separately with a unique IV.
46
+ *
47
+ * @param encryptedPackage - Raw bytes of the EncryptedPackage stream.
48
+ * @param key - The document encryption key.
49
+ * @param info - Parsed agile encryption info.
50
+ * @returns The decrypted package as an ArrayBuffer.
51
+ */
52
+ export declare function decryptAgilePackage(encryptedPackage: Uint8Array, key: Uint8Array, info: EncryptionInfo): Promise<ArrayBuffer>;
53
+ /**
54
+ * Decrypt the EncryptedPackage stream using standard encryption key.
55
+ *
56
+ * Standard encryption uses AES-ECB over the whole package ([MS-OFFCRYPTO] 2.3.4.15).
57
+ *
58
+ * @param encryptedPackage - Raw bytes of the EncryptedPackage stream.
59
+ * @param key - The encryption key.
60
+ * @returns The decrypted package as an ArrayBuffer.
61
+ */
62
+ export declare function decryptStandardPackage(encryptedPackage: Uint8Array, key: Uint8Array): Promise<ArrayBuffer>;
63
+ //# sourceMappingURL=decrypt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decrypt.d.ts","sourceRoot":"","sources":["../../src/crypto/decrypt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAMzE;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACxC,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAgC5B;AAMD;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC3C,IAAI,EAAE,sBAAsB,EAC5B,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA6B5B;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,wBAAwB,CAC7C,IAAI,EAAE,cAAc,EACpB,GAAG,EAAE,UAAU,EACf,gBAAgB,EAAE,UAAU,GAC1B,OAAO,CAAC,IAAI,CAAC,CA0Df;AAMD;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACxC,gBAAgB,EAAE,UAAU,EAC5B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,cAAc,GAClB,OAAO,CAAC,WAAW,CAAC,CAqCtB;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC3C,gBAAgB,EAAE,UAAU,EAC5B,GAAG,EAAE,UAAU,GACb,OAAO,CAAC,WAAW,CAAC,CAatB"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Recognises an encrypted OOXML package: a compound file (CFB, magic D0 CF 11 E0 A1 B1 1A E1)
3
+ * holding `EncryptionInfo` and `EncryptedPackage` streams, as opposed to a plain OOXML zip or a
4
+ * legacy binary document (.xls, .doc, .ppt), which is a compound file too.
5
+ *
6
+ * Moved from `src/pptx/core/utils/encryption-detection.ts` (see PROVENANCE.md);
7
+ * {@link isEncryptedOoxmlPackage} and {@link openEncryptedPackage} are new.
8
+ */
9
+ /** Bytes as a Uint8Array (no copy). */
10
+ export declare const toBytes: (input: Uint8Array | ArrayBuffer) => Uint8Array;
11
+ /** An ArrayBuffer holding exactly `bytes` (copied only when it is a view of a larger buffer). */
12
+ export declare function toArrayBuffer(bytes: Uint8Array): ArrayBuffer;
13
+ /** Whether the bytes start with the compound-file magic. */
14
+ export declare function isCompoundFile(input: Uint8Array | ArrayBuffer): boolean;
15
+ /** The two streams of an encrypted package. */
16
+ export interface EncryptedPackageStreams {
17
+ encryptionInfo: Uint8Array;
18
+ encryptedPackage: Uint8Array;
19
+ }
20
+ /**
21
+ * The `EncryptionInfo` and `EncryptedPackage` streams of an encrypted OOXML package, or
22
+ * `undefined` when the bytes are not a compound file or lack either stream (a legacy binary
23
+ * document). Never throws.
24
+ */
25
+ export declare function openEncryptedPackage(input: Uint8Array | ArrayBuffer): EncryptedPackageStreams | undefined;
26
+ /**
27
+ * Whether the bytes are an encrypted OOXML package (.xlsx, .docx, .pptx and their macro and
28
+ * template variants saved with a password to open). A legacy .xls/.doc/.ppt is `false`.
29
+ */
30
+ export declare function isEncryptedOoxmlPackage(input: Uint8Array | ArrayBuffer): boolean;
31
+ /** A coarse container sniff: zip, compound file (possibly an encrypted package) or unknown. */
32
+ export type FileFormatDetection = {
33
+ format: 'zip';
34
+ encrypted: false;
35
+ } | {
36
+ format: 'ole';
37
+ encrypted: true;
38
+ } | {
39
+ format: 'unknown';
40
+ encrypted: false;
41
+ };
42
+ /**
43
+ * Detect the container format from the magic bytes. A compound file is reported as
44
+ * `encrypted` without opening it (use {@link isEncryptedOoxmlPackage} to tell an encrypted
45
+ * package from a legacy binary document). Must be called before parsing as a zip.
46
+ */
47
+ export declare function detectFileFormat(data: ArrayBuffer | Uint8Array): FileFormatDetection;
48
+ /**
49
+ * Thrown when an encrypted file is detected where a plain package was expected. Callers can
50
+ * check `isEncrypted` (or `instanceof`) to tell it from generic parse failures.
51
+ */
52
+ export declare class EncryptedFileError extends Error {
53
+ readonly isEncrypted = true;
54
+ constructor(message: string);
55
+ }
56
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../src/crypto/detect.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,uCAAuC;AACvC,eAAO,MAAM,OAAO,GAAI,OAAO,UAAU,GAAG,WAAW,KAAG,UACE,CAAC;AAE7D,iGAAiG;AACjG,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAK5D;AAED,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,OAAO,CAGvE;AAED,+CAA+C;AAC/C,MAAM,WAAW,uBAAuB;IACvC,cAAc,EAAE,UAAU,CAAC;IAC3B,gBAAgB,EAAE,UAAU,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,UAAU,GAAG,WAAW,GAC7B,uBAAuB,GAAG,SAAS,CAarC;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,OAAO,CAShF;AAED,+FAA+F;AAC/F,MAAM,MAAM,mBAAmB,GAC5B;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,KAAK,CAAA;CAAE,GACnC;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,IAAI,CAAA;CAAE,GAClC;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,KAAK,CAAA;CAAE,CAAC;AAE3C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,mBAAmB,CAMpF;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC5C,SAAgB,WAAW,QAAQ;gBAEhB,OAAO,EAAE,MAAM;CAIlC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * OOXML package encryption: the agile scheme (Office 2010+, the default) and the ECMA-376
3
+ * Standard scheme (Office 2007), each producing a compound file with `EncryptionInfo` and
4
+ * `EncryptedPackage` streams.
5
+ *
6
+ * Moved from `src/pptx/core/utils/ooxml-crypto-encrypt.ts` and the agile half of
7
+ * `ooxml-crypto.ts` (see PROVENANCE.md).
8
+ */
9
+ import type { EncryptionInfo, EncryptionOptions } from './types.js';
10
+ /**
11
+ * Encrypt a package with the agile scheme: each 4096-byte segment is encrypted separately with
12
+ * an IV derived from the segment index. Returns the bytes with the 8-byte size prefix.
13
+ */
14
+ export declare function encryptAgilePackage(packageData: Uint8Array, key: Uint8Array, info: EncryptionInfo): Promise<Uint8Array>;
15
+ /**
16
+ * Encrypt a package with the ECMA-376 Standard scheme: AES-ECB under the password-derived key
17
+ * ([MS-OFFCRYPTO] 2.3.4.15). Returns the bytes with the 8-byte size prefix.
18
+ */
19
+ export declare function encryptStandardPackage(packageData: Uint8Array, key: Uint8Array): Promise<Uint8Array>;
20
+ /** The agile scheme (AES-CBC, SHA-512, 100,000 spins by default) as a compound file. */
21
+ export declare function encryptAgile(packageData: Uint8Array, password: string, options?: EncryptionOptions): Promise<Uint8Array>;
22
+ /**
23
+ * The ECMA-376 Standard scheme (Office 2007-compatible) as a compound file. There is no
24
+ * separate document key: the password-derived key encrypts the whole package (AES-ECB).
25
+ */
26
+ export declare function encryptStandard(packageData: Uint8Array, password: string, options?: EncryptionOptions): Promise<Uint8Array>;
27
+ //# sourceMappingURL=encrypt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encrypt.d.ts","sourceRoot":"","sources":["../../src/crypto/encrypt.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAwBH,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAoCpE;;;GAGG;AACH,wBAAsB,mBAAmB,CACxC,WAAW,EAAE,UAAU,EACvB,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,cAAc,GAClB,OAAO,CAAC,UAAU,CAAC,CAerB;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAC3C,WAAW,EAAE,UAAU,EACvB,GAAG,EAAE,UAAU,GACb,OAAO,CAAC,UAAU,CAAC,CAGrB;AAED,wFAAwF;AACxF,wBAAsB,YAAY,CACjC,WAAW,EAAE,UAAU,EACvB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,UAAU,CAAC,CAgErB;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACpC,WAAW,EAAE,UAAU,EACvB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,UAAU,CAAC,CAgBrB"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * EncryptionInfo stream writers for the agile ([MS-OFFCRYPTO] 2.3.4.10) and Standard (2.3.4.5)
3
+ * schemes.
4
+ *
5
+ * Moved from `src/pptx/core/utils/ooxml-crypto-encrypt.ts` (see PROVENANCE.md).
6
+ */
7
+ import type { EncryptionInfo } from './types.js';
8
+ /**
9
+ * Generate EncryptionInfo XML for agile encryption.
10
+ *
11
+ * Builds the XML document that describes the encryption parameters,
12
+ * key data, data integrity values, and password key encryptor.
13
+ *
14
+ * @param keyData - Key data parameters.
15
+ * @param pke - Password key encryptor parameters.
16
+ * @param dataIntegrity - Data integrity HMAC values.
17
+ * @returns Serialized XML string.
18
+ */
19
+ export declare function buildAgileEncryptionInfoXml(keyData: EncryptionInfo['keyData'], pke: EncryptionInfo['passwordKeyEncryptor'], dataIntegrity: NonNullable<EncryptionInfo['dataIntegrity']>): string;
20
+ /**
21
+ * Build the EncryptionInfo stream bytes for agile encryption.
22
+ *
23
+ * Prepends the 8-byte header (version 4.4 + reserved flag) to the
24
+ * XML content.
25
+ *
26
+ * @param xmlString - The agile encryption info XML string.
27
+ * @returns Raw bytes of the EncryptionInfo stream.
28
+ */
29
+ export declare function buildEncryptionInfoStream(xmlString: string): Uint8Array;
30
+ /** AlgIDHash value for SHA-1, the only hash the Standard scheme uses. */
31
+ export declare const STANDARD_ALG_ID_HASH_SHA1 = 32772;
32
+ /**
33
+ * Build the binary EncryptionInfo stream for the ECMA-376 Standard scheme.
34
+ *
35
+ * Layout per [MS-OFFCRYPTO] 2.3.4.5-2.3.4.7: version + flags + header size,
36
+ * followed by the EncryptionHeader (algorithm/provider) and the
37
+ * EncryptionVerifier (salt + encrypted verifier + encrypted verifier hash).
38
+ *
39
+ * @param keyBits - Key size in bits (128, 192, or 256).
40
+ * @param salt - 16-byte verifier salt.
41
+ * @param encryptedVerifier - 16-byte AES-CBC encrypted random verifier.
42
+ * @param encryptedVerifierHash - 32-byte AES-CBC encrypted (padded) SHA-1 hash of the verifier.
43
+ * @returns Raw bytes of the EncryptionInfo stream.
44
+ */
45
+ export declare function buildStandardEncryptionInfoStream(keyBits: number, salt: Uint8Array, encryptedVerifier: Uint8Array, encryptedVerifierHash: Uint8Array): Uint8Array;
46
+ //# sourceMappingURL=encryption-info-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryption-info-write.d.ts","sourceRoot":"","sources":["../../src/crypto/encryption-info-write.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAC1C,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,EAClC,GAAG,EAAE,cAAc,CAAC,sBAAsB,CAAC,EAC3C,aAAa,EAAE,WAAW,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,GACzD,MAAM,CAoCR;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAavE;AASD,yEAAyE;AACzE,eAAO,MAAM,yBAAyB,QAAa,CAAC;AAWpD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iCAAiC,CAChD,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,UAAU,EAChB,iBAAiB,EAAE,UAAU,EAC7B,qBAAqB,EAAE,UAAU,GAC/B,UAAU,CAgDZ"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * EncryptionInfo stream parsing ([MS-OFFCRYPTO] 2.3.4.5 Standard, 2.3.4.10 agile).
3
+ *
4
+ * Moved from `src/pptx/core/utils/ooxml-crypto-key-derivation.ts` (see PROVENANCE.md).
5
+ */
6
+ import type { EncryptionInfo, StandardEncryptionInfo } from './types.js';
7
+ /**
8
+ * Algorithm ID for RC4 in the [MS-OFFCRYPTO] EncryptionHeader `algId` field.
9
+ *
10
+ * RC4 is a stream cipher, so its encrypted verifier hash is stored at exactly
11
+ * `verifierHashSize` bytes with no block-alignment padding, unlike AES (a block cipher, padded
12
+ * up to a 16-byte boundary).
13
+ */
14
+ export declare const RC4_ALG_ID = 26625;
15
+ /**
16
+ * Parse the EncryptionInfo stream of an encrypted OOXML file: agile (version 4.4) or Standard
17
+ * (versions 2.2, 3.2 and 4.2).
18
+ *
19
+ * @throws Error if the encryption version is unsupported.
20
+ */
21
+ export declare function parseEncryptionInfo(data: Uint8Array): EncryptionInfo | StandardEncryptionInfo;
22
+ //# sourceMappingURL=encryption-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryption-info.d.ts","sourceRoot":"","sources":["../../src/crypto/encryption-info.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,QAAS,CAAC;AAEjC;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,GAAG,sBAAsB,CAa7F"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Errors of OOXML package encryption. Each carries a stable `code`: every subpath bundle
3
+ * (`ooxml-core/crypto`, `/xlsx/load`, `/docx/load`, `/pptx`) inlines its own copy of these
4
+ * classes, so a UI should test `error.code` (or `name`) rather than `instanceof` across entries.
5
+ *
6
+ * Moved from `src/pptx/core/utils/ooxml-crypto-errors.ts` (see PROVENANCE.md); `code` and
7
+ * {@link PasswordRequiredError} are new.
8
+ */
9
+ /** The stable codes of the package encryption errors. */
10
+ export type OoxmlCryptoErrorCode = 'password-required' | 'incorrect-password' | 'data-integrity';
11
+ /**
12
+ * The file is an encrypted OOXML package (a compound file holding `EncryptionInfo` and
13
+ * `EncryptedPackage`) and no password was supplied.
14
+ */
15
+ export declare class PasswordRequiredError extends Error {
16
+ readonly code: "password-required";
17
+ constructor(message?: string);
18
+ }
19
+ /**
20
+ * The supplied password did not match the password verifier stored in the encrypted file's
21
+ * EncryptionInfo stream.
22
+ */
23
+ export declare class IncorrectPasswordError extends Error {
24
+ readonly code: "incorrect-password";
25
+ constructor(message?: string);
26
+ }
27
+ /**
28
+ * The HMAC computed over the encrypted package did not match the one stored in the
29
+ * EncryptionInfo stream: the file may be corrupted or tampered with.
30
+ */
31
+ export declare class DataIntegrityError extends Error {
32
+ readonly code: "data-integrity";
33
+ constructor(message?: string);
34
+ }
35
+ /** Whether `error` is one of the package encryption errors (by `code`, across bundles). */
36
+ export declare function isOoxmlCryptoError(error: unknown): error is Error & {
37
+ readonly code: OoxmlCryptoErrorCode;
38
+ };
39
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/crypto/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,yDAAyD;AACzD,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG,oBAAoB,GAAG,gBAAgB,CAAC;AAEjG;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC/C,SAAgB,IAAI,EAAG,mBAAmB,CAAU;gBAEjC,OAAO,SAAoE;CAI9F;AAED;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAChD,SAAgB,IAAI,EAAG,oBAAoB,CAAU;gBAElC,OAAO,SAA+B;CAIzD;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC5C,SAAgB,IAAI,EAAG,gBAAgB,CAAU;gBAGhD,OAAO,SAAuF;CAK/F;AAED,2FAA2F;AAC3F,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,OAAO,GACZ,KAAK,IAAI,KAAK,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAA;CAAE,CAI1D"}