@poe-platform/safe-bash 0.1.811 → 0.1.813
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.
- package/dist/audio-ast/id3-source.d.ts +27 -0
- package/dist/audio-ast/index.d.ts +5 -0
- package/dist/audio-ast/index.js +1001 -596
- package/dist/audio-ast/mp3-source.d.ts +18 -0
- package/dist/audio-ast/ogg-source.d.ts +25 -0
- package/dist/audio-ast/ogg-stream-source.d.ts +22 -0
- package/dist/audio-ast/vorbis.d.ts +14 -0
- package/dist/image-ast/index.js +139 -9
- package/dist/mp4-ast/containers/adapters.d.ts +7 -0
- package/dist/office-xml/retained-xml-document.d.ts +8 -0
- package/dist/pdf-ast/ast.d.ts +2 -0
- package/dist/pdf-ast/content/dictionary-cursor.d.ts +15 -0
- package/dist/pdf-ast/content/range-operator-parser.d.ts +4 -0
- package/dist/pdf-ast/content/stored-dictionary.d.ts +10 -0
- package/dist/pdf-ast/cos/lexer.d.ts +8 -5
- package/dist/pdf-ast/cos/object-reader.d.ts +4 -3
- package/dist/pdf-ast/cos/range-parser.d.ts +4 -0
- package/dist/pdf-ast/cos/retained-objects.d.ts +1 -0
- package/dist/pdf-ast/cos/retained-writer.d.ts +1 -0
- package/dist/pdf-ast/cos/value-parser.d.ts +32 -2
- package/dist/pdf-ast/edit/retained-append-attachments.d.ts +13 -0
- package/dist/pdf-ast/edit/retained-bookmarks.d.ts +13 -0
- package/dist/pdf-ast/edit/retained-graph.d.ts +6 -0
- package/dist/pdf-ast/edit/retained-save.d.ts +2 -0
- package/dist/pdf-ast/edit/retained-stamps.d.ts +9 -0
- package/dist/pdf-ast/extract/retained-form-field-details.d.ts +20 -0
- package/dist/pdf-ast/extract/retained-form-fields.d.ts +17 -4
- package/dist/pdf-ast/fonts/resolve.d.ts +3 -1
- package/dist/pdf-ast/index.d.ts +4 -1
- package/dist/pdf-ast/index.js +2127 -975
- package/dist/pdf-ast/retained-document.d.ts +4 -0
- package/dist/safe-bash/audio-ast.browser.js +7 -1
- package/dist/safe-bash/chunks/{chunk-HHSOUC3Z.js → chunk-HPQE675Q.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-BUYRKFW2.js → chunk-I6ECNJMR.js} +1 -1
- package/dist/safe-bash/chunks/{pdftk-WRYEP3CA.js → pdftk-Y2TX74LY.js} +2 -1
- package/dist/safe-bash/command-chunks/biff-4ALVARRF-7SRX6R6N.js +5192 -0
- package/dist/safe-bash/command-chunks/{chunk-EHSM5ZQS.js → chunk-2DGJOOXM.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-Q6S57NOQ.js → chunk-2E2H7MBH.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-MMBZTYXO.js → chunk-2PQRZDNR.js} +221 -0
- package/dist/safe-bash/command-chunks/{chunk-5OO2P27R.js → chunk-2V6FOLXV.js} +78 -25
- package/dist/safe-bash/command-chunks/{chunk-56NYSX65.js → chunk-2Z3WRRFT.js} +9 -9
- package/dist/safe-bash/command-chunks/chunk-3D24WDND.js +63 -0
- package/dist/safe-bash/command-chunks/{chunk-47NEG4UO.js → chunk-3JST2Q7G.js} +219 -43
- package/dist/safe-bash/command-chunks/{chunk-WGG6G2KG.js → chunk-3LJAXFH5.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-AHA6IWAJ.js → chunk-3TYDSGAH.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-YSMNXMAO.js → chunk-3Y4XZB24.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-ZIIO6GRY.js → chunk-4PBNMKAT.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-JFYWVQ4V.js → chunk-4Z6W5EOC.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-GEM47B2P.js → chunk-57DDYKE5.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-HARUYHH7.js → chunk-5HUICAWD.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4CKFNXRN.js → chunk-5IFRAI7Y.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-RHYJVTJO.js → chunk-5KGEZ3RW.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-A5FZBR7X.js → chunk-5MFDRSGG.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-7GKKMNL6.js → chunk-5P6I2T63.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-6M6TM5Z5.js → chunk-5VQVZPP3.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-MIRL7HTF.js → chunk-6244HYJY.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-63EMPQ7Z.js +115 -0
- package/dist/safe-bash/command-chunks/{chunk-XRVKWGVQ.js → chunk-6CY5BHBS.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-XVP6V5K3.js → chunk-6IWE7PTK.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-6QBMND4A.js → chunk-6SRHWVEB.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-6ZHQB453.js +35 -0
- package/dist/safe-bash/command-chunks/chunk-73NYFNAS.js +173 -0
- package/dist/safe-bash/command-chunks/{chunk-VU3EQF7F.js → chunk-7NXTEWPR.js} +229 -75
- package/dist/safe-bash/command-chunks/{chunk-554Z6IKP.js → chunk-7PRL6RJ6.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-SDTPO2VV.js → chunk-7PZHWMK6.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-XZ2FWFNV.js → chunk-7QZ2HP2F.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-OEJM666F.js → chunk-7UC2Q6Z6.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-COKYZUBW.js → chunk-AJI55RS7.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-2VCKUNDZ.js → chunk-B2C3UPJS.js} +27 -17
- package/dist/safe-bash/command-chunks/{chunk-WXRYDALR.js → chunk-BBAB7LC4.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-QYMEASQ6.js → chunk-BEHUSUOY.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-Z2JW6M2D.js → chunk-BK7ISUJL.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-33YCKZZX.js → chunk-C5KLFZGT.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-TVH4JORU.js → chunk-C5QDEB3I.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-N4R2SHSS.js → chunk-CCZZVCHX.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-2VLAXKTS.js → chunk-CTDC4LJT.js} +121 -85
- package/dist/safe-bash/command-chunks/{chunk-S6R3IB36.js → chunk-D55REQA3.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-Y4EYCZFT.js → chunk-D6WJY6QO.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-2CORNDGF.js → chunk-DBLHCJJU.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-SPW4GW4Z.js → chunk-DFI7QF3M.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-456PHA3L.js → chunk-DMCI6T6N.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-TW73OXPR.js → chunk-EJTNVXWF.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-QD7ZRDUN.js → chunk-ET2VPDUA.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-5LI2DLNZ.js → chunk-EXOQGXEU.js} +26 -26
- package/dist/safe-bash/command-chunks/{chunk-CRV2Q3PB.js → chunk-EZ4NQIPL.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-FWKLBDMK.js +0 -0
- package/dist/safe-bash/command-chunks/{chunk-22MOB45U.js → chunk-FWPVQGYK.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-QC5RMGSA.js → chunk-G3RUXKVY.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-JYUJAF4L.js → chunk-G7NENPYV.js} +4 -0
- package/dist/safe-bash/command-chunks/{chunk-KCOJA7EM.js → chunk-GKILM4HZ.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-HTVIYLVB.js → chunk-GNXTMSYN.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-D2ASPM7R.js → chunk-GOBUDKZ3.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-RNSKXOG3.js → chunk-GVWVRPG6.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-ZHRGYR7B.js → chunk-HCKYUQ3L.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-AGLK7OJR.js → chunk-HDSIIQBS.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-DM2CPMB4.js → chunk-HKOMXGJS.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-IT7TAC3F.js → chunk-HVW53ARH.js} +16 -16
- package/dist/safe-bash/command-chunks/{chunk-M7QE2MN7.js → chunk-I4GMCWAT.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-5MB64DWR.js → chunk-IHSOOSNC.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-LCZDBW55.js → chunk-JAHJWVGF.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-MOZD7RUY.js → chunk-JORIVUPM.js} +27 -11
- package/dist/safe-bash/command-chunks/{chunk-PMAM4N33.js → chunk-JUJHYPYL.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-ENT3IV2G.js → chunk-KBUBSMCQ.js} +12 -12
- package/dist/safe-bash/command-chunks/{chunk-ZXR6LXV5.js → chunk-KCE5D4Z4.js} +48 -4
- package/dist/safe-bash/command-chunks/{chunk-FIIAYCWS.js → chunk-KZ5ODST6.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-PNGDJA6M.js → chunk-LD7BONZY.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-KJ4XXZIL.js → chunk-M3Z5PU2M.js} +582 -59
- package/dist/safe-bash/command-chunks/{chunk-LXLLA4PM.js → chunk-MKX4JAZ6.js} +17 -17
- package/dist/safe-bash/command-chunks/{chunk-RQIQ75W5.js → chunk-MNHBQBF6.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-A2CLZMQZ.js → chunk-MPKY37QR.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-K5GB2YMN.js → chunk-MUUWBZIC.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-JOCFI7TG.js → chunk-N32GSM3J.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-EUT24Y5Z.js → chunk-NKTULXVD.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-5HPU7D36.js → chunk-NMPED6L5.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-QZZ73J2O.js → chunk-NPFHUS4X.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-X7FA7ZD5.js → chunk-O675URF4.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-R6EGGK5M.js → chunk-P7EL2FWW.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-YS25EI54.js → chunk-PCCFLPUQ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-RRL3Y562.js → chunk-PI6MOMHA.js} +11 -11
- package/dist/safe-bash/command-chunks/{chunk-26VCZHLJ.js → chunk-PIOQBOEK.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-PK36TVXB.js +175 -0
- package/dist/safe-bash/command-chunks/{chunk-72C3TZ2U.js → chunk-PKLJRB7W.js} +264 -129
- package/dist/safe-bash/command-chunks/{chunk-6CCQI6XZ.js → chunk-PSCOXGCA.js} +12 -12
- package/dist/safe-bash/command-chunks/{chunk-XPD636C4.js → chunk-PVGZMLC6.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-JQVHUSDD.js → chunk-PXWS3Q7L.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-HDJVJTCK.js → chunk-QFF5KBOM.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-MPUHH2KR.js → chunk-QM2HZJSJ.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-UAXSE3XE.js → chunk-R2BMZAHG.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-KB7DUBVL.js → chunk-RGOQKIG6.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-D2KZ66W4.js → chunk-RLCQ7BN3.js} +187 -39
- package/dist/safe-bash/command-chunks/{chunk-B5LDP7AA.js → chunk-S2N2V5U4.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-OA75SGN2.js → chunk-SGPCXAG7.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-Z5QOVRVH.js → chunk-SU26FZLJ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-QUM3SYAJ.js → chunk-SYSX46IV.js} +3 -3
- package/dist/safe-bash/command-chunks/chunk-T3E5RV3U.js +737 -0
- package/dist/safe-bash/command-chunks/{chunk-YORJDX4V.js → chunk-T5ERNELL.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-KL3OIBKB.js → chunk-T6C5QP7T.js} +6495 -6343
- package/dist/safe-bash/command-chunks/{chunk-ATTWQVR2.js → chunk-TKRLZIFI.js} +17 -17
- package/dist/safe-bash/command-chunks/{chunk-ZMHEGDU2.js → chunk-TODWFDYB.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-YSY6R6AS.js → chunk-TQEB4DH4.js} +703 -102
- package/dist/safe-bash/command-chunks/{chunk-36XGIPOG.js → chunk-U5TWQFZY.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-APEWTWCC.js → chunk-UAF4IX5H.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-6VPQ3CDZ.js → chunk-V37D6AHO.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-RID6VYS3.js → chunk-V6XBEYPC.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-WJCN2IXI.js → chunk-VQOINPVF.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-W5YSINXC.js → chunk-VVWXY6IA.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-HKATEVAP.js → chunk-WPVBUVFK.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-UYWSIIUX.js → chunk-X53AEG36.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-L5MCW6CM.js → chunk-X64XGIXZ.js} +9 -155
- package/dist/safe-bash/command-chunks/{chunk-Q73EMLLZ.js → chunk-X6RHJ6YN.js} +84 -5
- package/dist/safe-bash/command-chunks/{chunk-7PVHO47B.js → chunk-XG6UWQV5.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-NQDIT667.js → chunk-XIDGHIGB.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-DPR5CYQV.js → chunk-XITDDJFT.js} +2 -0
- package/dist/safe-bash/command-chunks/{chunk-CV7M2QJU.js → chunk-XLYIVBAR.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-WVMHRNXZ.js → chunk-YUXTK3XA.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-SPLOIABU.js → chunk-YXD6VGVG.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-2ZFLMWOX.js → chunk-Z5BIM5B7.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-ZYLGNIGA.js +156 -0
- package/dist/safe-bash/command-chunks/{command-engine-BEWABZ75.js → command-engine-X3OLN7N6.js} +206 -86
- package/dist/safe-bash/command-chunks/{engine-AXXFTGCL-QBQNBI6K.js → engine-XUCIFZ7V-LJFGZM6O.js} +1 -1
- package/dist/safe-bash/command-chunks/paradox-4FCZE53D-LQPGVMEL.js +365 -0
- package/dist/safe-bash/commands/pandoc/index.browser.js +1 -1
- package/dist/safe-bash/full-core.browser.js +2 -2
- package/dist/safe-bash/plugins/index.browser.js +2 -2
- package/dist/safe-bash-command-apply-patch/apply.js +4 -4
- package/dist/safe-bash-command-apply-patch/index.js +4 -4
- package/dist/safe-bash-command-apply-patch/matcher.js +2 -2
- package/dist/safe-bash-command-apply-patch/parser.js +2 -2
- package/dist/safe-bash-command-apply-patch/shared.d.ts +2 -0
- package/dist/safe-bash-command-apply-patch/shared.js +1 -1
- package/dist/safe-bash-command-diff/diff.js +1 -1
- package/dist/safe-bash-command-diff/index.js +1 -1
- package/dist/safe-bash-command-ffmpeg/index.js +1 -1
- package/dist/safe-bash-command-ffprobe/index.js +2 -2
- package/dist/safe-bash-command-ffprobe/media.d.ts +3 -1
- package/dist/safe-bash-command-ffprobe/media.js +2 -2
- package/dist/safe-bash-command-html-to-markdown/budget.js +2 -1
- package/dist/safe-bash-command-html-to-markdown/entities.js +4 -3
- package/dist/safe-bash-command-html-to-markdown/index.js +564 -110
- package/dist/safe-bash-command-html-to-markdown/input.js +6 -5
- package/dist/safe-bash-command-html-to-markdown/options.js +2 -1
- package/dist/safe-bash-command-html-to-markdown/parser.js +5 -4
- package/dist/safe-bash-command-html-to-markdown/render.js +6 -5
- package/dist/safe-bash-command-html-to-markdown/text.js +3 -2
- package/dist/safe-bash-command-htmlq/index.js +361 -37
- package/dist/safe-bash-command-htmlq/tree.d.ts +3 -2
- package/dist/safe-bash-command-pandoc/command.js +7 -7
- package/dist/safe-bash-command-pandoc/index.js +55 -55
- package/dist/safe-bash-command-patch/index.js +6 -6
- package/dist/safe-bash-command-patch/patch-envelope.js +53 -3
- package/dist/safe-bash-command-patch/patch-formats.d.ts +2 -2
- package/dist/safe-bash-command-patch/patch-formats.js +2 -2
- package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +2 -1
- package/dist/safe-bash-command-patch/patch-gnu-reject.js +4 -3
- package/dist/safe-bash-command-patch/patch-publication.js +2 -1
- package/dist/safe-bash-command-patch/patch.js +6 -6
- package/dist/safe-bash-command-patch/unified.d.ts +10 -2
- package/dist/safe-bash-command-patch/unified.js +1 -1
- package/dist/safe-bash-command-pdftk/index.d.ts +6 -2
- package/dist/safe-bash-command-pdftk/index.js +835 -243
- package/dist/safe-bash-command-pptx/command-engine.d.ts +15 -3
- package/dist/safe-bash-command-pptx/engine.d.ts +2 -2
- package/dist/safe-bash-command-pptx/engine.js +1 -1
- package/dist/safe-bash-command-pptx/index.js +9 -2
- package/dist/safe-bash-command-soffice/index.js +1 -1
- package/dist/safe-bash-command-ssconvert/index.js +2 -2
- package/dist/safe-bash-command-xmllint/index.js +22 -31
- package/dist/safe-bash-diff-engine/document.d.ts +2 -1
- package/dist/safe-bash-diff-engine/document.js +7 -4
- package/dist/safe-bash-presentation-engine/accessibility.js +31 -30
- package/dist/safe-bash-presentation-engine/animation-editing.js +16 -15
- package/dist/safe-bash-presentation-engine/animations.js +16 -15
- package/dist/safe-bash-presentation-engine/backgrounds.js +17 -16
- package/dist/safe-bash-presentation-engine/bytes.js +3 -3
- package/dist/safe-bash-presentation-engine/chart-editing.js +34 -33
- package/dist/safe-bash-presentation-engine/chart-object-operations.js +25 -24
- package/dist/safe-bash-presentation-engine/charts.js +31 -30
- package/dist/safe-bash-presentation-engine/command-placeholder.js +59 -55
- package/dist/safe-bash-presentation-engine/comments.js +17 -16
- package/dist/safe-bash-presentation-engine/connector-operations.js +32 -31
- package/dist/safe-bash-presentation-engine/connectors.js +29 -28
- package/dist/safe-bash-presentation-engine/content-types.js +4 -4
- package/dist/safe-bash-presentation-engine/creation.js +6 -6
- package/dist/safe-bash-presentation-engine/diff.js +32 -31
- package/dist/safe-bash-presentation-engine/drawing-enums.d.ts +10 -10
- package/dist/safe-bash-presentation-engine/drawing-format.js +20 -19
- package/dist/safe-bash-presentation-engine/drawing-operations.js +31 -30
- package/dist/safe-bash-presentation-engine/drawing-schema.js +21 -20
- package/dist/safe-bash-presentation-engine/equations.js +17 -16
- package/dist/safe-bash-presentation-engine/errors.js +2 -2
- package/dist/safe-bash-presentation-engine/fields.js +17 -16
- package/dist/safe-bash-presentation-engine/font-metrics.js +3 -3
- package/dist/safe-bash-presentation-engine/image-extraction.js +20 -19
- package/dist/safe-bash-presentation-engine/image-formatting.js +32 -31
- package/dist/safe-bash-presentation-engine/image-insertion.js +18 -17
- package/dist/safe-bash-presentation-engine/image-replacement.js +21 -20
- package/dist/safe-bash-presentation-engine/image-value.js +4 -4
- package/dist/safe-bash-presentation-engine/images.js +19 -18
- package/dist/safe-bash-presentation-engine/index.d.ts +6 -2
- package/dist/safe-bash-presentation-engine/index.js +112 -97
- package/dist/safe-bash-presentation-engine/layouts.js +16 -15
- package/dist/safe-bash-presentation-engine/length.js +3 -3
- package/dist/safe-bash-presentation-engine/links.js +16 -15
- package/dist/safe-bash-presentation-engine/masters.js +15 -14
- package/dist/safe-bash-presentation-engine/media-editing.js +24 -23
- package/dist/safe-bash-presentation-engine/media-extraction.js +17 -16
- package/dist/safe-bash-presentation-engine/media.js +16 -15
- package/dist/safe-bash-presentation-engine/memberships.js +15 -14
- package/dist/safe-bash-presentation-engine/notes.js +16 -15
- package/dist/safe-bash-presentation-engine/ole-enum.js +4 -4
- package/dist/safe-bash-presentation-engine/ole-insertion.js +20 -19
- package/dist/safe-bash-presentation-engine/opaque-objects.js +9 -9
- package/dist/safe-bash-presentation-engine/package-reader.js +5 -5
- package/dist/safe-bash-presentation-engine/package-tools.d.ts +3 -0
- package/dist/safe-bash-presentation-engine/package-tools.js +27 -17
- package/dist/safe-bash-presentation-engine/package-uri.js +3 -3
- package/dist/safe-bash-presentation-engine/package-writer.js +4 -4
- package/dist/safe-bash-presentation-engine/presentation-model.js +58 -54
- package/dist/safe-bash-presentation-engine/presentation-settings.js +14 -13
- package/dist/safe-bash-presentation-engine/properties.js +16 -15
- package/dist/safe-bash-presentation-engine/relationships.js +4 -4
- package/dist/safe-bash-presentation-engine/resource-limits.js +1 -1
- package/dist/safe-bash-presentation-engine/retained-archive-staging.d.ts +19 -0
- package/dist/safe-bash-presentation-engine/retained-extraction-output.d.ts +18 -0
- package/dist/safe-bash-presentation-engine/retained-inspection.js +14 -12
- package/dist/safe-bash-presentation-engine/retained-package-extraction.d.ts +22 -0
- package/dist/safe-bash-presentation-engine/retained-package-packing.d.ts +19 -0
- package/dist/safe-bash-presentation-engine/retained-package.d.ts +2 -0
- package/dist/safe-bash-presentation-engine/retained-package.js +6 -4
- package/dist/safe-bash-presentation-engine/retained-slide-publication.d.ts +24 -0
- package/dist/safe-bash-presentation-engine/retained-text.js +19 -17
- package/dist/safe-bash-presentation-engine/retained-xml-parts.d.ts +5 -1
- package/dist/safe-bash-presentation-engine/retained-xml-publication.d.ts +18 -0
- package/dist/safe-bash-presentation-engine/retained-xml-replacement.d.ts +13 -0
- package/dist/safe-bash-presentation-engine/sanitize.js +17 -16
- package/dist/safe-bash-presentation-engine/selectors.js +10 -10
- package/dist/safe-bash-presentation-engine/shape-groups.js +31 -30
- package/dist/safe-bash-presentation-engine/shape-operations.js +30 -29
- package/dist/safe-bash-presentation-engine/shape-path-operations.js +32 -31
- package/dist/safe-bash-presentation-engine/shape-paths.js +16 -15
- package/dist/safe-bash-presentation-engine/shape-presets.js +3 -3
- package/dist/safe-bash-presentation-engine/shape-selection.js +31 -30
- package/dist/safe-bash-presentation-engine/shape-transforms.js +18 -17
- package/dist/safe-bash-presentation-engine/shapes.d.ts +1 -1
- package/dist/safe-bash-presentation-engine/shapes.js +27 -26
- package/dist/safe-bash-presentation-engine/slide-copy.js +17 -16
- package/dist/safe-bash-presentation-engine/slide-import.js +18 -17
- package/dist/safe-bash-presentation-engine/slide-merge-split.js +20 -19
- package/dist/safe-bash-presentation-engine/slide-model.js +43 -42
- package/dist/safe-bash-presentation-engine/slide-removal.js +18 -17
- package/dist/safe-bash-presentation-engine/slide-transfer-budget.js +9 -9
- package/dist/safe-bash-presentation-engine/slides.d.ts +1 -0
- package/dist/safe-bash-presentation-engine/slides.js +23 -17
- package/dist/safe-bash-presentation-engine/table-operations.js +33 -32
- package/dist/safe-bash-presentation-engine/table-spans.js +32 -31
- package/dist/safe-bash-presentation-engine/tables.js +31 -30
- package/dist/safe-bash-presentation-engine/tags.js +16 -15
- package/dist/safe-bash-presentation-engine/template-bindings.js +33 -32
- package/dist/safe-bash-presentation-engine/template-repeat.js +40 -39
- package/dist/safe-bash-presentation-engine/text-fitting.js +27 -26
- package/dist/safe-bash-presentation-engine/text-frames.js +27 -26
- package/dist/safe-bash-presentation-engine/text-paragraphs.js +27 -26
- package/dist/safe-bash-presentation-engine/text-reading.js +11 -11
- package/dist/safe-bash-presentation-engine/text-replacement.js +17 -16
- package/dist/safe-bash-presentation-engine/text-runs.js +20 -19
- package/dist/safe-bash-presentation-engine/themes.js +16 -15
- package/dist/safe-bash-presentation-engine/transitions.js +16 -15
- package/dist/safe-bash-presentation-engine/validation.js +10 -9
- package/dist/safe-bash-presentation-engine/xml-parts.d.ts +2 -0
- package/dist/safe-bash-presentation-engine/xml-parts.js +23 -15
- package/dist/safe-bash-presentation-engine/xml-view.js +3 -3
- package/dist/safe-bash-presentation-engine/xml.js +3 -3
- package/dist/safe-bash-regex-engine/index.js +1 -1
- package/dist/safe-bash-regex-engine/python-glob.js +1 -1
- package/dist/safe-bash-regex-engine/text/regex.d.ts +19 -0
- package/dist/safe-bash-regex-engine/text/regex.js +1 -1
- package/dist/safe-bash-xml-engine/document.js +3 -3
- package/dist/safe-bash-xml-engine/evaluate.js +1 -1
- package/dist/safe-bash-xml-engine/index.d.ts +1 -0
- package/dist/safe-bash-xml-engine/index.js +8 -4
- package/dist/safe-bash-xml-engine/query.js +2 -2
- package/dist/safe-bash-xml-engine/recovery.d.ts +10 -0
- package/dist/safe-bash-xml-engine/stored-document.d.ts +1 -1
- package/dist/safe-bash-xml-engine/stored-document.js +1 -1
- package/dist/safe-bash-xml-engine/stored-evaluate.js +1 -1
- package/dist/spreadsheet-engine/formulas/functions/python-printf.js +56 -33
- package/dist/spreadsheet-format-xls/biff-encrypted-properties.d.ts +2 -2
- package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +86 -24
- package/dist/spreadsheet-format-xls/biff-metadata.d.ts +1 -0
- package/dist/spreadsheet-format-xls/biff-metadata.js +2 -2
- package/dist/spreadsheet-format-xls/biff-properties-merge.d.ts +6 -2
- package/dist/spreadsheet-format-xls/biff-properties-merge.js +413 -296
- package/dist/spreadsheet-format-xls/biff-properties-write.js +40 -23
- package/dist/spreadsheet-format-xls/biff-properties.js +3 -68
- package/dist/spreadsheet-format-xls/biff-property-index.d.ts +23 -0
- package/dist/spreadsheet-format-xls/biff-property-index.js +93 -0
- package/dist/spreadsheet-format-xls/biff-property-name.d.ts +4 -0
- package/dist/spreadsheet-format-xls/biff-property-name.js +114 -0
- package/dist/spreadsheet-format-xls/biff-property-text.d.ts +6 -0
- package/dist/spreadsheet-format-xls/biff-property-text.js +68 -0
- package/dist/spreadsheet-format-xls/biff-property-transcode.d.ts +5 -0
- package/dist/spreadsheet-format-xls/biff-property-transcode.js +45 -0
- package/dist/spreadsheet-format-xls/biff-write-metadata.js +10 -1
- package/package.json +6 -3
- package/dist/safe-bash/command-chunks/biff-3EFLKBAH-NYWZOYQS.js +0 -4942
- package/dist/safe-bash/command-chunks/chunk-5Q22ZLNC.js +0 -127
- package/dist/safe-bash/command-chunks/chunk-JKLOBSMP.js +0 -56
- package/dist/safe-bash/command-chunks/chunk-JYTESTBS.js +0 -99
- package/dist/safe-bash/command-chunks/chunk-WH3TIOTS.js +0 -326
- package/dist/safe-bash/command-chunks/paradox-ZWWXYY4J-JYOSWSBL.js +0 -362
- package/dist/spreadsheet-format-xls/biff-properties-layout.js +0 -56
|
@@ -0,0 +1,737 @@
|
|
|
1
|
+
import {
|
|
2
|
+
openPackageArchive
|
|
3
|
+
} from "./chunk-KCE5D4Z4.js";
|
|
4
|
+
import {
|
|
5
|
+
boundedOutput,
|
|
6
|
+
openRetainedPresentationIndex,
|
|
7
|
+
rawJson,
|
|
8
|
+
streamJson
|
|
9
|
+
} from "./chunk-X64XGIXZ.js";
|
|
10
|
+
import {
|
|
11
|
+
RetainedOrder
|
|
12
|
+
} from "./chunk-ZYLGNIGA.js";
|
|
13
|
+
import {
|
|
14
|
+
loadShared
|
|
15
|
+
} from "./chunk-2Z3WRRFT.js";
|
|
16
|
+
import {
|
|
17
|
+
writePackageArchive
|
|
18
|
+
} from "./chunk-HKOMXGJS.js";
|
|
19
|
+
import {
|
|
20
|
+
readBinary
|
|
21
|
+
} from "./chunk-LD7BONZY.js";
|
|
22
|
+
import {
|
|
23
|
+
openRetainedPresentationValidation
|
|
24
|
+
} from "./chunk-GVWVRPG6.js";
|
|
25
|
+
import {
|
|
26
|
+
openRetainedContentTypes
|
|
27
|
+
} from "./chunk-G3RUXKVY.js";
|
|
28
|
+
import {
|
|
29
|
+
parseContentTypes
|
|
30
|
+
} from "./chunk-VQOINPVF.js";
|
|
31
|
+
import {
|
|
32
|
+
asciiKey,
|
|
33
|
+
partName
|
|
34
|
+
} from "./chunk-U5TWQFZY.js";
|
|
35
|
+
import {
|
|
36
|
+
PackageNotFoundError
|
|
37
|
+
} from "./chunk-D55REQA3.js";
|
|
38
|
+
import {
|
|
39
|
+
OfficeError,
|
|
40
|
+
RetainedValues,
|
|
41
|
+
characters,
|
|
42
|
+
digest,
|
|
43
|
+
equal,
|
|
44
|
+
folded,
|
|
45
|
+
literal,
|
|
46
|
+
openRetainedXmlDocument,
|
|
47
|
+
resolveOfficeResources
|
|
48
|
+
} from "./chunk-X6RHJ6YN.js";
|
|
49
|
+
import {
|
|
50
|
+
createZipCodec
|
|
51
|
+
} from "./chunk-IOEUZ4EA.js";
|
|
52
|
+
|
|
53
|
+
// packages/safe-bash-presentation-engine/src/package-tools.ts
|
|
54
|
+
import { sha256 as sha2562 } from "@noble/hashes/sha2.js";
|
|
55
|
+
|
|
56
|
+
// packages/safe-bash-presentation-engine/src/retained-package-extraction.ts
|
|
57
|
+
import { PagedStorage } from "@poe-platform/safe-fs/storage";
|
|
58
|
+
var extensions = { "image/png": "png", "image/jpeg": "jpg", "image/gif": "gif", "image/tiff": "tif", "image/bmp": "bmp", "audio/mpeg": "mp3", "video/mp4": "mp4" };
|
|
59
|
+
async function openRetainedPackageExtraction(input, settings, options = {}) {
|
|
60
|
+
const context = resolveOfficeResources(settings), signal = context.signal ?? new AbortController().signal;
|
|
61
|
+
if (!options || typeof options !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(options)) || Reflect.ownKeys(options).some((key) => key !== "parts" || !("value" in Object.getOwnPropertyDescriptor(options, key))))
|
|
62
|
+
throw new OfficeError("invalid-value", "Expected a plain package record.", "usage");
|
|
63
|
+
const selected = options.parts;
|
|
64
|
+
if (selected !== void 0) {
|
|
65
|
+
if (!Array.isArray(selected) || !selected.length || Object.getPrototypeOf(selected) !== Array.prototype)
|
|
66
|
+
throw new OfficeError("invalid-value", "Invalid package extraction options.", "usage");
|
|
67
|
+
if (selected.length > context.archiveLimits.maxMembers) throw new OfficeError("resource-limit", "Package member limit exceeded.", "usage");
|
|
68
|
+
if (Reflect.ownKeys(selected).length !== selected.length + 1) throw new OfficeError("invalid-value", "Expected a dense package array.", "usage");
|
|
69
|
+
for (let n = 0; n < selected.length; n++) if (!Object.getOwnPropertyDescriptor(selected, String(n)) || !("value" in Object.getOwnPropertyDescriptor(selected, String(n))))
|
|
70
|
+
throw new OfficeError("invalid-value", "Expected a dense package array.", "usage");
|
|
71
|
+
}
|
|
72
|
+
const working = { ...settings.workingStorage }, cacheBytes = working.cacheBytes ?? 1024 * 1024;
|
|
73
|
+
if (!working.fs || typeof working.directory !== "string" || !working.directory.startsWith("/") || !Number.isSafeInteger(cacheBytes) || cacheBytes < 16384 || cacheBytes % 16384)
|
|
74
|
+
throw new OfficeError("invalid-value", "Explicit extraction storage and a valid cache budget are required.", "usage");
|
|
75
|
+
if (!input || typeof input.read !== "function" || typeof input.stream !== "function") throw new OfficeError("invalid-type", "An immutable retained input is required.", "usage");
|
|
76
|
+
const pages = new PagedStorage({ fs: working.fs, cwd: working.directory, env: {}, signal }, cacheBytes / 16384);
|
|
77
|
+
let archive, index;
|
|
78
|
+
let validation, types;
|
|
79
|
+
let closed = false, closing, count = 0;
|
|
80
|
+
const check = () => {
|
|
81
|
+
if (closed) throw new OfficeError("invalid-handle", "Extraction is closed.", "select");
|
|
82
|
+
if (signal.aborted) throw new OfficeError("cancelled", "Operation cancelled.", "select");
|
|
83
|
+
};
|
|
84
|
+
const failure = (error) => error instanceof OfficeError ? error : new OfficeError(signal.aborted ? "cancelled" : "io-failure", "Extraction storage operation failed.", "select");
|
|
85
|
+
const close = () => {
|
|
86
|
+
closed = true;
|
|
87
|
+
return closing ??= (async () => {
|
|
88
|
+
const results = await Promise.allSettled([types?.close(), validation?.close(), index?.close(), archive?.close(), pages.close()]);
|
|
89
|
+
for (const result of results) if (result.status === "rejected") throw result.reason;
|
|
90
|
+
})();
|
|
91
|
+
};
|
|
92
|
+
const values = new RetainedValues(pages, check, signal), order = new RetainedOrder(pages, values, check), requests = new RetainedOrder(pages, values, check);
|
|
93
|
+
async function text(range) {
|
|
94
|
+
const decoder = new TextDecoder();
|
|
95
|
+
let value = "";
|
|
96
|
+
for await (const bytes of values.read(range)) value += decoder.decode(bytes, { stream: true });
|
|
97
|
+
return value + decoder.decode();
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
if (selected) for (let n = 0; n < selected.length; n++) {
|
|
101
|
+
check();
|
|
102
|
+
const name = selected[n], canonical = partName(name, false);
|
|
103
|
+
if (canonical !== name) throw new OfficeError("unsafe-path", "A canonical package part is required.", "usage");
|
|
104
|
+
const key = await values.store(folded(literal(name))), value = await values.store(literal(name));
|
|
105
|
+
if (!await values.insert("selected", key, value)) throw new OfficeError("invalid-value", "Duplicate extracted part.", "usage");
|
|
106
|
+
await requests.add(literal(String(n).padStart(16, "0")), value);
|
|
107
|
+
}
|
|
108
|
+
await requests.seal();
|
|
109
|
+
archive = await openPackageArchive(input, { ...context, workingStorage: working });
|
|
110
|
+
async function* original() {
|
|
111
|
+
check();
|
|
112
|
+
let iterator, exhausted = false, size = 0;
|
|
113
|
+
try {
|
|
114
|
+
iterator = input.stream()[Symbol.asyncIterator]();
|
|
115
|
+
} catch {
|
|
116
|
+
check();
|
|
117
|
+
throw new OfficeError("io-failure", "Byte input failed.", "admit");
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
for (let reads = 0; reads < context.limits.maxReads; reads++) {
|
|
121
|
+
check();
|
|
122
|
+
let item;
|
|
123
|
+
try {
|
|
124
|
+
item = await iterator.next();
|
|
125
|
+
} catch (error) {
|
|
126
|
+
check();
|
|
127
|
+
if (error && typeof error === "object" && "code" in error) {
|
|
128
|
+
if (error.code === "ENOENT") throw new PackageNotFoundError();
|
|
129
|
+
if (error.code === "EFBIG") throw new OfficeError("resource-limit", "Byte input exceeds its limit.", "admit");
|
|
130
|
+
}
|
|
131
|
+
throw new OfficeError("io-failure", "Byte input failed.", "admit");
|
|
132
|
+
}
|
|
133
|
+
check();
|
|
134
|
+
if (item.done) {
|
|
135
|
+
exhausted = true;
|
|
136
|
+
if (size !== input.size) throw new OfficeError("io-failure", "Retained input size changed.", "admit");
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (!(item.value instanceof Uint8Array)) throw new OfficeError("invalid-type", "Byte source returned an invalid chunk.", "admit");
|
|
140
|
+
if (item.value.length > input.size - size) throw new OfficeError("resource-limit", "Byte input exceeds its limit.", "admit");
|
|
141
|
+
size += item.value.length;
|
|
142
|
+
yield item.value;
|
|
143
|
+
}
|
|
144
|
+
throw new OfficeError("resource-limit", "Byte source exceeded its read limit.", "admit");
|
|
145
|
+
} finally {
|
|
146
|
+
if (!exhausted) try {
|
|
147
|
+
await iterator.return?.();
|
|
148
|
+
} catch {
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const fingerprint = await digest(original());
|
|
153
|
+
index = await openRetainedPresentationIndex(archive, fingerprint, { ...context, workingStorage: working });
|
|
154
|
+
const limits = { ...context.xmlLimits, ...context.relationshipLimits, maxBytes: Math.min(context.xmlLimits.maxBytes, context.relationshipLimits.maxBytes), maxEntries: context.archiveLimits.maxMembers };
|
|
155
|
+
validation = await openRetainedPresentationValidation(archive, { ...context, workingStorage: working }, limits);
|
|
156
|
+
if (!validation.valid) throw new OfficeError("invalid-opc", "Invalid presentation graph.", "validate-intent");
|
|
157
|
+
types = await openRetainedContentTypes(archive.read("/[Content_Types].xml"), { ...context, workingStorage: working }, { maxBytes: context.xmlLimits.maxBytes, maxEntries: context.archiveLimits.maxMembers });
|
|
158
|
+
async function* names() {
|
|
159
|
+
if (selected) {
|
|
160
|
+
for await (const name of requests.entries()) yield await text(name);
|
|
161
|
+
} else {
|
|
162
|
+
const names2 = new RetainedOrder(pages, values, check);
|
|
163
|
+
for await (const name of archive.parts()) {
|
|
164
|
+
const value = await values.store(literal(name));
|
|
165
|
+
await names2.add(literal(name), value);
|
|
166
|
+
}
|
|
167
|
+
await names2.seal();
|
|
168
|
+
for await (const name of names2.entries()) yield await text(name);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
for await (const part of names()) {
|
|
172
|
+
check();
|
|
173
|
+
const size = await archive.byteLength(part), hash = await digest(archive.read(part));
|
|
174
|
+
const type = await values.store(part === "/[Content_Types].xml" ? literal("application/xml") : await types.get(part));
|
|
175
|
+
let essence = "", suffix = "", pendingWhitespace = 0, overflow = false;
|
|
176
|
+
for await (const character of characters(values.read(type))) {
|
|
177
|
+
if (character === ";") break;
|
|
178
|
+
if (character.trim() === "") {
|
|
179
|
+
if (essence || overflow) pendingWhitespace++;
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (pendingWhitespace) {
|
|
183
|
+
if (essence.length + pendingWhitespace > 32) overflow = true;
|
|
184
|
+
else essence += " ".repeat(pendingWhitespace);
|
|
185
|
+
suffix = "";
|
|
186
|
+
pendingWhitespace = 0;
|
|
187
|
+
}
|
|
188
|
+
const lower = character.toLowerCase();
|
|
189
|
+
if (essence.length + lower.length > 32) overflow = true;
|
|
190
|
+
else if (!overflow) essence += lower;
|
|
191
|
+
suffix = (suffix + lower).slice(-4);
|
|
192
|
+
}
|
|
193
|
+
const extension = !overflow && (essence === "application/xml" || essence === "text/xml") || suffix === "+xml" ? "xml" : !overflow ? extensions[essence] ?? "bin" : "bin";
|
|
194
|
+
const name = `part-${String(++count).padStart(6, "0")}.${extension}`;
|
|
195
|
+
const partRange = await values.store(literal(part)), nameRange = await values.store(literal(name)), hashRange = await values.store(literal(hash));
|
|
196
|
+
const data = [partRange.start, partRange.length, nameRange.start, nameRange.length, hashRange.start, hashRange.length, type.start, type.length, size];
|
|
197
|
+
const bytes = new Uint8Array(data.length * 8), view = new DataView(bytes.buffer);
|
|
198
|
+
data.forEach((value, n) => view.setFloat64(n * 8, value, true));
|
|
199
|
+
const row = await values.store((async function* () {
|
|
200
|
+
yield bytes;
|
|
201
|
+
})());
|
|
202
|
+
await order.add(literal(String(count).padStart(16, "0")), row);
|
|
203
|
+
}
|
|
204
|
+
await order.seal();
|
|
205
|
+
await types.close();
|
|
206
|
+
types = void 0;
|
|
207
|
+
await validation.close();
|
|
208
|
+
validation = void 0;
|
|
209
|
+
await index.close();
|
|
210
|
+
index = void 0;
|
|
211
|
+
async function* members() {
|
|
212
|
+
try {
|
|
213
|
+
check();
|
|
214
|
+
for await (const stored of order.entries()) {
|
|
215
|
+
check();
|
|
216
|
+
const bytes = await pages.read(stored.start, stored.length), view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
217
|
+
const range = (n) => ({ start: view.getFloat64(n * 8, true), length: view.getFloat64((n + 1) * 8, true) });
|
|
218
|
+
const part = await text(range(0)), type = range(6);
|
|
219
|
+
yield Object.freeze({
|
|
220
|
+
part,
|
|
221
|
+
name: await text(range(2)),
|
|
222
|
+
sha256: await text(range(4)),
|
|
223
|
+
size: view.getFloat64(64, true),
|
|
224
|
+
async *contentType() {
|
|
225
|
+
try {
|
|
226
|
+
check();
|
|
227
|
+
yield* values.read(type);
|
|
228
|
+
check();
|
|
229
|
+
} catch (error) {
|
|
230
|
+
throw failure(error);
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
async *bytes() {
|
|
234
|
+
check();
|
|
235
|
+
for await (const bytes2 of archive.read(part)) {
|
|
236
|
+
check();
|
|
237
|
+
yield bytes2;
|
|
238
|
+
}
|
|
239
|
+
check();
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
check();
|
|
244
|
+
} catch (error) {
|
|
245
|
+
throw failure(error);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return Object.freeze({ count, members, close });
|
|
249
|
+
} catch (error) {
|
|
250
|
+
await close().catch(() => {
|
|
251
|
+
});
|
|
252
|
+
throw failure(error);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// packages/safe-bash-presentation-engine/src/retained-extraction-output.ts
|
|
257
|
+
import { PagedStorage as PagedStorage2 } from "@poe-platform/safe-fs/storage";
|
|
258
|
+
async function stageRetainedExtractionOutput(extraction, settings, output) {
|
|
259
|
+
output = { ...output };
|
|
260
|
+
const working = { ...settings.workingStorage }, cacheBytes = working.cacheBytes ?? 1024 * 1024;
|
|
261
|
+
if (!working.fs || typeof working.directory !== "string" || !working.directory.startsWith("/") || !Number.isSafeInteger(cacheBytes) || cacheBytes < 16384 || cacheBytes % 16384 || typeof output.directory !== "string" || !output.directory || typeof output.json !== "boolean" || typeof output.allowPartialOutput !== "boolean" || !(output.maxOutputBytes > 0 && (output.maxOutputBytes === Infinity || Number.isSafeInteger(output.maxOutputBytes)))) throw new OfficeError("invalid-value", "Invalid extraction output storage or options.", "usage");
|
|
262
|
+
const signal = settings.signal ?? new AbortController().signal, controller = new AbortController();
|
|
263
|
+
const abort = () => controller.abort(signal.reason);
|
|
264
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
265
|
+
if (signal.aborted) abort();
|
|
266
|
+
const context = { fs: working.fs, cwd: working.directory, env: {}, signal: controller.signal };
|
|
267
|
+
const pages = new PagedStorage2(context, cacheBytes / 16384), offsets = new PagedStorage2(context, cacheBytes / 16384);
|
|
268
|
+
let closed = false, closing;
|
|
269
|
+
const check = () => {
|
|
270
|
+
if (closed) throw new OfficeError("invalid-handle", "Extraction output is closed.", "publish");
|
|
271
|
+
controller.signal.throwIfAborted();
|
|
272
|
+
};
|
|
273
|
+
const values = new RetainedValues(pages, check, controller.signal);
|
|
274
|
+
const close = () => {
|
|
275
|
+
closed = true;
|
|
276
|
+
signal.removeEventListener("abort", abort);
|
|
277
|
+
return closing ??= (async () => {
|
|
278
|
+
const results = await Promise.allSettled([pages.close(), offsets.close()]);
|
|
279
|
+
for (const result of results) if (result.status === "rejected") throw result.reason;
|
|
280
|
+
})();
|
|
281
|
+
};
|
|
282
|
+
try {
|
|
283
|
+
let data2 = function(count2) {
|
|
284
|
+
return { outputs: { [rawJson]: () => manifest(count2) }, dryRun: false };
|
|
285
|
+
}, envelope2 = function(code, published = 0, reserve2 = false) {
|
|
286
|
+
return {
|
|
287
|
+
version: 1,
|
|
288
|
+
operation: "extract",
|
|
289
|
+
ok: !code,
|
|
290
|
+
warnings: [],
|
|
291
|
+
errors: code ? [{ code, message: "Output could not be published.", context: { phase: "publish" } }] : [],
|
|
292
|
+
locations: [],
|
|
293
|
+
affected: code && output.allowPartialOutput ? published : 0,
|
|
294
|
+
data: !code || reserve2 ? data2(count) : output.allowPartialOutput && published > 0 ? data2(published) : null
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
var data = data2, envelope = envelope2;
|
|
298
|
+
const start = pages.allocate(0), offsetStart = offsets.allocate(0);
|
|
299
|
+
let length = 0, count = 0;
|
|
300
|
+
const path = (name) => `${output.directory}${output.directory.endsWith("/") ? "" : "/"}${name}`;
|
|
301
|
+
for await (const member of extraction.members()) {
|
|
302
|
+
check();
|
|
303
|
+
if (count++) {
|
|
304
|
+
await pages.append(new Uint8Array([44]));
|
|
305
|
+
length++;
|
|
306
|
+
}
|
|
307
|
+
const item = await values.store(boundedOutput(streamJson({ part: member.part, name: member.name, contentType: member.contentType, sha256: member.sha256, path: path(member.name), bytes: member.size }), controller.signal, output.maxOutputBytes));
|
|
308
|
+
length += item.length;
|
|
309
|
+
if (!Number.isSafeInteger(length) || length > output.maxOutputBytes) throw new OfficeError("resource-limit", "Output limit exceeded.", "publish");
|
|
310
|
+
const end = new Uint8Array(8);
|
|
311
|
+
new DataView(end.buffer).setFloat64(0, length, true);
|
|
312
|
+
await offsets.append(end);
|
|
313
|
+
}
|
|
314
|
+
async function* manifest(count2) {
|
|
315
|
+
check();
|
|
316
|
+
yield* literal("[");
|
|
317
|
+
if (count2) {
|
|
318
|
+
const bytes = await offsets.read(offsetStart + (count2 - 1) * 8, 8), end = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getFloat64(0, true);
|
|
319
|
+
yield* values.read({ start, length: end });
|
|
320
|
+
}
|
|
321
|
+
yield* literal("]");
|
|
322
|
+
check();
|
|
323
|
+
}
|
|
324
|
+
async function* render(code, published = 0) {
|
|
325
|
+
if (output.json) {
|
|
326
|
+
yield* streamJson(envelope2(code, published));
|
|
327
|
+
yield* literal("\n");
|
|
328
|
+
} else if (!code) yield* literal(`Extracted ${count} package part(s)
|
|
329
|
+
`);
|
|
330
|
+
else {
|
|
331
|
+
yield* literal(`pptx: ${code}: Output could not be published.
|
|
332
|
+
`);
|
|
333
|
+
yield* streamJson(output.allowPartialOutput && published > 0 ? data2(published) : null);
|
|
334
|
+
yield* literal("\n");
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
for await (const chunk of boundedOutput(render(), signal, output.maxOutputBytes)) void chunk;
|
|
338
|
+
async function* reserve() {
|
|
339
|
+
yield* streamJson(envelope2("publication-unsupported", count, true));
|
|
340
|
+
yield* literal("\n");
|
|
341
|
+
}
|
|
342
|
+
for await (const chunk of boundedOutput(reserve(), signal, output.maxOutputBytes)) void chunk;
|
|
343
|
+
signal.throwIfAborted();
|
|
344
|
+
signal.removeEventListener("abort", abort);
|
|
345
|
+
return Object.freeze({ close, path, async write(sink, failure) {
|
|
346
|
+
check();
|
|
347
|
+
if (failure && (!["cancelled", "resource-limit", "stale-input", "publication-unsupported", "io-failure"].includes(failure.code) || !Number.isSafeInteger(failure.published) || failure.published < 0 || failure.published > count)) throw new OfficeError("invalid-value", "Invalid extraction outcome.", "usage");
|
|
348
|
+
for await (const chunk of boundedOutput(render(failure?.code, failure?.published), failure ? controller.signal : signal, output.maxOutputBytes)) await sink.write(chunk);
|
|
349
|
+
} });
|
|
350
|
+
} catch (error) {
|
|
351
|
+
await close().catch(() => {
|
|
352
|
+
});
|
|
353
|
+
throw error;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// packages/safe-bash-presentation-engine/src/retained-package-packing.ts
|
|
358
|
+
import { PagedStorage as PagedStorage3 } from "@poe-platform/safe-fs/storage";
|
|
359
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
360
|
+
|
|
361
|
+
// packages/safe-bash-presentation-engine/src/retained-package-edit-admission.ts
|
|
362
|
+
function unsupported() {
|
|
363
|
+
throw new OfficeError("unsupported-edit", "Signed, macro-enabled, labeled or protected packages cannot be edited.", "validate-intent");
|
|
364
|
+
}
|
|
365
|
+
async function mime(source) {
|
|
366
|
+
let text = "", window = "", pending = "", started = false, overflow = false;
|
|
367
|
+
for await (const value of characters(source)) {
|
|
368
|
+
if (value === ";") break;
|
|
369
|
+
if (!value.trim()) {
|
|
370
|
+
if (started) pending = " ";
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
started = true;
|
|
374
|
+
for (const character of pending + value.toLowerCase()) {
|
|
375
|
+
window = (window + character).slice(-17);
|
|
376
|
+
if (["digital-signature", "macroenabled", "vbaproject"].some((needle) => window.endsWith(needle))) unsupported();
|
|
377
|
+
if (text.length < 100) text += character;
|
|
378
|
+
else overflow = true;
|
|
379
|
+
}
|
|
380
|
+
pending = "";
|
|
381
|
+
}
|
|
382
|
+
return overflow ? "" : text;
|
|
383
|
+
}
|
|
384
|
+
async function admitRetainedPackageEdit(archive, main, types, graph, settings) {
|
|
385
|
+
const context = resolveOfficeResources(settings);
|
|
386
|
+
let metadataBytes = 0, metadataNodes = 0;
|
|
387
|
+
for await (const part of archive.parts()) {
|
|
388
|
+
if (part === "/[Content_Types].xml") continue;
|
|
389
|
+
const name = part.toLowerCase(), type = await mime(await types.get(part));
|
|
390
|
+
if (name.startsWith("/_xmlsignatures/") || name.endsWith("/vbaproject.bin") || name === "/docmetadata/labelinfo.xml" || type === "application/vnd.ms-office.classificationlabels+xml") unsupported();
|
|
391
|
+
if (type === "application/vnd.openxmlformats-officedocument.custom-properties+xml") {
|
|
392
|
+
metadataBytes += await archive.byteLength(part);
|
|
393
|
+
if (metadataBytes > context.xmlLimits.maxBytes || metadataNodes >= context.xmlLimits.maxNodes) throw new OfficeError("resource-limit", "Security metadata inspection limit exceeded.", "validate-intent");
|
|
394
|
+
const document2 = await openRetainedXmlDocument(archive.read(part), { ...settings, xmlLimits: { ...context.xmlLimits, maxNodes: context.xmlLimits.maxNodes - metadataNodes } });
|
|
395
|
+
let failed2 = false;
|
|
396
|
+
try {
|
|
397
|
+
metadataNodes += document2.nodeCount;
|
|
398
|
+
for await (const node of document2.children(document2.root)) {
|
|
399
|
+
if (node.kind !== "element" || !await equal(document2.raw(node.localName), literal("property"))) continue;
|
|
400
|
+
if (!await equal(document2.namespace(node), literal("http://schemas.openxmlformats.org/officeDocument/2006/custom-properties")) && !await equal(document2.namespace(node), literal("http://purl.oclc.org/ooxml/officeDocument/customProperties"))) continue;
|
|
401
|
+
for await (const attribute of document2.attributes(node)) if (await equal(document2.namespace(attribute), literal("")) && await equal(document2.raw(attribute.localName), literal("name"))) {
|
|
402
|
+
let prefix = "";
|
|
403
|
+
for await (const character of characters(document2.text(attribute))) {
|
|
404
|
+
prefix += character;
|
|
405
|
+
if (prefix.length >= 11) break;
|
|
406
|
+
}
|
|
407
|
+
if (prefix === "MSIP_Label_") unsupported();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
} catch (error) {
|
|
411
|
+
failed2 = true;
|
|
412
|
+
throw error;
|
|
413
|
+
} finally {
|
|
414
|
+
try {
|
|
415
|
+
await document2.close();
|
|
416
|
+
} catch (error) {
|
|
417
|
+
if (!failed2) await Promise.reject(error);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
async function* owners() {
|
|
423
|
+
yield "/";
|
|
424
|
+
yield* graph.parts();
|
|
425
|
+
}
|
|
426
|
+
for await (const owner of owners()) for await (const edge of graph.outgoing(owner)) {
|
|
427
|
+
let window = "";
|
|
428
|
+
for await (const character of characters(edge.type())) {
|
|
429
|
+
window = (window + character).slice(-19);
|
|
430
|
+
if (window.includes("/digital-signature/")) unsupported();
|
|
431
|
+
}
|
|
432
|
+
if (window.endsWith("/vbaProject")) unsupported();
|
|
433
|
+
}
|
|
434
|
+
const document = await openRetainedXmlDocument(archive.read(main), settings);
|
|
435
|
+
let failed = false;
|
|
436
|
+
try {
|
|
437
|
+
for await (const node of document.elements(document.root)) if (await equal(document.raw(node.localName), literal("modifyVerifier")) && await equal(document.namespace(node), document.namespace(document.root))) unsupported();
|
|
438
|
+
} catch (error) {
|
|
439
|
+
failed = true;
|
|
440
|
+
throw error;
|
|
441
|
+
} finally {
|
|
442
|
+
try {
|
|
443
|
+
await document.close();
|
|
444
|
+
} catch (error) {
|
|
445
|
+
if (!failed) await Promise.reject(error);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// packages/safe-bash-presentation-engine/src/retained-package-packing.ts
|
|
451
|
+
async function stageRetainedPackage(members, openMember, settings, options = {}) {
|
|
452
|
+
const context = resolveOfficeResources(settings), signal = context.signal ?? new AbortController().signal;
|
|
453
|
+
const working = { ...settings.workingStorage }, cacheBytes = working?.cacheBytes ?? 1024 * 1024;
|
|
454
|
+
if (!working?.fs || typeof working.directory !== "string" || !working.directory.startsWith("/") || !Number.isSafeInteger(cacheBytes) || cacheBytes < 16384 || cacheBytes % 16384)
|
|
455
|
+
throw new OfficeError("invalid-value", "Explicit packing storage and a valid cache budget are required.", "usage");
|
|
456
|
+
function record2(value, keys) {
|
|
457
|
+
if (!value || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value)) || Reflect.ownKeys(value).some((key) => typeof key !== "string" || !keys.includes(key) || !("value" in Object.getOwnPropertyDescriptor(value, key))))
|
|
458
|
+
throw new OfficeError("invalid-value", "Expected a plain package record.", "usage");
|
|
459
|
+
}
|
|
460
|
+
record2(options, ["kind"]);
|
|
461
|
+
if (options.kind !== void 0 && !["pptx", "potx", "ppsx"].includes(options.kind)) throw new OfficeError("invalid-value", "Invalid presentation kind.", "usage");
|
|
462
|
+
const kind = options.kind, admittedSettings = { ...context, signal, workingStorage: working };
|
|
463
|
+
if (!members || typeof members[Symbol.asyncIterator] !== "function" || typeof openMember !== "function") throw new OfficeError("invalid-type", "Explicit package member streams are required.", "usage");
|
|
464
|
+
const makePages = () => new PagedStorage3({ fs: working.fs, cwd: working.directory, env: {}, signal }, cacheBytes / 16384);
|
|
465
|
+
const descriptors = makePages(), zipPages = makePages(), output = makePages();
|
|
466
|
+
let closed = false, closing;
|
|
467
|
+
const check = () => {
|
|
468
|
+
if (closed) throw new OfficeError("invalid-handle", "Packed output is closed.", "serialize");
|
|
469
|
+
if (signal.aborted) throw new OfficeError("cancelled", "Operation cancelled.", "serialize");
|
|
470
|
+
};
|
|
471
|
+
const failure = (error) => {
|
|
472
|
+
if (signal.aborted) return new OfficeError("cancelled", "Operation cancelled.", "serialize");
|
|
473
|
+
if (error instanceof OfficeError) return error;
|
|
474
|
+
const code = error && typeof error === "object" && "code" in error ? error.code : void 0;
|
|
475
|
+
return new OfficeError(code === "resource-limit" || code === "EFBIG" ? "resource-limit" : "io-failure", "Package packing failed.", "serialize");
|
|
476
|
+
};
|
|
477
|
+
const close = () => {
|
|
478
|
+
closed = true;
|
|
479
|
+
return closing ??= (async () => {
|
|
480
|
+
const results = await Promise.allSettled([descriptors.close(), zipPages.close(), output.close()]);
|
|
481
|
+
for (const result of results) if (result.status === "rejected") throw result.reason;
|
|
482
|
+
})();
|
|
483
|
+
};
|
|
484
|
+
const values = new RetainedValues(descriptors, check, signal), order = new RetainedOrder(descriptors, values, check);
|
|
485
|
+
const hex = (bytes) => Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
486
|
+
const bounds = (size, maximum) => {
|
|
487
|
+
if (!Number.isSafeInteger(size) || size > maximum) throw new OfficeError("resource-limit", "Package byte limit exceeded.", "admit");
|
|
488
|
+
};
|
|
489
|
+
try {
|
|
490
|
+
check();
|
|
491
|
+
let count = 0;
|
|
492
|
+
for await (const member of members) {
|
|
493
|
+
check();
|
|
494
|
+
bounds(++count, Math.min(context.archiveLimits.maxMembers, 65534));
|
|
495
|
+
record2(member, ["part", "sha256"]);
|
|
496
|
+
const part = partName(member.part, false), expectedDigest = member.sha256;
|
|
497
|
+
if (part !== member.part || part.includes(":")) throw new OfficeError("unsafe-path", "A canonical package part is required.", "usage");
|
|
498
|
+
if (typeof expectedDigest !== "string" || expectedDigest.length !== 64 || [...expectedDigest].some((character) => !"0123456789abcdef".includes(character))) throw new OfficeError("invalid-value", "A lowercase SHA-256 digest is required.", "usage");
|
|
499
|
+
const name = [...part.slice(1)].map((character) => character.codePointAt(0) > 127 ? encodeURIComponent(character) : character).join("");
|
|
500
|
+
bounds(new TextEncoder().encode(name).length, Math.min(context.archiveLimits.maxPathBytes, 65535));
|
|
501
|
+
bounds(name.split("/").length, context.archiveLimits.maxDepth);
|
|
502
|
+
const key = asciiKey(part);
|
|
503
|
+
if (await values.find("names", () => literal(key)) || await values.find("parents", () => literal(key))) throw new OfficeError("invalid-opc", "Colliding package members.", "admit");
|
|
504
|
+
let parent = key.slice(0, key.lastIndexOf("/"));
|
|
505
|
+
while (parent) {
|
|
506
|
+
if (await values.find("names", () => literal(parent))) throw new OfficeError("invalid-opc", "Colliding package members.", "admit");
|
|
507
|
+
const value2 = await values.store(literal(parent));
|
|
508
|
+
await values.insert("parents", value2, value2);
|
|
509
|
+
parent = parent.slice(0, parent.lastIndexOf("/"));
|
|
510
|
+
}
|
|
511
|
+
const value = await values.store(literal(key));
|
|
512
|
+
await values.insert("names", value, value);
|
|
513
|
+
await order.add(literal(name), await values.store(literal(JSON.stringify({ part, name, sha256: expectedDigest }))));
|
|
514
|
+
}
|
|
515
|
+
if (!count) throw new OfficeError("invalid-value", "Explicit package members are required.", "usage");
|
|
516
|
+
await order.seal();
|
|
517
|
+
const storage = { allocate: (length) => zipPages.allocate(length), read: (position, length) => zipPages.read(position, length), write: (position, bytes2) => zipPages.write(position, bytes2) };
|
|
518
|
+
const writer = createZipCodec(void 0, { zip64: true, rejectDuplicateNames: true, utcDates: true }).createStagedWriter(
|
|
519
|
+
storage,
|
|
520
|
+
{ ...context.archiveLimits, maxArchiveBytes: Math.min(context.archiveLimits.maxArchiveBytes, context.limits.maxBytes) },
|
|
521
|
+
signal
|
|
522
|
+
);
|
|
523
|
+
let total = 0;
|
|
524
|
+
for await (const row of order.entries()) {
|
|
525
|
+
check();
|
|
526
|
+
let text = "";
|
|
527
|
+
const decoder = new TextDecoder();
|
|
528
|
+
for await (const bytes2 of values.read(row)) text += decoder.decode(bytes2, { stream: true });
|
|
529
|
+
text += decoder.decode();
|
|
530
|
+
const member = JSON.parse(text);
|
|
531
|
+
async function* source() {
|
|
532
|
+
let iterator, exhausted = false, size2 = 0;
|
|
533
|
+
const hash2 = sha256.create();
|
|
534
|
+
try {
|
|
535
|
+
try {
|
|
536
|
+
iterator = openMember(member.part)[Symbol.asyncIterator]();
|
|
537
|
+
} catch {
|
|
538
|
+
throw new OfficeError("io-failure", "Byte input failed.", "admit");
|
|
539
|
+
}
|
|
540
|
+
for (let reads = 0; reads < context.limits.maxReads; reads++) {
|
|
541
|
+
check();
|
|
542
|
+
let item;
|
|
543
|
+
try {
|
|
544
|
+
item = await iterator.next();
|
|
545
|
+
} catch (error) {
|
|
546
|
+
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") throw new PackageNotFoundError();
|
|
547
|
+
throw failure(error);
|
|
548
|
+
}
|
|
549
|
+
check();
|
|
550
|
+
if (item.done) {
|
|
551
|
+
exhausted = true;
|
|
552
|
+
if (hex(hash2.digest()) !== member.sha256) throw new OfficeError("invalid-value", "Package member digest does not match.", "admit");
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
if (!(item.value instanceof Uint8Array)) throw new OfficeError("invalid-type", "Byte source returned an invalid chunk.", "admit");
|
|
556
|
+
size2 += item.value.length;
|
|
557
|
+
total += item.value.length;
|
|
558
|
+
bounds(size2, Math.min(context.limits.maxBytes, context.archiveLimits.maxEntryBytes));
|
|
559
|
+
bounds(total, context.archiveLimits.maxTotalBytes);
|
|
560
|
+
for (let offset = 0; offset < item.value.length; offset += 16384) {
|
|
561
|
+
check();
|
|
562
|
+
const owned = new Uint8Array(item.value.subarray(offset, offset + 16384));
|
|
563
|
+
hash2.update(owned);
|
|
564
|
+
yield owned;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
throw new OfficeError("resource-limit", "Byte source exceeded its read limit.", "admit");
|
|
568
|
+
} finally {
|
|
569
|
+
if (!exhausted) try {
|
|
570
|
+
await iterator?.return?.();
|
|
571
|
+
} catch {
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
await writer.addSource(member.name, source(), { modified: new Date(Date.UTC(1980, 0, 1)), mode: 33188, directory: false, symlink: false, compression: "store" });
|
|
576
|
+
}
|
|
577
|
+
const start = output.allocate(0);
|
|
578
|
+
let size = 0;
|
|
579
|
+
const hash = sha256.create();
|
|
580
|
+
for await (const bytes2 of writer.finish()) {
|
|
581
|
+
check();
|
|
582
|
+
await output.append(bytes2);
|
|
583
|
+
hash.update(bytes2);
|
|
584
|
+
size += bytes2.length;
|
|
585
|
+
}
|
|
586
|
+
const fingerprint = hex(hash.digest());
|
|
587
|
+
await descriptors.close();
|
|
588
|
+
await zipPages.close();
|
|
589
|
+
async function* bytes() {
|
|
590
|
+
try {
|
|
591
|
+
check();
|
|
592
|
+
for (let offset = 0; offset < size; offset += 16384) {
|
|
593
|
+
check();
|
|
594
|
+
yield await output.read(start + offset, Math.min(16384, size - offset));
|
|
595
|
+
}
|
|
596
|
+
check();
|
|
597
|
+
} catch (error) {
|
|
598
|
+
throw failure(error);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
const archive = await openPackageArchive({ size, read: (position, maximum) => output.read(start + position, Math.min(maximum, size - position)) }, admittedSettings);
|
|
602
|
+
let index, validation, types, failed = false;
|
|
603
|
+
try {
|
|
604
|
+
index = await openRetainedPresentationIndex(archive, fingerprint, admittedSettings);
|
|
605
|
+
validation = await openRetainedPresentationValidation(archive, admittedSettings, { ...context.xmlLimits, ...context.relationshipLimits, maxBytes: Math.min(context.xmlLimits.maxBytes, context.relationshipLimits.maxBytes), maxEntries: context.archiveLimits.maxMembers });
|
|
606
|
+
if (!validation.valid) throw new OfficeError("invalid-opc", "Invalid presentation graph.", "validate-intent");
|
|
607
|
+
types = await openRetainedContentTypes(archive.read("/[Content_Types].xml"), admittedSettings, { maxBytes: Math.min(context.xmlLimits.maxBytes, context.relationshipLimits.maxBytes), maxEntries: context.archiveLimits.maxMembers });
|
|
608
|
+
await admitRetainedPackageEdit(archive, index.records.main, types, index.graph, admittedSettings);
|
|
609
|
+
if (kind !== void 0) await types.presentationKind(index.records.main, kind);
|
|
610
|
+
} catch (error) {
|
|
611
|
+
failed = true;
|
|
612
|
+
throw error;
|
|
613
|
+
} finally {
|
|
614
|
+
const results = await Promise.allSettled([types?.close(), validation?.close(), index?.close(), archive.close()]);
|
|
615
|
+
if (!failed) {
|
|
616
|
+
for (const result of results) if (result.status === "rejected") await Promise.reject(result.reason);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
check();
|
|
620
|
+
return Object.freeze({ count, size, fingerprint, bytes, close });
|
|
621
|
+
} catch (error) {
|
|
622
|
+
const primary = failure(error);
|
|
623
|
+
await close().catch(() => {
|
|
624
|
+
});
|
|
625
|
+
throw primary;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// packages/safe-bash-presentation-engine/src/package-tools.ts
|
|
630
|
+
function record(value, allowed) {
|
|
631
|
+
if (!value || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value)) || Reflect.ownKeys(value).some((key) => typeof key !== "string" || !allowed.includes(key) || !("value" in Object.getOwnPropertyDescriptor(value, key))))
|
|
632
|
+
throw new OfficeError("invalid-value", "Expected a plain package record.", "usage");
|
|
633
|
+
}
|
|
634
|
+
function list(value, maximum) {
|
|
635
|
+
if (!Array.isArray(value)) throw new OfficeError("invalid-value", "Expected package members.", "usage");
|
|
636
|
+
if (value.length > maximum) throw new OfficeError("resource-limit", "Package member limit exceeded.", "usage");
|
|
637
|
+
if (Object.getPrototypeOf(value) !== Array.prototype || Reflect.ownKeys(value).length !== value.length + 1 || Array.from({ length: value.length }, (_, index) => Object.getOwnPropertyDescriptor(value, String(index))).some((item) => !item || !("value" in item)))
|
|
638
|
+
throw new OfficeError("invalid-value", "Expected a dense package array.", "usage");
|
|
639
|
+
}
|
|
640
|
+
function digest2(bytes) {
|
|
641
|
+
return Array.from(sha2562(bytes), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
642
|
+
}
|
|
643
|
+
async function extractPackage(input, context, options = {}) {
|
|
644
|
+
record(options, ["parts"]);
|
|
645
|
+
if (!context?.archiveLimits) throw new OfficeError("invalid-value", "Explicit limits are required.", "usage");
|
|
646
|
+
if (options.parts !== void 0) list(options.parts, context.archiveLimits.maxMembers);
|
|
647
|
+
if (!options || Object.keys(options).some((key) => key !== "parts") || options.parts !== void 0 && (!Array.isArray(options.parts) || !options.parts.length))
|
|
648
|
+
throw new OfficeError("invalid-value", "Invalid package extraction options.", "usage");
|
|
649
|
+
const selected = options.parts?.map((part) => {
|
|
650
|
+
const canonical = partName(part, false);
|
|
651
|
+
if (canonical !== part) throw new OfficeError("unsafe-path", "A canonical package part is required.", "usage");
|
|
652
|
+
return canonical;
|
|
653
|
+
});
|
|
654
|
+
if (selected && new Set(selected.map(asciiKey)).size !== selected.length)
|
|
655
|
+
throw new OfficeError("invalid-value", "Duplicate extracted part.", "usage");
|
|
656
|
+
const { reader } = await loadShared(input, context, false);
|
|
657
|
+
const types = parseContentTypes(reader.get("/[Content_Types].xml"), {
|
|
658
|
+
maxBytes: context.xmlLimits.maxBytes,
|
|
659
|
+
maxEntries: context.archiveLimits.maxMembers
|
|
660
|
+
});
|
|
661
|
+
const names = selected ?? [...reader.names].sort();
|
|
662
|
+
return Object.freeze(names.map((part, index) => {
|
|
663
|
+
const bytes = reader.get(part);
|
|
664
|
+
const contentType = part === "/[Content_Types].xml" ? "application/xml" : types.get(part);
|
|
665
|
+
const essence = contentType.split(";", 1)[0].trim().toLowerCase();
|
|
666
|
+
const extension = essence === "application/xml" || essence === "text/xml" || essence.endsWith("+xml") ? "xml" : { "image/png": "png", "image/jpeg": "jpg", "image/gif": "gif", "image/tiff": "tif", "image/bmp": "bmp", "audio/mpeg": "mp3", "video/mp4": "mp4" }[essence] ?? "bin";
|
|
667
|
+
return Object.freeze({ part, name: `part-${String(index + 1).padStart(6, "0")}.${extension}`, contentType, sha256: digest2(bytes), bytes });
|
|
668
|
+
}));
|
|
669
|
+
}
|
|
670
|
+
async function packPackage(members, context, options = {}) {
|
|
671
|
+
record(options, ["kind"]);
|
|
672
|
+
if (!context?.limits || !context.archiveLimits || !Array.isArray(members) || !members.length || !options || Object.keys(options).some((key) => key !== "kind") || options.kind !== void 0 && !["pptx", "potx", "ppsx"].includes(options.kind))
|
|
673
|
+
throw new OfficeError("invalid-value", "Explicit package members and limits are required.", "usage");
|
|
674
|
+
if (context.signal?.aborted) throw new OfficeError("cancelled", "Operation cancelled.", "admit");
|
|
675
|
+
if (members.length > context.archiveLimits.maxMembers)
|
|
676
|
+
throw new OfficeError("resource-limit", "Package member limit exceeded.", "admit");
|
|
677
|
+
list(members, context.archiveLimits.maxMembers);
|
|
678
|
+
const names = /* @__PURE__ */ new Set();
|
|
679
|
+
const parents = /* @__PURE__ */ new Set();
|
|
680
|
+
let ownedTotal = 0;
|
|
681
|
+
const admitted = members.map((member) => {
|
|
682
|
+
record(member, ["part", "sha256", "bytes", "name", "contentType"]);
|
|
683
|
+
if (!member || typeof member.sha256 !== "string" || member.sha256.length !== 64 || [...member.sha256].some((character) => !"0123456789abcdef".includes(character)))
|
|
684
|
+
throw new OfficeError("invalid-value", "A lowercase SHA-256 digest is required.", "usage");
|
|
685
|
+
const part = partName(member.part, false);
|
|
686
|
+
if (part !== member.part || part.includes(":"))
|
|
687
|
+
throw new OfficeError("unsafe-path", "A canonical package part is required.", "usage");
|
|
688
|
+
const key = asciiKey(part);
|
|
689
|
+
if (names.has(key) || parents.has(key))
|
|
690
|
+
throw new OfficeError("invalid-opc", "Colliding package members.", "admit");
|
|
691
|
+
let parent = key.slice(0, key.lastIndexOf("/"));
|
|
692
|
+
while (parent) {
|
|
693
|
+
if (names.has(parent)) throw new OfficeError("invalid-opc", "Colliding package members.", "admit");
|
|
694
|
+
parents.add(parent);
|
|
695
|
+
parent = parent.slice(0, parent.lastIndexOf("/"));
|
|
696
|
+
}
|
|
697
|
+
names.add(key);
|
|
698
|
+
let input = member.bytes;
|
|
699
|
+
if (input instanceof Uint8Array) {
|
|
700
|
+
ownedTotal += input.length;
|
|
701
|
+
if (input.length > context.archiveLimits.maxEntryBytes || input.length > context.limits.maxBytes || ownedTotal > context.archiveLimits.maxTotalBytes)
|
|
702
|
+
throw new OfficeError("resource-limit", "Package byte limit exceeded.", "admit");
|
|
703
|
+
input = new Uint8Array(input);
|
|
704
|
+
}
|
|
705
|
+
return { part, sha256: member.sha256, input };
|
|
706
|
+
});
|
|
707
|
+
let total = 0;
|
|
708
|
+
const output = [];
|
|
709
|
+
for (const member of admitted) {
|
|
710
|
+
const remaining = context.archiveLimits.maxTotalBytes - total;
|
|
711
|
+
const bytes2 = await readBinary(member.input, context, { maxBytes: Math.min(context.limits.maxBytes, context.archiveLimits.maxEntryBytes, Math.max(1, remaining)) });
|
|
712
|
+
if (bytes2.length > remaining) throw new OfficeError("resource-limit", "Package byte limit exceeded.", "admit");
|
|
713
|
+
total += bytes2.length;
|
|
714
|
+
if (digest2(bytes2) !== member.sha256)
|
|
715
|
+
throw new OfficeError("invalid-value", "Package member digest does not match.", "admit");
|
|
716
|
+
const name = [...member.part.slice(1)].map((character) => character.codePointAt(0) > 127 ? encodeURIComponent(character) : character).join("");
|
|
717
|
+
output.push({ name, bytes: bytes2 });
|
|
718
|
+
}
|
|
719
|
+
const bytes = await writePackageArchive(output, context, { compression: "store" });
|
|
720
|
+
const loaded = await loadShared(bytes, context);
|
|
721
|
+
if (options.kind !== void 0) {
|
|
722
|
+
const types = parseContentTypes(loaded.reader.get("/[Content_Types].xml"), {
|
|
723
|
+
maxBytes: context.xmlLimits.maxBytes,
|
|
724
|
+
maxEntries: context.archiveLimits.maxMembers
|
|
725
|
+
});
|
|
726
|
+
types.presentationKind(loaded.main, options.kind);
|
|
727
|
+
}
|
|
728
|
+
return bytes;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
export {
|
|
732
|
+
openRetainedPackageExtraction,
|
|
733
|
+
stageRetainedExtractionOutput,
|
|
734
|
+
stageRetainedPackage,
|
|
735
|
+
extractPackage,
|
|
736
|
+
packPackage
|
|
737
|
+
};
|