@l1yp/file-viewer 0.1.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.
- package/LICENSE +21 -0
- package/README.md +134 -0
- package/dist/FileViewer.js +7 -0
- package/dist/FileViewer.vue.d.ts +37 -0
- package/dist/FileViewer.vue_vue_type_script_setup_true_lang.js +103 -0
- package/dist/_virtual/_plugin-vue_export-helper.js +8 -0
- package/dist/components/AppxViewer.js +7 -0
- package/dist/components/AppxViewer.vue.d.ts +18 -0
- package/dist/components/AppxViewer.vue_vue_type_script_setup_true_lang.js +174 -0
- package/dist/components/ArchiveBrowser.js +7 -0
- package/dist/components/ArchiveBrowser.vue.d.ts +18 -0
- package/dist/components/ArchiveBrowser.vue_vue_type_script_setup_true_lang.js +279 -0
- package/dist/components/AudioViewer.js +7 -0
- package/dist/components/AudioViewer.vue.d.ts +21 -0
- package/dist/components/AudioViewer.vue_vue_type_script_setup_true_lang.js +201 -0
- package/dist/components/BinObjBrowser.js +7 -0
- package/dist/components/BinObjBrowser.vue.d.ts +19 -0
- package/dist/components/BinObjBrowser.vue_vue_type_script_setup_true_lang.js +141 -0
- package/dist/components/CertViewer.js +7 -0
- package/dist/components/CertViewer.vue.d.ts +17 -0
- package/dist/components/CertViewer.vue_vue_type_script_setup_true_lang.js +251 -0
- package/dist/components/ClassViewer.js +7 -0
- package/dist/components/ClassViewer.vue.d.ts +15 -0
- package/dist/components/ClassViewer.vue_vue_type_script_setup_true_lang.js +164 -0
- package/dist/components/CodeBlock.js +7 -0
- package/dist/components/CodeBlock.vue.d.ts +17 -0
- package/dist/components/CodeBlock.vue_vue_type_script_setup_true_lang.js +79 -0
- package/dist/components/CodeView.js +7 -0
- package/dist/components/CodeView.vue.d.ts +21 -0
- package/dist/components/CodeView.vue_vue_type_script_setup_true_lang.js +180 -0
- package/dist/components/CsvViewer.js +7 -0
- package/dist/components/CsvViewer.vue.d.ts +26 -0
- package/dist/components/CsvViewer.vue_vue_type_script_setup_true_lang.js +187 -0
- package/dist/components/DicomViewer.js +7 -0
- package/dist/components/DicomViewer.vue.d.ts +30 -0
- package/dist/components/DicomViewer.vue_vue_type_script_setup_true_lang.js +362 -0
- package/dist/components/DocxViewer.js +7 -0
- package/dist/components/DocxViewer.vue.d.ts +19 -0
- package/dist/components/DocxViewer.vue_vue_type_script_setup_true_lang.js +59 -0
- package/dist/components/DrawioViewer.js +7 -0
- package/dist/components/DrawioViewer.vue.d.ts +16 -0
- package/dist/components/DrawioViewer.vue_vue_type_script_setup_true_lang.js +38 -0
- package/dist/components/DxfViewer.js +7 -0
- package/dist/components/DxfViewer.vue.d.ts +14 -0
- package/dist/components/DxfViewer.vue_vue_type_script_setup_true_lang.js +239 -0
- package/dist/components/EbookViewer.js +7 -0
- package/dist/components/EbookViewer.vue.d.ts +22 -0
- package/dist/components/EbookViewer.vue_vue_type_script_setup_true_lang.js +170 -0
- package/dist/components/EmlViewer.js +7 -0
- package/dist/components/EmlViewer.vue.d.ts +21 -0
- package/dist/components/EmlViewer.vue_vue_type_script_setup_true_lang.js +193 -0
- package/dist/components/EplViewer.js +7 -0
- package/dist/components/EplViewer.vue.d.ts +19 -0
- package/dist/components/EplViewer.vue_vue_type_script_setup_true_lang.js +201 -0
- package/dist/components/FileViewerBody.js +7 -0
- package/dist/components/FileViewerBody.vue.d.ts +47 -0
- package/dist/components/FileViewerBody.vue_vue_type_script_setup_true_lang.js +599 -0
- package/dist/components/FileViewerPanel.js +7 -0
- package/dist/components/FileViewerPanel.vue.d.ts +3 -0
- package/dist/components/FileViewerPanel.vue_vue_type_script_setup_true_lang.js +207 -0
- package/dist/components/FontViewer.js +7 -0
- package/dist/components/FontViewer.vue.d.ts +17 -0
- package/dist/components/FontViewer.vue_vue_type_script_setup_true_lang.js +120 -0
- package/dist/components/FrontmatterCard.js +7 -0
- package/dist/components/FrontmatterCard.vue.d.ts +11 -0
- package/dist/components/FrontmatterCard.vue_vue_type_script_setup_true_lang.js +30 -0
- package/dist/components/GeoViewer.js +7 -0
- package/dist/components/GeoViewer.vue.d.ts +17 -0
- package/dist/components/GeoViewer.vue_vue_type_script_setup_true_lang.js +255 -0
- package/dist/components/HarViewer.js +7 -0
- package/dist/components/HarViewer.vue.d.ts +20 -0
- package/dist/components/HarViewer.vue_vue_type_script_setup_true_lang.js +322 -0
- package/dist/components/HexViewer.js +7 -0
- package/dist/components/HexViewer.vue.d.ts +22 -0
- package/dist/components/HexViewer.vue_vue_type_script_setup_true_lang.js +121 -0
- package/dist/components/HprofViewer.js +7 -0
- package/dist/components/HprofViewer.vue.d.ts +27 -0
- package/dist/components/HprofViewer.vue_vue_type_script_setup_true_lang.js +561 -0
- package/dist/components/ImageLightbox.js +7 -0
- package/dist/components/ImageLightbox.vue.d.ts +3 -0
- package/dist/components/ImageLightbox.vue_vue_type_script_setup_true_lang.js +86 -0
- package/dist/components/InlineText.d.ts +29 -0
- package/dist/components/InlineText.js +21 -0
- package/dist/components/JksViewer.js +7 -0
- package/dist/components/JksViewer.vue.d.ts +22 -0
- package/dist/components/JksViewer.vue_vue_type_script_setup_true_lang.js +353 -0
- package/dist/components/JsonlViewer.js +7 -0
- package/dist/components/JsonlViewer.vue.d.ts +15 -0
- package/dist/components/JsonlViewer.vue_vue_type_script_setup_true_lang.js +103 -0
- package/dist/components/LogViewer.js +7 -0
- package/dist/components/LogViewer.vue.d.ts +29 -0
- package/dist/components/LogViewer.vue_vue_type_script_setup_true_lang.js +670 -0
- package/dist/components/LrcViewer.js +7 -0
- package/dist/components/LrcViewer.vue.d.ts +17 -0
- package/dist/components/LrcViewer.vue_vue_type_script_setup_true_lang.js +106 -0
- package/dist/components/MarkdownTable.js +7 -0
- package/dist/components/MarkdownTable.vue.d.ts +19 -0
- package/dist/components/MarkdownTable.vue_vue_type_script_setup_true_lang.js +71 -0
- package/dist/components/MarkdownText.d.ts +30 -0
- package/dist/components/MarkdownText.js +21 -0
- package/dist/components/MhtViewer.js +7 -0
- package/dist/components/MhtViewer.vue.d.ts +22 -0
- package/dist/components/MhtViewer.vue_vue_type_script_setup_true_lang.js +112 -0
- package/dist/components/MindMapView.js +7 -0
- package/dist/components/MindMapView.vue.d.ts +23 -0
- package/dist/components/MindMapView.vue_vue_type_script_setup_true_lang.js +337 -0
- package/dist/components/MissingDependency.js +7 -0
- package/dist/components/MissingDependency.vue.d.ts +17 -0
- package/dist/components/MissingDependency.vue_vue_type_script_setup_true_lang.js +37 -0
- package/dist/components/ModelViewer.js +7 -0
- package/dist/components/ModelViewer.vue.d.ts +18 -0
- package/dist/components/ModelViewer.vue_vue_type_script_setup_true_lang.js +157 -0
- package/dist/components/MsiViewer.js +7 -0
- package/dist/components/MsiViewer.vue.d.ts +19 -0
- package/dist/components/MsiViewer.vue_vue_type_script_setup_true_lang.js +136 -0
- package/dist/components/NotebookViewer.js +7 -0
- package/dist/components/NotebookViewer.vue.d.ts +20 -0
- package/dist/components/NotebookViewer.vue_vue_type_script_setup_true_lang.js +125 -0
- package/dist/components/PdfViewer.js +7 -0
- package/dist/components/PdfViewer.vue.d.ts +19 -0
- package/dist/components/PdfViewer.vue_vue_type_script_setup_true_lang.js +114 -0
- package/dist/components/PptxViewer.js +7 -0
- package/dist/components/PptxViewer.vue.d.ts +20 -0
- package/dist/components/PptxViewer.vue_vue_type_script_setup_true_lang.js +73 -0
- package/dist/components/PsdViewer.js +7 -0
- package/dist/components/PsdViewer.vue.d.ts +15 -0
- package/dist/components/PsdViewer.vue_vue_type_script_setup_true_lang.js +218 -0
- package/dist/components/QmcAudioViewer.js +7 -0
- package/dist/components/QmcAudioViewer.vue.d.ts +18 -0
- package/dist/components/QmcAudioViewer.vue_vue_type_script_setup_true_lang.js +92 -0
- package/dist/components/RasterViewer.js +7 -0
- package/dist/components/RasterViewer.vue.d.ts +21 -0
- package/dist/components/RasterViewer.vue_vue_type_script_setup_true_lang.js +161 -0
- package/dist/components/RtfViewer.js +7 -0
- package/dist/components/RtfViewer.vue.d.ts +21 -0
- package/dist/components/RtfViewer.vue_vue_type_script_setup_true_lang.js +66 -0
- package/dist/components/SevenZipBrowser.js +7 -0
- package/dist/components/SevenZipBrowser.vue.d.ts +13 -0
- package/dist/components/SevenZipBrowser.vue_vue_type_script_setup_true_lang.js +366 -0
- package/dist/components/SqliteViewer.js +7 -0
- package/dist/components/SqliteViewer.vue.d.ts +18 -0
- package/dist/components/SqliteViewer.vue_vue_type_script_setup_true_lang.js +186 -0
- package/dist/components/SubtitleViewer.js +7 -0
- package/dist/components/SubtitleViewer.vue.d.ts +15 -0
- package/dist/components/SubtitleViewer.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/components/XlsxChart.js +7 -0
- package/dist/components/XlsxChart.vue.d.ts +14 -0
- package/dist/components/XlsxChart.vue_vue_type_script_setup_true_lang.js +240 -0
- package/dist/components/XlsxViewer.js +7 -0
- package/dist/components/XlsxViewer.vue.d.ts +22 -0
- package/dist/components/XlsxViewer.vue_vue_type_script_setup_true_lang.js +814 -0
- package/dist/components/XmindViewer.js +7 -0
- package/dist/components/XmindViewer.vue.d.ts +13 -0
- package/dist/components/XmindViewer.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/components/ZipBrowser.js +7 -0
- package/dist/components/ZipBrowser.vue.d.ts +14 -0
- package/dist/components/ZipBrowser.vue_vue_type_script_setup_true_lang.js +326 -0
- package/dist/components/ZoomImage.js +7 -0
- package/dist/components/ZoomImage.vue.d.ts +29 -0
- package/dist/components/ZoomImage.vue_vue_type_script_setup_true_lang.js +147 -0
- package/dist/components/epl/EplCodeBlock.js +7 -0
- package/dist/components/epl/EplCodeBlock.vue.d.ts +15 -0
- package/dist/components/epl/EplCodeBlock.vue_vue_type_script_setup_true_lang.js +72 -0
- package/dist/components/epl/EplDoc.js +7 -0
- package/dist/components/epl/EplDoc.vue.d.ts +19 -0
- package/dist/components/epl/EplDoc.vue_vue_type_script_setup_true_lang.js +327 -0
- package/dist/components/epl/EplMethod.js +7 -0
- package/dist/components/epl/EplMethod.vue.d.ts +14 -0
- package/dist/components/epl/EplMethod.vue_vue_type_script_setup_true_lang.js +100 -0
- package/dist/components/epl/EplResource.js +7 -0
- package/dist/components/epl/EplResource.vue.d.ts +15 -0
- package/dist/components/epl/EplResource.vue_vue_type_script_setup_true_lang.js +204 -0
- package/dist/components/epl/EplTree.js +7 -0
- package/dist/components/epl/EplTree.vue.d.ts +27 -0
- package/dist/components/epl/EplTree.vue_vue_type_script_setup_true_lang.js +123 -0
- package/dist/components/epl/EplVarTable.js +7 -0
- package/dist/components/epl/EplVarTable.vue.d.ts +21 -0
- package/dist/components/epl/EplVarTable.vue_vue_type_script_setup_true_lang.js +60 -0
- package/dist/components/epl/docTypes.d.ts +12 -0
- package/dist/components/epl/numbering.d.ts +21 -0
- package/dist/components/epl/numbering.js +14 -0
- package/dist/components/icons/Icon.js +7 -0
- package/dist/components/icons/Icon.vue.d.ts +14 -0
- package/dist/components/icons/Icon.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/components/icons/iconPaths.d.ts +60 -0
- package/dist/components/icons/iconPaths.js +54 -0
- package/dist/components/optionalViewer.d.ts +14 -0
- package/dist/components/optionalViewer.js +37 -0
- package/dist/components/ui/ClampBlock.d.ts +82 -0
- package/dist/components/ui/ClampBlock.js +63 -0
- package/dist/composables/useFileViewer.d.ts +428 -0
- package/dist/composables/useFileViewer.js +27 -0
- package/dist/composables/useLightbox.d.ts +33 -0
- package/dist/composables/useLightbox.js +17 -0
- package/dist/composables/useLogRules.d.ts +47 -0
- package/dist/composables/useLogRules.js +74 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +30 -0
- package/dist/lib/aes.d.ts +25 -0
- package/dist/lib/aes.js +99 -0
- package/dist/lib/appx.d.ts +66 -0
- package/dist/lib/appx.js +112 -0
- package/dist/lib/archive.d.ts +29 -0
- package/dist/lib/asn1.d.ts +47 -0
- package/dist/lib/asn1.js +122 -0
- package/dist/lib/binobj.d.ts +69 -0
- package/dist/lib/binobj.js +430 -0
- package/dist/lib/brotli.d.ts +14 -0
- package/dist/lib/brotli.js +16 -0
- package/dist/lib/bzip2.d.ts +14 -0
- package/dist/lib/bzip2.js +161 -0
- package/dist/lib/classfile.d.ts +72 -0
- package/dist/lib/classfile.js +210 -0
- package/dist/lib/codePreview.d.ts +22 -0
- package/dist/lib/codePreview.js +27 -0
- package/dist/lib/codefold.d.ts +14 -0
- package/dist/lib/codefold.js +30 -0
- package/dist/lib/codeformat.d.ts +21 -0
- package/dist/lib/codeformat.js +130 -0
- package/dist/lib/csv.d.ts +19 -0
- package/dist/lib/csv.js +74 -0
- package/dist/lib/des.d.ts +17 -0
- package/dist/lib/des.js +928 -0
- package/dist/lib/diagram.d.ts +5 -0
- package/dist/lib/diagram.js +479 -0
- package/dist/lib/dicom.d.ts +69 -0
- package/dist/lib/dicom.js +442 -0
- package/dist/lib/dicomCodecs.d.ts +28 -0
- package/dist/lib/dicomCodecs.js +156 -0
- package/dist/lib/dicomRender.d.ts +46 -0
- package/dist/lib/dicomRender.js +114 -0
- package/dist/lib/dxf.d.ts +86 -0
- package/dist/lib/dxf.js +399 -0
- package/dist/lib/eml.d.ts +40 -0
- package/dist/lib/eml.js +46 -0
- package/dist/lib/encoding.d.ts +28 -0
- package/dist/lib/encoding.js +44 -0
- package/dist/lib/epl/code/ast.d.ts +150 -0
- package/dist/lib/epl/code/codeDataParser.d.ts +3 -0
- package/dist/lib/epl/code/codeDataParser.js +330 -0
- package/dist/lib/epl/code/codeLines.d.ts +20 -0
- package/dist/lib/epl/code/codeLines.js +191 -0
- package/dist/lib/epl/code/structures.d.ts +86 -0
- package/dist/lib/epl/code/textCode.d.ts +29 -0
- package/dist/lib/epl/code/textCode.js +150 -0
- package/dist/lib/epl/code/variable.d.ts +25 -0
- package/dist/lib/epl/eplDocument.d.ts +21 -0
- package/dist/lib/epl/eplDocument.js +36 -0
- package/dist/lib/epl/imageList.d.ts +28 -0
- package/dist/lib/epl/imageList.js +66 -0
- package/dist/lib/epl/index.d.ts +53 -0
- package/dist/lib/epl/index.js +45 -0
- package/dist/lib/epl/io/binaryReader.d.ts +56 -0
- package/dist/lib/epl/io/binaryReader.js +119 -0
- package/dist/lib/epl/io/encoding.d.ts +16 -0
- package/dist/lib/epl/io/encoding.js +27 -0
- package/dist/lib/epl/model/eplSystemId.d.ts +64 -0
- package/dist/lib/epl/model/eplSystemId.js +16 -0
- package/dist/lib/epl/model/section.d.ts +46 -0
- package/dist/lib/epl/names/eplLibData.js +39 -0
- package/dist/lib/epl/names/idToNameMap.d.ts +33 -0
- package/dist/lib/epl/names/idToNameMap.js +130 -0
- package/dist/lib/epl/names/libNameProvider.d.ts +15 -0
- package/dist/lib/epl/names/libNameProvider.js +18 -0
- package/dist/lib/epl/program.d.ts +120 -0
- package/dist/lib/epl/program.js +134 -0
- package/dist/lib/epl/projectFileReader.d.ts +23 -0
- package/dist/lib/epl/projectFileReader.js +65 -0
- package/dist/lib/epl/sections/code.d.ts +20 -0
- package/dist/lib/epl/sections/esystemInfo.d.ts +14 -0
- package/dist/lib/epl/sections/losable.d.ts +11 -0
- package/dist/lib/epl/sections/projectConfig.d.ts +23 -0
- package/dist/lib/epl/sections/resource.d.ts +57 -0
- package/dist/lib/fb2.d.ts +14 -0
- package/dist/lib/fb2.js +62 -0
- package/dist/lib/fileType.d.ts +315 -0
- package/dist/lib/fileType.js +800 -0
- package/dist/lib/fonts.d.ts +8 -0
- package/dist/lib/fonts.js +4 -0
- package/dist/lib/format.d.ts +16 -0
- package/dist/lib/format.js +38 -0
- package/dist/lib/frontmatter.d.ts +13 -0
- package/dist/lib/frontmatter.js +23 -0
- package/dist/lib/geo.d.ts +30 -0
- package/dist/lib/geo.js +235 -0
- package/dist/lib/har.d.ts +171 -0
- package/dist/lib/har.js +397 -0
- package/dist/lib/highlight.d.ts +18 -0
- package/dist/lib/highlight.js +34 -0
- package/dist/lib/highlightLangs.d.ts +15 -0
- package/dist/lib/highlightLangs.js +93 -0
- package/dist/lib/hprof.d.ts +211 -0
- package/dist/lib/hprof.js +709 -0
- package/dist/lib/ipynb.d.ts +48 -0
- package/dist/lib/ipynb.js +130 -0
- package/dist/lib/jks.d.ts +86 -0
- package/dist/lib/jks.js +167 -0
- package/dist/lib/jsonl.d.ts +29 -0
- package/dist/lib/jsonl.js +24 -0
- package/dist/lib/lrc.d.ts +32 -0
- package/dist/lib/lrc.js +84 -0
- package/dist/lib/lzma.d.ts +70 -0
- package/dist/lib/lzma.js +204 -0
- package/dist/lib/markdown/blocks.d.ts +9 -0
- package/dist/lib/markdown/blocks.js +221 -0
- package/dist/lib/markdown/index.d.ts +3 -0
- package/dist/lib/markdown/inline.d.ts +33 -0
- package/dist/lib/markdown/inline.js +84 -0
- package/dist/lib/markdown/math.d.ts +5 -0
- package/dist/lib/markdown/math.js +25 -0
- package/dist/lib/markdown/segmentize.d.ts +11 -0
- package/dist/lib/markdown/segmentize.js +28 -0
- package/dist/lib/markdown/styles.d.ts +26 -0
- package/dist/lib/markdown/styles.js +135 -0
- package/dist/lib/mht.d.ts +51 -0
- package/dist/lib/mht.js +122 -0
- package/dist/lib/midi.d.ts +28 -0
- package/dist/lib/midi.js +84 -0
- package/dist/lib/mime.d.ts +82 -0
- package/dist/lib/mime.js +151 -0
- package/dist/lib/mindmap.d.ts +51 -0
- package/dist/lib/mindmap.js +113 -0
- package/dist/lib/mobi.d.ts +15 -0
- package/dist/lib/mobi.js +68 -0
- package/dist/lib/msi.d.ts +50 -0
- package/dist/lib/msi.js +332 -0
- package/dist/lib/optionalDep.d.ts +26 -0
- package/dist/lib/optionalDep.js +20 -0
- package/dist/lib/pkcs12.d.ts +56 -0
- package/dist/lib/pkcs12.js +356 -0
- package/dist/lib/qmc.d.ts +50 -0
- package/dist/lib/qmc.js +213 -0
- package/dist/lib/rar.d.ts +16 -0
- package/dist/lib/rar.js +40 -0
- package/dist/lib/rawPreview.d.ts +12 -0
- package/dist/lib/rawPreview.js +54 -0
- package/dist/lib/rc2.d.ts +12 -0
- package/dist/lib/rc2.js +298 -0
- package/dist/lib/resolveInput.d.ts +22 -0
- package/dist/lib/resolveInput.js +55 -0
- package/dist/lib/rtf.d.ts +53 -0
- package/dist/lib/rtf.js +413 -0
- package/dist/lib/sevenZip.d.ts +82 -0
- package/dist/lib/sevenZip.js +395 -0
- package/dist/lib/sha1.d.ts +24 -0
- package/dist/lib/sha1.js +53 -0
- package/dist/lib/sha256.d.ts +21 -0
- package/dist/lib/sha256.js +119 -0
- package/dist/lib/speechAudio.d.ts +36 -0
- package/dist/lib/speechAudio.js +85 -0
- package/dist/lib/sqlite.d.ts +38 -0
- package/dist/lib/sqlite.js +104 -0
- package/dist/lib/subtitle.d.ts +26 -0
- package/dist/lib/subtitle.js +99 -0
- package/dist/lib/tarball.d.ts +20 -0
- package/dist/lib/tarball.js +248 -0
- package/dist/lib/viewerFormats.d.ts +35 -0
- package/dist/lib/viewerFormats.js +83 -0
- package/dist/lib/viewerKind.d.ts +36 -0
- package/dist/lib/viewerKind.js +233 -0
- package/dist/lib/x509.d.ts +68 -0
- package/dist/lib/x509.js +267 -0
- package/dist/lib/xlsx.d.ts +55 -0
- package/dist/lib/xlsx.js +321 -0
- package/dist/lib/xlsxCharts.d.ts +34 -0
- package/dist/lib/xlsxCharts.js +152 -0
- package/dist/lib/xmind.d.ts +6 -0
- package/dist/lib/xmind.js +124 -0
- package/dist/lib/zip.d.ts +56 -0
- package/dist/lib/zip.js +169 -0
- package/dist/style.css +2 -0
- package/dist/types.d.ts +42 -0
- package/package.json +128 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { aesCbcDecrypt as e } from "./aes.js";
|
|
2
|
+
import { Sha256 as t } from "./sha256.js";
|
|
3
|
+
import { bcjX86Decode as n, lzma2Decode as r, lzmaDecode as i } from "./lzma.js";
|
|
4
|
+
//#region src/lib/sevenZip.ts
|
|
5
|
+
var a = [
|
|
6
|
+
55,
|
|
7
|
+
122,
|
|
8
|
+
188,
|
|
9
|
+
175,
|
|
10
|
+
39,
|
|
11
|
+
28
|
|
12
|
+
], o = 32, s = 0, c = 1, l = 4, u = 5, d = 6, f = 7, p = 8, m = 9, h = 10, g = 11, _ = 12, v = 13, y = 14, b = 15, x = 17, S = 23, C = "06f10701", w = class extends Error {
|
|
13
|
+
constructor() {
|
|
14
|
+
super("该 7z 已加密,需要密码"), this.name = "SevenZipEncryptedError";
|
|
15
|
+
}
|
|
16
|
+
}, T = class extends Error {
|
|
17
|
+
constructor() {
|
|
18
|
+
super("密码错误,无法解压"), this.name = "SevenZipPasswordError";
|
|
19
|
+
}
|
|
20
|
+
}, E = class {
|
|
21
|
+
buf;
|
|
22
|
+
pos = 0;
|
|
23
|
+
constructor(e) {
|
|
24
|
+
this.buf = e;
|
|
25
|
+
}
|
|
26
|
+
byte() {
|
|
27
|
+
if (this.pos >= this.buf.length) throw Error("7z 头部意外结束");
|
|
28
|
+
return this.buf[this.pos++];
|
|
29
|
+
}
|
|
30
|
+
bytes(e) {
|
|
31
|
+
let t = this.buf.subarray(this.pos, this.pos + e);
|
|
32
|
+
return this.pos += e, t;
|
|
33
|
+
}
|
|
34
|
+
number() {
|
|
35
|
+
let e = this.byte(), t = 128, n = 0;
|
|
36
|
+
for (let r = 0; r < 8; r++) {
|
|
37
|
+
if ((e & t) === 0) {
|
|
38
|
+
n += (e & t - 1) * 2 ** (8 * r);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
n += this.byte() * 2 ** (8 * r), t >>= 1;
|
|
42
|
+
}
|
|
43
|
+
return n;
|
|
44
|
+
}
|
|
45
|
+
bitVector(e) {
|
|
46
|
+
let t = [], n = 0, r = 0;
|
|
47
|
+
for (let i = 0; i < e; i++) r === 0 && (n = this.byte(), r = 128), t.push((n & r) !== 0), r >>= 1;
|
|
48
|
+
return t;
|
|
49
|
+
}
|
|
50
|
+
boolVectorWithAll(e) {
|
|
51
|
+
return this.byte() === 0 ? this.bitVector(e) : Array.from({ length: e }, () => !0);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
function D(e, t) {
|
|
55
|
+
return e.getUint32(t + 4, !0) * 4294967296 + e.getUint32(t, !0);
|
|
56
|
+
}
|
|
57
|
+
function O(e) {
|
|
58
|
+
let t = e.number(), n = [], r = 0, i = 0;
|
|
59
|
+
for (let a = 0; a < t; a++) {
|
|
60
|
+
let t = e.byte(), a = t & 15, o = e.bytes(a), s = "";
|
|
61
|
+
for (let e of o) s += e.toString(16).padStart(2, "0");
|
|
62
|
+
let c = 1, l = 1;
|
|
63
|
+
t & 16 && (c = e.number(), l = e.number());
|
|
64
|
+
let u = new Uint8Array();
|
|
65
|
+
t & 32 && (u = e.bytes(e.number()).slice()), n.push({
|
|
66
|
+
id: s,
|
|
67
|
+
numIn: c,
|
|
68
|
+
numOut: l,
|
|
69
|
+
props: u
|
|
70
|
+
}), r += c, i += l;
|
|
71
|
+
}
|
|
72
|
+
let a = i - 1, o = [];
|
|
73
|
+
for (let t = 0; t < a; t++) o.push({
|
|
74
|
+
inIndex: e.number(),
|
|
75
|
+
outIndex: e.number()
|
|
76
|
+
});
|
|
77
|
+
let s = r - a, c = [];
|
|
78
|
+
if (s === 1) {
|
|
79
|
+
for (let e = 0; e < r; e++) if (!o.some((t) => t.inIndex === e)) {
|
|
80
|
+
c.push(e);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
} else for (let t = 0; t < s; t++) c.push(e.number());
|
|
84
|
+
return {
|
|
85
|
+
coders: n,
|
|
86
|
+
bindPairs: o,
|
|
87
|
+
packedIndices: c,
|
|
88
|
+
unpackSizes: [],
|
|
89
|
+
numPackStreams: s,
|
|
90
|
+
packStreams: []
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function k(e) {
|
|
94
|
+
let t = 0;
|
|
95
|
+
for (let n of e.coders) t += n.numOut;
|
|
96
|
+
for (let n = 0; n < t; n++) if (!e.bindPairs.some((e) => e.outIndex === n)) return n;
|
|
97
|
+
return t - 1;
|
|
98
|
+
}
|
|
99
|
+
function A(e) {
|
|
100
|
+
return e.unpackSizes[k(e)] ?? 0;
|
|
101
|
+
}
|
|
102
|
+
function j(e) {
|
|
103
|
+
let t = {
|
|
104
|
+
packPos: 0,
|
|
105
|
+
packSizes: [],
|
|
106
|
+
folders: [],
|
|
107
|
+
numUnpackStreamsInFolders: [],
|
|
108
|
+
subSizes: [],
|
|
109
|
+
folderHasCrc: []
|
|
110
|
+
}, n = e.byte();
|
|
111
|
+
if (n === d) {
|
|
112
|
+
t.packPos = e.number();
|
|
113
|
+
let r = e.number(), i = e.byte();
|
|
114
|
+
for (; i !== s;) {
|
|
115
|
+
if (i === m) for (let n = 0; n < r; n++) t.packSizes.push(e.number());
|
|
116
|
+
else if (i === h) N(e, r);
|
|
117
|
+
else throw Error(`7z PackInfo 未知字段 0x${i.toString(16)}`);
|
|
118
|
+
i = e.byte();
|
|
119
|
+
}
|
|
120
|
+
n = e.byte();
|
|
121
|
+
}
|
|
122
|
+
if (n === f) {
|
|
123
|
+
if (e.byte() !== g) throw Error("7z UnpackInfo 缺少 Folder");
|
|
124
|
+
let r = e.number();
|
|
125
|
+
if (e.byte() !== 0) throw Error("7z 不支持外部 Folder 定义");
|
|
126
|
+
for (let n = 0; n < r; n++) t.folders.push(O(e));
|
|
127
|
+
if (e.byte() !== _) throw Error("7z 缺少 CodersUnpackSize");
|
|
128
|
+
for (let n of t.folders) {
|
|
129
|
+
let t = 0;
|
|
130
|
+
for (let e of n.coders) t += e.numOut;
|
|
131
|
+
for (let r = 0; r < t; r++) n.unpackSizes.push(e.number());
|
|
132
|
+
}
|
|
133
|
+
t.folderHasCrc = t.folders.map(() => !1);
|
|
134
|
+
let i = e.byte();
|
|
135
|
+
for (; i !== s;) {
|
|
136
|
+
if (i === h) t.folderHasCrc = N(e, t.folders.length);
|
|
137
|
+
else throw Error(`7z UnpackInfo 未知字段 0x${i.toString(16)}`);
|
|
138
|
+
i = e.byte();
|
|
139
|
+
}
|
|
140
|
+
n = e.byte();
|
|
141
|
+
}
|
|
142
|
+
if (t.numUnpackStreamsInFolders = t.folders.map(() => 1), n === p ? (M(e, t), n = e.byte()) : t.subSizes = t.folders.map((e) => A(e)), n !== s) throw Error(`7z StreamsInfo 未以 End 结束 (0x${n.toString(16)})`);
|
|
143
|
+
let r = 0, i = o + t.packPos, a = [];
|
|
144
|
+
for (let e of t.packSizes) a.push(i), i += e;
|
|
145
|
+
for (let e of t.folders) for (let n = 0; n < e.numPackStreams; n++) e.packStreams.push({
|
|
146
|
+
offset: a[r],
|
|
147
|
+
size: t.packSizes[r]
|
|
148
|
+
}), r++;
|
|
149
|
+
return t;
|
|
150
|
+
}
|
|
151
|
+
function M(e, t) {
|
|
152
|
+
let n = e.byte();
|
|
153
|
+
n === v ? (t.numUnpackStreamsInFolders = t.folders.map(() => e.number()), n = e.byte()) : t.numUnpackStreamsInFolders = t.folders.map(() => 1);
|
|
154
|
+
let r = [];
|
|
155
|
+
for (let i = 0; i < t.folders.length; i++) {
|
|
156
|
+
let a = t.numUnpackStreamsInFolders[i];
|
|
157
|
+
if (a === 0) continue;
|
|
158
|
+
let o = 0;
|
|
159
|
+
if (n === m) for (let t = 1; t < a; t++) {
|
|
160
|
+
let t = e.number();
|
|
161
|
+
r.push(t), o += t;
|
|
162
|
+
}
|
|
163
|
+
r.push(A(t.folders[i]) - o);
|
|
164
|
+
}
|
|
165
|
+
t.subSizes = r, n === m && (n = e.byte());
|
|
166
|
+
let i = 0;
|
|
167
|
+
for (let e = 0; e < t.folders.length; e++) {
|
|
168
|
+
let n = t.numUnpackStreamsInFolders[e];
|
|
169
|
+
(n !== 1 || !t.folderHasCrc[e]) && (i += n);
|
|
170
|
+
}
|
|
171
|
+
for (n === h && (N(e, i), n = e.byte()); n !== s;) n = e.byte();
|
|
172
|
+
}
|
|
173
|
+
function N(e, t) {
|
|
174
|
+
let n = e.boolVectorWithAll(t);
|
|
175
|
+
for (let t of n) t && e.bytes(4);
|
|
176
|
+
return n;
|
|
177
|
+
}
|
|
178
|
+
function P(e) {
|
|
179
|
+
let t = e.number(), n = {
|
|
180
|
+
names: Array.from({ length: t }, () => ""),
|
|
181
|
+
emptyStream: Array.from({ length: t }, () => !1),
|
|
182
|
+
emptyFile: []
|
|
183
|
+
}, r = 0;
|
|
184
|
+
for (;;) {
|
|
185
|
+
let i = e.number();
|
|
186
|
+
if (i === s) break;
|
|
187
|
+
let a = e.number(), o = e.pos + a;
|
|
188
|
+
switch (i) {
|
|
189
|
+
case y:
|
|
190
|
+
n.emptyStream = e.bitVector(t), r = n.emptyStream.filter(Boolean).length, n.emptyFile = Array.from({ length: r }, () => !1);
|
|
191
|
+
break;
|
|
192
|
+
case b:
|
|
193
|
+
n.emptyFile = e.bitVector(r);
|
|
194
|
+
break;
|
|
195
|
+
case x:
|
|
196
|
+
if (e.byte() !== 0) throw Error("7z 不支持外部文件名");
|
|
197
|
+
n.names = F(e, o, t);
|
|
198
|
+
break;
|
|
199
|
+
default: break;
|
|
200
|
+
}
|
|
201
|
+
e.pos = o;
|
|
202
|
+
}
|
|
203
|
+
return n;
|
|
204
|
+
}
|
|
205
|
+
function F(e, t, n) {
|
|
206
|
+
let r = [], i = "";
|
|
207
|
+
for (; e.pos + 1 < t && r.length < n;) {
|
|
208
|
+
let t = e.byte() | e.byte() << 8;
|
|
209
|
+
t === 0 ? (r.push(i), i = "") : i += String.fromCharCode(t);
|
|
210
|
+
}
|
|
211
|
+
return r;
|
|
212
|
+
}
|
|
213
|
+
function I(e, t) {
|
|
214
|
+
let n = [], r = t.names.length, i = 0, a = 0, o = 0, s = 0, c = 0, l = () => {
|
|
215
|
+
for (; e && i < e.folders.length && a >= e.numUnpackStreamsInFolders[i];) i++, a = 0, o = 0;
|
|
216
|
+
};
|
|
217
|
+
for (let u = 0; u < r; u++) {
|
|
218
|
+
let r = t.names[u].replace(/\\/g, "/"), d = r.replace(/\/+$/, "").split("/").pop() ?? r;
|
|
219
|
+
if (t.emptyStream[u]) {
|
|
220
|
+
let e = t.emptyFile[c++] === !0;
|
|
221
|
+
n.push({
|
|
222
|
+
path: r,
|
|
223
|
+
name: d,
|
|
224
|
+
size: 0,
|
|
225
|
+
isDir: !e,
|
|
226
|
+
encrypted: !1,
|
|
227
|
+
folderIndex: -1,
|
|
228
|
+
offsetInFolder: 0
|
|
229
|
+
});
|
|
230
|
+
} else {
|
|
231
|
+
l();
|
|
232
|
+
let t = e ? e.subSizes[s++] : 0;
|
|
233
|
+
n.push({
|
|
234
|
+
path: r,
|
|
235
|
+
name: d,
|
|
236
|
+
size: t,
|
|
237
|
+
isDir: !1,
|
|
238
|
+
encrypted: e ? R(e.folders[i]) : !1,
|
|
239
|
+
folderIndex: i,
|
|
240
|
+
offsetInFolder: o
|
|
241
|
+
}), o += t, a++;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return n;
|
|
245
|
+
}
|
|
246
|
+
function L(e) {
|
|
247
|
+
let t = e.byte();
|
|
248
|
+
if (t !== c) throw Error(`7z 头部类型异常 (0x${t.toString(16)})`);
|
|
249
|
+
let n = e.byte(), r = null, i = {
|
|
250
|
+
names: [],
|
|
251
|
+
emptyStream: [],
|
|
252
|
+
emptyFile: []
|
|
253
|
+
};
|
|
254
|
+
return n === l && (r = j(e), n = e.byte()), n === u && (i = P(e), n = e.byte()), {
|
|
255
|
+
entries: I(r, i),
|
|
256
|
+
folders: r?.folders ?? []
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function R(e) {
|
|
260
|
+
return e.coders.some((e) => e.id === C);
|
|
261
|
+
}
|
|
262
|
+
function z(e) {
|
|
263
|
+
let t = new Uint8Array(e.length * 2);
|
|
264
|
+
for (let n = 0; n < e.length; n++) {
|
|
265
|
+
let r = e.charCodeAt(n);
|
|
266
|
+
t[2 * n] = r & 255, t[2 * n + 1] = r >> 8 & 255;
|
|
267
|
+
}
|
|
268
|
+
return t;
|
|
269
|
+
}
|
|
270
|
+
function B(e, n) {
|
|
271
|
+
let r = e[0] ?? 0, i = r & 63, a = r >> 7 & 1, o = r >> 6 & 1;
|
|
272
|
+
if (e.length >= 2) {
|
|
273
|
+
let t = e[1];
|
|
274
|
+
a += t >> 4, o += t & 15;
|
|
275
|
+
}
|
|
276
|
+
let s = e.subarray(2, 2 + a), c = new Uint8Array(16);
|
|
277
|
+
c.set(e.subarray(2 + a, 2 + a + o));
|
|
278
|
+
let l = z(n), u = new Uint8Array(32);
|
|
279
|
+
if (i === 63) {
|
|
280
|
+
let e = 0;
|
|
281
|
+
for (let t = 0; t < s.length && e < 32; t++) u[e++] = s[t];
|
|
282
|
+
for (let t = 0; t < l.length && e < 32; t++) u[e++] = l[t];
|
|
283
|
+
return {
|
|
284
|
+
key: u,
|
|
285
|
+
iv: c
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
let d = 2 ** i, f = new t(), p = new Uint8Array(8);
|
|
289
|
+
for (let e = 0; e < d; e++) {
|
|
290
|
+
s.length && f.update(s), f.update(l), f.update(p);
|
|
291
|
+
for (let e = 0; e < 8 && (p[e] = p[e] + 1 & 255, p[e] === 0); e++);
|
|
292
|
+
}
|
|
293
|
+
return u.set(f.digest()), {
|
|
294
|
+
key: u,
|
|
295
|
+
iv: c
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function V(t, a, o, s) {
|
|
299
|
+
switch (t.id) {
|
|
300
|
+
case "00": return a[0].length === o ? a[0] : a[0].subarray(0, o);
|
|
301
|
+
case "21": return r(a[0], t.props, o);
|
|
302
|
+
case "030101": return i(a[0], t.props, o);
|
|
303
|
+
case "03030103": {
|
|
304
|
+
let e = a[0].slice(0, o);
|
|
305
|
+
return n(e), e;
|
|
306
|
+
}
|
|
307
|
+
case C: {
|
|
308
|
+
if (!s?.password) throw new w();
|
|
309
|
+
let { key: n, iv: r } = B(t.props, s.password), i = e(n, r, a[0]);
|
|
310
|
+
return i.length === o ? i : i.subarray(0, o);
|
|
311
|
+
}
|
|
312
|
+
default: throw Error(`不支持的压缩方式 (coder ${t.id})`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function H(e, t, n) {
|
|
316
|
+
let r = [], i = [], a = 0, o = 0;
|
|
317
|
+
for (let e of t.coders) r.push(a), i.push(o), a += e.numIn, o += e.numOut;
|
|
318
|
+
let s = (e) => {
|
|
319
|
+
for (let n = 0; n < t.coders.length; n++) if (e >= i[n] && e < i[n] + t.coders[n].numOut) return n;
|
|
320
|
+
throw Error("7z folder 输出流索引越界");
|
|
321
|
+
}, c = /* @__PURE__ */ new Map(), l = (i) => {
|
|
322
|
+
let a = c.get(i);
|
|
323
|
+
if (a) return a;
|
|
324
|
+
let o = s(i), u = t.coders[o], d = [];
|
|
325
|
+
for (let n = 0; n < u.numIn; n++) {
|
|
326
|
+
let i = r[o] + n, a = t.bindPairs.find((e) => e.inIndex === i);
|
|
327
|
+
if (a) d.push(l(a.outIndex));
|
|
328
|
+
else {
|
|
329
|
+
let n = t.packedIndices.indexOf(i);
|
|
330
|
+
if (n < 0) throw Error("7z folder 输入流未绑定也非打包流");
|
|
331
|
+
let r = t.packStreams[n];
|
|
332
|
+
d.push(e.subarray(r.offset, r.offset + r.size));
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
let f = V(u, d, t.unpackSizes[i], n);
|
|
336
|
+
return c.set(i, f), f;
|
|
337
|
+
};
|
|
338
|
+
return l(k(t));
|
|
339
|
+
}
|
|
340
|
+
function U(e) {
|
|
341
|
+
if (e.byteLength < o) return !1;
|
|
342
|
+
let t = new Uint8Array(e, 0, a.length);
|
|
343
|
+
return a.every((e, n) => t[n] === e);
|
|
344
|
+
}
|
|
345
|
+
function W(e, t) {
|
|
346
|
+
if (!U(e)) throw Error("不是有效的 7z 文件");
|
|
347
|
+
let n = new DataView(e), r = new Uint8Array(e), i = D(n, 12), a = D(n, 20);
|
|
348
|
+
if (a === 0) return {
|
|
349
|
+
entries: [],
|
|
350
|
+
folders: []
|
|
351
|
+
};
|
|
352
|
+
let s = o + i;
|
|
353
|
+
if (s + a > e.byteLength) throw Error("7z 头部超出文件范围");
|
|
354
|
+
let l = r.subarray(s, s + a), u = new E(l), d = u.byte(), f = !1;
|
|
355
|
+
if (d === S) {
|
|
356
|
+
let e = j(u);
|
|
357
|
+
if (e.folders.length !== 1) throw Error("7z 编码头部格式异常");
|
|
358
|
+
f = R(e.folders[0]);
|
|
359
|
+
try {
|
|
360
|
+
l = H(r, e.folders[0], { password: t });
|
|
361
|
+
} catch (e) {
|
|
362
|
+
throw f && t && !(e instanceof w) ? new T() : e;
|
|
363
|
+
}
|
|
364
|
+
u = new E(l), d = u.byte();
|
|
365
|
+
}
|
|
366
|
+
if (d !== c) throw f && t ? new T() : Error(`7z 头部类型异常 (0x${d.toString(16)})`);
|
|
367
|
+
u.pos = 0;
|
|
368
|
+
try {
|
|
369
|
+
return L(u);
|
|
370
|
+
} catch (e) {
|
|
371
|
+
throw f && t ? new T() : e;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
var G = null, K = null;
|
|
375
|
+
function q(e, t, n, r) {
|
|
376
|
+
if (n.isDir || n.folderIndex < 0 || n.size === 0) return new Uint8Array();
|
|
377
|
+
let i = t.folders[n.folderIndex];
|
|
378
|
+
if (!i) throw Error("7z 条目缺少对应 folder");
|
|
379
|
+
let a;
|
|
380
|
+
if (K && G && G.buf === e && G.index === n.folderIndex) a = K;
|
|
381
|
+
else {
|
|
382
|
+
try {
|
|
383
|
+
a = H(new Uint8Array(e), i, { password: r });
|
|
384
|
+
} catch (e) {
|
|
385
|
+
throw R(i) && r && !(e instanceof w) ? new T() : e;
|
|
386
|
+
}
|
|
387
|
+
G = {
|
|
388
|
+
buf: e,
|
|
389
|
+
index: n.folderIndex
|
|
390
|
+
}, K = a;
|
|
391
|
+
}
|
|
392
|
+
return a.subarray(n.offsetInFolder, n.offsetInFolder + n.size).slice();
|
|
393
|
+
}
|
|
394
|
+
//#endregion
|
|
395
|
+
export { w as SevenZipEncryptedError, T as SevenZipPasswordError, q as extractSevenZipEntry, W as readSevenZip };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal synchronous SHA-1 (FIPS 180-4) — no dependency, no WASM.
|
|
3
|
+
*
|
|
4
|
+
* JKS / JCEKS keystores lean on SHA-1 in two synchronous, tight loops (see lib/jks.ts): the store-integrity
|
|
5
|
+
* MAC — SHA1(passwordUtf16BE ‖ "Mighty Aphrodite" ‖ storeBytes) — and Sun's KeyProtector, which chains SHA-1
|
|
6
|
+
* over password‖runningDigest once per 20 bytes of key material. WebCrypto's digest is async + one-shot, which
|
|
7
|
+
* would turn the whole parse path async and force a throwaway buffer each round; this incremental hasher stays
|
|
8
|
+
* synchronous and lets the KeyProtector feed the password + running digest directly, mirroring {@link Sha256}.
|
|
9
|
+
*
|
|
10
|
+
* SHA-1 is broken for collision resistance — used here ONLY because the JKS on-disk format mandates it, never
|
|
11
|
+
* as a security primitive for anything new. Not constant-time (fine for reading a keystore locally).
|
|
12
|
+
*/
|
|
13
|
+
export declare class Sha1 {
|
|
14
|
+
private readonly h;
|
|
15
|
+
private readonly block;
|
|
16
|
+
private readonly w;
|
|
17
|
+
private blen;
|
|
18
|
+
private total;
|
|
19
|
+
update(data: Uint8Array): this;
|
|
20
|
+
digest(): Uint8Array;
|
|
21
|
+
private compress;
|
|
22
|
+
}
|
|
23
|
+
/** One-shot convenience: SHA-1 of a single buffer. */
|
|
24
|
+
export declare function sha1(data: Uint8Array): Uint8Array;
|
package/dist/lib/sha1.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//#region src/lib/sha1.ts
|
|
2
|
+
var e = class {
|
|
3
|
+
h = new Uint32Array([
|
|
4
|
+
1732584193,
|
|
5
|
+
4023233417,
|
|
6
|
+
2562383102,
|
|
7
|
+
271733878,
|
|
8
|
+
3285377520
|
|
9
|
+
]);
|
|
10
|
+
block = new Uint8Array(64);
|
|
11
|
+
w = new Uint32Array(80);
|
|
12
|
+
blen = 0;
|
|
13
|
+
total = 0;
|
|
14
|
+
update(e) {
|
|
15
|
+
this.total += e.length;
|
|
16
|
+
for (let t = 0; t < e.length; t++) this.block[this.blen++] = e[t], this.blen === 64 && (this.compress(), this.blen = 0);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
digest() {
|
|
20
|
+
let e = this.total * 8;
|
|
21
|
+
if (this.block[this.blen++] = 128, this.blen > 56) {
|
|
22
|
+
for (; this.blen < 64;) this.block[this.blen++] = 0;
|
|
23
|
+
this.compress(), this.blen = 0;
|
|
24
|
+
}
|
|
25
|
+
for (; this.blen < 56;) this.block[this.blen++] = 0;
|
|
26
|
+
let t = Math.floor(e / 4294967296), n = e >>> 0;
|
|
27
|
+
this.block[56] = t >>> 24 & 255, this.block[57] = t >>> 16 & 255, this.block[58] = t >>> 8 & 255, this.block[59] = t & 255, this.block[60] = n >>> 24 & 255, this.block[61] = n >>> 16 & 255, this.block[62] = n >>> 8 & 255, this.block[63] = n & 255, this.compress();
|
|
28
|
+
let r = new Uint8Array(20);
|
|
29
|
+
for (let e = 0; e < 5; e++) r[4 * e] = this.h[e] >>> 24 & 255, r[4 * e + 1] = this.h[e] >>> 16 & 255, r[4 * e + 2] = this.h[e] >>> 8 & 255, r[4 * e + 3] = this.h[e] & 255;
|
|
30
|
+
return r;
|
|
31
|
+
}
|
|
32
|
+
compress() {
|
|
33
|
+
let e = this.w, t = this.block;
|
|
34
|
+
for (let n = 0; n < 16; n++) e[n] = t[4 * n] << 24 | t[4 * n + 1] << 16 | t[4 * n + 2] << 8 | t[4 * n + 3];
|
|
35
|
+
for (let t = 16; t < 80; t++) {
|
|
36
|
+
let n = e[t - 3] ^ e[t - 8] ^ e[t - 14] ^ e[t - 16];
|
|
37
|
+
e[t] = n << 1 | n >>> 31;
|
|
38
|
+
}
|
|
39
|
+
let n = this.h[0], r = this.h[1], i = this.h[2], a = this.h[3], o = this.h[4];
|
|
40
|
+
for (let t = 0; t < 80; t++) {
|
|
41
|
+
let s, c;
|
|
42
|
+
t < 20 ? (s = r & i | ~r & a, c = 1518500249) : t < 40 ? (s = r ^ i ^ a, c = 1859775393) : t < 60 ? (s = r & i | r & a | i & a, c = 2400959708) : (s = r ^ i ^ a, c = 3395469782);
|
|
43
|
+
let l = (n << 5 | n >>> 27) + s + o + c + e[t] | 0;
|
|
44
|
+
o = a, a = i, i = r << 30 | r >>> 2, r = n, n = l;
|
|
45
|
+
}
|
|
46
|
+
this.h[0] = this.h[0] + n | 0, this.h[1] = this.h[1] + r | 0, this.h[2] = this.h[2] + i | 0, this.h[3] = this.h[3] + a | 0, this.h[4] = this.h[4] + o | 0;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function t(t) {
|
|
50
|
+
return new e().update(t).digest();
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { e as Sha1, t as sha1 };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal synchronous SHA-256 (FIPS 180-4) — no dependency, no WASM.
|
|
3
|
+
*
|
|
4
|
+
* WebCrypto's digest is async and one-shot (no streaming), which is awkward for the 7z key-derivation loop
|
|
5
|
+
* that hashes salt‖password‖counter hundreds of thousands of times: a one-shot API would force a ~10 MB
|
|
6
|
+
* throwaway buffer AND make the whole 7z decode path async. This incremental hasher lets {@link lib/sevenZip}
|
|
7
|
+
* feed each round's bytes directly and stay synchronous. Not constant-time — fine for archive key derivation,
|
|
8
|
+
* not for anything that must resist timing attacks.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Sha256 {
|
|
11
|
+
private readonly h;
|
|
12
|
+
private readonly block;
|
|
13
|
+
private readonly w;
|
|
14
|
+
private blen;
|
|
15
|
+
private total;
|
|
16
|
+
update(data: Uint8Array): this;
|
|
17
|
+
digest(): Uint8Array;
|
|
18
|
+
private compress;
|
|
19
|
+
}
|
|
20
|
+
/** One-shot convenience: SHA-256 of a single buffer. */
|
|
21
|
+
export declare function sha256(data: Uint8Array): Uint8Array;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
//#region src/lib/sha256.ts
|
|
2
|
+
var e = /* @__PURE__ */ new Uint32Array([
|
|
3
|
+
1116352408,
|
|
4
|
+
1899447441,
|
|
5
|
+
3049323471,
|
|
6
|
+
3921009573,
|
|
7
|
+
961987163,
|
|
8
|
+
1508970993,
|
|
9
|
+
2453635748,
|
|
10
|
+
2870763221,
|
|
11
|
+
3624381080,
|
|
12
|
+
310598401,
|
|
13
|
+
607225278,
|
|
14
|
+
1426881987,
|
|
15
|
+
1925078388,
|
|
16
|
+
2162078206,
|
|
17
|
+
2614888103,
|
|
18
|
+
3248222580,
|
|
19
|
+
3835390401,
|
|
20
|
+
4022224774,
|
|
21
|
+
264347078,
|
|
22
|
+
604807628,
|
|
23
|
+
770255983,
|
|
24
|
+
1249150122,
|
|
25
|
+
1555081692,
|
|
26
|
+
1996064986,
|
|
27
|
+
2554220882,
|
|
28
|
+
2821834349,
|
|
29
|
+
2952996808,
|
|
30
|
+
3210313671,
|
|
31
|
+
3336571891,
|
|
32
|
+
3584528711,
|
|
33
|
+
113926993,
|
|
34
|
+
338241895,
|
|
35
|
+
666307205,
|
|
36
|
+
773529912,
|
|
37
|
+
1294757372,
|
|
38
|
+
1396182291,
|
|
39
|
+
1695183700,
|
|
40
|
+
1986661051,
|
|
41
|
+
2177026350,
|
|
42
|
+
2456956037,
|
|
43
|
+
2730485921,
|
|
44
|
+
2820302411,
|
|
45
|
+
3259730800,
|
|
46
|
+
3345764771,
|
|
47
|
+
3516065817,
|
|
48
|
+
3600352804,
|
|
49
|
+
4094571909,
|
|
50
|
+
275423344,
|
|
51
|
+
430227734,
|
|
52
|
+
506948616,
|
|
53
|
+
659060556,
|
|
54
|
+
883997877,
|
|
55
|
+
958139571,
|
|
56
|
+
1322822218,
|
|
57
|
+
1537002063,
|
|
58
|
+
1747873779,
|
|
59
|
+
1955562222,
|
|
60
|
+
2024104815,
|
|
61
|
+
2227730452,
|
|
62
|
+
2361852424,
|
|
63
|
+
2428436474,
|
|
64
|
+
2756734187,
|
|
65
|
+
3204031479,
|
|
66
|
+
3329325298
|
|
67
|
+
]), t = class {
|
|
68
|
+
h = new Uint32Array([
|
|
69
|
+
1779033703,
|
|
70
|
+
3144134277,
|
|
71
|
+
1013904242,
|
|
72
|
+
2773480762,
|
|
73
|
+
1359893119,
|
|
74
|
+
2600822924,
|
|
75
|
+
528734635,
|
|
76
|
+
1541459225
|
|
77
|
+
]);
|
|
78
|
+
block = new Uint8Array(64);
|
|
79
|
+
w = new Uint32Array(64);
|
|
80
|
+
blen = 0;
|
|
81
|
+
total = 0;
|
|
82
|
+
update(e) {
|
|
83
|
+
this.total += e.length;
|
|
84
|
+
for (let t = 0; t < e.length; t++) this.block[this.blen++] = e[t], this.blen === 64 && (this.compress(), this.blen = 0);
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
digest() {
|
|
88
|
+
let e = this.total * 8;
|
|
89
|
+
if (this.block[this.blen++] = 128, this.blen > 56) {
|
|
90
|
+
for (; this.blen < 64;) this.block[this.blen++] = 0;
|
|
91
|
+
this.compress(), this.blen = 0;
|
|
92
|
+
}
|
|
93
|
+
for (; this.blen < 56;) this.block[this.blen++] = 0;
|
|
94
|
+
let t = Math.floor(e / 4294967296), n = e >>> 0;
|
|
95
|
+
this.block[56] = t >>> 24 & 255, this.block[57] = t >>> 16 & 255, this.block[58] = t >>> 8 & 255, this.block[59] = t & 255, this.block[60] = n >>> 24 & 255, this.block[61] = n >>> 16 & 255, this.block[62] = n >>> 8 & 255, this.block[63] = n & 255, this.compress();
|
|
96
|
+
let r = new Uint8Array(32);
|
|
97
|
+
for (let e = 0; e < 8; e++) r[4 * e] = this.h[e] >>> 24 & 255, r[4 * e + 1] = this.h[e] >>> 16 & 255, r[4 * e + 2] = this.h[e] >>> 8 & 255, r[4 * e + 3] = this.h[e] & 255;
|
|
98
|
+
return r;
|
|
99
|
+
}
|
|
100
|
+
compress() {
|
|
101
|
+
let t = this.w, n = this.block;
|
|
102
|
+
for (let e = 0; e < 16; e++) t[e] = n[4 * e] << 24 | n[4 * e + 1] << 16 | n[4 * e + 2] << 8 | n[4 * e + 3];
|
|
103
|
+
for (let e = 16; e < 64; e++) {
|
|
104
|
+
let n = t[e - 15], r = t[e - 2], i = (n >>> 7 | n << 25) ^ (n >>> 18 | n << 14) ^ n >>> 3, a = (r >>> 17 | r << 15) ^ (r >>> 19 | r << 13) ^ r >>> 10;
|
|
105
|
+
t[e] = t[e - 16] + i + t[e - 7] + a | 0;
|
|
106
|
+
}
|
|
107
|
+
let r = this.h[0], i = this.h[1], a = this.h[2], o = this.h[3], s = this.h[4], c = this.h[5], l = this.h[6], u = this.h[7];
|
|
108
|
+
for (let n = 0; n < 64; n++) {
|
|
109
|
+
let d = (s >>> 6 | s << 26) ^ (s >>> 11 | s << 21) ^ (s >>> 25 | s << 7), f = s & c ^ ~s & l, p = u + d + f + e[n] + t[n] | 0, m = ((r >>> 2 | r << 30) ^ (r >>> 13 | r << 19) ^ (r >>> 22 | r << 10)) + (r & i ^ r & a ^ i & a) | 0;
|
|
110
|
+
u = l, l = c, c = s, s = o + p | 0, o = a, a = i, i = r, r = p + m | 0;
|
|
111
|
+
}
|
|
112
|
+
this.h[0] = this.h[0] + r | 0, this.h[1] = this.h[1] + i | 0, this.h[2] = this.h[2] + a | 0, this.h[3] = this.h[3] + o | 0, this.h[4] = this.h[4] + s | 0, this.h[5] = this.h[5] + c | 0, this.h[6] = this.h[6] + l | 0, this.h[7] = this.h[7] + u | 0;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
function n(e) {
|
|
116
|
+
return new t().update(e).digest();
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
export { t as Sha256, n as sha256 };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 语音编解码(3GPP AMR / 腾讯 SILK)→ WAV 的浏览器内解码器 —— 按需懒加载 WASM。
|
|
3
|
+
*
|
|
4
|
+
* 浏览器原生 <audio> 不认 3GPP AMR,也不认腾讯 SILK(微信 / QQ 语音;文件常见 `.silk` / `.slk`,也
|
|
5
|
+
* 大量以 `.amr` 为扩展名而内容其实是 SILK)。两者都是 CELP 系语音编解码,无法手搓,故各引一个编译好的
|
|
6
|
+
* WASM 解码器(与 lib/brotli、lib/sqlite 的 wasm 同思路:仅在真正播放这类文件时才 `import()`):
|
|
7
|
+
* - AMR-NB(8kHz) / AMR-WB(16kHz):`@audio/decode-amr`(opencore-amr 编译;wasm 内联进 .cjs,无独立资源)
|
|
8
|
+
* - SILK v3:`silk-wasm`(腾讯 SILK 编解码;独立 `silk.wasm`,Vite 经 `import.meta.url` 产出同源资源)
|
|
9
|
+
*
|
|
10
|
+
* 解出 PCM(s16le) 后用手写的 44 字节 PCM WAV 头包成 WAV,交给 <audio> 原生播放(同 QMC 解密后播放)。
|
|
11
|
+
* 识别一律按**文件头魔数**而非扩展名 —— 微信 `.amr` 实为 SILK,故 `.amr` 既可能是真 AMR 也可能是 SILK。
|
|
12
|
+
*/
|
|
13
|
+
export type SpeechCodec = 'silk' | 'amr-nb' | 'amr-wb';
|
|
14
|
+
/**
|
|
15
|
+
* 按文件头判别语音编解码;非语音编解码(普通 mp3/wav/… 或无法识别)返回 null。
|
|
16
|
+
* SILK 容器有两种头:Skype 裸头 `#!SILK_V3`(偏移 0)与腾讯头 `\x02#!SILK_V3`(偏移 1)。
|
|
17
|
+
* AMR-WB 必须先于 AMR-NB 判断(`#!AMR` 是 `#!AMR-WB` 的前缀)。
|
|
18
|
+
*/
|
|
19
|
+
export declare function sniffSpeechCodec(bytes: Uint8Array): SpeechCodec | null;
|
|
20
|
+
export interface DecodedSpeech {
|
|
21
|
+
/** 完整 WAV 字节(44 字节头 + PCM s16le)。 */
|
|
22
|
+
wav: Uint8Array;
|
|
23
|
+
codec: SpeechCodec;
|
|
24
|
+
sampleRate: number;
|
|
25
|
+
channels: number;
|
|
26
|
+
durationSec: number;
|
|
27
|
+
}
|
|
28
|
+
export declare class SpeechDecodeError extends Error {
|
|
29
|
+
}
|
|
30
|
+
/** 用 PCM s16le 数据包出一段标准 44 字节头的 WAV(单声道、16 位)。 */
|
|
31
|
+
export declare function wavFromPcmS16le(pcm: Uint8Array, sampleRate: number, channels?: number): Uint8Array;
|
|
32
|
+
/**
|
|
33
|
+
* 把一段 AMR / SILK 语音字节解码成可播放的 WAV:先 {@link sniffSpeechCodec} 判型,再懒加载对应 WASM
|
|
34
|
+
* 解码器解出 PCM 并包成 WAV。非 AMR/SILK 抛 {@link SpeechDecodeError}(调用方据此回退原生播放)。
|
|
35
|
+
*/
|
|
36
|
+
export declare function decodeSpeechToWav(input: ArrayBuffer | Uint8Array): Promise<DecodedSpeech>;
|