@zip.js/zip.js 2.7.21 → 2.7.23
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/zip-fs-full.js +884 -234
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +60 -45
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +60 -45
- package/dist/zip-full.min.js +1 -1
- package/dist/zip-no-worker-deflate.min.js +1 -1
- package/dist/zip-no-worker-inflate.min.js +1 -1
- package/dist/zip-no-worker.min.js +1 -1
- package/dist/zip.js +60 -45
- package/dist/zip.min.js +1 -1
- package/index.cjs +884 -234
- package/index.min.js +1 -0
- package/lib/core/util/mime-type.js +824 -189
- package/lib/core/zip-reader.js +18 -13
- package/lib/core/zip-writer.js +42 -32
- package/package.json +4 -2
package/lib/core/zip-reader.js
CHANGED
|
@@ -383,7 +383,7 @@ class ZipEntry {
|
|
|
383
383
|
localDirectory.rawExtraField = localDirectory.extraFieldLength ?
|
|
384
384
|
await readUint8Array(reader, offset + 30 + localDirectory.filenameLength, localDirectory.extraFieldLength, diskNumberStart) :
|
|
385
385
|
new Uint8Array();
|
|
386
|
-
await readCommonFooter(zipEntry, localDirectory, dataView, 4);
|
|
386
|
+
await readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
|
|
387
387
|
Object.assign(fileEntry, {
|
|
388
388
|
lastAccessDate: localDirectory.lastAccessDate,
|
|
389
389
|
creationDate: localDirectory.creationDate
|
|
@@ -470,7 +470,7 @@ function readCommonHeader(directory, dataView, offset) {
|
|
|
470
470
|
});
|
|
471
471
|
}
|
|
472
472
|
|
|
473
|
-
async function readCommonFooter(fileEntry, directory, dataView, offset) {
|
|
473
|
+
async function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory) {
|
|
474
474
|
const { rawExtraField } = directory;
|
|
475
475
|
const extraField = directory.extraField = new Map();
|
|
476
476
|
const rawExtraFieldView = getDataView(new Uint8Array(rawExtraField));
|
|
@@ -523,7 +523,7 @@ async function readCommonFooter(fileEntry, directory, dataView, offset) {
|
|
|
523
523
|
}
|
|
524
524
|
const extraFieldExtendedTimestamp = extraField.get(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
525
525
|
if (extraFieldExtendedTimestamp) {
|
|
526
|
-
readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory);
|
|
526
|
+
readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory, localDirectory);
|
|
527
527
|
directory.extraFieldExtendedTimestamp = extraFieldExtendedTimestamp;
|
|
528
528
|
}
|
|
529
529
|
}
|
|
@@ -614,23 +614,28 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
|
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
-
function readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory) {
|
|
617
|
+
function readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory, localDirectory) {
|
|
618
618
|
const extraFieldView = getDataView(extraFieldExtendedTimestamp.data);
|
|
619
619
|
const flags = getUint8(extraFieldView, 0);
|
|
620
620
|
const timeProperties = [];
|
|
621
621
|
const timeRawProperties = [];
|
|
622
|
-
if (
|
|
622
|
+
if (localDirectory) {
|
|
623
|
+
if ((flags & 0x1) == 0x1) {
|
|
624
|
+
timeProperties.push(PROPERTY_NAME_LAST_MODIFICATION_DATE);
|
|
625
|
+
timeRawProperties.push(PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE);
|
|
626
|
+
}
|
|
627
|
+
if ((flags & 0x2) == 0x2) {
|
|
628
|
+
timeProperties.push(PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
629
|
+
timeRawProperties.push(PROPERTY_NAME_RAW_LAST_ACCESS_DATE);
|
|
630
|
+
}
|
|
631
|
+
if ((flags & 0x4) == 0x4) {
|
|
632
|
+
timeProperties.push(PROPERTY_NAME_CREATION_DATE);
|
|
633
|
+
timeRawProperties.push(PROPERTY_NAME_RAW_CREATION_DATE);
|
|
634
|
+
}
|
|
635
|
+
} else if (extraFieldExtendedTimestamp.data.length >= 5) {
|
|
623
636
|
timeProperties.push(PROPERTY_NAME_LAST_MODIFICATION_DATE);
|
|
624
637
|
timeRawProperties.push(PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE);
|
|
625
638
|
}
|
|
626
|
-
if ((flags & 0x2) == 0x2) {
|
|
627
|
-
timeProperties.push(PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
628
|
-
timeRawProperties.push(PROPERTY_NAME_RAW_LAST_ACCESS_DATE);
|
|
629
|
-
}
|
|
630
|
-
if ((flags & 0x4) == 0x4) {
|
|
631
|
-
timeProperties.push(PROPERTY_NAME_CREATION_DATE);
|
|
632
|
-
timeRawProperties.push(PROPERTY_NAME_RAW_CREATION_DATE);
|
|
633
|
-
}
|
|
634
639
|
let offset = 1;
|
|
635
640
|
timeProperties.forEach((propertyName, indexProperty) => {
|
|
636
641
|
if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
|
package/lib/core/zip-writer.js
CHANGED
|
@@ -482,6 +482,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
482
482
|
version,
|
|
483
483
|
compressionMethod,
|
|
484
484
|
rawExtraFieldExtendedTimestamp,
|
|
485
|
+
extraFieldExtendedTimestampFlag,
|
|
485
486
|
rawExtraFieldNTFS,
|
|
486
487
|
rawExtraFieldAES
|
|
487
488
|
} = headerInfo;
|
|
@@ -613,6 +614,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
613
614
|
headerArray,
|
|
614
615
|
signature,
|
|
615
616
|
rawExtraFieldZip64,
|
|
617
|
+
extraFieldExtendedTimestampFlag,
|
|
616
618
|
zip64UncompressedSize,
|
|
617
619
|
zip64CompressedSize,
|
|
618
620
|
zip64Offset,
|
|
@@ -635,7 +637,7 @@ function getHeaderInfo(options) {
|
|
|
635
637
|
directory,
|
|
636
638
|
rawExtraField,
|
|
637
639
|
encryptionStrength,
|
|
638
|
-
extendedTimestamp
|
|
640
|
+
extendedTimestamp
|
|
639
641
|
} = options;
|
|
640
642
|
const compressed = level !== 0 && !directory;
|
|
641
643
|
const encrypted = Boolean(password && getLength(password));
|
|
@@ -652,19 +654,23 @@ function getHeaderInfo(options) {
|
|
|
652
654
|
}
|
|
653
655
|
let rawExtraFieldNTFS;
|
|
654
656
|
let rawExtraFieldExtendedTimestamp;
|
|
657
|
+
let extraFieldExtendedTimestampFlag;
|
|
655
658
|
if (extendedTimestamp) {
|
|
656
659
|
rawExtraFieldExtendedTimestamp = new Uint8Array(9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0));
|
|
657
660
|
const extraFieldExtendedTimestampView = getDataView(rawExtraFieldExtendedTimestamp);
|
|
658
661
|
setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
659
662
|
setUint16(extraFieldExtendedTimestampView, 2, getLength(rawExtraFieldExtendedTimestamp) - 4);
|
|
660
|
-
|
|
663
|
+
extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
|
|
661
664
|
setUint8(extraFieldExtendedTimestampView, 4, extraFieldExtendedTimestampFlag);
|
|
662
|
-
|
|
665
|
+
let offset = 5;
|
|
666
|
+
setUint32(extraFieldExtendedTimestampView, offset, Math.floor(lastModDate.getTime() / 1000));
|
|
667
|
+
offset += 4;
|
|
663
668
|
if (lastAccessDate) {
|
|
664
|
-
setUint32(extraFieldExtendedTimestampView,
|
|
669
|
+
setUint32(extraFieldExtendedTimestampView, offset, Math.floor(lastAccessDate.getTime() / 1000));
|
|
670
|
+
offset += 4;
|
|
665
671
|
}
|
|
666
672
|
if (creationDate) {
|
|
667
|
-
setUint32(extraFieldExtendedTimestampView,
|
|
673
|
+
setUint32(extraFieldExtendedTimestampView, offset, Math.floor(creationDate.getTime() / 1000));
|
|
668
674
|
}
|
|
669
675
|
try {
|
|
670
676
|
rawExtraFieldNTFS = new Uint8Array(36);
|
|
@@ -745,6 +751,7 @@ function getHeaderInfo(options) {
|
|
|
745
751
|
compressed,
|
|
746
752
|
version,
|
|
747
753
|
compressionMethod,
|
|
754
|
+
extraFieldExtendedTimestampFlag,
|
|
748
755
|
rawExtraFieldExtendedTimestamp,
|
|
749
756
|
rawExtraFieldNTFS,
|
|
750
757
|
rawExtraFieldAES
|
|
@@ -881,23 +888,38 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
881
888
|
let directoryDataLength = 0;
|
|
882
889
|
let directoryOffset = zipWriter.offset - diskOffset;
|
|
883
890
|
let filesLength = files.size;
|
|
884
|
-
for (const [, {
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
891
|
+
for (const [, fileEntry] of files) {
|
|
892
|
+
const {
|
|
893
|
+
rawFilename,
|
|
894
|
+
rawExtraFieldZip64,
|
|
895
|
+
rawExtraFieldAES,
|
|
896
|
+
rawComment,
|
|
897
|
+
rawExtraFieldNTFS,
|
|
898
|
+
rawExtraField,
|
|
899
|
+
extendedTimestamp,
|
|
900
|
+
extraFieldExtendedTimestampFlag,
|
|
901
|
+
lastModDate
|
|
902
|
+
} = fileEntry;
|
|
903
|
+
let rawExtraFieldTimestamp;
|
|
904
|
+
if (extendedTimestamp) {
|
|
905
|
+
rawExtraFieldTimestamp = new Uint8Array(9);
|
|
906
|
+
const extraFieldExtendedTimestampView = getDataView(rawExtraFieldTimestamp);
|
|
907
|
+
setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
908
|
+
setUint16(extraFieldExtendedTimestampView, 2, 5);
|
|
909
|
+
setUint8(extraFieldExtendedTimestampView, 4, extraFieldExtendedTimestampFlag);
|
|
910
|
+
setUint32(extraFieldExtendedTimestampView, 5, Math.floor(lastModDate.getTime() / 1000));
|
|
911
|
+
} else {
|
|
912
|
+
rawExtraFieldTimestamp = new Uint8Array();
|
|
913
|
+
}
|
|
914
|
+
fileEntry.rawExtraFieldCDExtendedTimestamp = rawExtraFieldTimestamp;
|
|
893
915
|
directoryDataLength += 46 +
|
|
894
916
|
getLength(
|
|
895
917
|
rawFilename,
|
|
896
918
|
rawComment,
|
|
897
919
|
rawExtraFieldZip64,
|
|
898
920
|
rawExtraFieldAES,
|
|
899
|
-
rawExtraFieldExtendedTimestamp,
|
|
900
921
|
rawExtraFieldNTFS,
|
|
922
|
+
rawExtraFieldTimestamp,
|
|
901
923
|
rawExtraField);
|
|
902
924
|
}
|
|
903
925
|
const directoryArray = new Uint8Array(directoryDataLength);
|
|
@@ -910,6 +932,7 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
910
932
|
rawFilename,
|
|
911
933
|
rawExtraFieldZip64,
|
|
912
934
|
rawExtraFieldAES,
|
|
935
|
+
rawExtraFieldCDExtendedTimestamp,
|
|
913
936
|
rawExtraFieldNTFS,
|
|
914
937
|
rawExtraField,
|
|
915
938
|
rawComment,
|
|
@@ -924,24 +947,11 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
924
947
|
msDosCompatible,
|
|
925
948
|
internalFileAttribute,
|
|
926
949
|
externalFileAttribute,
|
|
927
|
-
extendedTimestamp,
|
|
928
|
-
lastModDate,
|
|
929
950
|
diskNumberStart,
|
|
930
951
|
uncompressedSize,
|
|
931
952
|
compressedSize
|
|
932
953
|
} = fileEntry;
|
|
933
|
-
|
|
934
|
-
if (extendedTimestamp) {
|
|
935
|
-
rawExtraFieldExtendedTimestamp = new Uint8Array(9);
|
|
936
|
-
const extraFieldExtendedTimestampView = getDataView(rawExtraFieldExtendedTimestamp);
|
|
937
|
-
setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
938
|
-
setUint16(extraFieldExtendedTimestampView, 2, getLength(rawExtraFieldExtendedTimestamp) - 4);
|
|
939
|
-
setUint8(extraFieldExtendedTimestampView, 4, 0x1);
|
|
940
|
-
setUint32(extraFieldExtendedTimestampView, 5, Math.floor(lastModDate.getTime() / 1000));
|
|
941
|
-
} else {
|
|
942
|
-
rawExtraFieldExtendedTimestamp = new Uint8Array();
|
|
943
|
-
}
|
|
944
|
-
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraField);
|
|
954
|
+
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldCDExtendedTimestamp, rawExtraFieldNTFS, rawExtraField);
|
|
945
955
|
setUint32(directoryView, offset, CENTRAL_FILE_HEADER_SIGNATURE);
|
|
946
956
|
setUint16(directoryView, offset + 4, versionMadeBy);
|
|
947
957
|
const headerView = getDataView(headerArray);
|
|
@@ -965,9 +975,9 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
965
975
|
arraySet(directoryArray, rawFilename, offset + 46);
|
|
966
976
|
arraySet(directoryArray, rawExtraFieldZip64, offset + 46 + getLength(rawFilename));
|
|
967
977
|
arraySet(directoryArray, rawExtraFieldAES, offset + 46 + getLength(rawFilename, rawExtraFieldZip64));
|
|
968
|
-
arraySet(directoryArray,
|
|
969
|
-
arraySet(directoryArray, rawExtraFieldNTFS, offset + 46 + getLength(rawFilename, rawExtraFieldZip64, rawExtraFieldAES,
|
|
970
|
-
arraySet(directoryArray, rawExtraField, offset + 46 + getLength(rawFilename, rawExtraFieldZip64, rawExtraFieldAES,
|
|
978
|
+
arraySet(directoryArray, rawExtraFieldCDExtendedTimestamp, offset + 46 + getLength(rawFilename, rawExtraFieldZip64, rawExtraFieldAES));
|
|
979
|
+
arraySet(directoryArray, rawExtraFieldNTFS, offset + 46 + getLength(rawFilename, rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldCDExtendedTimestamp));
|
|
980
|
+
arraySet(directoryArray, rawExtraField, offset + 46 + getLength(rawFilename, rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldCDExtendedTimestamp, rawExtraFieldNTFS));
|
|
971
981
|
arraySet(directoryArray, rawComment, offset + 46 + getLength(rawFilename) + extraFieldLength);
|
|
972
982
|
const directoryEntryLength = 46 + getLength(rawFilename, rawComment) + extraFieldLength;
|
|
973
983
|
if (offset - directoryDiskOffset > writer.availableSize) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A JavaScript library to zip and unzip files in the browser, Deno and Node.js",
|
|
4
4
|
"author": "Gildas Lormeau",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
|
-
"version": "2.7.
|
|
6
|
+
"version": "2.7.23",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"zip",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
],
|
|
28
28
|
"engines": {
|
|
29
29
|
"deno": ">=1.0.0",
|
|
30
|
-
"node": ">=16.5.0"
|
|
30
|
+
"node": ">=16.5.0",
|
|
31
|
+
"bun": ">=0.7.0"
|
|
31
32
|
},
|
|
32
33
|
"scripts": {
|
|
33
34
|
"build": "npx rollup -c",
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
"types": "./index.d.ts",
|
|
47
48
|
"exports": {
|
|
48
49
|
"./package.json": "./package.json",
|
|
50
|
+
"./index.min.js": "./index.min.js",
|
|
49
51
|
".": {
|
|
50
52
|
"import": {
|
|
51
53
|
"types": "./index.d.ts",
|