@neoware_inc/neozipkit 0.5.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/README.md +134 -0
- package/dist/browser/ZipkitBrowser.d.ts +27 -0
- package/dist/browser/ZipkitBrowser.d.ts.map +1 -0
- package/dist/browser/ZipkitBrowser.js +303 -0
- package/dist/browser/ZipkitBrowser.js.map +1 -0
- package/dist/browser/index.d.ts +9 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.esm.d.ts +12 -0
- package/dist/browser/index.esm.d.ts.map +1 -0
- package/dist/browser/index.esm.js +46 -0
- package/dist/browser/index.esm.js.map +1 -0
- package/dist/browser/index.js +38 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser-esm/index.d.ts +9 -0
- package/dist/browser-esm/index.js +50211 -0
- package/dist/browser-esm/index.js.map +7 -0
- package/dist/browser-umd/index.d.ts +9 -0
- package/dist/browser-umd/index.js +50221 -0
- package/dist/browser-umd/index.js.map +7 -0
- package/dist/browser-umd/index.min.js +39 -0
- package/dist/browser.d.ts +9 -0
- package/dist/browser.js +38 -0
- package/dist/core/ZipCompress.d.ts +99 -0
- package/dist/core/ZipCompress.d.ts.map +1 -0
- package/dist/core/ZipCompress.js +287 -0
- package/dist/core/ZipCompress.js.map +1 -0
- package/dist/core/ZipCopy.d.ts +175 -0
- package/dist/core/ZipCopy.d.ts.map +1 -0
- package/dist/core/ZipCopy.js +310 -0
- package/dist/core/ZipCopy.js.map +1 -0
- package/dist/core/ZipDecompress.d.ts +57 -0
- package/dist/core/ZipDecompress.d.ts.map +1 -0
- package/dist/core/ZipDecompress.js +155 -0
- package/dist/core/ZipDecompress.js.map +1 -0
- package/dist/core/ZipEntry.d.ts +138 -0
- package/dist/core/ZipEntry.d.ts.map +1 -0
- package/dist/core/ZipEntry.js +829 -0
- package/dist/core/ZipEntry.js.map +1 -0
- package/dist/core/Zipkit.d.ts +315 -0
- package/dist/core/Zipkit.d.ts.map +1 -0
- package/dist/core/Zipkit.js +647 -0
- package/dist/core/Zipkit.js.map +1 -0
- package/dist/core/ZstdManager.d.ts +56 -0
- package/dist/core/ZstdManager.d.ts.map +1 -0
- package/dist/core/ZstdManager.js +144 -0
- package/dist/core/ZstdManager.js.map +1 -0
- package/dist/core/components/HashCalculator.d.ts +138 -0
- package/dist/core/components/HashCalculator.d.ts.map +1 -0
- package/dist/core/components/HashCalculator.js +360 -0
- package/dist/core/components/HashCalculator.js.map +1 -0
- package/dist/core/components/Logger.d.ts +73 -0
- package/dist/core/components/Logger.d.ts.map +1 -0
- package/dist/core/components/Logger.js +156 -0
- package/dist/core/components/Logger.js.map +1 -0
- package/dist/core/components/ProgressTracker.d.ts +43 -0
- package/dist/core/components/ProgressTracker.d.ts.map +1 -0
- package/dist/core/components/ProgressTracker.js +112 -0
- package/dist/core/components/ProgressTracker.js.map +1 -0
- package/dist/core/components/Support.d.ts +64 -0
- package/dist/core/components/Support.d.ts.map +1 -0
- package/dist/core/components/Support.js +71 -0
- package/dist/core/components/Support.js.map +1 -0
- package/dist/core/components/Util.d.ts +26 -0
- package/dist/core/components/Util.d.ts.map +1 -0
- package/dist/core/components/Util.js +95 -0
- package/dist/core/components/Util.js.map +1 -0
- package/dist/core/constants/Errors.d.ts +52 -0
- package/dist/core/constants/Errors.d.ts.map +1 -0
- package/dist/core/constants/Errors.js +67 -0
- package/dist/core/constants/Errors.js.map +1 -0
- package/dist/core/constants/Headers.d.ts +170 -0
- package/dist/core/constants/Headers.d.ts.map +1 -0
- package/dist/core/constants/Headers.js +194 -0
- package/dist/core/constants/Headers.js.map +1 -0
- package/dist/core/encryption/Manager.d.ts +58 -0
- package/dist/core/encryption/Manager.d.ts.map +1 -0
- package/dist/core/encryption/Manager.js +121 -0
- package/dist/core/encryption/Manager.js.map +1 -0
- package/dist/core/encryption/ZipCrypto.d.ts +172 -0
- package/dist/core/encryption/ZipCrypto.d.ts.map +1 -0
- package/dist/core/encryption/ZipCrypto.js +554 -0
- package/dist/core/encryption/ZipCrypto.js.map +1 -0
- package/dist/core/encryption/index.d.ts +9 -0
- package/dist/core/encryption/index.d.ts.map +1 -0
- package/dist/core/encryption/index.js +17 -0
- package/dist/core/encryption/index.js.map +1 -0
- package/dist/core/encryption/types.d.ts +29 -0
- package/dist/core/encryption/types.d.ts.map +1 -0
- package/dist/core/encryption/types.js +12 -0
- package/dist/core/encryption/types.js.map +1 -0
- package/dist/core/index.d.ts +27 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +59 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/version.d.ts +5 -0
- package/dist/core/version.d.ts.map +1 -0
- package/dist/core/version.js +31 -0
- package/dist/core/version.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/node/ZipCompressNode.d.ts +123 -0
- package/dist/node/ZipCompressNode.d.ts.map +1 -0
- package/dist/node/ZipCompressNode.js +565 -0
- package/dist/node/ZipCompressNode.js.map +1 -0
- package/dist/node/ZipCopyNode.d.ts +165 -0
- package/dist/node/ZipCopyNode.d.ts.map +1 -0
- package/dist/node/ZipCopyNode.js +347 -0
- package/dist/node/ZipCopyNode.js.map +1 -0
- package/dist/node/ZipDecompressNode.d.ts +197 -0
- package/dist/node/ZipDecompressNode.d.ts.map +1 -0
- package/dist/node/ZipDecompressNode.js +678 -0
- package/dist/node/ZipDecompressNode.js.map +1 -0
- package/dist/node/ZipkitNode.d.ts +466 -0
- package/dist/node/ZipkitNode.d.ts.map +1 -0
- package/dist/node/ZipkitNode.js +1426 -0
- package/dist/node/ZipkitNode.js.map +1 -0
- package/dist/node/index.d.ts +25 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +54 -0
- package/dist/node/index.js.map +1 -0
- package/dist/types/index.d.ts +45 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/examples/README.md +261 -0
- package/examples/append-data.json +44 -0
- package/examples/copy-zip-append.ts +139 -0
- package/examples/copy-zip.ts +152 -0
- package/examples/create-zip.ts +172 -0
- package/examples/extract-zip.ts +118 -0
- package/examples/list-zip.ts +161 -0
- package/examples/test-files/data.json +116 -0
- package/examples/test-files/document.md +80 -0
- package/examples/test-files/document.txt +6 -0
- package/examples/test-files/file1.txt +48 -0
- package/examples/test-files/file2.txt +80 -0
- package/examples/tsconfig.json +44 -0
- package/package.json +167 -0
- package/src/browser/ZipkitBrowser.ts +305 -0
- package/src/browser/index.esm.ts +32 -0
- package/src/browser/index.ts +19 -0
- package/src/core/ZipCompress.ts +370 -0
- package/src/core/ZipCopy.ts +434 -0
- package/src/core/ZipDecompress.ts +191 -0
- package/src/core/ZipEntry.ts +917 -0
- package/src/core/Zipkit.ts +794 -0
- package/src/core/ZstdManager.ts +165 -0
- package/src/core/components/HashCalculator.ts +384 -0
- package/src/core/components/Logger.ts +180 -0
- package/src/core/components/ProgressTracker.ts +134 -0
- package/src/core/components/Support.ts +77 -0
- package/src/core/components/Util.ts +91 -0
- package/src/core/constants/Errors.ts +78 -0
- package/src/core/constants/Headers.ts +205 -0
- package/src/core/encryption/Manager.ts +137 -0
- package/src/core/encryption/ZipCrypto.ts +650 -0
- package/src/core/encryption/index.ts +15 -0
- package/src/core/encryption/types.ts +33 -0
- package/src/core/index.ts +42 -0
- package/src/core/version.ts +33 -0
- package/src/index.ts +19 -0
- package/src/node/ZipCompressNode.ts +618 -0
- package/src/node/ZipCopyNode.ts +437 -0
- package/src/node/ZipDecompressNode.ts +793 -0
- package/src/node/ZipkitNode.ts +1706 -0
- package/src/node/index.ts +40 -0
- package/src/types/index.ts +68 -0
- package/src/types/modules.d.ts +22 -0
- package/src/types/opentimestamps.d.ts +1 -0
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Traditional ZIP Crypto encryption implementation
|
|
4
|
+
* Compatible with standard ZIP 2.0 encryption (ZipCrypto)
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DecryptionStream = exports.ZipCrypto = void 0;
|
|
8
|
+
exports.crc32 = crc32;
|
|
9
|
+
exports.crc32update = crc32update;
|
|
10
|
+
exports.sha256 = sha256;
|
|
11
|
+
const types_1 = require("./types");
|
|
12
|
+
const Logger_1 = require("../components/Logger");
|
|
13
|
+
const Headers_1 = require("../constants/Headers");
|
|
14
|
+
const crypto_1 = require("crypto");
|
|
15
|
+
class ZipCrypto {
|
|
16
|
+
canHandle(method) {
|
|
17
|
+
return method === types_1.EncryptionMethod.ZIP_CRYPTO;
|
|
18
|
+
}
|
|
19
|
+
getMethodName() {
|
|
20
|
+
return 'ZIP-Crypto';
|
|
21
|
+
}
|
|
22
|
+
getKeyLength() {
|
|
23
|
+
return ZipCrypto.KEY_LENGTH;
|
|
24
|
+
}
|
|
25
|
+
async encrypt(data, options) {
|
|
26
|
+
try {
|
|
27
|
+
if (options.method !== types_1.EncryptionMethod.ZIP_CRYPTO) {
|
|
28
|
+
return {
|
|
29
|
+
success: false,
|
|
30
|
+
error: 'ZIP-Crypto encryption method required'
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Initialize keys from password
|
|
34
|
+
const keys = this.initKeys(options.password);
|
|
35
|
+
// Encrypt data using traditional ZIP crypto
|
|
36
|
+
const encryptedData = Buffer.alloc(data.length);
|
|
37
|
+
for (let i = 0; i < data.length; i++) {
|
|
38
|
+
const byte = data[i];
|
|
39
|
+
const encryptedByte = this.encryptByte(keys, byte);
|
|
40
|
+
encryptedData[i] = encryptedByte;
|
|
41
|
+
this.updateKeys(keys, byte);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
success: true,
|
|
45
|
+
encryptedData: encryptedData
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return {
|
|
50
|
+
success: false,
|
|
51
|
+
error: error instanceof Error ? error.message : 'Unknown encryption error'
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async decrypt(data, options) {
|
|
56
|
+
try {
|
|
57
|
+
if (options.method !== types_1.EncryptionMethod.ZIP_CRYPTO) {
|
|
58
|
+
return {
|
|
59
|
+
success: false,
|
|
60
|
+
error: 'ZIP-Crypto decryption method required'
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Initialize keys from password
|
|
64
|
+
const keys = this.initKeys(options.password);
|
|
65
|
+
// Decrypt data using traditional ZIP crypto
|
|
66
|
+
const decryptedData = Buffer.alloc(data.length);
|
|
67
|
+
for (let i = 0; i < data.length; i++) {
|
|
68
|
+
const encryptedByte = data[i];
|
|
69
|
+
const decryptedByte = this.decryptByte(keys, encryptedByte);
|
|
70
|
+
decryptedData[i] = decryptedByte;
|
|
71
|
+
this.updateKeys(keys, decryptedByte);
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
success: true,
|
|
75
|
+
decryptedData: decryptedData
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
return {
|
|
80
|
+
success: false,
|
|
81
|
+
error: error instanceof Error ? error.message : 'Unknown decryption error'
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Verify password using check byte from decrypted header
|
|
87
|
+
* @param decryptedHeader - 12-byte decrypted encryption header
|
|
88
|
+
* @param checkByte - Expected check byte value
|
|
89
|
+
* @throws Error if password verification fails
|
|
90
|
+
*/
|
|
91
|
+
verifyPassword(decryptedHeader, checkByte) {
|
|
92
|
+
if (decryptedHeader.length < 12) {
|
|
93
|
+
throw new Error('Decrypted header must be at least 12 bytes');
|
|
94
|
+
}
|
|
95
|
+
// Verify check byte (11th byte, 0-indexed)
|
|
96
|
+
if (decryptedHeader[11] !== checkByte) {
|
|
97
|
+
throw new Error('Password verification FAILED');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Parse local header to extract information needed for decryption
|
|
102
|
+
* @param localHeaderBuffer - 30-byte local header buffer
|
|
103
|
+
* @param entry - ZIP entry to update with extracted information
|
|
104
|
+
* @returns Object with bitFlags, lastModTimeDate, localCrc, and checkByte
|
|
105
|
+
*/
|
|
106
|
+
parseLocalHeaderForDecryption(localHeaderBuffer, entry) {
|
|
107
|
+
// Verify signature
|
|
108
|
+
if (localHeaderBuffer.readUInt32LE(0) !== 0x04034b50) {
|
|
109
|
+
throw new Error('Invalid local header signature');
|
|
110
|
+
}
|
|
111
|
+
// Read bit flags, lastModTimeDate, and CRC from local header
|
|
112
|
+
const bitFlags = localHeaderBuffer.readUInt16LE(6);
|
|
113
|
+
const lastModTimeDate = localHeaderBuffer.readUInt32LE(10);
|
|
114
|
+
const localCrc = localHeaderBuffer.readUInt32LE(14);
|
|
115
|
+
// Store lastModTimeDate in entry if DATA_DESC flag is set
|
|
116
|
+
if ((bitFlags & Headers_1.GP_FLAG.DATA_DESC) && (!entry.lastModTimeDate || entry.lastModTimeDate === 0)) {
|
|
117
|
+
entry.lastModTimeDate = lastModTimeDate;
|
|
118
|
+
}
|
|
119
|
+
// Store local CRC for check byte calculation
|
|
120
|
+
entry.localCrc = localCrc;
|
|
121
|
+
// Calculate check byte
|
|
122
|
+
let checkByte;
|
|
123
|
+
if (bitFlags & Headers_1.GP_FLAG.DATA_DESC) {
|
|
124
|
+
const timeDate = entry.lastModTimeDate || entry.timeDateDOS || 0;
|
|
125
|
+
checkByte = (timeDate >> 8) & 0xff;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const crc = localCrc && localCrc !== 0 ? localCrc : entry.crc;
|
|
129
|
+
checkByte = (crc >> 24) & 0xff;
|
|
130
|
+
}
|
|
131
|
+
return { bitFlags, lastModTimeDate, localCrc, checkByte };
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Create encryption header (12 bytes) for PKZIP encryption
|
|
135
|
+
* Generates 11 random bytes + 1 check byte
|
|
136
|
+
* @param entry - ZIP entry to create header for
|
|
137
|
+
* @param password - Password for encryption (used to calculate check byte)
|
|
138
|
+
* @returns 12-byte encryption header buffer
|
|
139
|
+
*/
|
|
140
|
+
createEncryptionHeader(entry, password) {
|
|
141
|
+
const header = Buffer.alloc(Headers_1.ENCRYPT_HDR_SIZE);
|
|
142
|
+
// Generate 11 random bytes (bytes 0-10)
|
|
143
|
+
const random = (0, crypto_1.randomBytes)(11);
|
|
144
|
+
random.copy(header, 0);
|
|
145
|
+
// Calculate check byte (byte 11)
|
|
146
|
+
// For DATA_DESC files: use lastModTimeDate >> 8
|
|
147
|
+
// For regular files: use CRC >> 24
|
|
148
|
+
let checkByte;
|
|
149
|
+
if ((entry.bitFlags & Headers_1.GP_FLAG.DATA_DESC) !== 0) {
|
|
150
|
+
const timeDate = entry.lastModTimeDate || entry.timeDateDOS || 0;
|
|
151
|
+
checkByte = (timeDate >> 8) & 0xff;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// Use CRC from entry (should be calculated before encryption)
|
|
155
|
+
checkByte = (entry.crc >> 24) & 0xff;
|
|
156
|
+
}
|
|
157
|
+
// Set check byte (11th byte, 0-indexed)
|
|
158
|
+
header[11] = checkByte;
|
|
159
|
+
Logger_1.Logger.debug(`[ZipCrypto] Created encryption header: checkByte=0x${checkByte.toString(16).padStart(2, '0')}, DATA_DESC=${(entry.bitFlags & Headers_1.GP_FLAG.DATA_DESC) !== 0}`);
|
|
160
|
+
return header;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Encrypt buffer (header + compressed data) for PKZIP encryption
|
|
164
|
+
* Creates encryption header, concatenates with compressed data, and encrypts everything
|
|
165
|
+
* @param entry - ZIP entry to encrypt
|
|
166
|
+
* @param compressedData - Compressed data to encrypt
|
|
167
|
+
* @param password - Password for encryption
|
|
168
|
+
* @returns Encrypted buffer (encrypted header + encrypted compressed data)
|
|
169
|
+
*/
|
|
170
|
+
encryptBuffer(entry, compressedData, password) {
|
|
171
|
+
// Create 12-byte encryption header
|
|
172
|
+
const header = this.createEncryptionHeader(entry, password);
|
|
173
|
+
// Concatenate header + compressed data
|
|
174
|
+
const dataToEncrypt = Buffer.concat([header, compressedData]);
|
|
175
|
+
// Initialize encryption keys from password
|
|
176
|
+
const keys = this.initKeys(password);
|
|
177
|
+
// Encrypt the entire buffer (header + compressed data) maintaining key state
|
|
178
|
+
// This ensures keys are updated correctly throughout encryption
|
|
179
|
+
const encryptedData = Buffer.alloc(dataToEncrypt.length);
|
|
180
|
+
for (let i = 0; i < dataToEncrypt.length; i++) {
|
|
181
|
+
const byte = dataToEncrypt[i];
|
|
182
|
+
const encryptedByte = this.encryptByte(keys, byte);
|
|
183
|
+
encryptedData[i] = encryptedByte;
|
|
184
|
+
// Update keys after each byte - state must be maintained across the entire buffer
|
|
185
|
+
this.updateKeys(keys, byte);
|
|
186
|
+
}
|
|
187
|
+
Logger_1.Logger.debug(`[ZipCrypto] Encrypted buffer: ${compressedData.length} bytes compressed data + ${Headers_1.ENCRYPT_HDR_SIZE} bytes header = ${encryptedData.length} bytes total`);
|
|
188
|
+
return encryptedData;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Decrypt buffer-based encrypted data (for in-memory extraction)
|
|
192
|
+
* Handles local header parsing, encryption header extraction, and decryption
|
|
193
|
+
* @param entry - ZIP entry with encryption information
|
|
194
|
+
* @param buffer - Full ZIP file buffer
|
|
195
|
+
* @param encryptedData - Encrypted data without header (from parseLocalHeader)
|
|
196
|
+
* @param password - Password for decryption
|
|
197
|
+
* @returns Decrypted compressed data (without header)
|
|
198
|
+
*/
|
|
199
|
+
decryptBuffer(entry, buffer, encryptedData, password) {
|
|
200
|
+
// Read local header to get lastModTimeDate for DATA_DESC files (needed for check byte)
|
|
201
|
+
const localData = buffer.subarray(entry.localHdrOffset);
|
|
202
|
+
const localHeaderBuffer = localData.subarray(0, 30);
|
|
203
|
+
// Parse local header to extract decryption info
|
|
204
|
+
const { bitFlags, localCrc, checkByte } = this.parseLocalHeaderForDecryption(localHeaderBuffer, entry);
|
|
205
|
+
// Extract the 12-byte encryption header
|
|
206
|
+
// parseLocalHeader returns data WITHOUT the 12-byte encryption header
|
|
207
|
+
// We need to prepend the header before decrypting so keys are updated correctly
|
|
208
|
+
const fnameLen = localHeaderBuffer.readUInt16LE(26);
|
|
209
|
+
const extraLen = localHeaderBuffer.readUInt16LE(28);
|
|
210
|
+
const localSize = 30 + fnameLen + extraLen;
|
|
211
|
+
const ENCRYPT_HDR_SIZE = 12;
|
|
212
|
+
const encryptHeader = localData.subarray(localSize, localSize + ENCRYPT_HDR_SIZE);
|
|
213
|
+
// Prepend the header to the encrypted data
|
|
214
|
+
const encryptedDataWithHeader = Buffer.concat([encryptHeader, encryptedData]);
|
|
215
|
+
// Decrypt the full data (header + compressed data) in one pass
|
|
216
|
+
// This ensures keys are updated correctly throughout the decryption
|
|
217
|
+
// MEMORY EFFICIENCY: Decrypt in-place into encryptedDataWithHeader (no new allocation)
|
|
218
|
+
const keys = this.initKeys(password);
|
|
219
|
+
for (let i = 0; i < encryptedDataWithHeader.length; i++) {
|
|
220
|
+
const encryptedByte = encryptedDataWithHeader[i];
|
|
221
|
+
const decryptedByte = this.decryptByte(keys, encryptedByte);
|
|
222
|
+
encryptedDataWithHeader[i] = decryptedByte;
|
|
223
|
+
this.updateKeys(keys, decryptedByte);
|
|
224
|
+
}
|
|
225
|
+
// Extract the decrypted header (first 12 bytes) for password verification
|
|
226
|
+
// encryptedDataWithHeader now contains decrypted data
|
|
227
|
+
const decryptedHeader = encryptedDataWithHeader.subarray(0, ENCRYPT_HDR_SIZE);
|
|
228
|
+
// Verify password using check byte
|
|
229
|
+
this.verifyPassword(decryptedHeader, checkByte);
|
|
230
|
+
// Skip the decrypted header (first 12 bytes) and return only the decrypted compressed data
|
|
231
|
+
return encryptedDataWithHeader.subarray(ENCRYPT_HDR_SIZE);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Create a streaming decryptor for chunked data processing
|
|
235
|
+
* Handles 12-byte header decryption and verification, then yields decrypted chunks
|
|
236
|
+
*
|
|
237
|
+
* MEMORY EFFICIENCY: This method processes encrypted data one block at a time.
|
|
238
|
+
* - Decryption state (keys) is maintained across blocks via updateKeys()
|
|
239
|
+
* - Only the minimum 12-byte header is accumulated before password verification
|
|
240
|
+
* - Each decrypted block is yielded immediately without accumulation
|
|
241
|
+
*
|
|
242
|
+
* @param password - Password for decryption
|
|
243
|
+
* @param checkByte - Expected check byte value for password verification
|
|
244
|
+
* @param encryptedStream - Async generator of encrypted data chunks (one block at a time)
|
|
245
|
+
* @returns Async generator of decrypted data chunks (one block at a time)
|
|
246
|
+
*/
|
|
247
|
+
async *createStreamDecryptor(password, checkByte, encryptedStream) {
|
|
248
|
+
// Initialize keys from password - state maintained across all blocks
|
|
249
|
+
const keys = this.initKeys(password);
|
|
250
|
+
// Process 12-byte encryption header incrementally (minimum accumulation)
|
|
251
|
+
const ENCRYPT_HDR_SIZE = 12;
|
|
252
|
+
const headerBuffer = Buffer.alloc(ENCRYPT_HDR_SIZE);
|
|
253
|
+
let headerBytesCollected = 0;
|
|
254
|
+
let currentChunk = null;
|
|
255
|
+
let currentChunkOffset = 0;
|
|
256
|
+
// Read chunks incrementally until we have exactly 12 bytes for header
|
|
257
|
+
// This minimizes memory usage by only accumulating the necessary header bytes
|
|
258
|
+
while (headerBytesCollected < ENCRYPT_HDR_SIZE) {
|
|
259
|
+
// Get next chunk if current chunk is exhausted
|
|
260
|
+
if (!currentChunk || currentChunkOffset >= currentChunk.length) {
|
|
261
|
+
const result = await encryptedStream.next();
|
|
262
|
+
if (result.done || !result.value) {
|
|
263
|
+
throw new Error('ZIP-Crypto: insufficient encrypted data (missing encryption header)');
|
|
264
|
+
}
|
|
265
|
+
currentChunk = result.value;
|
|
266
|
+
currentChunkOffset = 0;
|
|
267
|
+
}
|
|
268
|
+
// Copy bytes from current chunk to header buffer
|
|
269
|
+
const bytesNeeded = ENCRYPT_HDR_SIZE - headerBytesCollected;
|
|
270
|
+
const bytesToCopy = Math.min(bytesNeeded, currentChunk.length - currentChunkOffset);
|
|
271
|
+
currentChunk.copy(headerBuffer, headerBytesCollected, currentChunkOffset, currentChunkOffset + bytesToCopy);
|
|
272
|
+
headerBytesCollected += bytesToCopy;
|
|
273
|
+
currentChunkOffset += bytesToCopy;
|
|
274
|
+
}
|
|
275
|
+
// Decrypt the 12-byte encryption header byte-by-byte
|
|
276
|
+
// This maintains proper key state for subsequent decryption
|
|
277
|
+
// MEMORY EFFICIENCY: Decrypt in-place into headerBuffer (no new allocation)
|
|
278
|
+
for (let i = 0; i < ENCRYPT_HDR_SIZE; i++) {
|
|
279
|
+
const encryptedByte = headerBuffer[i];
|
|
280
|
+
const decryptedByte = this.decryptByte(keys, encryptedByte) & 0xff;
|
|
281
|
+
headerBuffer[i] = decryptedByte;
|
|
282
|
+
// Update keys after each byte - state must be maintained across blocks
|
|
283
|
+
this.updateKeys(keys, decryptedByte);
|
|
284
|
+
}
|
|
285
|
+
// Verify password using check byte (11th byte of decrypted header)
|
|
286
|
+
// headerBuffer now contains decrypted header data
|
|
287
|
+
this.verifyPassword(headerBuffer, checkByte);
|
|
288
|
+
// Process remaining data from the first chunk (after header) if any
|
|
289
|
+
// This ensures we decrypt and yield data immediately without accumulating
|
|
290
|
+
// MEMORY EFFICIENCY: Decrypt in-place into currentChunk buffer (no new allocation)
|
|
291
|
+
if (currentChunk && currentChunkOffset < currentChunk.length) {
|
|
292
|
+
const remainingInChunk = currentChunk.length - currentChunkOffset;
|
|
293
|
+
for (let i = 0; i < remainingInChunk; i++) {
|
|
294
|
+
const pos = currentChunkOffset + i;
|
|
295
|
+
const encryptedByte = currentChunk[pos];
|
|
296
|
+
const decryptedByte = this.decryptByte(keys, encryptedByte);
|
|
297
|
+
currentChunk[pos] = decryptedByte;
|
|
298
|
+
// Maintain state across bytes - keys updated for next block
|
|
299
|
+
this.updateKeys(keys, decryptedByte);
|
|
300
|
+
}
|
|
301
|
+
// Yield subarray of currentChunk (already decrypted in-place)
|
|
302
|
+
yield currentChunk.subarray(currentChunkOffset);
|
|
303
|
+
}
|
|
304
|
+
// Process remaining chunks one at a time - decrypt and yield immediately
|
|
305
|
+
// Decryption state (keys) continues across blocks via updateKeys()
|
|
306
|
+
// MEMORY EFFICIENCY: Decrypt in-place into encryptedChunk buffer (no new allocation)
|
|
307
|
+
for await (const encryptedChunk of encryptedStream) {
|
|
308
|
+
// Decrypt each byte in-place, maintaining state across bytes
|
|
309
|
+
for (let i = 0; i < encryptedChunk.length; i++) {
|
|
310
|
+
const encryptedByte = encryptedChunk[i];
|
|
311
|
+
const decryptedByte = this.decryptByte(keys, encryptedByte);
|
|
312
|
+
encryptedChunk[i] = decryptedByte;
|
|
313
|
+
// Update keys after each byte - ensures state continues correctly across blocks
|
|
314
|
+
this.updateKeys(keys, decryptedByte);
|
|
315
|
+
}
|
|
316
|
+
// Yield the same buffer (now containing decrypted data) - no accumulation
|
|
317
|
+
yield encryptedChunk;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Initialize encryption keys from password
|
|
322
|
+
*/
|
|
323
|
+
initKeys(password) {
|
|
324
|
+
const keys = [0x12345678, 0x23456789, 0x34567890];
|
|
325
|
+
for (let i = 0; i < password.length; i++) {
|
|
326
|
+
this.updateKeys(keys, password.charCodeAt(i));
|
|
327
|
+
}
|
|
328
|
+
return keys;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Update encryption keys with a byte
|
|
332
|
+
* Based on zip.js implementation - uses Math.imul for 32-bit integer multiplication
|
|
333
|
+
*/
|
|
334
|
+
updateKeys(keys, byte) {
|
|
335
|
+
keys[0] = ((keys[0] >>> 8) ^ ZipCrypto.CRC_TABLE[(keys[0] ^ byte) & 0xff]) >>> 0;
|
|
336
|
+
// Use Math.imul for multiplication (matches zip.js) and 0x08088405 constant
|
|
337
|
+
keys[1] = ((Math.imul(keys[1] + (keys[0] & 0xff), 0x08088405) + 1) & 0xFFFFFFFF) >>> 0;
|
|
338
|
+
keys[2] = ((keys[2] >>> 8) ^ ZipCrypto.CRC_TABLE[(keys[2] ^ (keys[1] >>> 24)) & 0xff]) >>> 0;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Encrypt a single byte
|
|
342
|
+
* Based on zip.js implementation - uses Math.imul for 32-bit integer multiplication
|
|
343
|
+
*/
|
|
344
|
+
encryptByte(keys, byte) {
|
|
345
|
+
const temp = keys[2] | 2;
|
|
346
|
+
// Use Math.imul like zip.js and mask with 0xFF
|
|
347
|
+
return (byte ^ (Math.imul(temp, (temp ^ 1)) >>> 8)) & 0xFF;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Decrypt a single byte
|
|
351
|
+
* Based on zip.js implementation - uses Math.imul for 32-bit integer multiplication
|
|
352
|
+
*/
|
|
353
|
+
decryptByte(keys, encryptedByte) {
|
|
354
|
+
const temp = keys[2] | 2;
|
|
355
|
+
// Use Math.imul like zip.js and mask with 0xFF
|
|
356
|
+
return (encryptedByte ^ (Math.imul(temp, (temp ^ 1)) >>> 8)) & 0xFF;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* CRC32 implementation for ZIP crypto (single byte update)
|
|
360
|
+
* Used internally for key updates during encryption/decryption
|
|
361
|
+
*/
|
|
362
|
+
crc32(crc, byte) {
|
|
363
|
+
return ((crc >>> 8) ^ ZipCrypto.CRC_TABLE[(crc ^ byte) & 0xff]) >>> 0;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Static CRC32 calculation for a full buffer
|
|
367
|
+
* Delegates to exported crc32() function
|
|
368
|
+
* @param buf - Buffer or string to calculate CRC32 for
|
|
369
|
+
* @returns CRC32 checksum as unsigned 32-bit integer
|
|
370
|
+
*/
|
|
371
|
+
static crc32(buf) {
|
|
372
|
+
return crc32Impl(buf);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Static CRC32 incremental update (single byte)
|
|
376
|
+
* Delegates to exported crc32update() function
|
|
377
|
+
* @param crc - Current CRC32 value
|
|
378
|
+
* @param byte - Byte to update with
|
|
379
|
+
* @returns Updated CRC32 value
|
|
380
|
+
*/
|
|
381
|
+
static crc32update(crc, byte) {
|
|
382
|
+
return crc32updateImpl(crc, byte);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
exports.ZipCrypto = ZipCrypto;
|
|
386
|
+
ZipCrypto.KEY_LENGTH = 3; // 24 bits for traditional ZIP crypto
|
|
387
|
+
/**
|
|
388
|
+
* CRC32 lookup table (shared for all CRC32 operations)
|
|
389
|
+
*/
|
|
390
|
+
ZipCrypto.CRC_TABLE = [
|
|
391
|
+
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
|
392
|
+
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
|
393
|
+
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
|
|
394
|
+
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
|
395
|
+
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
|
396
|
+
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
|
397
|
+
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
|
|
398
|
+
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
|
399
|
+
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
|
|
400
|
+
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
|
401
|
+
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
|
|
402
|
+
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
|
403
|
+
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
|
|
404
|
+
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
|
405
|
+
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
|
406
|
+
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
|
407
|
+
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
|
|
408
|
+
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
|
409
|
+
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
|
|
410
|
+
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
|
411
|
+
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
|
|
412
|
+
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
|
413
|
+
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
|
|
414
|
+
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
|
415
|
+
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
|
416
|
+
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
|
417
|
+
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
|
|
418
|
+
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
|
419
|
+
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
|
|
420
|
+
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
|
421
|
+
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
|
|
422
|
+
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
|
423
|
+
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
|
|
424
|
+
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
|
425
|
+
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
|
426
|
+
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
|
427
|
+
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
|
|
428
|
+
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
|
429
|
+
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
|
|
430
|
+
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
|
431
|
+
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
|
|
432
|
+
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
|
433
|
+
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
|
434
|
+
];
|
|
435
|
+
/**
|
|
436
|
+
* CRC32 calculation for a full buffer
|
|
437
|
+
* Main public API for CRC32 calculation
|
|
438
|
+
* @param buf - Buffer or string to calculate CRC32 for
|
|
439
|
+
* @returns CRC32 checksum as unsigned 32-bit integer
|
|
440
|
+
*/
|
|
441
|
+
function crc32Impl(buf) {
|
|
442
|
+
if (typeof buf === "string") {
|
|
443
|
+
buf = Buffer.from(buf, "utf8");
|
|
444
|
+
}
|
|
445
|
+
let len = buf.length;
|
|
446
|
+
let crc = ~0;
|
|
447
|
+
for (let off = 0; off < len;) {
|
|
448
|
+
crc = ZipCrypto.CRC_TABLE[(crc ^ buf[off++]) & 0xff] ^ (crc >>> 8);
|
|
449
|
+
}
|
|
450
|
+
// Finalize: xor with ~0 and cast as uint32
|
|
451
|
+
return ~crc >>> 0;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* CRC32 incremental update (single byte)
|
|
455
|
+
* Used for streaming CRC32 calculation
|
|
456
|
+
* @param crc - Current CRC32 value
|
|
457
|
+
* @param byte - Byte to update with
|
|
458
|
+
* @returns Updated CRC32 value
|
|
459
|
+
*/
|
|
460
|
+
function crc32updateImpl(crc, byte) {
|
|
461
|
+
return ZipCrypto.CRC_TABLE[(crc ^ byte) & 0xff] ^ (crc >>> 8);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* CRC32 calculation for a full buffer
|
|
465
|
+
* Main public API for CRC32 calculation
|
|
466
|
+
* @param buf - Buffer or string to calculate CRC32 for
|
|
467
|
+
* @returns CRC32 checksum as unsigned 32-bit integer
|
|
468
|
+
*/
|
|
469
|
+
function crc32(buf) {
|
|
470
|
+
return crc32Impl(buf);
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* CRC32 incremental update (single byte)
|
|
474
|
+
* Used for streaming CRC32 calculation
|
|
475
|
+
* @param crc - Current CRC32 value
|
|
476
|
+
* @param byte - Byte to update with
|
|
477
|
+
* @returns Updated CRC32 value
|
|
478
|
+
*/
|
|
479
|
+
function crc32update(crc, byte) {
|
|
480
|
+
return crc32updateImpl(crc, byte);
|
|
481
|
+
}
|
|
482
|
+
// Cryptographic utility functions
|
|
483
|
+
const crypto_2 = require("crypto");
|
|
484
|
+
// Return the SHA256 hash of a buffer
|
|
485
|
+
function sha256(data) {
|
|
486
|
+
const hash = (0, crypto_2.createHash)('sha256');
|
|
487
|
+
return hash
|
|
488
|
+
.update(data)
|
|
489
|
+
.digest('hex');
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Streaming decryption for chunked compressed data processing
|
|
493
|
+
* Encapsulated within ZipCrypto for PKZIP decryption
|
|
494
|
+
*/
|
|
495
|
+
class DecryptionStream {
|
|
496
|
+
constructor(options) {
|
|
497
|
+
this.password = options.password;
|
|
498
|
+
this.method = options.method;
|
|
499
|
+
this.entry = options.entry;
|
|
500
|
+
this.zipCrypto = new ZipCrypto();
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Decrypt compressed data stream chunk by chunk
|
|
504
|
+
*/
|
|
505
|
+
async *decrypt(encryptedStream) {
|
|
506
|
+
if (this.method !== types_1.EncryptionMethod.ZIP_CRYPTO) {
|
|
507
|
+
throw new Error(`Unsupported encryption method: ${this.method}`);
|
|
508
|
+
}
|
|
509
|
+
// Calculate check byte based on entry
|
|
510
|
+
const checkByte = this.calculateCheckByte();
|
|
511
|
+
// Use ZipCrypto's streaming decryptor
|
|
512
|
+
yield* this.zipCrypto.createStreamDecryptor(this.password, checkByte, encryptedStream);
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Calculate check byte for password verification
|
|
516
|
+
* For DATA_DESC files: lastModTimeDate >> 8
|
|
517
|
+
* For non-DATA_DESC files: CRC >> 24
|
|
518
|
+
*/
|
|
519
|
+
calculateCheckByte() {
|
|
520
|
+
if (this.entry.bitFlags & Headers_1.GP_FLAG.DATA_DESC) {
|
|
521
|
+
let lastModTimeDate = this.entry.lastModTimeDate;
|
|
522
|
+
if (!lastModTimeDate || lastModTimeDate === 0) {
|
|
523
|
+
lastModTimeDate = this.entry.timeDateDOS || 0;
|
|
524
|
+
}
|
|
525
|
+
const checkByte = (lastModTimeDate >> 8) & 0xff;
|
|
526
|
+
return checkByte;
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
const crc = this.entry.localCrc && this.entry.localCrc !== 0
|
|
530
|
+
? this.entry.localCrc
|
|
531
|
+
: this.entry.crc;
|
|
532
|
+
const checkByte = (crc >> 24) & 0xff;
|
|
533
|
+
return checkByte;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Prepare entry for decryption by parsing local header from file handle
|
|
538
|
+
* This extracts the information needed for check byte calculation
|
|
539
|
+
* @param fileHandle - File handle to read from
|
|
540
|
+
* @param entry - ZIP entry to update
|
|
541
|
+
* @returns Check byte value for password verification
|
|
542
|
+
*/
|
|
543
|
+
static async prepareEntryForDecryption(fileHandle, entry) {
|
|
544
|
+
// Read local header to get lastModTimeDate for DATA_DESC files (needed for check byte)
|
|
545
|
+
const localHeaderBuffer = Buffer.alloc(30);
|
|
546
|
+
await fileHandle.read(localHeaderBuffer, 0, 30, entry.localHdrOffset);
|
|
547
|
+
// Use ZipCrypto to parse the header
|
|
548
|
+
const zipCrypto = new ZipCrypto();
|
|
549
|
+
const { checkByte } = zipCrypto.parseLocalHeaderForDecryption(localHeaderBuffer, entry);
|
|
550
|
+
return checkByte;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
exports.DecryptionStream = DecryptionStream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Ae,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;YAChD,OAAO,SAAS,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,GAAI,IAAI,CAAC,KAAa,CAAC,QAAQ,IAAK,IAAI,CAAC,KAAa,CAAC,QAAQ,KAAK,CAAC;gBAC5E,CAAC,CAAE,IAAI,CAAC,KAAa,CAAC,QAAQ;gBAC9B,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;YACnB,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;YACrC,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,UAAe,EAAE,KAAe;QACrE,uFAAuF;QACvF,MAAM,iBAAiB,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC3C,MAAM,UAAU,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;QAEtE,oCAAoC;QACpC,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QAClC,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC,6BAA6B,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;QAExF,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AApED,4CAoEC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NeoZipKit Encryption Extension
|
|
3
|
+
* Provides encryption capabilities for neozip-cli
|
|
4
|
+
* Supports traditional ZIP encryption (PKZIP compatible)
|
|
5
|
+
*/
|
|
6
|
+
export { ZipCrypto, crc32, crc32update } from './ZipCrypto';
|
|
7
|
+
export { EncryptionManager } from './Manager';
|
|
8
|
+
export { EncryptionMethod, EncryptionOptions, EncryptionResult, DecryptionResult, EncryptionProvider } from './types';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/encryption/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* NeoZipKit Encryption Extension
|
|
4
|
+
* Provides encryption capabilities for neozip-cli
|
|
5
|
+
* Supports traditional ZIP encryption (PKZIP compatible)
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.EncryptionMethod = exports.EncryptionManager = exports.crc32update = exports.crc32 = exports.ZipCrypto = void 0;
|
|
9
|
+
var ZipCrypto_1 = require("./ZipCrypto");
|
|
10
|
+
Object.defineProperty(exports, "ZipCrypto", { enumerable: true, get: function () { return ZipCrypto_1.ZipCrypto; } });
|
|
11
|
+
Object.defineProperty(exports, "crc32", { enumerable: true, get: function () { return ZipCrypto_1.crc32; } });
|
|
12
|
+
Object.defineProperty(exports, "crc32update", { enumerable: true, get: function () { return ZipCrypto_1.crc32update; } });
|
|
13
|
+
var Manager_1 = require("./Manager");
|
|
14
|
+
Object.defineProperty(exports, "EncryptionManager", { enumerable: true, get: function () { return Manager_1.EncryptionManager; } });
|
|
15
|
+
var types_1 = require("./types");
|
|
16
|
+
Object.defineProperty(exports, "EncryptionMethod", { enumerable: true, get: function () { return types_1.EncryptionMethod; } });
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/encryption/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,yCAA4D;AAAnD,sGAAA,SAAS,OAAA;AAAE,kGAAA,KAAK,OAAA;AAAE,wGAAA,WAAW,OAAA;AACtC,qCAA8C;AAArC,4GAAA,iBAAiB,OAAA;AAC1B,iCAMiB;AALf,yGAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encryption types and interfaces for NeoZipKit extension
|
|
3
|
+
*/
|
|
4
|
+
export declare enum EncryptionMethod {
|
|
5
|
+
NONE = 0,
|
|
6
|
+
ZIP_CRYPTO = 1
|
|
7
|
+
}
|
|
8
|
+
export interface EncryptionOptions {
|
|
9
|
+
method: EncryptionMethod;
|
|
10
|
+
password: string;
|
|
11
|
+
}
|
|
12
|
+
export interface EncryptionResult {
|
|
13
|
+
success: boolean;
|
|
14
|
+
encryptedData?: Buffer;
|
|
15
|
+
error?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface DecryptionResult {
|
|
18
|
+
success: boolean;
|
|
19
|
+
decryptedData?: Buffer;
|
|
20
|
+
error?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface EncryptionProvider {
|
|
23
|
+
encrypt(data: Buffer, options: EncryptionOptions): Promise<EncryptionResult>;
|
|
24
|
+
decrypt(data: Buffer, options: EncryptionOptions): Promise<DecryptionResult>;
|
|
25
|
+
canHandle(method: EncryptionMethod): boolean;
|
|
26
|
+
getMethodName(): string;
|
|
27
|
+
getKeyLength(): number;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/encryption/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAY,gBAAgB;IAC1B,IAAI,IAAI;IACR,UAAU,IAAI;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7E,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7E,SAAS,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAC7C,aAAa,IAAI,MAAM,CAAC;IACxB,YAAY,IAAI,MAAM,CAAC;CACxB"}
|