@uipath/audit-commands 1.202.1 → 1.203.0-preview.180
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/THIRD-PARTY-NOTICES.md +31 -31
- package/dist/index.js +712 -2541
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -2097,2492 +2097,6 @@ var require_commander = __commonJS(function(exports) {
|
|
|
2097
2097
|
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
2098
2098
|
});
|
|
2099
2099
|
|
|
2100
|
-
// ../../../node_modules/adm-zip/util/constants.js
|
|
2101
|
-
var require_constants = __commonJS(function(exports, module) {
|
|
2102
|
-
module.exports = {
|
|
2103
|
-
LOCHDR: 30,
|
|
2104
|
-
LOCSIG: 67324752,
|
|
2105
|
-
LOCVER: 4,
|
|
2106
|
-
LOCFLG: 6,
|
|
2107
|
-
LOCHOW: 8,
|
|
2108
|
-
LOCTIM: 10,
|
|
2109
|
-
LOCCRC: 14,
|
|
2110
|
-
LOCSIZ: 18,
|
|
2111
|
-
LOCLEN: 22,
|
|
2112
|
-
LOCNAM: 26,
|
|
2113
|
-
LOCEXT: 28,
|
|
2114
|
-
EXTSIG: 134695760,
|
|
2115
|
-
EXTHDR: 16,
|
|
2116
|
-
EXTCRC: 4,
|
|
2117
|
-
EXTSIZ: 8,
|
|
2118
|
-
EXTLEN: 12,
|
|
2119
|
-
CENHDR: 46,
|
|
2120
|
-
CENSIG: 33639248,
|
|
2121
|
-
CENVEM: 4,
|
|
2122
|
-
CENVER: 6,
|
|
2123
|
-
CENFLG: 8,
|
|
2124
|
-
CENHOW: 10,
|
|
2125
|
-
CENTIM: 12,
|
|
2126
|
-
CENCRC: 16,
|
|
2127
|
-
CENSIZ: 20,
|
|
2128
|
-
CENLEN: 24,
|
|
2129
|
-
CENNAM: 28,
|
|
2130
|
-
CENEXT: 30,
|
|
2131
|
-
CENCOM: 32,
|
|
2132
|
-
CENDSK: 34,
|
|
2133
|
-
CENATT: 36,
|
|
2134
|
-
CENATX: 38,
|
|
2135
|
-
CENOFF: 42,
|
|
2136
|
-
ENDHDR: 22,
|
|
2137
|
-
ENDSIG: 101010256,
|
|
2138
|
-
ENDSUB: 8,
|
|
2139
|
-
ENDTOT: 10,
|
|
2140
|
-
ENDSIZ: 12,
|
|
2141
|
-
ENDOFF: 16,
|
|
2142
|
-
ENDCOM: 20,
|
|
2143
|
-
END64HDR: 20,
|
|
2144
|
-
END64SIG: 117853008,
|
|
2145
|
-
END64START: 4,
|
|
2146
|
-
END64OFF: 8,
|
|
2147
|
-
END64NUMDISKS: 16,
|
|
2148
|
-
ZIP64SIG: 101075792,
|
|
2149
|
-
ZIP64HDR: 56,
|
|
2150
|
-
ZIP64LEAD: 12,
|
|
2151
|
-
ZIP64SIZE: 4,
|
|
2152
|
-
ZIP64VEM: 12,
|
|
2153
|
-
ZIP64VER: 14,
|
|
2154
|
-
ZIP64DSK: 16,
|
|
2155
|
-
ZIP64DSKDIR: 20,
|
|
2156
|
-
ZIP64SUB: 24,
|
|
2157
|
-
ZIP64TOT: 32,
|
|
2158
|
-
ZIP64SIZB: 40,
|
|
2159
|
-
ZIP64OFF: 48,
|
|
2160
|
-
ZIP64EXTRA: 56,
|
|
2161
|
-
STORED: 0,
|
|
2162
|
-
SHRUNK: 1,
|
|
2163
|
-
REDUCED1: 2,
|
|
2164
|
-
REDUCED2: 3,
|
|
2165
|
-
REDUCED3: 4,
|
|
2166
|
-
REDUCED4: 5,
|
|
2167
|
-
IMPLODED: 6,
|
|
2168
|
-
DEFLATED: 8,
|
|
2169
|
-
ENHANCED_DEFLATED: 9,
|
|
2170
|
-
PKWARE: 10,
|
|
2171
|
-
BZIP2: 12,
|
|
2172
|
-
LZMA: 14,
|
|
2173
|
-
IBM_TERSE: 18,
|
|
2174
|
-
IBM_LZ77: 19,
|
|
2175
|
-
AES_ENCRYPT: 99,
|
|
2176
|
-
FLG_ENC: 1,
|
|
2177
|
-
FLG_COMP1: 2,
|
|
2178
|
-
FLG_COMP2: 4,
|
|
2179
|
-
FLG_DESC: 8,
|
|
2180
|
-
FLG_ENH: 16,
|
|
2181
|
-
FLG_PATCH: 32,
|
|
2182
|
-
FLG_STR: 64,
|
|
2183
|
-
FLG_EFS: 2048,
|
|
2184
|
-
FLG_MSK: 4096,
|
|
2185
|
-
FILE: 2,
|
|
2186
|
-
BUFFER: 1,
|
|
2187
|
-
NONE: 0,
|
|
2188
|
-
EF_ID: 0,
|
|
2189
|
-
EF_SIZE: 2,
|
|
2190
|
-
ID_ZIP64: 1,
|
|
2191
|
-
ID_AVINFO: 7,
|
|
2192
|
-
ID_PFS: 8,
|
|
2193
|
-
ID_OS2: 9,
|
|
2194
|
-
ID_NTFS: 10,
|
|
2195
|
-
ID_OPENVMS: 12,
|
|
2196
|
-
ID_UNIX: 13,
|
|
2197
|
-
ID_FORK: 14,
|
|
2198
|
-
ID_PATCH: 15,
|
|
2199
|
-
ID_X509_PKCS7: 20,
|
|
2200
|
-
ID_X509_CERTID_F: 21,
|
|
2201
|
-
ID_X509_CERTID_C: 22,
|
|
2202
|
-
ID_STRONGENC: 23,
|
|
2203
|
-
ID_RECORD_MGT: 24,
|
|
2204
|
-
ID_X509_PKCS7_RL: 25,
|
|
2205
|
-
ID_IBM1: 101,
|
|
2206
|
-
ID_IBM2: 102,
|
|
2207
|
-
ID_POSZIP: 18064,
|
|
2208
|
-
EF_ZIP64_OR_32: 4294967295,
|
|
2209
|
-
EF_ZIP64_OR_16: 65535,
|
|
2210
|
-
EF_ZIP64_SUNCOMP: 0,
|
|
2211
|
-
EF_ZIP64_SCOMP: 8,
|
|
2212
|
-
EF_ZIP64_RHO: 16,
|
|
2213
|
-
EF_ZIP64_DSN: 24
|
|
2214
|
-
};
|
|
2215
|
-
});
|
|
2216
|
-
|
|
2217
|
-
// ../../../node_modules/adm-zip/util/errors.js
|
|
2218
|
-
var require_errors = __commonJS(function(exports) {
|
|
2219
|
-
var errors = {
|
|
2220
|
-
INVALID_LOC: "Invalid LOC header (bad signature)",
|
|
2221
|
-
INVALID_CEN: "Invalid CEN header (bad signature)",
|
|
2222
|
-
INVALID_END: "Invalid END header (bad signature)",
|
|
2223
|
-
DESCRIPTOR_NOT_EXIST: "No descriptor present",
|
|
2224
|
-
DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
|
|
2225
|
-
DESCRIPTOR_FAULTY: "Descriptor data is malformed",
|
|
2226
|
-
NO_DATA: "Nothing to decompress",
|
|
2227
|
-
BAD_CRC: "CRC32 checksum failed {0}",
|
|
2228
|
-
MAX_OUTPUT_EXCEEDED: "Decompressed data exceeds the declared uncompressed size",
|
|
2229
|
-
FILE_IN_THE_WAY: "There is a file in the way: {0}",
|
|
2230
|
-
UNKNOWN_METHOD: "Invalid/unsupported compression method",
|
|
2231
|
-
AVAIL_DATA: "inflate::Available inflate data did not terminate",
|
|
2232
|
-
INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
|
|
2233
|
-
TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
|
|
2234
|
-
INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
|
|
2235
|
-
INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
|
|
2236
|
-
INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
|
|
2237
|
-
INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
|
|
2238
|
-
INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
|
|
2239
|
-
INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
|
|
2240
|
-
INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
|
|
2241
|
-
CANT_EXTRACT_FILE: "Could not extract the file",
|
|
2242
|
-
CANT_OVERRIDE: "Target file already exists",
|
|
2243
|
-
DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
|
|
2244
|
-
NO_ZIP: "No zip file was loaded",
|
|
2245
|
-
NO_ENTRY: "Entry doesn't exist",
|
|
2246
|
-
DUPLICATE_ENTRY: "Duplicate entry name {0}",
|
|
2247
|
-
DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
|
|
2248
|
-
FILE_NOT_FOUND: 'File not found: "{0}"',
|
|
2249
|
-
NOT_IMPLEMENTED: "Not implemented",
|
|
2250
|
-
INVALID_FILENAME: "Invalid filename",
|
|
2251
|
-
INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
|
|
2252
|
-
ZIP64_VALUE_TOO_LARGE: "Zip64 value exceeds the maximum safe integer",
|
|
2253
|
-
INVALID_PASS_PARAM: "Incompatible password parameter",
|
|
2254
|
-
WRONG_PASSWORD: "Wrong Password",
|
|
2255
|
-
COMMENT_TOO_LONG: "Comment is too long",
|
|
2256
|
-
EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
|
|
2257
|
-
};
|
|
2258
|
-
function E(message) {
|
|
2259
|
-
return function(...args) {
|
|
2260
|
-
if (args.length) {
|
|
2261
|
-
message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
|
|
2262
|
-
}
|
|
2263
|
-
return new Error("ADM-ZIP: " + message);
|
|
2264
|
-
};
|
|
2265
|
-
}
|
|
2266
|
-
for (const msg of Object.keys(errors)) {
|
|
2267
|
-
exports[msg] = E(errors[msg]);
|
|
2268
|
-
}
|
|
2269
|
-
});
|
|
2270
|
-
|
|
2271
|
-
// ../../../node_modules/adm-zip/util/utils.js
|
|
2272
|
-
var require_utils = __commonJS(function(exports, module) {
|
|
2273
|
-
var fsystem = __require("fs");
|
|
2274
|
-
var pth = __require("path");
|
|
2275
|
-
var Constants = require_constants();
|
|
2276
|
-
var Errors = require_errors();
|
|
2277
|
-
var isWin = typeof process === "object" && process.platform === "win32";
|
|
2278
|
-
var is_Obj = (obj) => typeof obj === "object" && obj !== null;
|
|
2279
|
-
var crcTable = new Uint32Array(256).map((t, c) => {
|
|
2280
|
-
for (let k = 0;k < 8; k++) {
|
|
2281
|
-
if ((c & 1) !== 0) {
|
|
2282
|
-
c = 3988292384 ^ c >>> 1;
|
|
2283
|
-
} else {
|
|
2284
|
-
c >>>= 1;
|
|
2285
|
-
}
|
|
2286
|
-
}
|
|
2287
|
-
return c >>> 0;
|
|
2288
|
-
});
|
|
2289
|
-
function Utils(opts) {
|
|
2290
|
-
this.sep = pth.sep;
|
|
2291
|
-
this.fs = fsystem;
|
|
2292
|
-
if (is_Obj(opts)) {
|
|
2293
|
-
if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
|
|
2294
|
-
this.fs = opts.fs;
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
2297
|
-
}
|
|
2298
|
-
module.exports = Utils;
|
|
2299
|
-
Utils.prototype.makeDir = function(folder) {
|
|
2300
|
-
const self = this;
|
|
2301
|
-
function mkdirSync(fpath) {
|
|
2302
|
-
let resolvedPath = fpath.split(self.sep)[0];
|
|
2303
|
-
fpath.split(self.sep).forEach(function(name) {
|
|
2304
|
-
if (!name || name.substr(-1, 1) === ":")
|
|
2305
|
-
return;
|
|
2306
|
-
resolvedPath += self.sep + name;
|
|
2307
|
-
var stat2;
|
|
2308
|
-
try {
|
|
2309
|
-
stat2 = self.fs.statSync(resolvedPath);
|
|
2310
|
-
} catch (e) {
|
|
2311
|
-
if (e.message && e.message.startsWith("ENOENT")) {
|
|
2312
|
-
self.fs.mkdirSync(resolvedPath);
|
|
2313
|
-
} else {
|
|
2314
|
-
throw e;
|
|
2315
|
-
}
|
|
2316
|
-
}
|
|
2317
|
-
if (stat2 && stat2.isFile())
|
|
2318
|
-
throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
|
|
2319
|
-
});
|
|
2320
|
-
}
|
|
2321
|
-
mkdirSync(folder);
|
|
2322
|
-
};
|
|
2323
|
-
Utils.prototype.writeFileTo = function(path2, content, overwrite, attr) {
|
|
2324
|
-
const self = this;
|
|
2325
|
-
if (self.fs.existsSync(path2)) {
|
|
2326
|
-
if (!overwrite)
|
|
2327
|
-
return false;
|
|
2328
|
-
var stat2 = self.fs.statSync(path2);
|
|
2329
|
-
if (stat2.isDirectory()) {
|
|
2330
|
-
return false;
|
|
2331
|
-
}
|
|
2332
|
-
}
|
|
2333
|
-
var folder = pth.dirname(path2);
|
|
2334
|
-
if (!self.fs.existsSync(folder)) {
|
|
2335
|
-
self.makeDir(folder);
|
|
2336
|
-
}
|
|
2337
|
-
var fd;
|
|
2338
|
-
try {
|
|
2339
|
-
fd = self.fs.openSync(path2, "w", 438);
|
|
2340
|
-
} catch (e) {
|
|
2341
|
-
self.fs.chmodSync(path2, 438);
|
|
2342
|
-
fd = self.fs.openSync(path2, "w", 438);
|
|
2343
|
-
}
|
|
2344
|
-
if (fd) {
|
|
2345
|
-
try {
|
|
2346
|
-
self.fs.writeSync(fd, content, 0, content.length, 0);
|
|
2347
|
-
} finally {
|
|
2348
|
-
self.fs.closeSync(fd);
|
|
2349
|
-
}
|
|
2350
|
-
}
|
|
2351
|
-
self.fs.chmodSync(path2, attr || 438);
|
|
2352
|
-
return true;
|
|
2353
|
-
};
|
|
2354
|
-
Utils.prototype.writeFileToAsync = function(path2, content, overwrite, attr, callback) {
|
|
2355
|
-
if (typeof attr === "function") {
|
|
2356
|
-
callback = attr;
|
|
2357
|
-
attr = undefined;
|
|
2358
|
-
}
|
|
2359
|
-
const self = this;
|
|
2360
|
-
self.fs.exists(path2, function(exist) {
|
|
2361
|
-
if (exist && !overwrite)
|
|
2362
|
-
return callback(false);
|
|
2363
|
-
self.fs.stat(path2, function(err, stat2) {
|
|
2364
|
-
if (exist && stat2 && stat2.isDirectory()) {
|
|
2365
|
-
return callback(false);
|
|
2366
|
-
}
|
|
2367
|
-
var folder = pth.dirname(path2);
|
|
2368
|
-
self.fs.exists(folder, function(exists) {
|
|
2369
|
-
if (!exists) {
|
|
2370
|
-
try {
|
|
2371
|
-
self.makeDir(folder);
|
|
2372
|
-
} catch (e) {
|
|
2373
|
-
return callback(false);
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
|
-
const writeToFd = function(fd) {
|
|
2377
|
-
self.fs.write(fd, content, 0, content.length, 0, function(writeErr) {
|
|
2378
|
-
self.fs.close(fd, function() {
|
|
2379
|
-
if (writeErr)
|
|
2380
|
-
return callback(false);
|
|
2381
|
-
self.fs.chmod(path2, attr || 438, function() {
|
|
2382
|
-
callback(true);
|
|
2383
|
-
});
|
|
2384
|
-
});
|
|
2385
|
-
});
|
|
2386
|
-
};
|
|
2387
|
-
self.fs.open(path2, "w", 438, function(err2, fd) {
|
|
2388
|
-
if (err2) {
|
|
2389
|
-
self.fs.chmod(path2, 438, function() {
|
|
2390
|
-
self.fs.open(path2, "w", 438, function(retryErr, fd2) {
|
|
2391
|
-
if (retryErr || !fd2)
|
|
2392
|
-
return callback(false);
|
|
2393
|
-
writeToFd(fd2);
|
|
2394
|
-
});
|
|
2395
|
-
});
|
|
2396
|
-
} else if (fd) {
|
|
2397
|
-
writeToFd(fd);
|
|
2398
|
-
} else {
|
|
2399
|
-
callback(false);
|
|
2400
|
-
}
|
|
2401
|
-
});
|
|
2402
|
-
});
|
|
2403
|
-
});
|
|
2404
|
-
});
|
|
2405
|
-
};
|
|
2406
|
-
Utils.prototype.assertPathSafe = function(root, target) {
|
|
2407
|
-
const self = this;
|
|
2408
|
-
if (typeof self.fs.lstatSync !== "function")
|
|
2409
|
-
return;
|
|
2410
|
-
const resolvedRoot = pth.resolve(root);
|
|
2411
|
-
const resolvedTarget = pth.resolve(target);
|
|
2412
|
-
if (resolvedTarget === resolvedRoot)
|
|
2413
|
-
return;
|
|
2414
|
-
const rel = pth.relative(resolvedRoot, resolvedTarget);
|
|
2415
|
-
if (!rel || rel === ".." || rel.startsWith(".." + pth.sep) || pth.isAbsolute(rel))
|
|
2416
|
-
return;
|
|
2417
|
-
let cur = resolvedRoot;
|
|
2418
|
-
for (const part of rel.split(pth.sep)) {
|
|
2419
|
-
if (!part || part === ".")
|
|
2420
|
-
continue;
|
|
2421
|
-
cur = pth.join(cur, part);
|
|
2422
|
-
let stat2;
|
|
2423
|
-
try {
|
|
2424
|
-
stat2 = self.fs.lstatSync(cur);
|
|
2425
|
-
} catch (e) {
|
|
2426
|
-
break;
|
|
2427
|
-
}
|
|
2428
|
-
if (stat2.isSymbolicLink())
|
|
2429
|
-
throw Errors.FILE_IN_THE_WAY(`"${cur}"`);
|
|
2430
|
-
}
|
|
2431
|
-
};
|
|
2432
|
-
Utils.prototype.findFiles = function(path2) {
|
|
2433
|
-
const self = this;
|
|
2434
|
-
const canLstat = typeof self.fs.lstatSync === "function";
|
|
2435
|
-
const rootReal = self.fs.realpathSync(path2);
|
|
2436
|
-
function escapesRoot(p) {
|
|
2437
|
-
if (!canLstat)
|
|
2438
|
-
return false;
|
|
2439
|
-
if (!self.fs.lstatSync(p).isSymbolicLink())
|
|
2440
|
-
return false;
|
|
2441
|
-
let real;
|
|
2442
|
-
try {
|
|
2443
|
-
real = self.fs.realpathSync(p);
|
|
2444
|
-
} catch (e) {
|
|
2445
|
-
return true;
|
|
2446
|
-
}
|
|
2447
|
-
return !(real === rootReal || real.startsWith(rootReal + pth.sep));
|
|
2448
|
-
}
|
|
2449
|
-
function findSync(dir, pattern, recursive, visited) {
|
|
2450
|
-
if (typeof pattern === "boolean") {
|
|
2451
|
-
recursive = pattern;
|
|
2452
|
-
pattern = undefined;
|
|
2453
|
-
}
|
|
2454
|
-
let files = [];
|
|
2455
|
-
self.fs.readdirSync(dir).forEach(function(file) {
|
|
2456
|
-
const path3 = pth.join(dir, file);
|
|
2457
|
-
if (escapesRoot(path3))
|
|
2458
|
-
return;
|
|
2459
|
-
const stat2 = self.fs.statSync(path3);
|
|
2460
|
-
if (!pattern || pattern.test(path3)) {
|
|
2461
|
-
files.push(pth.normalize(path3) + (stat2.isDirectory() ? self.sep : ""));
|
|
2462
|
-
}
|
|
2463
|
-
if (stat2.isDirectory() && recursive) {
|
|
2464
|
-
const realDir = self.fs.realpathSync(path3);
|
|
2465
|
-
if (!visited.has(realDir)) {
|
|
2466
|
-
visited.add(realDir);
|
|
2467
|
-
files = files.concat(findSync(path3, pattern, recursive, visited));
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2470
|
-
});
|
|
2471
|
-
return files;
|
|
2472
|
-
}
|
|
2473
|
-
return findSync(path2, undefined, true, new Set([rootReal]));
|
|
2474
|
-
};
|
|
2475
|
-
Utils.prototype.findFilesAsync = function(dir, cb) {
|
|
2476
|
-
const self = this;
|
|
2477
|
-
const results = [];
|
|
2478
|
-
let finished = false;
|
|
2479
|
-
const finish = function(err) {
|
|
2480
|
-
if (finished)
|
|
2481
|
-
return;
|
|
2482
|
-
finished = true;
|
|
2483
|
-
cb(err, err ? undefined : results);
|
|
2484
|
-
};
|
|
2485
|
-
const canLstat = typeof self.fs.lstat === "function";
|
|
2486
|
-
let rootReal = null;
|
|
2487
|
-
const escapesRoot = function(file, cb2) {
|
|
2488
|
-
if (!canLstat)
|
|
2489
|
-
return cb2(null, false);
|
|
2490
|
-
self.fs.lstat(file, function(err, lst) {
|
|
2491
|
-
if (err)
|
|
2492
|
-
return cb2(err);
|
|
2493
|
-
if (!lst || !lst.isSymbolicLink())
|
|
2494
|
-
return cb2(null, false);
|
|
2495
|
-
self.fs.realpath(file, function(err2, real) {
|
|
2496
|
-
if (err2)
|
|
2497
|
-
return cb2(null, true);
|
|
2498
|
-
cb2(null, !(real === rootReal || real.startsWith(rootReal + pth.sep)));
|
|
2499
|
-
});
|
|
2500
|
-
});
|
|
2501
|
-
};
|
|
2502
|
-
const walk = function(dir2, visited, done) {
|
|
2503
|
-
self.fs.readdir(dir2, function(err, list) {
|
|
2504
|
-
if (err)
|
|
2505
|
-
return done(err);
|
|
2506
|
-
let pending = list.length;
|
|
2507
|
-
if (!pending)
|
|
2508
|
-
return done();
|
|
2509
|
-
list.forEach(function(name) {
|
|
2510
|
-
const file = pth.join(dir2, name);
|
|
2511
|
-
escapesRoot(file, function(err2, escapes) {
|
|
2512
|
-
if (err2)
|
|
2513
|
-
return done(err2);
|
|
2514
|
-
if (escapes) {
|
|
2515
|
-
if (!--pending)
|
|
2516
|
-
done();
|
|
2517
|
-
return;
|
|
2518
|
-
}
|
|
2519
|
-
self.fs.stat(file, function(err3, stat2) {
|
|
2520
|
-
if (err3)
|
|
2521
|
-
return done(err3);
|
|
2522
|
-
if (!stat2) {
|
|
2523
|
-
if (!--pending)
|
|
2524
|
-
done();
|
|
2525
|
-
return;
|
|
2526
|
-
}
|
|
2527
|
-
results.push(pth.normalize(file) + (stat2.isDirectory() ? self.sep : ""));
|
|
2528
|
-
if (!stat2.isDirectory()) {
|
|
2529
|
-
if (!--pending)
|
|
2530
|
-
done();
|
|
2531
|
-
return;
|
|
2532
|
-
}
|
|
2533
|
-
self.fs.realpath(file, function(err4, realDir) {
|
|
2534
|
-
if (err4)
|
|
2535
|
-
return done(err4);
|
|
2536
|
-
if (visited.has(realDir)) {
|
|
2537
|
-
if (!--pending)
|
|
2538
|
-
done();
|
|
2539
|
-
return;
|
|
2540
|
-
}
|
|
2541
|
-
visited.add(realDir);
|
|
2542
|
-
walk(file, visited, function(err5) {
|
|
2543
|
-
if (err5)
|
|
2544
|
-
return done(err5);
|
|
2545
|
-
if (!--pending)
|
|
2546
|
-
done();
|
|
2547
|
-
});
|
|
2548
|
-
});
|
|
2549
|
-
});
|
|
2550
|
-
});
|
|
2551
|
-
});
|
|
2552
|
-
});
|
|
2553
|
-
};
|
|
2554
|
-
self.fs.realpath(dir, function(err, realDir) {
|
|
2555
|
-
if (err)
|
|
2556
|
-
return finish(err);
|
|
2557
|
-
rootReal = realDir;
|
|
2558
|
-
walk(dir, new Set([realDir]), finish);
|
|
2559
|
-
});
|
|
2560
|
-
};
|
|
2561
|
-
Utils.prototype.getAttributes = function() {};
|
|
2562
|
-
Utils.prototype.setAttributes = function() {};
|
|
2563
|
-
Utils.crc32update = function(crc, byte) {
|
|
2564
|
-
return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
|
|
2565
|
-
};
|
|
2566
|
-
Utils.crc32 = function(buf) {
|
|
2567
|
-
if (typeof buf === "string") {
|
|
2568
|
-
buf = Buffer.from(buf, "utf8");
|
|
2569
|
-
}
|
|
2570
|
-
let len = buf.length;
|
|
2571
|
-
let crc = ~0;
|
|
2572
|
-
for (let off = 0;off < len; )
|
|
2573
|
-
crc = Utils.crc32update(crc, buf[off++]);
|
|
2574
|
-
return ~crc >>> 0;
|
|
2575
|
-
};
|
|
2576
|
-
Utils.methodToString = function(method) {
|
|
2577
|
-
switch (method) {
|
|
2578
|
-
case Constants.STORED:
|
|
2579
|
-
return "STORED (" + method + ")";
|
|
2580
|
-
case Constants.DEFLATED:
|
|
2581
|
-
return "DEFLATED (" + method + ")";
|
|
2582
|
-
default:
|
|
2583
|
-
return "UNSUPPORTED (" + method + ")";
|
|
2584
|
-
}
|
|
2585
|
-
};
|
|
2586
|
-
Utils.canonical = function(path2) {
|
|
2587
|
-
if (!path2)
|
|
2588
|
-
return "";
|
|
2589
|
-
const safeSuffix = pth.posix.normalize("/" + path2.split("\\").join("/"));
|
|
2590
|
-
return pth.join(".", safeSuffix);
|
|
2591
|
-
};
|
|
2592
|
-
Utils.zipnamefix = function(path2) {
|
|
2593
|
-
if (!path2)
|
|
2594
|
-
return "";
|
|
2595
|
-
const safeSuffix = pth.posix.normalize("/" + path2.split("\\").join("/"));
|
|
2596
|
-
return pth.posix.join(".", safeSuffix);
|
|
2597
|
-
};
|
|
2598
|
-
Utils.findLast = function(arr, callback) {
|
|
2599
|
-
if (!Array.isArray(arr))
|
|
2600
|
-
throw new TypeError("arr is not array");
|
|
2601
|
-
const len = arr.length >>> 0;
|
|
2602
|
-
for (let i = len - 1;i >= 0; i--) {
|
|
2603
|
-
if (callback(arr[i], i, arr)) {
|
|
2604
|
-
return arr[i];
|
|
2605
|
-
}
|
|
2606
|
-
}
|
|
2607
|
-
return;
|
|
2608
|
-
};
|
|
2609
|
-
Utils.sanitize = function(prefix, name) {
|
|
2610
|
-
prefix = pth.resolve(pth.normalize(prefix));
|
|
2611
|
-
var parts = name.split("/");
|
|
2612
|
-
for (var i = 0, l = parts.length;i < l; i++) {
|
|
2613
|
-
var path2 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
|
|
2614
|
-
if (path2 === prefix || path2.startsWith(prefix + pth.sep)) {
|
|
2615
|
-
return path2;
|
|
2616
|
-
}
|
|
2617
|
-
}
|
|
2618
|
-
return pth.normalize(pth.join(prefix, pth.basename(name)));
|
|
2619
|
-
};
|
|
2620
|
-
Utils.toBuffer = function toBuffer(input, encoder) {
|
|
2621
|
-
if (Buffer.isBuffer(input)) {
|
|
2622
|
-
return input;
|
|
2623
|
-
} else if (input instanceof Uint8Array) {
|
|
2624
|
-
return Buffer.from(input);
|
|
2625
|
-
} else {
|
|
2626
|
-
return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
|
|
2627
|
-
}
|
|
2628
|
-
};
|
|
2629
|
-
Utils.readBigUInt64LE = function(buffer, index) {
|
|
2630
|
-
const lo = buffer.readUInt32LE(index);
|
|
2631
|
-
const hi = buffer.readUInt32LE(index + 4);
|
|
2632
|
-
const value = hi * 4294967296 + lo;
|
|
2633
|
-
if (value > Number.MAX_SAFE_INTEGER) {
|
|
2634
|
-
throw Errors.ZIP64_VALUE_TOO_LARGE();
|
|
2635
|
-
}
|
|
2636
|
-
return value;
|
|
2637
|
-
};
|
|
2638
|
-
Utils.writeBigUInt64LE = function(buffer, value, index) {
|
|
2639
|
-
const lo = value >>> 0;
|
|
2640
|
-
const hi = Math.floor(value / 4294967296) >>> 0;
|
|
2641
|
-
buffer.writeUInt32LE(lo, index);
|
|
2642
|
-
buffer.writeUInt32LE(hi, index + 4);
|
|
2643
|
-
};
|
|
2644
|
-
Utils.fromDOS2Date = function(val) {
|
|
2645
|
-
return new Date((val >> 25 & 127) + 1980, Math.max((val >> 21 & 15) - 1, 0), Math.max(val >> 16 & 31, 1), val >> 11 & 31, val >> 5 & 63, (val & 31) << 1);
|
|
2646
|
-
};
|
|
2647
|
-
Utils.fromDate2DOS = function(val) {
|
|
2648
|
-
let date = 0;
|
|
2649
|
-
let time = 0;
|
|
2650
|
-
if (val.getFullYear() > 1979) {
|
|
2651
|
-
date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
|
|
2652
|
-
time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
|
|
2653
|
-
}
|
|
2654
|
-
return date << 16 | time;
|
|
2655
|
-
};
|
|
2656
|
-
Utils.isWin = isWin;
|
|
2657
|
-
Utils.crcTable = crcTable;
|
|
2658
|
-
});
|
|
2659
|
-
|
|
2660
|
-
// ../../../node_modules/adm-zip/util/fattr.js
|
|
2661
|
-
var require_fattr = __commonJS(function(exports, module) {
|
|
2662
|
-
var pth = __require("path");
|
|
2663
|
-
module.exports = function(path2, { fs: fs2 }) {
|
|
2664
|
-
var _path = path2 || "", _obj = newAttr(), _stat = null;
|
|
2665
|
-
function newAttr() {
|
|
2666
|
-
return {
|
|
2667
|
-
directory: false,
|
|
2668
|
-
readonly: false,
|
|
2669
|
-
hidden: false,
|
|
2670
|
-
executable: false,
|
|
2671
|
-
mtime: 0,
|
|
2672
|
-
atime: 0
|
|
2673
|
-
};
|
|
2674
|
-
}
|
|
2675
|
-
if (_path && fs2.existsSync(_path)) {
|
|
2676
|
-
_stat = fs2.statSync(_path);
|
|
2677
|
-
_obj.directory = _stat.isDirectory();
|
|
2678
|
-
_obj.mtime = _stat.mtime;
|
|
2679
|
-
_obj.atime = _stat.atime;
|
|
2680
|
-
_obj.executable = (73 & _stat.mode) !== 0;
|
|
2681
|
-
_obj.readonly = (128 & _stat.mode) === 0;
|
|
2682
|
-
_obj.hidden = pth.basename(_path)[0] === ".";
|
|
2683
|
-
} else {
|
|
2684
|
-
console.warn("Invalid path: " + _path);
|
|
2685
|
-
}
|
|
2686
|
-
return {
|
|
2687
|
-
get directory() {
|
|
2688
|
-
return _obj.directory;
|
|
2689
|
-
},
|
|
2690
|
-
get readOnly() {
|
|
2691
|
-
return _obj.readonly;
|
|
2692
|
-
},
|
|
2693
|
-
get hidden() {
|
|
2694
|
-
return _obj.hidden;
|
|
2695
|
-
},
|
|
2696
|
-
get mtime() {
|
|
2697
|
-
return _obj.mtime;
|
|
2698
|
-
},
|
|
2699
|
-
get atime() {
|
|
2700
|
-
return _obj.atime;
|
|
2701
|
-
},
|
|
2702
|
-
get executable() {
|
|
2703
|
-
return _obj.executable;
|
|
2704
|
-
},
|
|
2705
|
-
decodeAttributes: function() {},
|
|
2706
|
-
encodeAttributes: function() {},
|
|
2707
|
-
toJSON: function() {
|
|
2708
|
-
return {
|
|
2709
|
-
path: _path,
|
|
2710
|
-
isDirectory: _obj.directory,
|
|
2711
|
-
isReadOnly: _obj.readonly,
|
|
2712
|
-
isHidden: _obj.hidden,
|
|
2713
|
-
isExecutable: _obj.executable,
|
|
2714
|
-
mTime: _obj.mtime,
|
|
2715
|
-
aTime: _obj.atime
|
|
2716
|
-
};
|
|
2717
|
-
},
|
|
2718
|
-
toString: function() {
|
|
2719
|
-
return JSON.stringify(this.toJSON(), null, "\t");
|
|
2720
|
-
}
|
|
2721
|
-
};
|
|
2722
|
-
};
|
|
2723
|
-
});
|
|
2724
|
-
|
|
2725
|
-
// ../../../node_modules/adm-zip/util/decoder.js
|
|
2726
|
-
var require_decoder = __commonJS(function(exports, module) {
|
|
2727
|
-
module.exports = {
|
|
2728
|
-
efs: true,
|
|
2729
|
-
encode: (data) => Buffer.from(data, "utf8"),
|
|
2730
|
-
decode: (data) => data.toString("utf8")
|
|
2731
|
-
};
|
|
2732
|
-
});
|
|
2733
|
-
|
|
2734
|
-
// ../../../node_modules/adm-zip/util/index.js
|
|
2735
|
-
var require_util = __commonJS(function(exports, module) {
|
|
2736
|
-
module.exports = require_utils();
|
|
2737
|
-
module.exports.Constants = require_constants();
|
|
2738
|
-
module.exports.Errors = require_errors();
|
|
2739
|
-
module.exports.FileAttr = require_fattr();
|
|
2740
|
-
module.exports.decoder = require_decoder();
|
|
2741
|
-
});
|
|
2742
|
-
|
|
2743
|
-
// ../../../node_modules/adm-zip/headers/entryHeader.js
|
|
2744
|
-
var require_entryHeader = __commonJS(function(exports, module) {
|
|
2745
|
-
var Utils = require_util();
|
|
2746
|
-
var Constants = Utils.Constants;
|
|
2747
|
-
module.exports = function() {
|
|
2748
|
-
var _verMade = 20, _version = 10, _flags = 0, _method = 0, _time = 0, _crc = 0, _compressedSize = 0, _size = 0, _fnameLen = 0, _extraLen = 0, _comLen = 0, _diskStart = 0, _inattr = 0, _attr = 0, _offset = 0;
|
|
2749
|
-
_verMade |= Utils.isWin ? 2560 : 768;
|
|
2750
|
-
_flags |= Constants.FLG_EFS;
|
|
2751
|
-
const _localHeader = {
|
|
2752
|
-
extraLen: 0
|
|
2753
|
-
};
|
|
2754
|
-
const uint32 = (val) => Math.max(0, val) >>> 0;
|
|
2755
|
-
const uint16 = (val) => Math.max(0, val) & 65535;
|
|
2756
|
-
const uint8 = (val) => Math.max(0, val) & 255;
|
|
2757
|
-
_time = Utils.fromDate2DOS(new Date);
|
|
2758
|
-
return {
|
|
2759
|
-
get made() {
|
|
2760
|
-
return _verMade;
|
|
2761
|
-
},
|
|
2762
|
-
set made(val) {
|
|
2763
|
-
_verMade = val;
|
|
2764
|
-
},
|
|
2765
|
-
get version() {
|
|
2766
|
-
return _version;
|
|
2767
|
-
},
|
|
2768
|
-
set version(val) {
|
|
2769
|
-
_version = val;
|
|
2770
|
-
},
|
|
2771
|
-
get flags() {
|
|
2772
|
-
return _flags;
|
|
2773
|
-
},
|
|
2774
|
-
set flags(val) {
|
|
2775
|
-
_flags = val;
|
|
2776
|
-
},
|
|
2777
|
-
get flags_efs() {
|
|
2778
|
-
return (_flags & Constants.FLG_EFS) > 0;
|
|
2779
|
-
},
|
|
2780
|
-
set flags_efs(val) {
|
|
2781
|
-
if (val) {
|
|
2782
|
-
_flags |= Constants.FLG_EFS;
|
|
2783
|
-
} else {
|
|
2784
|
-
_flags &= ~Constants.FLG_EFS;
|
|
2785
|
-
}
|
|
2786
|
-
},
|
|
2787
|
-
get flags_desc() {
|
|
2788
|
-
return (_flags & Constants.FLG_DESC) > 0;
|
|
2789
|
-
},
|
|
2790
|
-
set flags_desc(val) {
|
|
2791
|
-
if (val) {
|
|
2792
|
-
_flags |= Constants.FLG_DESC;
|
|
2793
|
-
} else {
|
|
2794
|
-
_flags &= ~Constants.FLG_DESC;
|
|
2795
|
-
}
|
|
2796
|
-
},
|
|
2797
|
-
get method() {
|
|
2798
|
-
return _method;
|
|
2799
|
-
},
|
|
2800
|
-
set method(val) {
|
|
2801
|
-
switch (val) {
|
|
2802
|
-
case Constants.STORED:
|
|
2803
|
-
this.version = 10;
|
|
2804
|
-
break;
|
|
2805
|
-
case Constants.DEFLATED:
|
|
2806
|
-
default:
|
|
2807
|
-
this.version = 20;
|
|
2808
|
-
}
|
|
2809
|
-
_method = val;
|
|
2810
|
-
},
|
|
2811
|
-
get time() {
|
|
2812
|
-
return Utils.fromDOS2Date(this.timeval);
|
|
2813
|
-
},
|
|
2814
|
-
set time(val) {
|
|
2815
|
-
val = new Date(val);
|
|
2816
|
-
this.timeval = Utils.fromDate2DOS(val);
|
|
2817
|
-
},
|
|
2818
|
-
get timeval() {
|
|
2819
|
-
return _time;
|
|
2820
|
-
},
|
|
2821
|
-
set timeval(val) {
|
|
2822
|
-
_time = uint32(val);
|
|
2823
|
-
},
|
|
2824
|
-
get timeHighByte() {
|
|
2825
|
-
return uint8(_time >>> 8);
|
|
2826
|
-
},
|
|
2827
|
-
get crc() {
|
|
2828
|
-
return _crc;
|
|
2829
|
-
},
|
|
2830
|
-
set crc(val) {
|
|
2831
|
-
_crc = uint32(val);
|
|
2832
|
-
},
|
|
2833
|
-
get compressedSize() {
|
|
2834
|
-
return _compressedSize;
|
|
2835
|
-
},
|
|
2836
|
-
set compressedSize(val) {
|
|
2837
|
-
_compressedSize = uint32(val);
|
|
2838
|
-
},
|
|
2839
|
-
get size() {
|
|
2840
|
-
return _size;
|
|
2841
|
-
},
|
|
2842
|
-
set size(val) {
|
|
2843
|
-
_size = uint32(val);
|
|
2844
|
-
},
|
|
2845
|
-
get fileNameLength() {
|
|
2846
|
-
return _fnameLen;
|
|
2847
|
-
},
|
|
2848
|
-
set fileNameLength(val) {
|
|
2849
|
-
_fnameLen = val;
|
|
2850
|
-
},
|
|
2851
|
-
get extraLength() {
|
|
2852
|
-
return _extraLen;
|
|
2853
|
-
},
|
|
2854
|
-
set extraLength(val) {
|
|
2855
|
-
_extraLen = val;
|
|
2856
|
-
},
|
|
2857
|
-
get extraLocalLength() {
|
|
2858
|
-
return _localHeader.extraLen;
|
|
2859
|
-
},
|
|
2860
|
-
set extraLocalLength(val) {
|
|
2861
|
-
_localHeader.extraLen = val;
|
|
2862
|
-
},
|
|
2863
|
-
get commentLength() {
|
|
2864
|
-
return _comLen;
|
|
2865
|
-
},
|
|
2866
|
-
set commentLength(val) {
|
|
2867
|
-
_comLen = val;
|
|
2868
|
-
},
|
|
2869
|
-
get diskNumStart() {
|
|
2870
|
-
return _diskStart;
|
|
2871
|
-
},
|
|
2872
|
-
set diskNumStart(val) {
|
|
2873
|
-
_diskStart = uint32(val);
|
|
2874
|
-
},
|
|
2875
|
-
get inAttr() {
|
|
2876
|
-
return _inattr;
|
|
2877
|
-
},
|
|
2878
|
-
set inAttr(val) {
|
|
2879
|
-
_inattr = uint32(val);
|
|
2880
|
-
},
|
|
2881
|
-
get attr() {
|
|
2882
|
-
return _attr;
|
|
2883
|
-
},
|
|
2884
|
-
set attr(val) {
|
|
2885
|
-
_attr = uint32(val);
|
|
2886
|
-
},
|
|
2887
|
-
get fileAttr() {
|
|
2888
|
-
return (_attr || 0) >> 16 & 511;
|
|
2889
|
-
},
|
|
2890
|
-
get offset() {
|
|
2891
|
-
return _offset;
|
|
2892
|
-
},
|
|
2893
|
-
set offset(val) {
|
|
2894
|
-
_offset = uint32(val);
|
|
2895
|
-
},
|
|
2896
|
-
get encrypted() {
|
|
2897
|
-
return (_flags & Constants.FLG_ENC) === Constants.FLG_ENC;
|
|
2898
|
-
},
|
|
2899
|
-
get centralHeaderSize() {
|
|
2900
|
-
return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
|
|
2901
|
-
},
|
|
2902
|
-
get realDataOffset() {
|
|
2903
|
-
return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen;
|
|
2904
|
-
},
|
|
2905
|
-
get localHeader() {
|
|
2906
|
-
return _localHeader;
|
|
2907
|
-
},
|
|
2908
|
-
loadLocalHeaderFromBinary: function(input) {
|
|
2909
|
-
if (_offset < 0 || _offset + Constants.LOCHDR > input.length) {
|
|
2910
|
-
throw Utils.Errors.INVALID_LOC();
|
|
2911
|
-
}
|
|
2912
|
-
var data = input.slice(_offset, _offset + Constants.LOCHDR);
|
|
2913
|
-
if (data.readUInt32LE(0) !== Constants.LOCSIG) {
|
|
2914
|
-
throw Utils.Errors.INVALID_LOC();
|
|
2915
|
-
}
|
|
2916
|
-
_localHeader.version = data.readUInt16LE(Constants.LOCVER);
|
|
2917
|
-
_localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
|
|
2918
|
-
_localHeader.flags_desc = (_localHeader.flags & Constants.FLG_DESC) > 0;
|
|
2919
|
-
_localHeader.method = data.readUInt16LE(Constants.LOCHOW);
|
|
2920
|
-
_localHeader.time = data.readUInt32LE(Constants.LOCTIM);
|
|
2921
|
-
_localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
|
|
2922
|
-
_localHeader.compressedSize = data.readUInt32LE(Constants.LOCSIZ);
|
|
2923
|
-
_localHeader.size = data.readUInt32LE(Constants.LOCLEN);
|
|
2924
|
-
_localHeader.fnameLen = data.readUInt16LE(Constants.LOCNAM);
|
|
2925
|
-
_localHeader.extraLen = data.readUInt16LE(Constants.LOCEXT);
|
|
2926
|
-
const extraStart = _offset + Constants.LOCHDR + _localHeader.fnameLen;
|
|
2927
|
-
const extraEnd = extraStart + _localHeader.extraLen;
|
|
2928
|
-
return input.slice(extraStart, extraEnd);
|
|
2929
|
-
},
|
|
2930
|
-
loadFromBinary: function(data) {
|
|
2931
|
-
if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
|
|
2932
|
-
throw Utils.Errors.INVALID_CEN();
|
|
2933
|
-
}
|
|
2934
|
-
_verMade = data.readUInt16LE(Constants.CENVEM);
|
|
2935
|
-
_version = data.readUInt16LE(Constants.CENVER);
|
|
2936
|
-
_flags = data.readUInt16LE(Constants.CENFLG);
|
|
2937
|
-
_method = data.readUInt16LE(Constants.CENHOW);
|
|
2938
|
-
_time = data.readUInt32LE(Constants.CENTIM);
|
|
2939
|
-
_crc = data.readUInt32LE(Constants.CENCRC);
|
|
2940
|
-
_compressedSize = data.readUInt32LE(Constants.CENSIZ);
|
|
2941
|
-
_size = data.readUInt32LE(Constants.CENLEN);
|
|
2942
|
-
_fnameLen = data.readUInt16LE(Constants.CENNAM);
|
|
2943
|
-
_extraLen = data.readUInt16LE(Constants.CENEXT);
|
|
2944
|
-
_comLen = data.readUInt16LE(Constants.CENCOM);
|
|
2945
|
-
_diskStart = data.readUInt16LE(Constants.CENDSK);
|
|
2946
|
-
_inattr = data.readUInt16LE(Constants.CENATT);
|
|
2947
|
-
_attr = data.readUInt32LE(Constants.CENATX);
|
|
2948
|
-
_offset = data.readUInt32LE(Constants.CENOFF);
|
|
2949
|
-
},
|
|
2950
|
-
localHeaderToBinary: function() {
|
|
2951
|
-
var data = Buffer.alloc(Constants.LOCHDR);
|
|
2952
|
-
data.writeUInt32LE(Constants.LOCSIG, 0);
|
|
2953
|
-
data.writeUInt16LE(_version, Constants.LOCVER);
|
|
2954
|
-
data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.LOCFLG);
|
|
2955
|
-
data.writeUInt16LE(_method, Constants.LOCHOW);
|
|
2956
|
-
data.writeUInt32LE(_time, Constants.LOCTIM);
|
|
2957
|
-
data.writeUInt32LE(_crc, Constants.LOCCRC);
|
|
2958
|
-
data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
|
|
2959
|
-
data.writeUInt32LE(_size, Constants.LOCLEN);
|
|
2960
|
-
data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
|
|
2961
|
-
data.writeUInt16LE(_localHeader.extraLen, Constants.LOCEXT);
|
|
2962
|
-
return data;
|
|
2963
|
-
},
|
|
2964
|
-
centralHeaderToBinary: function() {
|
|
2965
|
-
var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
|
|
2966
|
-
data.writeUInt32LE(Constants.CENSIG, 0);
|
|
2967
|
-
data.writeUInt16LE(_verMade, Constants.CENVEM);
|
|
2968
|
-
data.writeUInt16LE(_version, Constants.CENVER);
|
|
2969
|
-
data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.CENFLG);
|
|
2970
|
-
data.writeUInt16LE(_method, Constants.CENHOW);
|
|
2971
|
-
data.writeUInt32LE(_time, Constants.CENTIM);
|
|
2972
|
-
data.writeUInt32LE(_crc, Constants.CENCRC);
|
|
2973
|
-
data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
|
|
2974
|
-
data.writeUInt32LE(_size, Constants.CENLEN);
|
|
2975
|
-
data.writeUInt16LE(_fnameLen, Constants.CENNAM);
|
|
2976
|
-
data.writeUInt16LE(_extraLen, Constants.CENEXT);
|
|
2977
|
-
data.writeUInt16LE(_comLen, Constants.CENCOM);
|
|
2978
|
-
data.writeUInt16LE(_diskStart, Constants.CENDSK);
|
|
2979
|
-
data.writeUInt16LE(_inattr, Constants.CENATT);
|
|
2980
|
-
data.writeUInt32LE(_attr, Constants.CENATX);
|
|
2981
|
-
data.writeUInt32LE(_offset, Constants.CENOFF);
|
|
2982
|
-
return data;
|
|
2983
|
-
},
|
|
2984
|
-
toJSON: function() {
|
|
2985
|
-
const bytes = function(nr) {
|
|
2986
|
-
return nr + " bytes";
|
|
2987
|
-
};
|
|
2988
|
-
return {
|
|
2989
|
-
made: _verMade,
|
|
2990
|
-
version: _version,
|
|
2991
|
-
flags: _flags,
|
|
2992
|
-
method: Utils.methodToString(_method),
|
|
2993
|
-
time: this.time,
|
|
2994
|
-
crc: "0x" + _crc.toString(16).toUpperCase(),
|
|
2995
|
-
compressedSize: bytes(_compressedSize),
|
|
2996
|
-
size: bytes(_size),
|
|
2997
|
-
fileNameLength: bytes(_fnameLen),
|
|
2998
|
-
extraLength: bytes(_extraLen),
|
|
2999
|
-
commentLength: bytes(_comLen),
|
|
3000
|
-
diskNumStart: _diskStart,
|
|
3001
|
-
inAttr: _inattr,
|
|
3002
|
-
attr: _attr,
|
|
3003
|
-
offset: _offset,
|
|
3004
|
-
centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
|
|
3005
|
-
};
|
|
3006
|
-
},
|
|
3007
|
-
toString: function() {
|
|
3008
|
-
return JSON.stringify(this.toJSON(), null, "\t");
|
|
3009
|
-
}
|
|
3010
|
-
};
|
|
3011
|
-
};
|
|
3012
|
-
});
|
|
3013
|
-
|
|
3014
|
-
// ../../../node_modules/adm-zip/headers/mainHeader.js
|
|
3015
|
-
var require_mainHeader = __commonJS(function(exports, module) {
|
|
3016
|
-
var Utils = require_util();
|
|
3017
|
-
var Constants = Utils.Constants;
|
|
3018
|
-
module.exports = function() {
|
|
3019
|
-
var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
|
|
3020
|
-
const needsZip64 = () => _volumeEntries > Constants.EF_ZIP64_OR_16 || _totalEntries > Constants.EF_ZIP64_OR_16 || _size > Constants.EF_ZIP64_OR_32 || _offset > Constants.EF_ZIP64_OR_32;
|
|
3021
|
-
return {
|
|
3022
|
-
get diskEntries() {
|
|
3023
|
-
return _volumeEntries;
|
|
3024
|
-
},
|
|
3025
|
-
set diskEntries(val) {
|
|
3026
|
-
_volumeEntries = _totalEntries = val;
|
|
3027
|
-
},
|
|
3028
|
-
get totalEntries() {
|
|
3029
|
-
return _totalEntries;
|
|
3030
|
-
},
|
|
3031
|
-
set totalEntries(val) {
|
|
3032
|
-
_totalEntries = _volumeEntries = val;
|
|
3033
|
-
},
|
|
3034
|
-
get size() {
|
|
3035
|
-
return _size;
|
|
3036
|
-
},
|
|
3037
|
-
set size(val) {
|
|
3038
|
-
_size = val;
|
|
3039
|
-
},
|
|
3040
|
-
get offset() {
|
|
3041
|
-
return _offset;
|
|
3042
|
-
},
|
|
3043
|
-
set offset(val) {
|
|
3044
|
-
_offset = val;
|
|
3045
|
-
},
|
|
3046
|
-
get commentLength() {
|
|
3047
|
-
return _commentLength;
|
|
3048
|
-
},
|
|
3049
|
-
set commentLength(val) {
|
|
3050
|
-
_commentLength = val;
|
|
3051
|
-
},
|
|
3052
|
-
get mainHeaderSize() {
|
|
3053
|
-
return (needsZip64() ? Constants.ZIP64HDR + Constants.END64HDR : 0) + Constants.ENDHDR + _commentLength;
|
|
3054
|
-
},
|
|
3055
|
-
loadFromBinary: function(data) {
|
|
3056
|
-
if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
|
|
3057
|
-
throw Utils.Errors.INVALID_END();
|
|
3058
|
-
}
|
|
3059
|
-
if (data.readUInt32LE(0) === Constants.ENDSIG) {
|
|
3060
|
-
_volumeEntries = data.readUInt16LE(Constants.ENDSUB);
|
|
3061
|
-
_totalEntries = data.readUInt16LE(Constants.ENDTOT);
|
|
3062
|
-
_size = data.readUInt32LE(Constants.ENDSIZ);
|
|
3063
|
-
_offset = data.readUInt32LE(Constants.ENDOFF);
|
|
3064
|
-
_commentLength = data.readUInt16LE(Constants.ENDCOM);
|
|
3065
|
-
} else {
|
|
3066
|
-
_volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
|
|
3067
|
-
_totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
|
|
3068
|
-
_size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZB);
|
|
3069
|
-
_offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
|
|
3070
|
-
_commentLength = 0;
|
|
3071
|
-
}
|
|
3072
|
-
},
|
|
3073
|
-
toBinary: function() {
|
|
3074
|
-
if (!needsZip64()) {
|
|
3075
|
-
var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
|
|
3076
|
-
b.writeUInt32LE(Constants.ENDSIG, 0);
|
|
3077
|
-
b.writeUInt32LE(0, 4);
|
|
3078
|
-
b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
|
|
3079
|
-
b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
|
|
3080
|
-
b.writeUInt32LE(_size, Constants.ENDSIZ);
|
|
3081
|
-
b.writeUInt32LE(_offset, Constants.ENDOFF);
|
|
3082
|
-
b.writeUInt16LE(_commentLength, Constants.ENDCOM);
|
|
3083
|
-
b.fill(" ", Constants.ENDHDR);
|
|
3084
|
-
return b;
|
|
3085
|
-
}
|
|
3086
|
-
var b = Buffer.alloc(this.mainHeaderSize);
|
|
3087
|
-
let offset = 0;
|
|
3088
|
-
b.writeUInt32LE(Constants.ZIP64SIG, offset);
|
|
3089
|
-
Utils.writeBigUInt64LE(b, Constants.ZIP64HDR - Constants.ZIP64LEAD, offset + Constants.ZIP64SIZE);
|
|
3090
|
-
b.writeUInt16LE(45, offset + Constants.ZIP64VEM);
|
|
3091
|
-
b.writeUInt16LE(45, offset + Constants.ZIP64VER);
|
|
3092
|
-
b.writeUInt32LE(0, offset + Constants.ZIP64DSK);
|
|
3093
|
-
b.writeUInt32LE(0, offset + Constants.ZIP64DSKDIR);
|
|
3094
|
-
Utils.writeBigUInt64LE(b, _volumeEntries, offset + Constants.ZIP64SUB);
|
|
3095
|
-
Utils.writeBigUInt64LE(b, _totalEntries, offset + Constants.ZIP64TOT);
|
|
3096
|
-
Utils.writeBigUInt64LE(b, _size, offset + Constants.ZIP64SIZB);
|
|
3097
|
-
Utils.writeBigUInt64LE(b, _offset, offset + Constants.ZIP64OFF);
|
|
3098
|
-
const zip64EndOffset = _offset + _size;
|
|
3099
|
-
offset += Constants.ZIP64HDR;
|
|
3100
|
-
b.writeUInt32LE(Constants.END64SIG, offset);
|
|
3101
|
-
b.writeUInt32LE(0, offset + Constants.END64START);
|
|
3102
|
-
Utils.writeBigUInt64LE(b, zip64EndOffset, offset + Constants.END64OFF);
|
|
3103
|
-
b.writeUInt32LE(1, offset + Constants.END64NUMDISKS);
|
|
3104
|
-
offset += Constants.END64HDR;
|
|
3105
|
-
b.writeUInt32LE(Constants.ENDSIG, offset);
|
|
3106
|
-
b.writeUInt32LE(0, offset + 4);
|
|
3107
|
-
b.writeUInt16LE(Math.min(_volumeEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDSUB);
|
|
3108
|
-
b.writeUInt16LE(Math.min(_totalEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDTOT);
|
|
3109
|
-
b.writeUInt32LE(Math.min(_size, Constants.EF_ZIP64_OR_32), offset + Constants.ENDSIZ);
|
|
3110
|
-
b.writeUInt32LE(Math.min(_offset, Constants.EF_ZIP64_OR_32), offset + Constants.ENDOFF);
|
|
3111
|
-
b.writeUInt16LE(_commentLength, offset + Constants.ENDCOM);
|
|
3112
|
-
b.fill(" ", offset + Constants.ENDHDR);
|
|
3113
|
-
return b;
|
|
3114
|
-
},
|
|
3115
|
-
toJSON: function() {
|
|
3116
|
-
const offset = function(nr, len) {
|
|
3117
|
-
let offs = nr.toString(16).toUpperCase();
|
|
3118
|
-
while (offs.length < len)
|
|
3119
|
-
offs = "0" + offs;
|
|
3120
|
-
return "0x" + offs;
|
|
3121
|
-
};
|
|
3122
|
-
return {
|
|
3123
|
-
diskEntries: _volumeEntries,
|
|
3124
|
-
totalEntries: _totalEntries,
|
|
3125
|
-
size: _size + " bytes",
|
|
3126
|
-
offset: offset(_offset, 4),
|
|
3127
|
-
commentLength: _commentLength
|
|
3128
|
-
};
|
|
3129
|
-
},
|
|
3130
|
-
toString: function() {
|
|
3131
|
-
return JSON.stringify(this.toJSON(), null, "\t");
|
|
3132
|
-
}
|
|
3133
|
-
};
|
|
3134
|
-
};
|
|
3135
|
-
});
|
|
3136
|
-
|
|
3137
|
-
// ../../../node_modules/adm-zip/headers/index.js
|
|
3138
|
-
var require_headers = __commonJS(function(exports) {
|
|
3139
|
-
exports.EntryHeader = require_entryHeader();
|
|
3140
|
-
exports.MainHeader = require_mainHeader();
|
|
3141
|
-
});
|
|
3142
|
-
|
|
3143
|
-
// ../../../node_modules/adm-zip/methods/deflater.js
|
|
3144
|
-
var require_deflater = __commonJS(function(exports, module) {
|
|
3145
|
-
module.exports = function(inbuf) {
|
|
3146
|
-
var zlib = __require("zlib");
|
|
3147
|
-
var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
|
|
3148
|
-
return {
|
|
3149
|
-
deflate: function() {
|
|
3150
|
-
return zlib.deflateRawSync(inbuf, opts);
|
|
3151
|
-
},
|
|
3152
|
-
deflateAsync: function(callback) {
|
|
3153
|
-
var tmp = zlib.createDeflateRaw(opts), parts = [], total = 0;
|
|
3154
|
-
tmp.on("data", function(data) {
|
|
3155
|
-
parts.push(data);
|
|
3156
|
-
total += data.length;
|
|
3157
|
-
});
|
|
3158
|
-
tmp.on("end", function() {
|
|
3159
|
-
var buf = Buffer.alloc(total), written = 0;
|
|
3160
|
-
buf.fill(0);
|
|
3161
|
-
for (var i = 0;i < parts.length; i++) {
|
|
3162
|
-
var part = parts[i];
|
|
3163
|
-
part.copy(buf, written);
|
|
3164
|
-
written += part.length;
|
|
3165
|
-
}
|
|
3166
|
-
callback && callback(buf);
|
|
3167
|
-
});
|
|
3168
|
-
tmp.end(inbuf);
|
|
3169
|
-
}
|
|
3170
|
-
};
|
|
3171
|
-
};
|
|
3172
|
-
});
|
|
3173
|
-
|
|
3174
|
-
// ../../../node_modules/adm-zip/methods/inflater.js
|
|
3175
|
-
var require_inflater = __commonJS(function(exports, module) {
|
|
3176
|
-
var version = +(process?.versions?.node ?? "").split(".")[0] || 0;
|
|
3177
|
-
var Errors = require_errors();
|
|
3178
|
-
module.exports = function(inbuf, expectedLength) {
|
|
3179
|
-
var zlib = __require("zlib");
|
|
3180
|
-
const maxOutputLength = expectedLength > 0 ? expectedLength : 1;
|
|
3181
|
-
const option = version >= 15 ? { maxOutputLength } : {};
|
|
3182
|
-
return {
|
|
3183
|
-
inflate: function() {
|
|
3184
|
-
return zlib.inflateRawSync(inbuf, option);
|
|
3185
|
-
},
|
|
3186
|
-
inflateAsync: function(callback) {
|
|
3187
|
-
var tmp = zlib.createInflateRaw(option), parts = [], total = 0, done = false;
|
|
3188
|
-
const fail = function(err) {
|
|
3189
|
-
if (done)
|
|
3190
|
-
return;
|
|
3191
|
-
done = true;
|
|
3192
|
-
tmp.destroy();
|
|
3193
|
-
callback && callback(Buffer.alloc(0), err);
|
|
3194
|
-
};
|
|
3195
|
-
tmp.on("error", function(err) {
|
|
3196
|
-
fail(err);
|
|
3197
|
-
});
|
|
3198
|
-
tmp.on("data", function(data) {
|
|
3199
|
-
if (done)
|
|
3200
|
-
return;
|
|
3201
|
-
total += data.length;
|
|
3202
|
-
if (total > maxOutputLength) {
|
|
3203
|
-
return fail(Errors.MAX_OUTPUT_EXCEEDED());
|
|
3204
|
-
}
|
|
3205
|
-
parts.push(data);
|
|
3206
|
-
});
|
|
3207
|
-
tmp.on("end", function() {
|
|
3208
|
-
if (done)
|
|
3209
|
-
return;
|
|
3210
|
-
done = true;
|
|
3211
|
-
var buf = Buffer.alloc(total), written = 0;
|
|
3212
|
-
buf.fill(0);
|
|
3213
|
-
for (var i = 0;i < parts.length; i++) {
|
|
3214
|
-
var part = parts[i];
|
|
3215
|
-
part.copy(buf, written);
|
|
3216
|
-
written += part.length;
|
|
3217
|
-
}
|
|
3218
|
-
callback && callback(buf);
|
|
3219
|
-
});
|
|
3220
|
-
tmp.end(inbuf);
|
|
3221
|
-
}
|
|
3222
|
-
};
|
|
3223
|
-
};
|
|
3224
|
-
});
|
|
3225
|
-
|
|
3226
|
-
// ../../../node_modules/adm-zip/methods/zipcrypto.js
|
|
3227
|
-
var require_zipcrypto = __commonJS(function(exports, module) {
|
|
3228
|
-
var { randomFillSync } = __require("crypto");
|
|
3229
|
-
var Errors = require_errors();
|
|
3230
|
-
var crctable = new Uint32Array(256).map((t, crc) => {
|
|
3231
|
-
for (let j = 0;j < 8; j++) {
|
|
3232
|
-
if ((crc & 1) !== 0) {
|
|
3233
|
-
crc = crc >>> 1 ^ 3988292384;
|
|
3234
|
-
} else {
|
|
3235
|
-
crc >>>= 1;
|
|
3236
|
-
}
|
|
3237
|
-
}
|
|
3238
|
-
return crc >>> 0;
|
|
3239
|
-
});
|
|
3240
|
-
var uMul = (a, b) => Math.imul(a, b) >>> 0;
|
|
3241
|
-
var crc32update = (pCrc32, bval) => {
|
|
3242
|
-
return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
|
|
3243
|
-
};
|
|
3244
|
-
var genSalt = () => {
|
|
3245
|
-
if (typeof randomFillSync === "function") {
|
|
3246
|
-
return randomFillSync(Buffer.alloc(12));
|
|
3247
|
-
} else {
|
|
3248
|
-
return genSalt.node();
|
|
3249
|
-
}
|
|
3250
|
-
};
|
|
3251
|
-
genSalt.node = () => {
|
|
3252
|
-
const salt = Buffer.alloc(12);
|
|
3253
|
-
const len = salt.length;
|
|
3254
|
-
for (let i = 0;i < len; i++)
|
|
3255
|
-
salt[i] = Math.random() * 256 & 255;
|
|
3256
|
-
return salt;
|
|
3257
|
-
};
|
|
3258
|
-
var config = {
|
|
3259
|
-
genSalt
|
|
3260
|
-
};
|
|
3261
|
-
function Initkeys(pw) {
|
|
3262
|
-
const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
|
|
3263
|
-
this.keys = new Uint32Array([305419896, 591751049, 878082192]);
|
|
3264
|
-
for (let i = 0;i < pass.length; i++) {
|
|
3265
|
-
this.updateKeys(pass[i]);
|
|
3266
|
-
}
|
|
3267
|
-
}
|
|
3268
|
-
Initkeys.prototype.updateKeys = function(byteValue) {
|
|
3269
|
-
const keys = this.keys;
|
|
3270
|
-
keys[0] = crc32update(keys[0], byteValue);
|
|
3271
|
-
keys[1] += keys[0] & 255;
|
|
3272
|
-
keys[1] = uMul(keys[1], 134775813) + 1;
|
|
3273
|
-
keys[2] = crc32update(keys[2], keys[1] >>> 24);
|
|
3274
|
-
return byteValue;
|
|
3275
|
-
};
|
|
3276
|
-
Initkeys.prototype.next = function() {
|
|
3277
|
-
const k = (this.keys[2] | 2) >>> 0;
|
|
3278
|
-
return uMul(k, k ^ 1) >> 8 & 255;
|
|
3279
|
-
};
|
|
3280
|
-
function make_decrypter(pwd) {
|
|
3281
|
-
const keys = new Initkeys(pwd);
|
|
3282
|
-
return function(data) {
|
|
3283
|
-
const result = Buffer.alloc(data.length);
|
|
3284
|
-
let pos = 0;
|
|
3285
|
-
for (let c of data) {
|
|
3286
|
-
result[pos++] = keys.updateKeys(c ^ keys.next());
|
|
3287
|
-
}
|
|
3288
|
-
return result;
|
|
3289
|
-
};
|
|
3290
|
-
}
|
|
3291
|
-
function make_encrypter(pwd) {
|
|
3292
|
-
const keys = new Initkeys(pwd);
|
|
3293
|
-
return function(data, result, pos = 0) {
|
|
3294
|
-
if (!result)
|
|
3295
|
-
result = Buffer.alloc(data.length);
|
|
3296
|
-
for (let c of data) {
|
|
3297
|
-
const k = keys.next();
|
|
3298
|
-
result[pos++] = c ^ k;
|
|
3299
|
-
keys.updateKeys(c);
|
|
3300
|
-
}
|
|
3301
|
-
return result;
|
|
3302
|
-
};
|
|
3303
|
-
}
|
|
3304
|
-
function decrypt(data, header, pwd) {
|
|
3305
|
-
if (!data || !Buffer.isBuffer(data) || data.length < 12) {
|
|
3306
|
-
return Buffer.alloc(0);
|
|
3307
|
-
}
|
|
3308
|
-
const decrypter = make_decrypter(pwd);
|
|
3309
|
-
const salt = decrypter(data.slice(0, 12));
|
|
3310
|
-
const verifyByte = (header.flags & 8) === 8 ? header.timeHighByte : header.crc >>> 24;
|
|
3311
|
-
if (salt[11] !== verifyByte) {
|
|
3312
|
-
throw Errors.WRONG_PASSWORD();
|
|
3313
|
-
}
|
|
3314
|
-
return decrypter(data.slice(12));
|
|
3315
|
-
}
|
|
3316
|
-
function _salter(data) {
|
|
3317
|
-
if (Buffer.isBuffer(data) && data.length >= 12) {
|
|
3318
|
-
config.genSalt = function() {
|
|
3319
|
-
return data.slice(0, 12);
|
|
3320
|
-
};
|
|
3321
|
-
} else if (data === "node") {
|
|
3322
|
-
config.genSalt = genSalt.node;
|
|
3323
|
-
} else {
|
|
3324
|
-
config.genSalt = genSalt;
|
|
3325
|
-
}
|
|
3326
|
-
}
|
|
3327
|
-
function encrypt(data, header, pwd, oldlike = false) {
|
|
3328
|
-
if (data == null)
|
|
3329
|
-
data = Buffer.alloc(0);
|
|
3330
|
-
if (!Buffer.isBuffer(data))
|
|
3331
|
-
data = Buffer.from(data.toString());
|
|
3332
|
-
const encrypter = make_encrypter(pwd);
|
|
3333
|
-
const salt = config.genSalt();
|
|
3334
|
-
salt[11] = header.crc >>> 24 & 255;
|
|
3335
|
-
if (oldlike)
|
|
3336
|
-
salt[10] = header.crc >>> 16 & 255;
|
|
3337
|
-
const result = Buffer.alloc(data.length + 12);
|
|
3338
|
-
encrypter(salt, result);
|
|
3339
|
-
return encrypter(data, result, 12);
|
|
3340
|
-
}
|
|
3341
|
-
module.exports = { decrypt, encrypt, _salter };
|
|
3342
|
-
});
|
|
3343
|
-
|
|
3344
|
-
// ../../../node_modules/adm-zip/methods/index.js
|
|
3345
|
-
var require_methods = __commonJS(function(exports) {
|
|
3346
|
-
exports.Deflater = require_deflater();
|
|
3347
|
-
exports.Inflater = require_inflater();
|
|
3348
|
-
exports.ZipCrypto = require_zipcrypto();
|
|
3349
|
-
});
|
|
3350
|
-
|
|
3351
|
-
// ../../../node_modules/adm-zip/zipEntry.js
|
|
3352
|
-
var require_zipEntry = __commonJS(function(exports, module) {
|
|
3353
|
-
var Utils = require_util();
|
|
3354
|
-
var Headers2 = require_headers();
|
|
3355
|
-
var Constants = Utils.Constants;
|
|
3356
|
-
var Methods = require_methods();
|
|
3357
|
-
module.exports = function(options, input) {
|
|
3358
|
-
var _centralHeader = new Headers2.EntryHeader, _entryName = Buffer.alloc(0), _comment = Buffer.alloc(0), _isDirectory = false, uncompressedData = null, _extra = Buffer.alloc(0), _extralocal = Buffer.alloc(0), _efs = true;
|
|
3359
|
-
const opts = options;
|
|
3360
|
-
const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
|
|
3361
|
-
_efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
|
|
3362
|
-
function getCompressedDataFromZip() {
|
|
3363
|
-
if (!input || !(input instanceof Uint8Array)) {
|
|
3364
|
-
return Buffer.alloc(0);
|
|
3365
|
-
}
|
|
3366
|
-
_extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
|
|
3367
|
-
const dataOffset = _centralHeader.realDataOffset;
|
|
3368
|
-
const dataEnd = dataOffset + _centralHeader.compressedSize;
|
|
3369
|
-
if (dataOffset < 0 || dataEnd < dataOffset || dataEnd > input.length) {
|
|
3370
|
-
throw Utils.Errors.INVALID_LOC();
|
|
3371
|
-
}
|
|
3372
|
-
return input.slice(dataOffset, dataEnd);
|
|
3373
|
-
}
|
|
3374
|
-
function crc32OK(data) {
|
|
3375
|
-
const expectedCrc = _centralHeader.flags_desc || _centralHeader.localHeader.flags_desc ? _centralHeader.crc : _centralHeader.localHeader.crc;
|
|
3376
|
-
return Utils.crc32(data) === expectedCrc;
|
|
3377
|
-
}
|
|
3378
|
-
function decompress(async, callback, pass) {
|
|
3379
|
-
if (typeof callback === "undefined" && typeof async === "string") {
|
|
3380
|
-
pass = async;
|
|
3381
|
-
async = undefined;
|
|
3382
|
-
}
|
|
3383
|
-
if (_isDirectory) {
|
|
3384
|
-
if (async && callback) {
|
|
3385
|
-
callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
|
|
3386
|
-
}
|
|
3387
|
-
return Buffer.alloc(0);
|
|
3388
|
-
}
|
|
3389
|
-
var compressedData;
|
|
3390
|
-
try {
|
|
3391
|
-
compressedData = getCompressedDataFromZip();
|
|
3392
|
-
if (compressedData.length === 0) {
|
|
3393
|
-
if (async && callback)
|
|
3394
|
-
callback(compressedData);
|
|
3395
|
-
return compressedData;
|
|
3396
|
-
}
|
|
3397
|
-
if (_centralHeader.encrypted) {
|
|
3398
|
-
if (typeof pass !== "string" && !Buffer.isBuffer(pass)) {
|
|
3399
|
-
throw Utils.Errors.INVALID_PASS_PARAM();
|
|
3400
|
-
}
|
|
3401
|
-
compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
|
|
3402
|
-
}
|
|
3403
|
-
} catch (err) {
|
|
3404
|
-
if (async && callback) {
|
|
3405
|
-
callback(Buffer.alloc(0), err);
|
|
3406
|
-
return Buffer.alloc(0);
|
|
3407
|
-
}
|
|
3408
|
-
throw err;
|
|
3409
|
-
}
|
|
3410
|
-
var data;
|
|
3411
|
-
switch (_centralHeader.method) {
|
|
3412
|
-
case Utils.Constants.STORED:
|
|
3413
|
-
data = Buffer.alloc(compressedData.length);
|
|
3414
|
-
compressedData.copy(data);
|
|
3415
|
-
if (!crc32OK(data)) {
|
|
3416
|
-
if (async && callback)
|
|
3417
|
-
callback(data, Utils.Errors.BAD_CRC());
|
|
3418
|
-
throw Utils.Errors.BAD_CRC();
|
|
3419
|
-
} else {
|
|
3420
|
-
if (async && callback)
|
|
3421
|
-
callback(data);
|
|
3422
|
-
return data;
|
|
3423
|
-
}
|
|
3424
|
-
case Utils.Constants.DEFLATED:
|
|
3425
|
-
var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
|
|
3426
|
-
if (!async) {
|
|
3427
|
-
data = inflater.inflate();
|
|
3428
|
-
if (!crc32OK(data)) {
|
|
3429
|
-
throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
|
|
3430
|
-
}
|
|
3431
|
-
return data;
|
|
3432
|
-
} else {
|
|
3433
|
-
inflater.inflateAsync(function(result, err) {
|
|
3434
|
-
if (!callback)
|
|
3435
|
-
return;
|
|
3436
|
-
if (err) {
|
|
3437
|
-
callback(Buffer.alloc(0), err);
|
|
3438
|
-
} else if (!crc32OK(result)) {
|
|
3439
|
-
callback(result, Utils.Errors.BAD_CRC());
|
|
3440
|
-
} else {
|
|
3441
|
-
callback(result);
|
|
3442
|
-
}
|
|
3443
|
-
});
|
|
3444
|
-
}
|
|
3445
|
-
break;
|
|
3446
|
-
default:
|
|
3447
|
-
if (async && callback)
|
|
3448
|
-
callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
|
|
3449
|
-
throw Utils.Errors.UNKNOWN_METHOD();
|
|
3450
|
-
}
|
|
3451
|
-
}
|
|
3452
|
-
function compress(async, callback) {
|
|
3453
|
-
if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
|
|
3454
|
-
if (async && callback)
|
|
3455
|
-
callback(getCompressedDataFromZip());
|
|
3456
|
-
return getCompressedDataFromZip();
|
|
3457
|
-
}
|
|
3458
|
-
if (uncompressedData.length && !_isDirectory) {
|
|
3459
|
-
var compressedData;
|
|
3460
|
-
switch (_centralHeader.method) {
|
|
3461
|
-
case Utils.Constants.STORED:
|
|
3462
|
-
_centralHeader.compressedSize = _centralHeader.size;
|
|
3463
|
-
compressedData = Buffer.alloc(uncompressedData.length);
|
|
3464
|
-
uncompressedData.copy(compressedData);
|
|
3465
|
-
if (async && callback)
|
|
3466
|
-
callback(compressedData);
|
|
3467
|
-
return compressedData;
|
|
3468
|
-
default:
|
|
3469
|
-
case Utils.Constants.DEFLATED:
|
|
3470
|
-
var deflater = new Methods.Deflater(uncompressedData);
|
|
3471
|
-
if (!async) {
|
|
3472
|
-
var deflated = deflater.deflate();
|
|
3473
|
-
_centralHeader.compressedSize = deflated.length;
|
|
3474
|
-
return deflated;
|
|
3475
|
-
} else {
|
|
3476
|
-
deflater.deflateAsync(function(data) {
|
|
3477
|
-
compressedData = Buffer.alloc(data.length);
|
|
3478
|
-
_centralHeader.compressedSize = data.length;
|
|
3479
|
-
data.copy(compressedData);
|
|
3480
|
-
callback && callback(compressedData);
|
|
3481
|
-
});
|
|
3482
|
-
}
|
|
3483
|
-
deflater = null;
|
|
3484
|
-
break;
|
|
3485
|
-
}
|
|
3486
|
-
} else if (async && callback) {
|
|
3487
|
-
callback(Buffer.alloc(0));
|
|
3488
|
-
} else {
|
|
3489
|
-
return Buffer.alloc(0);
|
|
3490
|
-
}
|
|
3491
|
-
}
|
|
3492
|
-
function readUInt64LE(buffer, offset) {
|
|
3493
|
-
return Utils.readBigUInt64LE(buffer, offset);
|
|
3494
|
-
}
|
|
3495
|
-
function parseExtra(data) {
|
|
3496
|
-
try {
|
|
3497
|
-
var offset = 0;
|
|
3498
|
-
var signature, size, part;
|
|
3499
|
-
while (offset + 4 < data.length) {
|
|
3500
|
-
signature = data.readUInt16LE(offset);
|
|
3501
|
-
offset += 2;
|
|
3502
|
-
size = data.readUInt16LE(offset);
|
|
3503
|
-
offset += 2;
|
|
3504
|
-
part = data.slice(offset, offset + size);
|
|
3505
|
-
offset += size;
|
|
3506
|
-
if (Constants.ID_ZIP64 === signature) {
|
|
3507
|
-
parseZip64ExtendedInformation(part);
|
|
3508
|
-
}
|
|
3509
|
-
}
|
|
3510
|
-
} catch (error) {
|
|
3511
|
-
throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
|
|
3512
|
-
}
|
|
3513
|
-
}
|
|
3514
|
-
function parseZip64ExtendedInformation(data) {
|
|
3515
|
-
var size, compressedSize, offset, diskNumStart;
|
|
3516
|
-
if (data.length >= Constants.EF_ZIP64_SCOMP) {
|
|
3517
|
-
size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
|
|
3518
|
-
if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
|
|
3519
|
-
_centralHeader.size = size;
|
|
3520
|
-
}
|
|
3521
|
-
}
|
|
3522
|
-
if (data.length >= Constants.EF_ZIP64_RHO) {
|
|
3523
|
-
compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
|
|
3524
|
-
if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
|
|
3525
|
-
_centralHeader.compressedSize = compressedSize;
|
|
3526
|
-
}
|
|
3527
|
-
}
|
|
3528
|
-
if (data.length >= Constants.EF_ZIP64_DSN) {
|
|
3529
|
-
offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
|
|
3530
|
-
if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
|
|
3531
|
-
_centralHeader.offset = offset;
|
|
3532
|
-
}
|
|
3533
|
-
}
|
|
3534
|
-
if (data.length >= Constants.EF_ZIP64_DSN + 4) {
|
|
3535
|
-
diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
|
|
3536
|
-
if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
|
|
3537
|
-
_centralHeader.diskNumStart = diskNumStart;
|
|
3538
|
-
}
|
|
3539
|
-
}
|
|
3540
|
-
}
|
|
3541
|
-
return {
|
|
3542
|
-
get entryName() {
|
|
3543
|
-
return decoder.decode(_entryName);
|
|
3544
|
-
},
|
|
3545
|
-
get rawEntryName() {
|
|
3546
|
-
return _entryName;
|
|
3547
|
-
},
|
|
3548
|
-
set entryName(val) {
|
|
3549
|
-
_entryName = Utils.toBuffer(val, decoder.encode);
|
|
3550
|
-
var lastChar = _entryName[_entryName.length - 1];
|
|
3551
|
-
_isDirectory = lastChar === 47 || lastChar === 92;
|
|
3552
|
-
_centralHeader.fileNameLength = _entryName.length;
|
|
3553
|
-
},
|
|
3554
|
-
get efs() {
|
|
3555
|
-
if (typeof _efs === "function") {
|
|
3556
|
-
return _efs(this.entryName);
|
|
3557
|
-
} else {
|
|
3558
|
-
return _efs;
|
|
3559
|
-
}
|
|
3560
|
-
},
|
|
3561
|
-
get extra() {
|
|
3562
|
-
return _extra;
|
|
3563
|
-
},
|
|
3564
|
-
set extra(val) {
|
|
3565
|
-
_extra = val;
|
|
3566
|
-
_centralHeader.extraLength = val.length;
|
|
3567
|
-
parseExtra(val);
|
|
3568
|
-
},
|
|
3569
|
-
get comment() {
|
|
3570
|
-
return decoder.decode(_comment);
|
|
3571
|
-
},
|
|
3572
|
-
set comment(val) {
|
|
3573
|
-
_comment = Utils.toBuffer(val, decoder.encode);
|
|
3574
|
-
_centralHeader.commentLength = _comment.length;
|
|
3575
|
-
if (_comment.length > 65535)
|
|
3576
|
-
throw Utils.Errors.COMMENT_TOO_LONG();
|
|
3577
|
-
},
|
|
3578
|
-
get name() {
|
|
3579
|
-
const n = decoder.decode(_entryName);
|
|
3580
|
-
return _isDirectory ? n.replace(/[/\\]$/, "").split("/").pop() : n.split("/").pop();
|
|
3581
|
-
},
|
|
3582
|
-
get isDirectory() {
|
|
3583
|
-
return _isDirectory;
|
|
3584
|
-
},
|
|
3585
|
-
getCompressedData: function() {
|
|
3586
|
-
return compress(false, null);
|
|
3587
|
-
},
|
|
3588
|
-
getCompressedDataAsync: function(callback) {
|
|
3589
|
-
compress(true, callback);
|
|
3590
|
-
},
|
|
3591
|
-
setData: function(value) {
|
|
3592
|
-
uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
|
|
3593
|
-
if (!_isDirectory && uncompressedData.length) {
|
|
3594
|
-
_centralHeader.size = uncompressedData.length;
|
|
3595
|
-
_centralHeader.method = Utils.Constants.DEFLATED;
|
|
3596
|
-
_centralHeader.crc = Utils.crc32(value);
|
|
3597
|
-
_centralHeader.changed = true;
|
|
3598
|
-
} else {
|
|
3599
|
-
_centralHeader.method = Utils.Constants.STORED;
|
|
3600
|
-
}
|
|
3601
|
-
},
|
|
3602
|
-
getData: function(pass) {
|
|
3603
|
-
if (_centralHeader.changed) {
|
|
3604
|
-
return uncompressedData;
|
|
3605
|
-
} else {
|
|
3606
|
-
return decompress(false, null, pass);
|
|
3607
|
-
}
|
|
3608
|
-
},
|
|
3609
|
-
getDataAsync: function(callback, pass) {
|
|
3610
|
-
if (_centralHeader.changed) {
|
|
3611
|
-
callback(uncompressedData);
|
|
3612
|
-
} else {
|
|
3613
|
-
decompress(true, callback, pass);
|
|
3614
|
-
}
|
|
3615
|
-
},
|
|
3616
|
-
set attr(attr) {
|
|
3617
|
-
_centralHeader.attr = attr;
|
|
3618
|
-
},
|
|
3619
|
-
get attr() {
|
|
3620
|
-
return _centralHeader.attr;
|
|
3621
|
-
},
|
|
3622
|
-
set header(data) {
|
|
3623
|
-
_centralHeader.loadFromBinary(data);
|
|
3624
|
-
},
|
|
3625
|
-
get header() {
|
|
3626
|
-
return _centralHeader;
|
|
3627
|
-
},
|
|
3628
|
-
packCentralHeader: function() {
|
|
3629
|
-
_centralHeader.flags_efs = this.efs;
|
|
3630
|
-
_centralHeader.extraLength = _extra.length;
|
|
3631
|
-
var header = _centralHeader.centralHeaderToBinary();
|
|
3632
|
-
var addpos = Utils.Constants.CENHDR;
|
|
3633
|
-
_entryName.copy(header, addpos);
|
|
3634
|
-
addpos += _entryName.length;
|
|
3635
|
-
_extra.copy(header, addpos);
|
|
3636
|
-
addpos += _centralHeader.extraLength;
|
|
3637
|
-
_comment.copy(header, addpos);
|
|
3638
|
-
return header;
|
|
3639
|
-
},
|
|
3640
|
-
packLocalHeader: function() {
|
|
3641
|
-
let addpos = 0;
|
|
3642
|
-
_centralHeader.flags_efs = this.efs;
|
|
3643
|
-
_centralHeader.extraLocalLength = _extralocal.length;
|
|
3644
|
-
const localHeaderBuf = _centralHeader.localHeaderToBinary();
|
|
3645
|
-
const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
|
|
3646
|
-
localHeaderBuf.copy(localHeader, addpos);
|
|
3647
|
-
addpos += localHeaderBuf.length;
|
|
3648
|
-
_entryName.copy(localHeader, addpos);
|
|
3649
|
-
addpos += _entryName.length;
|
|
3650
|
-
_extralocal.copy(localHeader, addpos);
|
|
3651
|
-
addpos += _extralocal.length;
|
|
3652
|
-
return localHeader;
|
|
3653
|
-
},
|
|
3654
|
-
toJSON: function() {
|
|
3655
|
-
const bytes = function(nr) {
|
|
3656
|
-
return "<" + (nr && nr.length + " bytes buffer" || "null") + ">";
|
|
3657
|
-
};
|
|
3658
|
-
return {
|
|
3659
|
-
entryName: this.entryName,
|
|
3660
|
-
name: this.name,
|
|
3661
|
-
comment: this.comment,
|
|
3662
|
-
isDirectory: this.isDirectory,
|
|
3663
|
-
header: _centralHeader.toJSON(),
|
|
3664
|
-
compressedData: bytes(input),
|
|
3665
|
-
data: bytes(uncompressedData)
|
|
3666
|
-
};
|
|
3667
|
-
},
|
|
3668
|
-
toString: function() {
|
|
3669
|
-
return JSON.stringify(this.toJSON(), null, "\t");
|
|
3670
|
-
}
|
|
3671
|
-
};
|
|
3672
|
-
};
|
|
3673
|
-
});
|
|
3674
|
-
|
|
3675
|
-
// ../../../node_modules/adm-zip/zipFile.js
|
|
3676
|
-
var require_zipFile = __commonJS(function(exports, module) {
|
|
3677
|
-
var ZipEntry = require_zipEntry();
|
|
3678
|
-
var Headers2 = require_headers();
|
|
3679
|
-
var Utils = require_util();
|
|
3680
|
-
module.exports = function(inBuffer, options) {
|
|
3681
|
-
var entryList = [], entryTable = Object.create(null), _comment = Buffer.alloc(0), mainHeader = new Headers2.MainHeader, loadedEntries = false;
|
|
3682
|
-
var password = null;
|
|
3683
|
-
const temporary = new Set;
|
|
3684
|
-
const opts = options;
|
|
3685
|
-
const { noSort, decoder } = opts;
|
|
3686
|
-
if (inBuffer) {
|
|
3687
|
-
readMainHeader(opts.readEntries);
|
|
3688
|
-
} else {
|
|
3689
|
-
loadedEntries = true;
|
|
3690
|
-
}
|
|
3691
|
-
function makeTemporaryFolders() {
|
|
3692
|
-
const foldersList = new Set;
|
|
3693
|
-
for (const elem of Object.keys(entryTable)) {
|
|
3694
|
-
const elements = elem.split("/");
|
|
3695
|
-
elements.pop();
|
|
3696
|
-
if (!elements.length)
|
|
3697
|
-
continue;
|
|
3698
|
-
for (let i = 0;i < elements.length; i++) {
|
|
3699
|
-
const sub = elements.slice(0, i + 1).join("/") + "/";
|
|
3700
|
-
foldersList.add(sub);
|
|
3701
|
-
}
|
|
3702
|
-
}
|
|
3703
|
-
for (const elem of foldersList) {
|
|
3704
|
-
if (!(elem in entryTable)) {
|
|
3705
|
-
const tempfolder = new ZipEntry(opts);
|
|
3706
|
-
tempfolder.entryName = elem;
|
|
3707
|
-
tempfolder.attr = 16;
|
|
3708
|
-
tempfolder.temporary = true;
|
|
3709
|
-
entryList.push(tempfolder);
|
|
3710
|
-
entryTable[tempfolder.entryName] = tempfolder;
|
|
3711
|
-
temporary.add(tempfolder);
|
|
3712
|
-
}
|
|
3713
|
-
}
|
|
3714
|
-
}
|
|
3715
|
-
function readEntries() {
|
|
3716
|
-
loadedEntries = true;
|
|
3717
|
-
entryTable = Object.create(null);
|
|
3718
|
-
if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
|
|
3719
|
-
throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
|
|
3720
|
-
}
|
|
3721
|
-
entryList = new Array(mainHeader.diskEntries);
|
|
3722
|
-
var index = mainHeader.offset;
|
|
3723
|
-
for (var i = 0;i < entryList.length; i++) {
|
|
3724
|
-
var tmp = index, entry = new ZipEntry(opts, inBuffer);
|
|
3725
|
-
entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
|
|
3726
|
-
entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
|
|
3727
|
-
if (entry.header.extraLength) {
|
|
3728
|
-
entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
|
|
3729
|
-
}
|
|
3730
|
-
if (entry.header.commentLength)
|
|
3731
|
-
entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
|
|
3732
|
-
index += entry.header.centralHeaderSize;
|
|
3733
|
-
if (entry.entryName in entryTable) {
|
|
3734
|
-
throw Utils.Errors.DUPLICATE_ENTRY(`"${entry.entryName}"`);
|
|
3735
|
-
}
|
|
3736
|
-
entryList[i] = entry;
|
|
3737
|
-
entryTable[entry.entryName] = entry;
|
|
3738
|
-
}
|
|
3739
|
-
temporary.clear();
|
|
3740
|
-
makeTemporaryFolders();
|
|
3741
|
-
}
|
|
3742
|
-
function readMainHeader(readNow) {
|
|
3743
|
-
var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
|
|
3744
|
-
const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
|
|
3745
|
-
if (trailingSpace)
|
|
3746
|
-
max = 0;
|
|
3747
|
-
for (i;i >= n; i--) {
|
|
3748
|
-
if (inBuffer[i] !== 80)
|
|
3749
|
-
continue;
|
|
3750
|
-
if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
|
|
3751
|
-
endOffset = i;
|
|
3752
|
-
commentEnd = i;
|
|
3753
|
-
endStart = i + Utils.Constants.ENDHDR;
|
|
3754
|
-
n = i - Utils.Constants.END64HDR;
|
|
3755
|
-
continue;
|
|
3756
|
-
}
|
|
3757
|
-
if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
|
|
3758
|
-
n = max;
|
|
3759
|
-
continue;
|
|
3760
|
-
}
|
|
3761
|
-
if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
|
|
3762
|
-
endOffset = i;
|
|
3763
|
-
endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
|
|
3764
|
-
break;
|
|
3765
|
-
}
|
|
3766
|
-
}
|
|
3767
|
-
if (endOffset == -1)
|
|
3768
|
-
throw Utils.Errors.INVALID_FORMAT();
|
|
3769
|
-
mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
|
|
3770
|
-
if (mainHeader.commentLength) {
|
|
3771
|
-
_comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
|
|
3772
|
-
}
|
|
3773
|
-
if (readNow)
|
|
3774
|
-
readEntries();
|
|
3775
|
-
}
|
|
3776
|
-
function sortEntries() {
|
|
3777
|
-
if (entryList.length > 1 && !noSort) {
|
|
3778
|
-
entryList = entryList.map((entry) => ({ entry, key: entry.entryName.toLowerCase() })).sort((a, b) => a.key.localeCompare(b.key)).map((pair) => pair.entry);
|
|
3779
|
-
}
|
|
3780
|
-
}
|
|
3781
|
-
return {
|
|
3782
|
-
get entries() {
|
|
3783
|
-
if (!loadedEntries) {
|
|
3784
|
-
readEntries();
|
|
3785
|
-
}
|
|
3786
|
-
return entryList.filter((e) => !temporary.has(e));
|
|
3787
|
-
},
|
|
3788
|
-
get comment() {
|
|
3789
|
-
return decoder.decode(_comment);
|
|
3790
|
-
},
|
|
3791
|
-
set comment(val) {
|
|
3792
|
-
_comment = Utils.toBuffer(val, decoder.encode);
|
|
3793
|
-
mainHeader.commentLength = _comment.length;
|
|
3794
|
-
},
|
|
3795
|
-
getEntryCount: function() {
|
|
3796
|
-
if (!loadedEntries) {
|
|
3797
|
-
return mainHeader.diskEntries;
|
|
3798
|
-
}
|
|
3799
|
-
return entryList.length;
|
|
3800
|
-
},
|
|
3801
|
-
forEach: function(callback) {
|
|
3802
|
-
this.entries.forEach(callback);
|
|
3803
|
-
},
|
|
3804
|
-
getEntry: function(entryName) {
|
|
3805
|
-
if (!loadedEntries) {
|
|
3806
|
-
readEntries();
|
|
3807
|
-
}
|
|
3808
|
-
return entryTable[entryName] || null;
|
|
3809
|
-
},
|
|
3810
|
-
setEntry: function(entry) {
|
|
3811
|
-
if (!loadedEntries) {
|
|
3812
|
-
readEntries();
|
|
3813
|
-
}
|
|
3814
|
-
entryList.push(entry);
|
|
3815
|
-
entryTable[entry.entryName] = entry;
|
|
3816
|
-
mainHeader.totalEntries = entryList.length;
|
|
3817
|
-
},
|
|
3818
|
-
deleteFile: function(entryName, withsubfolders = true) {
|
|
3819
|
-
if (!loadedEntries) {
|
|
3820
|
-
readEntries();
|
|
3821
|
-
}
|
|
3822
|
-
const entry = entryTable[entryName];
|
|
3823
|
-
const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
|
|
3824
|
-
list.forEach(this.deleteEntry);
|
|
3825
|
-
},
|
|
3826
|
-
deleteEntry: function(entryName) {
|
|
3827
|
-
if (!loadedEntries) {
|
|
3828
|
-
readEntries();
|
|
3829
|
-
}
|
|
3830
|
-
const entry = entryTable[entryName];
|
|
3831
|
-
const index = entryList.indexOf(entry);
|
|
3832
|
-
if (index >= 0) {
|
|
3833
|
-
entryList.splice(index, 1);
|
|
3834
|
-
delete entryTable[entryName];
|
|
3835
|
-
mainHeader.totalEntries = entryList.length;
|
|
3836
|
-
}
|
|
3837
|
-
},
|
|
3838
|
-
getEntryChildren: function(entry, subfolders = true) {
|
|
3839
|
-
if (!loadedEntries) {
|
|
3840
|
-
readEntries();
|
|
3841
|
-
}
|
|
3842
|
-
if (typeof entry === "object") {
|
|
3843
|
-
if (entry.isDirectory && subfolders) {
|
|
3844
|
-
const list = [];
|
|
3845
|
-
const name = entry.entryName;
|
|
3846
|
-
for (const zipEntry of entryList) {
|
|
3847
|
-
if (zipEntry.entryName.startsWith(name)) {
|
|
3848
|
-
list.push(zipEntry);
|
|
3849
|
-
}
|
|
3850
|
-
}
|
|
3851
|
-
return list;
|
|
3852
|
-
} else {
|
|
3853
|
-
return [entry];
|
|
3854
|
-
}
|
|
3855
|
-
}
|
|
3856
|
-
return [];
|
|
3857
|
-
},
|
|
3858
|
-
getChildCount: function(entry) {
|
|
3859
|
-
if (entry && entry.isDirectory) {
|
|
3860
|
-
const list = this.getEntryChildren(entry);
|
|
3861
|
-
return list.includes(entry) ? list.length - 1 : list.length;
|
|
3862
|
-
}
|
|
3863
|
-
return 0;
|
|
3864
|
-
},
|
|
3865
|
-
compressToBuffer: function() {
|
|
3866
|
-
if (!loadedEntries) {
|
|
3867
|
-
readEntries();
|
|
3868
|
-
}
|
|
3869
|
-
sortEntries();
|
|
3870
|
-
const dataBlock = [];
|
|
3871
|
-
const headerBlocks = [];
|
|
3872
|
-
let totalSize = 0;
|
|
3873
|
-
let dindex = 0;
|
|
3874
|
-
mainHeader.size = 0;
|
|
3875
|
-
mainHeader.offset = 0;
|
|
3876
|
-
let totalEntries = 0;
|
|
3877
|
-
for (const entry of this.entries) {
|
|
3878
|
-
const compressedData = entry.getCompressedData();
|
|
3879
|
-
entry.header.offset = dindex;
|
|
3880
|
-
const localHeader = entry.packLocalHeader();
|
|
3881
|
-
const dataLength = localHeader.length + compressedData.length;
|
|
3882
|
-
dindex += dataLength;
|
|
3883
|
-
dataBlock.push(localHeader);
|
|
3884
|
-
dataBlock.push(compressedData);
|
|
3885
|
-
const centralHeader = entry.packCentralHeader();
|
|
3886
|
-
headerBlocks.push(centralHeader);
|
|
3887
|
-
mainHeader.size += centralHeader.length;
|
|
3888
|
-
totalSize += dataLength + centralHeader.length;
|
|
3889
|
-
totalEntries++;
|
|
3890
|
-
}
|
|
3891
|
-
totalSize += mainHeader.mainHeaderSize;
|
|
3892
|
-
mainHeader.offset = dindex;
|
|
3893
|
-
mainHeader.totalEntries = totalEntries;
|
|
3894
|
-
dindex = 0;
|
|
3895
|
-
const outBuffer = Buffer.alloc(totalSize);
|
|
3896
|
-
for (const content of dataBlock) {
|
|
3897
|
-
content.copy(outBuffer, dindex);
|
|
3898
|
-
dindex += content.length;
|
|
3899
|
-
}
|
|
3900
|
-
for (const content of headerBlocks) {
|
|
3901
|
-
content.copy(outBuffer, dindex);
|
|
3902
|
-
dindex += content.length;
|
|
3903
|
-
}
|
|
3904
|
-
const mh = mainHeader.toBinary();
|
|
3905
|
-
if (_comment) {
|
|
3906
|
-
_comment.copy(mh, mh.length - _comment.length);
|
|
3907
|
-
}
|
|
3908
|
-
mh.copy(outBuffer, dindex);
|
|
3909
|
-
inBuffer = outBuffer;
|
|
3910
|
-
loadedEntries = false;
|
|
3911
|
-
return outBuffer;
|
|
3912
|
-
},
|
|
3913
|
-
toAsyncBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
|
|
3914
|
-
try {
|
|
3915
|
-
if (!loadedEntries) {
|
|
3916
|
-
readEntries();
|
|
3917
|
-
}
|
|
3918
|
-
sortEntries();
|
|
3919
|
-
const dataBlock = [];
|
|
3920
|
-
const centralHeaders = [];
|
|
3921
|
-
let totalSize = 0;
|
|
3922
|
-
let dindex = 0;
|
|
3923
|
-
let totalEntries = 0;
|
|
3924
|
-
mainHeader.size = 0;
|
|
3925
|
-
mainHeader.offset = 0;
|
|
3926
|
-
const compress2Buffer = function(entryLists) {
|
|
3927
|
-
if (entryLists.length > 0) {
|
|
3928
|
-
const entry = entryLists.shift();
|
|
3929
|
-
const name = entry.entryName + entry.extra.toString();
|
|
3930
|
-
if (onItemStart)
|
|
3931
|
-
onItemStart(name);
|
|
3932
|
-
entry.getCompressedDataAsync(function(compressedData) {
|
|
3933
|
-
if (onItemEnd)
|
|
3934
|
-
onItemEnd(name);
|
|
3935
|
-
entry.header.offset = dindex;
|
|
3936
|
-
const localHeader = entry.packLocalHeader();
|
|
3937
|
-
const dataLength = localHeader.length + compressedData.length;
|
|
3938
|
-
dindex += dataLength;
|
|
3939
|
-
dataBlock.push(localHeader);
|
|
3940
|
-
dataBlock.push(compressedData);
|
|
3941
|
-
const centalHeader = entry.packCentralHeader();
|
|
3942
|
-
centralHeaders.push(centalHeader);
|
|
3943
|
-
mainHeader.size += centalHeader.length;
|
|
3944
|
-
totalSize += dataLength + centalHeader.length;
|
|
3945
|
-
totalEntries++;
|
|
3946
|
-
compress2Buffer(entryLists);
|
|
3947
|
-
});
|
|
3948
|
-
} else {
|
|
3949
|
-
totalSize += mainHeader.mainHeaderSize;
|
|
3950
|
-
mainHeader.offset = dindex;
|
|
3951
|
-
mainHeader.totalEntries = totalEntries;
|
|
3952
|
-
dindex = 0;
|
|
3953
|
-
const outBuffer = Buffer.alloc(totalSize);
|
|
3954
|
-
dataBlock.forEach(function(content) {
|
|
3955
|
-
content.copy(outBuffer, dindex);
|
|
3956
|
-
dindex += content.length;
|
|
3957
|
-
});
|
|
3958
|
-
centralHeaders.forEach(function(content) {
|
|
3959
|
-
content.copy(outBuffer, dindex);
|
|
3960
|
-
dindex += content.length;
|
|
3961
|
-
});
|
|
3962
|
-
const mh = mainHeader.toBinary();
|
|
3963
|
-
if (_comment) {
|
|
3964
|
-
_comment.copy(mh, mh.length - _comment.length);
|
|
3965
|
-
}
|
|
3966
|
-
mh.copy(outBuffer, dindex);
|
|
3967
|
-
inBuffer = outBuffer;
|
|
3968
|
-
loadedEntries = false;
|
|
3969
|
-
onSuccess(outBuffer);
|
|
3970
|
-
}
|
|
3971
|
-
};
|
|
3972
|
-
compress2Buffer(Array.from(this.entries));
|
|
3973
|
-
} catch (e) {
|
|
3974
|
-
onFail(e);
|
|
3975
|
-
}
|
|
3976
|
-
}
|
|
3977
|
-
};
|
|
3978
|
-
};
|
|
3979
|
-
});
|
|
3980
|
-
|
|
3981
|
-
// ../../../node_modules/adm-zip/adm-zip.js
|
|
3982
|
-
var require_adm_zip = __commonJS(function(exports, module) {
|
|
3983
|
-
var Utils = require_util();
|
|
3984
|
-
var pth = __require("path");
|
|
3985
|
-
var ZipEntry = require_zipEntry();
|
|
3986
|
-
var ZipFile = require_zipFile();
|
|
3987
|
-
var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
|
|
3988
|
-
var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
|
|
3989
|
-
var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
|
|
3990
|
-
var defaultOptions = {
|
|
3991
|
-
noSort: false,
|
|
3992
|
-
readEntries: false,
|
|
3993
|
-
method: Utils.Constants.NONE,
|
|
3994
|
-
fs: null
|
|
3995
|
-
};
|
|
3996
|
-
module.exports = function(input, options) {
|
|
3997
|
-
let inBuffer = null;
|
|
3998
|
-
const opts = Object.assign(Object.create(null), defaultOptions);
|
|
3999
|
-
if (input && typeof input === "object") {
|
|
4000
|
-
if (!(input instanceof Uint8Array)) {
|
|
4001
|
-
Object.assign(opts, input);
|
|
4002
|
-
input = opts.input ? opts.input : undefined;
|
|
4003
|
-
if (opts.input)
|
|
4004
|
-
delete opts.input;
|
|
4005
|
-
}
|
|
4006
|
-
if (Buffer.isBuffer(input)) {
|
|
4007
|
-
inBuffer = input;
|
|
4008
|
-
opts.method = Utils.Constants.BUFFER;
|
|
4009
|
-
input = undefined;
|
|
4010
|
-
}
|
|
4011
|
-
}
|
|
4012
|
-
Object.assign(opts, options);
|
|
4013
|
-
const filetools = new Utils(opts);
|
|
4014
|
-
const applyDirAttributes = (dirEntries) => {
|
|
4015
|
-
dirEntries.filter((d) => d.attr).sort((a, b) => b.path.length - a.path.length).forEach((d) => filetools.fs.chmodSync(d.path, d.attr));
|
|
4016
|
-
};
|
|
4017
|
-
if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
|
|
4018
|
-
opts.decoder = Utils.decoder;
|
|
4019
|
-
}
|
|
4020
|
-
if (input && typeof input === "string") {
|
|
4021
|
-
if (filetools.fs.existsSync(input)) {
|
|
4022
|
-
opts.method = Utils.Constants.FILE;
|
|
4023
|
-
opts.filename = input;
|
|
4024
|
-
inBuffer = filetools.fs.readFileSync(input);
|
|
4025
|
-
} else {
|
|
4026
|
-
throw Utils.Errors.INVALID_FILENAME();
|
|
4027
|
-
}
|
|
4028
|
-
}
|
|
4029
|
-
const _zip = new ZipFile(inBuffer, opts);
|
|
4030
|
-
const { canonical, sanitize, zipnamefix } = Utils;
|
|
4031
|
-
function getEntry(entry) {
|
|
4032
|
-
if (entry && _zip) {
|
|
4033
|
-
var item;
|
|
4034
|
-
if (typeof entry === "string")
|
|
4035
|
-
item = _zip.getEntry(pth.posix.normalize(entry));
|
|
4036
|
-
if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined")
|
|
4037
|
-
item = _zip.getEntry(entry.entryName);
|
|
4038
|
-
if (item) {
|
|
4039
|
-
return item;
|
|
4040
|
-
}
|
|
4041
|
-
}
|
|
4042
|
-
return null;
|
|
4043
|
-
}
|
|
4044
|
-
function fixPath(zipPath) {
|
|
4045
|
-
const { join: join2, normalize, sep } = pth.posix;
|
|
4046
|
-
return join2(pth.isAbsolute(zipPath) ? "/" : ".", normalize(sep + zipPath.split("\\").join(sep) + sep));
|
|
4047
|
-
}
|
|
4048
|
-
function filenameFilter(filterfn) {
|
|
4049
|
-
if (filterfn instanceof RegExp) {
|
|
4050
|
-
return function(rx) {
|
|
4051
|
-
return function(filename) {
|
|
4052
|
-
return rx.test(filename);
|
|
4053
|
-
};
|
|
4054
|
-
}(filterfn);
|
|
4055
|
-
} else if (typeof filterfn !== "function") {
|
|
4056
|
-
return () => true;
|
|
4057
|
-
}
|
|
4058
|
-
return filterfn;
|
|
4059
|
-
}
|
|
4060
|
-
const relativePath = (local, entry) => {
|
|
4061
|
-
let lastChar = entry.slice(-1);
|
|
4062
|
-
lastChar = lastChar === filetools.sep ? filetools.sep : "";
|
|
4063
|
-
return pth.relative(local, entry) + lastChar;
|
|
4064
|
-
};
|
|
4065
|
-
return {
|
|
4066
|
-
readFile: function(entry, pass) {
|
|
4067
|
-
var item = getEntry(entry);
|
|
4068
|
-
return item && item.getData(pass) || null;
|
|
4069
|
-
},
|
|
4070
|
-
childCount: function(entry) {
|
|
4071
|
-
const item = getEntry(entry);
|
|
4072
|
-
if (item) {
|
|
4073
|
-
return _zip.getChildCount(item);
|
|
4074
|
-
}
|
|
4075
|
-
},
|
|
4076
|
-
readFileAsync: function(entry, callback) {
|
|
4077
|
-
var item = getEntry(entry);
|
|
4078
|
-
if (item) {
|
|
4079
|
-
item.getDataAsync(callback);
|
|
4080
|
-
} else {
|
|
4081
|
-
callback(null, "getEntry failed for:" + entry);
|
|
4082
|
-
}
|
|
4083
|
-
},
|
|
4084
|
-
readAsText: function(entry, encoding) {
|
|
4085
|
-
var item = getEntry(entry);
|
|
4086
|
-
if (item) {
|
|
4087
|
-
var data = item.getData();
|
|
4088
|
-
if (data && data.length) {
|
|
4089
|
-
return data.toString(encoding || "utf8");
|
|
4090
|
-
}
|
|
4091
|
-
}
|
|
4092
|
-
return "";
|
|
4093
|
-
},
|
|
4094
|
-
readAsTextAsync: function(entry, callback, encoding) {
|
|
4095
|
-
var item = getEntry(entry);
|
|
4096
|
-
if (item) {
|
|
4097
|
-
item.getDataAsync(function(data, err) {
|
|
4098
|
-
if (err) {
|
|
4099
|
-
callback(data, err);
|
|
4100
|
-
return;
|
|
4101
|
-
}
|
|
4102
|
-
if (data && data.length) {
|
|
4103
|
-
callback(data.toString(encoding || "utf8"));
|
|
4104
|
-
} else {
|
|
4105
|
-
callback("");
|
|
4106
|
-
}
|
|
4107
|
-
});
|
|
4108
|
-
} else {
|
|
4109
|
-
callback("");
|
|
4110
|
-
}
|
|
4111
|
-
},
|
|
4112
|
-
deleteFile: function(entry, withsubfolders = true) {
|
|
4113
|
-
var item = getEntry(entry);
|
|
4114
|
-
if (item) {
|
|
4115
|
-
_zip.deleteFile(item.entryName, withsubfolders);
|
|
4116
|
-
}
|
|
4117
|
-
},
|
|
4118
|
-
deleteEntry: function(entry) {
|
|
4119
|
-
var item = getEntry(entry);
|
|
4120
|
-
if (item) {
|
|
4121
|
-
_zip.deleteEntry(item.entryName);
|
|
4122
|
-
}
|
|
4123
|
-
},
|
|
4124
|
-
addZipComment: function(comment) {
|
|
4125
|
-
_zip.comment = comment;
|
|
4126
|
-
},
|
|
4127
|
-
getZipComment: function() {
|
|
4128
|
-
return _zip.comment || "";
|
|
4129
|
-
},
|
|
4130
|
-
addZipEntryComment: function(entry, comment) {
|
|
4131
|
-
var item = getEntry(entry);
|
|
4132
|
-
if (item) {
|
|
4133
|
-
item.comment = comment;
|
|
4134
|
-
}
|
|
4135
|
-
},
|
|
4136
|
-
getZipEntryComment: function(entry) {
|
|
4137
|
-
var item = getEntry(entry);
|
|
4138
|
-
if (item) {
|
|
4139
|
-
return item.comment || "";
|
|
4140
|
-
}
|
|
4141
|
-
return "";
|
|
4142
|
-
},
|
|
4143
|
-
updateFile: function(entry, content) {
|
|
4144
|
-
var item = getEntry(entry);
|
|
4145
|
-
if (item) {
|
|
4146
|
-
item.setData(content);
|
|
4147
|
-
}
|
|
4148
|
-
},
|
|
4149
|
-
addLocalFile: function(localPath, zipPath, zipName, comment) {
|
|
4150
|
-
if (filetools.fs.existsSync(localPath)) {
|
|
4151
|
-
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
4152
|
-
const p = pth.win32.basename(pth.win32.normalize(localPath));
|
|
4153
|
-
zipPath += zipName ? zipName : p;
|
|
4154
|
-
const _attr = filetools.fs.statSync(localPath);
|
|
4155
|
-
const data = _attr.isFile() ? filetools.fs.readFileSync(localPath) : Buffer.alloc(0);
|
|
4156
|
-
if (_attr.isDirectory())
|
|
4157
|
-
zipPath += filetools.sep;
|
|
4158
|
-
this.addFile(zipPath, data, comment, _attr);
|
|
4159
|
-
} else {
|
|
4160
|
-
throw Utils.Errors.FILE_NOT_FOUND(localPath);
|
|
4161
|
-
}
|
|
4162
|
-
},
|
|
4163
|
-
addLocalFileAsync: function(options2, callback) {
|
|
4164
|
-
options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
|
|
4165
|
-
const localPath = pth.resolve(options2.localPath);
|
|
4166
|
-
const { comment } = options2;
|
|
4167
|
-
let { zipPath, zipName } = options2;
|
|
4168
|
-
const self = this;
|
|
4169
|
-
filetools.fs.stat(localPath, function(err, stats) {
|
|
4170
|
-
if (err)
|
|
4171
|
-
return callback(err, false);
|
|
4172
|
-
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
4173
|
-
const p = pth.win32.basename(pth.win32.normalize(localPath));
|
|
4174
|
-
zipPath += zipName ? zipName : p;
|
|
4175
|
-
if (stats.isFile()) {
|
|
4176
|
-
filetools.fs.readFile(localPath, function(err2, data) {
|
|
4177
|
-
if (err2)
|
|
4178
|
-
return callback(err2, false);
|
|
4179
|
-
self.addFile(zipPath, data, comment, stats);
|
|
4180
|
-
return setImmediate(callback, undefined, true);
|
|
4181
|
-
});
|
|
4182
|
-
} else if (stats.isDirectory()) {
|
|
4183
|
-
zipPath += filetools.sep;
|
|
4184
|
-
self.addFile(zipPath, Buffer.alloc(0), comment, stats);
|
|
4185
|
-
return setImmediate(callback, undefined, true);
|
|
4186
|
-
}
|
|
4187
|
-
});
|
|
4188
|
-
},
|
|
4189
|
-
addLocalFolder: function(localPath, zipPath, filter) {
|
|
4190
|
-
filter = filenameFilter(filter);
|
|
4191
|
-
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
4192
|
-
localPath = pth.normalize(localPath);
|
|
4193
|
-
if (filetools.fs.existsSync(localPath)) {
|
|
4194
|
-
const items = filetools.findFiles(localPath);
|
|
4195
|
-
const self = this;
|
|
4196
|
-
if (items.length) {
|
|
4197
|
-
for (const filepath of items) {
|
|
4198
|
-
const p = pth.join(zipPath, relativePath(localPath, filepath));
|
|
4199
|
-
if (filter(p)) {
|
|
4200
|
-
self.addLocalFile(filepath, pth.dirname(p));
|
|
4201
|
-
}
|
|
4202
|
-
}
|
|
4203
|
-
}
|
|
4204
|
-
} else {
|
|
4205
|
-
throw Utils.Errors.FILE_NOT_FOUND(localPath);
|
|
4206
|
-
}
|
|
4207
|
-
},
|
|
4208
|
-
addLocalFolderAsync: function(localPath, callback, zipPath, filter) {
|
|
4209
|
-
filter = filenameFilter(filter);
|
|
4210
|
-
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
4211
|
-
localPath = pth.normalize(localPath);
|
|
4212
|
-
var self = this;
|
|
4213
|
-
filetools.fs.open(localPath, "r", function(err) {
|
|
4214
|
-
if (err && err.code === "ENOENT") {
|
|
4215
|
-
callback(undefined, Utils.Errors.FILE_NOT_FOUND(localPath));
|
|
4216
|
-
} else if (err) {
|
|
4217
|
-
callback(undefined, err);
|
|
4218
|
-
} else {
|
|
4219
|
-
var items = filetools.findFiles(localPath);
|
|
4220
|
-
var i = -1;
|
|
4221
|
-
var next = function() {
|
|
4222
|
-
i += 1;
|
|
4223
|
-
if (i < items.length) {
|
|
4224
|
-
var filepath = items[i];
|
|
4225
|
-
var p = relativePath(localPath, filepath).split("\\").join("/");
|
|
4226
|
-
p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
|
|
4227
|
-
if (filter(p)) {
|
|
4228
|
-
filetools.fs.stat(filepath, function(er0, stats) {
|
|
4229
|
-
if (er0)
|
|
4230
|
-
callback(undefined, er0);
|
|
4231
|
-
if (stats.isFile()) {
|
|
4232
|
-
filetools.fs.readFile(filepath, function(er1, data) {
|
|
4233
|
-
if (er1) {
|
|
4234
|
-
callback(undefined, er1);
|
|
4235
|
-
} else {
|
|
4236
|
-
self.addFile(zipPath + p, data, "", stats);
|
|
4237
|
-
next();
|
|
4238
|
-
}
|
|
4239
|
-
});
|
|
4240
|
-
} else {
|
|
4241
|
-
self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
|
|
4242
|
-
next();
|
|
4243
|
-
}
|
|
4244
|
-
});
|
|
4245
|
-
} else {
|
|
4246
|
-
process.nextTick(() => {
|
|
4247
|
-
next();
|
|
4248
|
-
});
|
|
4249
|
-
}
|
|
4250
|
-
} else {
|
|
4251
|
-
callback(true, undefined);
|
|
4252
|
-
}
|
|
4253
|
-
};
|
|
4254
|
-
next();
|
|
4255
|
-
}
|
|
4256
|
-
});
|
|
4257
|
-
},
|
|
4258
|
-
addLocalFolderAsync2: function(options2, callback) {
|
|
4259
|
-
const self = this;
|
|
4260
|
-
options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
|
|
4261
|
-
const localPath = pth.resolve(options2.localPath);
|
|
4262
|
-
let { zipPath, filter, namefix } = options2;
|
|
4263
|
-
if (filter instanceof RegExp) {
|
|
4264
|
-
filter = function(rx) {
|
|
4265
|
-
return function(filename) {
|
|
4266
|
-
return rx.test(filename);
|
|
4267
|
-
};
|
|
4268
|
-
}(filter);
|
|
4269
|
-
} else if (typeof filter !== "function") {
|
|
4270
|
-
filter = function() {
|
|
4271
|
-
return true;
|
|
4272
|
-
};
|
|
4273
|
-
}
|
|
4274
|
-
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
4275
|
-
if (namefix === "latin1") {
|
|
4276
|
-
namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
|
|
4277
|
-
}
|
|
4278
|
-
if (typeof namefix !== "function")
|
|
4279
|
-
namefix = (str) => str;
|
|
4280
|
-
const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
|
|
4281
|
-
const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
|
|
4282
|
-
filetools.fs.open(localPath, "r", function(err) {
|
|
4283
|
-
if (err && err.code === "ENOENT") {
|
|
4284
|
-
callback(Utils.Errors.FILE_NOT_FOUND(localPath), false);
|
|
4285
|
-
} else if (err) {
|
|
4286
|
-
callback(err, false);
|
|
4287
|
-
} else {
|
|
4288
|
-
filetools.findFilesAsync(localPath, function(err2, fileEntries) {
|
|
4289
|
-
if (err2)
|
|
4290
|
-
return callback(err2, false);
|
|
4291
|
-
fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
|
|
4292
|
-
if (!fileEntries.length)
|
|
4293
|
-
return callback(undefined, true);
|
|
4294
|
-
setImmediate(fileEntries.reverse().reduce(function(next, entry) {
|
|
4295
|
-
return function(err3, done) {
|
|
4296
|
-
if (err3 || done === false)
|
|
4297
|
-
return setImmediate(next, err3, false);
|
|
4298
|
-
self.addLocalFileAsync({
|
|
4299
|
-
localPath: entry,
|
|
4300
|
-
zipPath: pth.dirname(relPathFix(entry)),
|
|
4301
|
-
zipName: fileNameFix(entry)
|
|
4302
|
-
}, next);
|
|
4303
|
-
};
|
|
4304
|
-
}, callback));
|
|
4305
|
-
});
|
|
4306
|
-
}
|
|
4307
|
-
});
|
|
4308
|
-
},
|
|
4309
|
-
addLocalFolderPromise: function(localPath, props) {
|
|
4310
|
-
return new Promise((resolve2, reject) => {
|
|
4311
|
-
this.addLocalFolderAsync2(Object.assign({ localPath }, props), (err, done) => {
|
|
4312
|
-
if (err)
|
|
4313
|
-
return reject(err);
|
|
4314
|
-
if (done)
|
|
4315
|
-
resolve2(this);
|
|
4316
|
-
});
|
|
4317
|
-
});
|
|
4318
|
-
},
|
|
4319
|
-
addFile: function(entryName, content, comment, attr) {
|
|
4320
|
-
entryName = zipnamefix(entryName);
|
|
4321
|
-
let entry = getEntry(entryName);
|
|
4322
|
-
const update = entry != null;
|
|
4323
|
-
if (!update) {
|
|
4324
|
-
entry = new ZipEntry(opts);
|
|
4325
|
-
entry.entryName = entryName;
|
|
4326
|
-
}
|
|
4327
|
-
entry.comment = comment || "";
|
|
4328
|
-
const isStat = typeof attr === "object" && attr instanceof filetools.fs.Stats;
|
|
4329
|
-
if (isStat) {
|
|
4330
|
-
entry.header.time = attr.mtime;
|
|
4331
|
-
}
|
|
4332
|
-
var fileattr = entry.isDirectory ? 16 : 0;
|
|
4333
|
-
let unix = entry.isDirectory ? 16384 : 32768;
|
|
4334
|
-
if (isStat) {
|
|
4335
|
-
unix |= 4095 & attr.mode;
|
|
4336
|
-
} else if (typeof attr === "number") {
|
|
4337
|
-
unix |= 4095 & attr;
|
|
4338
|
-
} else {
|
|
4339
|
-
unix |= entry.isDirectory ? 493 : 420;
|
|
4340
|
-
}
|
|
4341
|
-
fileattr = (fileattr | unix << 16) >>> 0;
|
|
4342
|
-
entry.attr = fileattr;
|
|
4343
|
-
entry.setData(content);
|
|
4344
|
-
if (!update)
|
|
4345
|
-
_zip.setEntry(entry);
|
|
4346
|
-
return entry;
|
|
4347
|
-
},
|
|
4348
|
-
getEntries: function(password) {
|
|
4349
|
-
_zip.password = password;
|
|
4350
|
-
return _zip ? _zip.entries : [];
|
|
4351
|
-
},
|
|
4352
|
-
getEntry: function(name) {
|
|
4353
|
-
return getEntry(name);
|
|
4354
|
-
},
|
|
4355
|
-
getEntryCount: function() {
|
|
4356
|
-
return _zip.getEntryCount();
|
|
4357
|
-
},
|
|
4358
|
-
forEach: function(callback) {
|
|
4359
|
-
return _zip.forEach(callback);
|
|
4360
|
-
},
|
|
4361
|
-
extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite, keepOriginalPermission, outFileName) {
|
|
4362
|
-
overwrite = get_Bool(false, overwrite);
|
|
4363
|
-
keepOriginalPermission = get_Bool(false, keepOriginalPermission);
|
|
4364
|
-
maintainEntryPath = get_Bool(true, maintainEntryPath);
|
|
4365
|
-
outFileName = get_Str(keepOriginalPermission, outFileName);
|
|
4366
|
-
var item = getEntry(entry);
|
|
4367
|
-
if (!item) {
|
|
4368
|
-
throw Utils.Errors.NO_ENTRY();
|
|
4369
|
-
}
|
|
4370
|
-
var entryName = canonical(item.entryName);
|
|
4371
|
-
var target = sanitize(targetPath, outFileName && !item.isDirectory ? canonical(outFileName) : maintainEntryPath ? entryName : pth.basename(entryName));
|
|
4372
|
-
if (item.isDirectory) {
|
|
4373
|
-
var children = _zip.getEntryChildren(item);
|
|
4374
|
-
children.forEach(function(child) {
|
|
4375
|
-
if (child.isDirectory)
|
|
4376
|
-
return;
|
|
4377
|
-
var content2 = child.getData();
|
|
4378
|
-
if (!content2) {
|
|
4379
|
-
throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
4380
|
-
}
|
|
4381
|
-
var name = canonical(maintainEntryPath ? child.entryName : child.entryName.substring(item.entryName.length));
|
|
4382
|
-
var childName = sanitize(targetPath, name);
|
|
4383
|
-
filetools.assertPathSafe(targetPath, childName);
|
|
4384
|
-
const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : undefined;
|
|
4385
|
-
filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
|
|
4386
|
-
});
|
|
4387
|
-
return true;
|
|
4388
|
-
}
|
|
4389
|
-
var content = item.getData(_zip.password);
|
|
4390
|
-
if (!content)
|
|
4391
|
-
throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
4392
|
-
filetools.assertPathSafe(targetPath, target);
|
|
4393
|
-
if (filetools.fs.existsSync(target) && !overwrite) {
|
|
4394
|
-
throw Utils.Errors.CANT_OVERRIDE();
|
|
4395
|
-
}
|
|
4396
|
-
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
|
4397
|
-
filetools.writeFileTo(target, content, overwrite, fileAttr);
|
|
4398
|
-
return true;
|
|
4399
|
-
},
|
|
4400
|
-
test: function(pass) {
|
|
4401
|
-
if (!_zip) {
|
|
4402
|
-
return false;
|
|
4403
|
-
}
|
|
4404
|
-
for (var entry of _zip.entries) {
|
|
4405
|
-
try {
|
|
4406
|
-
if (entry.isDirectory) {
|
|
4407
|
-
continue;
|
|
4408
|
-
}
|
|
4409
|
-
var content = entry.getData(pass);
|
|
4410
|
-
if (!content) {
|
|
4411
|
-
return false;
|
|
4412
|
-
}
|
|
4413
|
-
} catch (err) {
|
|
4414
|
-
return false;
|
|
4415
|
-
}
|
|
4416
|
-
}
|
|
4417
|
-
return true;
|
|
4418
|
-
},
|
|
4419
|
-
extractAllTo: function(targetPath, overwrite, keepOriginalPermission, pass) {
|
|
4420
|
-
keepOriginalPermission = get_Bool(false, keepOriginalPermission);
|
|
4421
|
-
pass = get_Str(keepOriginalPermission, pass);
|
|
4422
|
-
overwrite = get_Bool(false, overwrite);
|
|
4423
|
-
if (!_zip)
|
|
4424
|
-
throw Utils.Errors.NO_ZIP();
|
|
4425
|
-
const dirEntries = [];
|
|
4426
|
-
_zip.entries.forEach(function(entry) {
|
|
4427
|
-
var entryName = sanitize(targetPath, canonical(entry.entryName));
|
|
4428
|
-
filetools.assertPathSafe(targetPath, entryName);
|
|
4429
|
-
if (entry.isDirectory) {
|
|
4430
|
-
filetools.makeDir(entryName);
|
|
4431
|
-
if (keepOriginalPermission)
|
|
4432
|
-
dirEntries.push({ path: entryName, attr: entry.header.fileAttr });
|
|
4433
|
-
return;
|
|
4434
|
-
}
|
|
4435
|
-
var content = entry.getData(pass);
|
|
4436
|
-
if (!content) {
|
|
4437
|
-
throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
4438
|
-
}
|
|
4439
|
-
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
|
4440
|
-
filetools.writeFileTo(entryName, content, overwrite, fileAttr);
|
|
4441
|
-
try {
|
|
4442
|
-
filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
|
|
4443
|
-
} catch (err) {}
|
|
4444
|
-
});
|
|
4445
|
-
applyDirAttributes(dirEntries);
|
|
4446
|
-
},
|
|
4447
|
-
extractAllToAsync: function(targetPath, overwrite, keepOriginalPermission, callback) {
|
|
4448
|
-
callback = get_Fun(overwrite, keepOriginalPermission, callback);
|
|
4449
|
-
keepOriginalPermission = get_Bool(false, keepOriginalPermission);
|
|
4450
|
-
overwrite = get_Bool(false, overwrite);
|
|
4451
|
-
if (!callback) {
|
|
4452
|
-
return new Promise((resolve2, reject) => {
|
|
4453
|
-
this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function(err) {
|
|
4454
|
-
if (err) {
|
|
4455
|
-
reject(err);
|
|
4456
|
-
} else {
|
|
4457
|
-
resolve2(this);
|
|
4458
|
-
}
|
|
4459
|
-
});
|
|
4460
|
-
});
|
|
4461
|
-
}
|
|
4462
|
-
if (!_zip) {
|
|
4463
|
-
callback(Utils.Errors.NO_ZIP());
|
|
4464
|
-
return;
|
|
4465
|
-
}
|
|
4466
|
-
targetPath = pth.resolve(targetPath);
|
|
4467
|
-
const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName)));
|
|
4468
|
-
const getError = (msg, file) => new Error(msg + ': "' + file + '"');
|
|
4469
|
-
const dirEntries = [];
|
|
4470
|
-
const fileEntries = [];
|
|
4471
|
-
_zip.entries.forEach((e) => {
|
|
4472
|
-
if (e.isDirectory) {
|
|
4473
|
-
dirEntries.push(e);
|
|
4474
|
-
} else {
|
|
4475
|
-
fileEntries.push(e);
|
|
4476
|
-
}
|
|
4477
|
-
});
|
|
4478
|
-
const deferredDirAttr = [];
|
|
4479
|
-
for (const entry of dirEntries) {
|
|
4480
|
-
const dirPath = getPath(entry);
|
|
4481
|
-
const dirAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
|
4482
|
-
try {
|
|
4483
|
-
filetools.assertPathSafe(targetPath, dirPath);
|
|
4484
|
-
filetools.makeDir(dirPath);
|
|
4485
|
-
} catch (er) {
|
|
4486
|
-
callback(getError("Unable to create folder", dirPath));
|
|
4487
|
-
continue;
|
|
4488
|
-
}
|
|
4489
|
-
if (dirAttr)
|
|
4490
|
-
deferredDirAttr.push({ path: dirPath, attr: dirAttr });
|
|
4491
|
-
try {
|
|
4492
|
-
filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
|
|
4493
|
-
} catch (er) {}
|
|
4494
|
-
}
|
|
4495
|
-
const done = (err) => {
|
|
4496
|
-
if (!err) {
|
|
4497
|
-
try {
|
|
4498
|
-
applyDirAttributes(deferredDirAttr);
|
|
4499
|
-
} catch (er) {
|
|
4500
|
-
return callback(getError("Unable to set folder permissions", er.path || ""));
|
|
4501
|
-
}
|
|
4502
|
-
}
|
|
4503
|
-
callback(err);
|
|
4504
|
-
};
|
|
4505
|
-
fileEntries.reverse().reduce(function(next, entry) {
|
|
4506
|
-
return function(err) {
|
|
4507
|
-
if (err) {
|
|
4508
|
-
next(err);
|
|
4509
|
-
} else {
|
|
4510
|
-
const entryName = pth.normalize(canonical(entry.entryName));
|
|
4511
|
-
const filePath = sanitize(targetPath, entryName);
|
|
4512
|
-
try {
|
|
4513
|
-
filetools.assertPathSafe(targetPath, filePath);
|
|
4514
|
-
} catch (er) {
|
|
4515
|
-
return next(er);
|
|
4516
|
-
}
|
|
4517
|
-
entry.getDataAsync(function(content, err_1) {
|
|
4518
|
-
if (err_1) {
|
|
4519
|
-
next(err_1);
|
|
4520
|
-
} else if (!content) {
|
|
4521
|
-
next(Utils.Errors.CANT_EXTRACT_FILE());
|
|
4522
|
-
} else {
|
|
4523
|
-
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
|
4524
|
-
filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
|
|
4525
|
-
if (!succ) {
|
|
4526
|
-
return next(getError("Unable to write file", filePath));
|
|
4527
|
-
}
|
|
4528
|
-
filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function() {
|
|
4529
|
-
next();
|
|
4530
|
-
});
|
|
4531
|
-
});
|
|
4532
|
-
}
|
|
4533
|
-
});
|
|
4534
|
-
}
|
|
4535
|
-
};
|
|
4536
|
-
}, done)();
|
|
4537
|
-
},
|
|
4538
|
-
writeZip: function(targetFileName, callback) {
|
|
4539
|
-
if (arguments.length === 1) {
|
|
4540
|
-
if (typeof targetFileName === "function") {
|
|
4541
|
-
callback = targetFileName;
|
|
4542
|
-
targetFileName = "";
|
|
4543
|
-
}
|
|
4544
|
-
}
|
|
4545
|
-
if (!targetFileName && opts.filename) {
|
|
4546
|
-
targetFileName = opts.filename;
|
|
4547
|
-
}
|
|
4548
|
-
if (!targetFileName)
|
|
4549
|
-
return;
|
|
4550
|
-
var zipData = _zip.compressToBuffer();
|
|
4551
|
-
if (zipData) {
|
|
4552
|
-
var ok = filetools.writeFileTo(targetFileName, zipData, true);
|
|
4553
|
-
if (typeof callback === "function")
|
|
4554
|
-
callback(!ok ? new Error("failed") : null, "");
|
|
4555
|
-
}
|
|
4556
|
-
},
|
|
4557
|
-
writeZipPromise: function(targetFileName, props) {
|
|
4558
|
-
const { overwrite, perm } = Object.assign({ overwrite: true }, props);
|
|
4559
|
-
return new Promise((resolve2, reject) => {
|
|
4560
|
-
if (!targetFileName && opts.filename)
|
|
4561
|
-
targetFileName = opts.filename;
|
|
4562
|
-
if (!targetFileName)
|
|
4563
|
-
reject("ADM-ZIP: ZIP File Name Missing");
|
|
4564
|
-
this.toBufferPromise().then((zipData) => {
|
|
4565
|
-
const ret = (done) => done ? resolve2(done) : reject("ADM-ZIP: Wasn't able to write zip file");
|
|
4566
|
-
filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
|
|
4567
|
-
}, reject);
|
|
4568
|
-
});
|
|
4569
|
-
},
|
|
4570
|
-
toBufferPromise: function() {
|
|
4571
|
-
return new Promise((resolve2, reject) => {
|
|
4572
|
-
_zip.toAsyncBuffer(resolve2, reject);
|
|
4573
|
-
});
|
|
4574
|
-
},
|
|
4575
|
-
toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
|
|
4576
|
-
if (typeof onSuccess === "function") {
|
|
4577
|
-
_zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
|
|
4578
|
-
return null;
|
|
4579
|
-
}
|
|
4580
|
-
return _zip.compressToBuffer();
|
|
4581
|
-
}
|
|
4582
|
-
};
|
|
4583
|
-
};
|
|
4584
|
-
});
|
|
4585
|
-
|
|
4586
2100
|
// ../../common/src/singleton.ts
|
|
4587
2101
|
var PREFIX = "@uipath/common/";
|
|
4588
2102
|
var _g = globalThis;
|
|
@@ -4945,8 +2459,9 @@ class VoidApiResponse {
|
|
|
4945
2459
|
// ../audit-sdk/package.json
|
|
4946
2460
|
var package_default = {
|
|
4947
2461
|
name: "@uipath/audit-sdk",
|
|
2462
|
+
author: "UiPath",
|
|
4948
2463
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
4949
|
-
version: "1.
|
|
2464
|
+
version: "1.203.0",
|
|
4950
2465
|
description: "SDK for the UiPath Audit Service — query audit event sources, list events, and download long-term-store exports.",
|
|
4951
2466
|
repository: {
|
|
4952
2467
|
type: "git",
|
|
@@ -6225,16 +3740,7 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
|
|
|
6225
3740
|
errorMessage: location.source === "absolute" ? `Environment file not found: ${envFilePath}` : `Unable to locate environment file: ${envFilePath}. Run 'uip login' to authenticate.`
|
|
6226
3741
|
};
|
|
6227
3742
|
};
|
|
6228
|
-
var
|
|
6229
|
-
const fs2 = getFileSystem();
|
|
6230
|
-
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
|
|
6231
|
-
if (!await fs2.exists(absolutePath)) {
|
|
6232
|
-
throw new Error(`Environment file not found: ${envPath}`);
|
|
6233
|
-
}
|
|
6234
|
-
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
6235
|
-
if (content === null) {
|
|
6236
|
-
throw new Error(`Environment file not found: ${envPath}`);
|
|
6237
|
-
}
|
|
3743
|
+
var parseEnvContent = (content) => {
|
|
6238
3744
|
const env = {};
|
|
6239
3745
|
for (const line of content.split(`
|
|
6240
3746
|
`)) {
|
|
@@ -6255,6 +3761,18 @@ var loadEnvFileAsync = async ({ envPath }) => {
|
|
|
6255
3761
|
}
|
|
6256
3762
|
return env;
|
|
6257
3763
|
};
|
|
3764
|
+
var loadEnvFileAsync = async ({ envPath }) => {
|
|
3765
|
+
const fs2 = getFileSystem();
|
|
3766
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
|
|
3767
|
+
if (!await fs2.exists(absolutePath)) {
|
|
3768
|
+
throw new Error(`Environment file not found: ${envPath}`);
|
|
3769
|
+
}
|
|
3770
|
+
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
3771
|
+
if (content === null) {
|
|
3772
|
+
throw new Error(`Environment file not found: ${envPath}`);
|
|
3773
|
+
}
|
|
3774
|
+
return parseEnvContent(content);
|
|
3775
|
+
};
|
|
6258
3776
|
var saveEnvFileAsync = async ({
|
|
6259
3777
|
envPath,
|
|
6260
3778
|
data,
|
|
@@ -7059,7 +4577,7 @@ var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{1
|
|
|
7059
4577
|
var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
7060
4578
|
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
7061
4579
|
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
7062
|
-
var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
4580
|
+
var PADDED_BASE64_PATTERN = /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
7063
4581
|
var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
|
|
7064
4582
|
var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
|
|
7065
4583
|
var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
|
|
@@ -7106,7 +4624,7 @@ var QUOTED_LITERAL_PATTERN = new RegExp([
|
|
|
7106
4624
|
`(?<![A-Za-z0-9])"(?:[^\\
|
|
7107
4625
|
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
|
|
7108
4626
|
].join("|"), "g");
|
|
7109
|
-
var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
|
|
4627
|
+
var JSON_BODY_PATTERN = /[{[][^{}[\]:,]*[:,][^{}[\]]*[\]}]/g;
|
|
7110
4628
|
var COLLAPSED_BODY = "{…}";
|
|
7111
4629
|
var COLLAPSED_BODY_MARKER = "\x01body\x01";
|
|
7112
4630
|
var MAX_BODY_NESTING = 8;
|
|
@@ -7121,10 +4639,13 @@ function collapseJsonBodies(text) {
|
|
|
7121
4639
|
}
|
|
7122
4640
|
return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
|
|
7123
4641
|
}
|
|
7124
|
-
var TRAILING_PROSE_PUNCT =
|
|
4642
|
+
var TRAILING_PROSE_PUNCT = `.,;:!?)]}>'"`;
|
|
7125
4643
|
function peelTrailingPunctuation(match) {
|
|
7126
|
-
|
|
7127
|
-
|
|
4644
|
+
let end = match.length;
|
|
4645
|
+
while (end > 0 && TRAILING_PROSE_PUNCT.includes(match[end - 1])) {
|
|
4646
|
+
end -= 1;
|
|
4647
|
+
}
|
|
4648
|
+
return [match.slice(0, end), match.slice(end)];
|
|
7128
4649
|
}
|
|
7129
4650
|
function redactUrl(raw) {
|
|
7130
4651
|
try {
|
|
@@ -7427,6 +4948,22 @@ function parseHttpStatusFromMessage(message) {
|
|
|
7427
4948
|
const status = Number(match[1]);
|
|
7428
4949
|
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
7429
4950
|
}
|
|
4951
|
+
function findHttpStatusInGraph(error) {
|
|
4952
|
+
for (const node of walkErrorGraph(error)) {
|
|
4953
|
+
const response = node.response;
|
|
4954
|
+
const explicit = typeof node.status === "number" ? node.status : response?.status;
|
|
4955
|
+
if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
|
|
4956
|
+
return explicit;
|
|
4957
|
+
}
|
|
4958
|
+
if (typeof node.message === "string") {
|
|
4959
|
+
const parsed = parseHttpStatusFromMessage(node.message);
|
|
4960
|
+
if (parsed !== undefined && parsed >= 400) {
|
|
4961
|
+
return parsed;
|
|
4962
|
+
}
|
|
4963
|
+
}
|
|
4964
|
+
}
|
|
4965
|
+
return;
|
|
4966
|
+
}
|
|
7430
4967
|
function isHtmlDocument(body) {
|
|
7431
4968
|
return /^\s*(<!doctype html|<html\b)/i.test(body);
|
|
7432
4969
|
}
|
|
@@ -7540,7 +5077,8 @@ async function extractErrorDetails(error, options) {
|
|
|
7540
5077
|
}
|
|
7541
5078
|
let message;
|
|
7542
5079
|
let result = "Failure";
|
|
7543
|
-
const
|
|
5080
|
+
const classificationStatus = status ?? findHttpStatusInGraph(error);
|
|
5081
|
+
const classification = classifyError(classificationStatus, error);
|
|
7544
5082
|
let retry = classification.retry;
|
|
7545
5083
|
if (status === 401) {
|
|
7546
5084
|
message = DEFAULT_401;
|
|
@@ -7616,8 +5154,8 @@ async function extractErrorDetails(error, options) {
|
|
|
7616
5154
|
details = describeThrownValue(error);
|
|
7617
5155
|
}
|
|
7618
5156
|
const context = {};
|
|
7619
|
-
if (
|
|
7620
|
-
context.httpStatus =
|
|
5157
|
+
if (classificationStatus) {
|
|
5158
|
+
context.httpStatus = classificationStatus;
|
|
7621
5159
|
}
|
|
7622
5160
|
if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
|
|
7623
5161
|
context.errorCode = parsedBody.errorCode;
|
|
@@ -8179,7 +5717,8 @@ function readRegistryValue(keyPath, valueName) {
|
|
|
8179
5717
|
}
|
|
8180
5718
|
const [error, output] = catchError2(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
|
|
8181
5719
|
encoding: "utf-8",
|
|
8182
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
5720
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
5721
|
+
windowsHide: true
|
|
8183
5722
|
}));
|
|
8184
5723
|
if (error) {
|
|
8185
5724
|
return "";
|
|
@@ -8855,28 +6394,32 @@ function isPlainRecord(value) {
|
|
|
8855
6394
|
const prototype = Object.getPrototypeOf(value);
|
|
8856
6395
|
return prototype === Object.prototype || prototype === null;
|
|
8857
6396
|
}
|
|
8858
|
-
function
|
|
6397
|
+
function splitPagedEnvelope(value) {
|
|
8859
6398
|
if (Array.isArray(value) || !isPlainRecord(value))
|
|
8860
6399
|
return null;
|
|
8861
|
-
const entries = Object.
|
|
6400
|
+
const entries = Object.entries(value);
|
|
8862
6401
|
if (entries.length === 0)
|
|
8863
6402
|
return null;
|
|
8864
|
-
let
|
|
8865
|
-
|
|
8866
|
-
for (const entry of entries) {
|
|
6403
|
+
let found = null;
|
|
6404
|
+
const meta = Object.create(null);
|
|
6405
|
+
for (const [key, entry] of entries) {
|
|
8867
6406
|
if (Array.isArray(entry)) {
|
|
8868
|
-
if (
|
|
6407
|
+
if (found !== null)
|
|
8869
6408
|
return null;
|
|
8870
|
-
|
|
6409
|
+
found = { key, rows: entry };
|
|
8871
6410
|
} else if (entry !== null && typeof entry === "object") {
|
|
8872
6411
|
return null;
|
|
8873
6412
|
} else {
|
|
8874
|
-
|
|
6413
|
+
meta[key] = entry;
|
|
8875
6414
|
}
|
|
8876
6415
|
}
|
|
8877
|
-
if (
|
|
6416
|
+
if (found === null || Object.keys(meta).length === 0)
|
|
8878
6417
|
return null;
|
|
8879
|
-
return
|
|
6418
|
+
return { ...found, meta };
|
|
6419
|
+
}
|
|
6420
|
+
function extractPagedRows(value) {
|
|
6421
|
+
const paged = splitPagedEnvelope(value);
|
|
6422
|
+
return paged === null ? null : paged.rows;
|
|
8880
6423
|
}
|
|
8881
6424
|
function toLowerCamelCaseKey(key) {
|
|
8882
6425
|
if (!key)
|
|
@@ -8980,6 +6523,9 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
|
|
|
8980
6523
|
}
|
|
8981
6524
|
break;
|
|
8982
6525
|
}
|
|
6526
|
+
case "markdown":
|
|
6527
|
+
logFn(renderMarkdown(data));
|
|
6528
|
+
break;
|
|
8983
6529
|
default: {
|
|
8984
6530
|
const hasData = "Data" in data && data.Data != null;
|
|
8985
6531
|
const pagedRows = hasData ? extractPagedRows(data.Data) : null;
|
|
@@ -9004,6 +6550,10 @@ function logOutput(data, format = "json", tableRowStyle) {
|
|
|
9004
6550
|
printOutput(data, format, (msg) => sink.writeOut(`${msg}
|
|
9005
6551
|
`), needsAsciiSafeJson(sink), styleFn);
|
|
9006
6552
|
}
|
|
6553
|
+
var PLUMBING_KEYS = new Set(["code", "log"]);
|
|
6554
|
+
function isPlumbingKey(key) {
|
|
6555
|
+
return PLUMBING_KEYS.has(key.toLowerCase());
|
|
6556
|
+
}
|
|
9007
6557
|
function cellToString(val) {
|
|
9008
6558
|
return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
|
|
9009
6559
|
}
|
|
@@ -9019,7 +6569,7 @@ function wrapText(text, width) {
|
|
|
9019
6569
|
function printTable(data, logFn, externalLogValue, tableRowStyle) {
|
|
9020
6570
|
if (data.length === 0)
|
|
9021
6571
|
return;
|
|
9022
|
-
const keys = Object.keys(data[0]).filter((key) => !
|
|
6572
|
+
const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
|
|
9023
6573
|
const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
|
|
9024
6574
|
const header = keys.map((key, i) => key.padEnd(maxWidths[i])).join(" | ");
|
|
9025
6575
|
logFn(header);
|
|
@@ -9041,7 +6591,7 @@ function isNonEmptyPlainObject(value) {
|
|
|
9041
6591
|
}
|
|
9042
6592
|
var NESTED_INDENT = " ";
|
|
9043
6593
|
function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
9044
|
-
const keys = Object.keys(data).filter((key) => !
|
|
6594
|
+
const keys = Object.keys(data).filter((key) => !isPlumbingKey(key));
|
|
9045
6595
|
if (keys.length === 0)
|
|
9046
6596
|
return;
|
|
9047
6597
|
const isBlockValue = (value) => isPlainObjectArray(value) || isNonEmptyPlainObject(value);
|
|
@@ -9072,7 +6622,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
|
9072
6622
|
function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
|
|
9073
6623
|
if (data.length === 0)
|
|
9074
6624
|
return;
|
|
9075
|
-
const keys = Object.keys(data[0]).filter((key) => !
|
|
6625
|
+
const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
|
|
9076
6626
|
if (keys.length === 0)
|
|
9077
6627
|
return;
|
|
9078
6628
|
if (!process.stdout.isTTY) {
|
|
@@ -9146,6 +6696,220 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
9146
6696
|
logFn(`Log: ${externalLogValue}`);
|
|
9147
6697
|
}
|
|
9148
6698
|
}
|
|
6699
|
+
var MARKDOWN_MAX_CELL = 200;
|
|
6700
|
+
var MARKDOWN_MAX_DEPTH = 3;
|
|
6701
|
+
function markdownHeading(depth) {
|
|
6702
|
+
return "#".repeat(Math.min(3 + depth, 6));
|
|
6703
|
+
}
|
|
6704
|
+
var BACKTICK_RUN = /`+/g;
|
|
6705
|
+
function fencedBlock(text) {
|
|
6706
|
+
const first = text.trimStart()[0];
|
|
6707
|
+
const language = first === "<" ? "xml" : first === "{" || first === "[" ? "json" : "";
|
|
6708
|
+
const longestRun = Math.max(0, ...Array.from(text.matchAll(BACKTICK_RUN), (match) => match[0].length));
|
|
6709
|
+
const fence = "`".repeat(Math.max(3, longestRun + 1));
|
|
6710
|
+
return `${fence}${language}
|
|
6711
|
+
${text}
|
|
6712
|
+
${fence}`;
|
|
6713
|
+
}
|
|
6714
|
+
function collapseNewlineRuns(text) {
|
|
6715
|
+
return text.split(/(\s+)/).map((part, index) => index % 2 === 1 && part.includes(`
|
|
6716
|
+
`) ? " " : part).join("");
|
|
6717
|
+
}
|
|
6718
|
+
function markdownCell(value) {
|
|
6719
|
+
const text = value instanceof Date ? value.toISOString() : cellToString(value);
|
|
6720
|
+
return collapseNewlineRuns(text).replace(/\|/g, "\\|");
|
|
6721
|
+
}
|
|
6722
|
+
function markdownLabel(key) {
|
|
6723
|
+
return collapseNewlineRuns(key).replace(/[\\`*|]/g, "\\$&");
|
|
6724
|
+
}
|
|
6725
|
+
function withoutPlumbing(record) {
|
|
6726
|
+
const kept = Object.create(null);
|
|
6727
|
+
for (const [key, value] of Object.entries(record)) {
|
|
6728
|
+
if (!isPlumbingKey(key))
|
|
6729
|
+
kept[key] = value;
|
|
6730
|
+
}
|
|
6731
|
+
return kept;
|
|
6732
|
+
}
|
|
6733
|
+
function rowsWithoutPlumbing(rows) {
|
|
6734
|
+
return rows.map((row) => isPlainRecord(row) ? withoutPlumbing(row) : row);
|
|
6735
|
+
}
|
|
6736
|
+
function markdownTable(rows) {
|
|
6737
|
+
const columns = [];
|
|
6738
|
+
const seen = new Set;
|
|
6739
|
+
for (const row of rows) {
|
|
6740
|
+
for (const key of Object.keys(row)) {
|
|
6741
|
+
if (!seen.has(key)) {
|
|
6742
|
+
seen.add(key);
|
|
6743
|
+
columns.push(key);
|
|
6744
|
+
}
|
|
6745
|
+
}
|
|
6746
|
+
}
|
|
6747
|
+
if (columns.length === 0)
|
|
6748
|
+
return null;
|
|
6749
|
+
const cells = rows.map((row) => columns.map((key) => markdownCell(row[key])));
|
|
6750
|
+
if (cells.some((row) => row.some((c) => c.length > MARKDOWN_MAX_CELL))) {
|
|
6751
|
+
return null;
|
|
6752
|
+
}
|
|
6753
|
+
return [
|
|
6754
|
+
`| ${columns.map(markdownLabel).join(" | ")} |`,
|
|
6755
|
+
`| ${columns.map(() => "---").join(" | ")} |`,
|
|
6756
|
+
...cells.map((row) => `| ${row.join(" | ")} |`)
|
|
6757
|
+
].join(`
|
|
6758
|
+
`);
|
|
6759
|
+
}
|
|
6760
|
+
function extractMessageSequence(rows) {
|
|
6761
|
+
const messages = [];
|
|
6762
|
+
for (const row of rows) {
|
|
6763
|
+
const message = extractSingleMessage(row);
|
|
6764
|
+
if (message === null)
|
|
6765
|
+
return null;
|
|
6766
|
+
messages.push(message);
|
|
6767
|
+
}
|
|
6768
|
+
return messages.join(`
|
|
6769
|
+
|
|
6770
|
+
`);
|
|
6771
|
+
}
|
|
6772
|
+
function markdownRows(rows, depth) {
|
|
6773
|
+
if (rows.length === 0)
|
|
6774
|
+
return "(none)";
|
|
6775
|
+
if (!isPlainObjectArray(rows)) {
|
|
6776
|
+
return rows.map((item) => `- ${markdownCell(item)}`).join(`
|
|
6777
|
+
`);
|
|
6778
|
+
}
|
|
6779
|
+
const prose = extractMessageSequence(rows);
|
|
6780
|
+
if (prose !== null)
|
|
6781
|
+
return prose;
|
|
6782
|
+
const table = markdownTable(rows);
|
|
6783
|
+
if (table !== null)
|
|
6784
|
+
return table;
|
|
6785
|
+
if (depth >= MARKDOWN_MAX_DEPTH) {
|
|
6786
|
+
return fencedBlock(JSON.stringify(rows, null, 2));
|
|
6787
|
+
}
|
|
6788
|
+
return rows.map((row, index) => [
|
|
6789
|
+
`${markdownHeading(depth)} ${index + 1}`,
|
|
6790
|
+
markdownObject(row, depth + 1)
|
|
6791
|
+
].join(`
|
|
6792
|
+
|
|
6793
|
+
`)).join(`
|
|
6794
|
+
|
|
6795
|
+
`);
|
|
6796
|
+
}
|
|
6797
|
+
function markdownObject(obj, depth) {
|
|
6798
|
+
const scalars = [];
|
|
6799
|
+
const blocks = [];
|
|
6800
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
6801
|
+
if (value === undefined)
|
|
6802
|
+
continue;
|
|
6803
|
+
const label = markdownLabel(key);
|
|
6804
|
+
if (Array.isArray(value)) {
|
|
6805
|
+
blocks.push(`${markdownHeading(depth)} ${label}
|
|
6806
|
+
|
|
6807
|
+
${markdownRows(value, depth + 1)}`);
|
|
6808
|
+
} else if (isNonEmptyPlainObject(value)) {
|
|
6809
|
+
const nested = depth < MARKDOWN_MAX_DEPTH ? markdownObject(value, depth + 1) : fencedBlock(JSON.stringify(value, null, 2));
|
|
6810
|
+
if (nested !== "") {
|
|
6811
|
+
blocks.push(`${markdownHeading(depth)} ${label}
|
|
6812
|
+
|
|
6813
|
+
${nested}`);
|
|
6814
|
+
}
|
|
6815
|
+
} else if (typeof value === "string" && value.includes(`
|
|
6816
|
+
`)) {
|
|
6817
|
+
blocks.push(`**${label}:**
|
|
6818
|
+
|
|
6819
|
+
${fencedBlock(value)}`);
|
|
6820
|
+
} else {
|
|
6821
|
+
scalars.push(`**${label}:** ${markdownCell(value)}`);
|
|
6822
|
+
}
|
|
6823
|
+
}
|
|
6824
|
+
const sections = scalars.length > 0 ? [scalars.join(`
|
|
6825
|
+
`)] : [];
|
|
6826
|
+
sections.push(...blocks);
|
|
6827
|
+
return sections.join(`
|
|
6828
|
+
|
|
6829
|
+
`);
|
|
6830
|
+
}
|
|
6831
|
+
function extractSingleMessage(payload) {
|
|
6832
|
+
if (!isPlainRecord(payload))
|
|
6833
|
+
return null;
|
|
6834
|
+
const keys = Object.keys(payload);
|
|
6835
|
+
if (keys.length !== 1 || keys[0].toLowerCase() !== "message")
|
|
6836
|
+
return null;
|
|
6837
|
+
const value = payload[keys[0]];
|
|
6838
|
+
return typeof value === "string" ? value : null;
|
|
6839
|
+
}
|
|
6840
|
+
function markdownPayload(payload) {
|
|
6841
|
+
const message = extractSingleMessage(payload);
|
|
6842
|
+
if (message !== null)
|
|
6843
|
+
return message;
|
|
6844
|
+
if (Array.isArray(payload)) {
|
|
6845
|
+
return markdownRows(rowsWithoutPlumbing(payload), 0);
|
|
6846
|
+
}
|
|
6847
|
+
const visible = withoutPlumbing(payload);
|
|
6848
|
+
const paged = splitPagedEnvelope(visible);
|
|
6849
|
+
if (paged !== null) {
|
|
6850
|
+
const meta = markdownObject(paged.meta, 0);
|
|
6851
|
+
const rows = `${markdownHeading(0)} ${markdownLabel(paged.key)}
|
|
6852
|
+
|
|
6853
|
+
${markdownRows(rowsWithoutPlumbing(paged.rows), 1)}`;
|
|
6854
|
+
return meta === "" ? rows : `${meta}
|
|
6855
|
+
|
|
6856
|
+
${rows}`;
|
|
6857
|
+
}
|
|
6858
|
+
return markdownObject(visible, 0);
|
|
6859
|
+
}
|
|
6860
|
+
function isPaginationWorthShowing(value) {
|
|
6861
|
+
if (typeof value !== "object" || value === null)
|
|
6862
|
+
return false;
|
|
6863
|
+
const page = value;
|
|
6864
|
+
return page.HasMore === true || typeof page.Offset === "number" && page.Offset > 0;
|
|
6865
|
+
}
|
|
6866
|
+
function markdownEnvelopeNotes(data) {
|
|
6867
|
+
const envelope = data;
|
|
6868
|
+
const notes = [];
|
|
6869
|
+
const warning = envelope.Warning;
|
|
6870
|
+
if (typeof warning === "string" && warning !== "") {
|
|
6871
|
+
notes.push(`> **Warning:** ${warning}`);
|
|
6872
|
+
}
|
|
6873
|
+
const instructions = envelope.Instructions;
|
|
6874
|
+
if (typeof instructions === "string" && instructions !== "") {
|
|
6875
|
+
notes.push(`> ${instructions}`);
|
|
6876
|
+
}
|
|
6877
|
+
const pagination = envelope.Pagination;
|
|
6878
|
+
if (isPaginationWorthShowing(pagination)) {
|
|
6879
|
+
const body = markdownObject(pagination, 1);
|
|
6880
|
+
if (body !== "") {
|
|
6881
|
+
notes.push(`${markdownHeading(0)} Pagination
|
|
6882
|
+
|
|
6883
|
+
${body}`);
|
|
6884
|
+
}
|
|
6885
|
+
}
|
|
6886
|
+
const log = envelope.Log;
|
|
6887
|
+
if (typeof log === "string" && log !== "") {
|
|
6888
|
+
notes.push(`**Log:** ${log}`);
|
|
6889
|
+
}
|
|
6890
|
+
return notes;
|
|
6891
|
+
}
|
|
6892
|
+
function renderMarkdown(data) {
|
|
6893
|
+
if (data.Result !== RESULTS.Success) {
|
|
6894
|
+
const failure = data;
|
|
6895
|
+
const sections = [`**Failed:** ${failure.Message}`];
|
|
6896
|
+
if (failure.Data != null) {
|
|
6897
|
+
sections.push(markdownPayload(failure.Data));
|
|
6898
|
+
}
|
|
6899
|
+
if (failure.Instructions) {
|
|
6900
|
+
sections.push(`> ${failure.Instructions}`);
|
|
6901
|
+
}
|
|
6902
|
+
return sections.filter((section) => section !== "").join(`
|
|
6903
|
+
|
|
6904
|
+
`);
|
|
6905
|
+
}
|
|
6906
|
+
if (!("Data" in data) || data.Data == null) {
|
|
6907
|
+
return markdownObject(withoutPlumbing(data), 0);
|
|
6908
|
+
}
|
|
6909
|
+
return [markdownPayload(data.Data), ...markdownEnvelopeNotes(data)].filter((section) => section !== "").join(`
|
|
6910
|
+
|
|
6911
|
+
`);
|
|
6912
|
+
}
|
|
9149
6913
|
function toYaml(data) {
|
|
9150
6914
|
const codec = getYamlCodec();
|
|
9151
6915
|
if (!codec) {
|
|
@@ -10109,7 +7873,417 @@ var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
|
|
|
10109
7873
|
var factorySlot = singleton("PackagerFactoryProvider");
|
|
10110
7874
|
// src/utils/chunked-export.ts
|
|
10111
7875
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
10112
|
-
|
|
7876
|
+
|
|
7877
|
+
// ../../../node_modules/fflate/esm/index.mjs
|
|
7878
|
+
import { createRequire } from "module";
|
|
7879
|
+
var require2 = createRequire("/");
|
|
7880
|
+
var _a;
|
|
7881
|
+
var Worker;
|
|
7882
|
+
var isMarkedAsUntransferable;
|
|
7883
|
+
try {
|
|
7884
|
+
_a = require2("worker_threads"), Worker = _a.Worker, isMarkedAsUntransferable = _a.isMarkedAsUntransferable;
|
|
7885
|
+
} catch (e) {}
|
|
7886
|
+
var u8 = Uint8Array;
|
|
7887
|
+
var u16 = Uint16Array;
|
|
7888
|
+
var i32 = Int32Array;
|
|
7889
|
+
var fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0, 0]);
|
|
7890
|
+
var fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 0, 0]);
|
|
7891
|
+
var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
|
|
7892
|
+
var freb = function(eb, start) {
|
|
7893
|
+
var b = new u16(31);
|
|
7894
|
+
for (var i = 0;i < 31; ++i) {
|
|
7895
|
+
b[i] = start += 1 << eb[i - 1];
|
|
7896
|
+
}
|
|
7897
|
+
var r = new i32(b[30]);
|
|
7898
|
+
for (var i = 1;i < 30; ++i) {
|
|
7899
|
+
for (var j = b[i];j < b[i + 1]; ++j) {
|
|
7900
|
+
r[j] = j - b[i] << 5 | i;
|
|
7901
|
+
}
|
|
7902
|
+
}
|
|
7903
|
+
return { b, r };
|
|
7904
|
+
};
|
|
7905
|
+
var _a = freb(fleb, 2);
|
|
7906
|
+
var fl = _a.b;
|
|
7907
|
+
var revfl = _a.r;
|
|
7908
|
+
fl[28] = 258, revfl[258] = 28;
|
|
7909
|
+
var _b = freb(fdeb, 0);
|
|
7910
|
+
var fd = _b.b;
|
|
7911
|
+
var revfd = _b.r;
|
|
7912
|
+
var rev = new u16(32768);
|
|
7913
|
+
for (i = 0;i < 32768; ++i) {
|
|
7914
|
+
x = (i & 43690) >> 1 | (i & 21845) << 1;
|
|
7915
|
+
x = (x & 52428) >> 2 | (x & 13107) << 2;
|
|
7916
|
+
x = (x & 61680) >> 4 | (x & 3855) << 4;
|
|
7917
|
+
rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
|
|
7918
|
+
}
|
|
7919
|
+
var x;
|
|
7920
|
+
var i;
|
|
7921
|
+
var hMap = function(cd, mb, r) {
|
|
7922
|
+
var s = cd.length;
|
|
7923
|
+
var i2 = 0;
|
|
7924
|
+
var l = new u16(mb);
|
|
7925
|
+
for (;i2 < s; ++i2) {
|
|
7926
|
+
if (cd[i2])
|
|
7927
|
+
++l[cd[i2] - 1];
|
|
7928
|
+
}
|
|
7929
|
+
var le = new u16(mb);
|
|
7930
|
+
for (i2 = 1;i2 < mb; ++i2) {
|
|
7931
|
+
le[i2] = le[i2 - 1] + l[i2 - 1] << 1;
|
|
7932
|
+
}
|
|
7933
|
+
var co;
|
|
7934
|
+
if (r) {
|
|
7935
|
+
co = new u16(1 << mb);
|
|
7936
|
+
var rvb = 15 - mb;
|
|
7937
|
+
for (i2 = 0;i2 < s; ++i2) {
|
|
7938
|
+
if (cd[i2]) {
|
|
7939
|
+
var sv = i2 << 4 | cd[i2];
|
|
7940
|
+
var r_1 = mb - cd[i2];
|
|
7941
|
+
var v = le[cd[i2] - 1]++ << r_1;
|
|
7942
|
+
for (var m = v | (1 << r_1) - 1;v <= m; ++v) {
|
|
7943
|
+
co[rev[v] >> rvb] = sv;
|
|
7944
|
+
}
|
|
7945
|
+
}
|
|
7946
|
+
}
|
|
7947
|
+
} else {
|
|
7948
|
+
co = new u16(s);
|
|
7949
|
+
for (i2 = 0;i2 < s; ++i2) {
|
|
7950
|
+
if (cd[i2]) {
|
|
7951
|
+
co[i2] = rev[le[cd[i2] - 1]++] >> 15 - cd[i2];
|
|
7952
|
+
}
|
|
7953
|
+
}
|
|
7954
|
+
}
|
|
7955
|
+
return co;
|
|
7956
|
+
};
|
|
7957
|
+
var flt = new u8(288);
|
|
7958
|
+
for (i = 0;i < 144; ++i)
|
|
7959
|
+
flt[i] = 8;
|
|
7960
|
+
var i;
|
|
7961
|
+
for (i = 144;i < 256; ++i)
|
|
7962
|
+
flt[i] = 9;
|
|
7963
|
+
var i;
|
|
7964
|
+
for (i = 256;i < 280; ++i)
|
|
7965
|
+
flt[i] = 7;
|
|
7966
|
+
var i;
|
|
7967
|
+
for (i = 280;i < 288; ++i)
|
|
7968
|
+
flt[i] = 8;
|
|
7969
|
+
var i;
|
|
7970
|
+
var fdt = new u8(32);
|
|
7971
|
+
for (i = 0;i < 32; ++i)
|
|
7972
|
+
fdt[i] = 5;
|
|
7973
|
+
var i;
|
|
7974
|
+
var flrm = /* @__PURE__ */ hMap(flt, 9, 1);
|
|
7975
|
+
var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
|
|
7976
|
+
var max = function(a) {
|
|
7977
|
+
var m = a[0];
|
|
7978
|
+
for (var i2 = 1;i2 < a.length; ++i2) {
|
|
7979
|
+
if (a[i2] > m)
|
|
7980
|
+
m = a[i2];
|
|
7981
|
+
}
|
|
7982
|
+
return m;
|
|
7983
|
+
};
|
|
7984
|
+
var bits = function(d, p, m) {
|
|
7985
|
+
var o = p / 8 | 0;
|
|
7986
|
+
return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
|
|
7987
|
+
};
|
|
7988
|
+
var bits16 = function(d, p) {
|
|
7989
|
+
var o = p / 8 | 0;
|
|
7990
|
+
return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
|
|
7991
|
+
};
|
|
7992
|
+
var shft = function(p) {
|
|
7993
|
+
return (p + 7) / 8 | 0;
|
|
7994
|
+
};
|
|
7995
|
+
var slc = function(v, s, e) {
|
|
7996
|
+
if (s == null || s < 0)
|
|
7997
|
+
s = 0;
|
|
7998
|
+
if (e == null || e > v.length)
|
|
7999
|
+
e = v.length;
|
|
8000
|
+
return new u8(v.subarray(s, e));
|
|
8001
|
+
};
|
|
8002
|
+
var ec = [
|
|
8003
|
+
"unexpected EOF",
|
|
8004
|
+
"invalid block type",
|
|
8005
|
+
"invalid length/literal",
|
|
8006
|
+
"invalid distance",
|
|
8007
|
+
"stream finished",
|
|
8008
|
+
"no stream handler",
|
|
8009
|
+
,
|
|
8010
|
+
"no callback",
|
|
8011
|
+
"invalid UTF-8 data",
|
|
8012
|
+
"extra field too long",
|
|
8013
|
+
"date not in range 1980-2099",
|
|
8014
|
+
"filename too long",
|
|
8015
|
+
"stream finishing",
|
|
8016
|
+
"invalid zip data"
|
|
8017
|
+
];
|
|
8018
|
+
var err = function(ind, msg, nt) {
|
|
8019
|
+
var e = new Error(msg || ec[ind]);
|
|
8020
|
+
e.code = ind;
|
|
8021
|
+
if (Error.captureStackTrace)
|
|
8022
|
+
Error.captureStackTrace(e, err);
|
|
8023
|
+
if (!nt)
|
|
8024
|
+
throw e;
|
|
8025
|
+
return e;
|
|
8026
|
+
};
|
|
8027
|
+
var inflt = function(dat, st, buf, dict) {
|
|
8028
|
+
var sl = dat.length, dl = dict ? dict.length : 0;
|
|
8029
|
+
if (!sl || st.f && !st.l)
|
|
8030
|
+
return buf || new u8(0);
|
|
8031
|
+
var noBuf = !buf;
|
|
8032
|
+
var resize = noBuf || st.i != 2;
|
|
8033
|
+
var noSt = st.i;
|
|
8034
|
+
if (noBuf)
|
|
8035
|
+
buf = new u8(sl * 3);
|
|
8036
|
+
var cbuf = function(l2) {
|
|
8037
|
+
var bl = buf.length;
|
|
8038
|
+
if (l2 > bl) {
|
|
8039
|
+
var nbuf = new u8(Math.max(bl * 2, l2));
|
|
8040
|
+
nbuf.set(buf);
|
|
8041
|
+
buf = nbuf;
|
|
8042
|
+
}
|
|
8043
|
+
};
|
|
8044
|
+
var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
|
|
8045
|
+
var tbts = sl * 8;
|
|
8046
|
+
do {
|
|
8047
|
+
if (!lm) {
|
|
8048
|
+
final = bits(dat, pos, 1);
|
|
8049
|
+
var type = bits(dat, pos + 1, 3);
|
|
8050
|
+
pos += 3;
|
|
8051
|
+
if (!type) {
|
|
8052
|
+
var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
|
|
8053
|
+
if (t > sl) {
|
|
8054
|
+
if (noSt)
|
|
8055
|
+
err(0);
|
|
8056
|
+
break;
|
|
8057
|
+
}
|
|
8058
|
+
if (resize)
|
|
8059
|
+
cbuf(bt + l);
|
|
8060
|
+
buf.set(dat.subarray(s, t), bt);
|
|
8061
|
+
st.b = bt += l, st.p = pos = t * 8, st.f = final;
|
|
8062
|
+
continue;
|
|
8063
|
+
} else if (type == 1)
|
|
8064
|
+
lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
|
|
8065
|
+
else if (type == 2) {
|
|
8066
|
+
var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
|
|
8067
|
+
var tl = hLit + bits(dat, pos + 5, 31) + 1;
|
|
8068
|
+
pos += 14;
|
|
8069
|
+
var ldt = new u8(tl);
|
|
8070
|
+
var clt = new u8(19);
|
|
8071
|
+
for (var i2 = 0;i2 < hcLen; ++i2) {
|
|
8072
|
+
clt[clim[i2]] = bits(dat, pos + i2 * 3, 7);
|
|
8073
|
+
}
|
|
8074
|
+
pos += hcLen * 3;
|
|
8075
|
+
var clb = max(clt), clbmsk = (1 << clb) - 1;
|
|
8076
|
+
var clm = hMap(clt, clb, 1);
|
|
8077
|
+
for (var i2 = 0;i2 < tl; ) {
|
|
8078
|
+
var r = clm[bits(dat, pos, clbmsk)];
|
|
8079
|
+
pos += r & 15;
|
|
8080
|
+
var s = r >> 4;
|
|
8081
|
+
if (s < 16) {
|
|
8082
|
+
ldt[i2++] = s;
|
|
8083
|
+
} else {
|
|
8084
|
+
var c = 0, n = 0;
|
|
8085
|
+
if (s == 16)
|
|
8086
|
+
n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i2 - 1];
|
|
8087
|
+
else if (s == 17)
|
|
8088
|
+
n = 3 + bits(dat, pos, 7), pos += 3;
|
|
8089
|
+
else if (s == 18)
|
|
8090
|
+
n = 11 + bits(dat, pos, 127), pos += 7;
|
|
8091
|
+
while (n--)
|
|
8092
|
+
ldt[i2++] = c;
|
|
8093
|
+
}
|
|
8094
|
+
}
|
|
8095
|
+
var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
|
|
8096
|
+
lbt = max(lt);
|
|
8097
|
+
dbt = max(dt);
|
|
8098
|
+
lm = hMap(lt, lbt, 1);
|
|
8099
|
+
dm = hMap(dt, dbt, 1);
|
|
8100
|
+
} else
|
|
8101
|
+
err(1);
|
|
8102
|
+
if (pos > tbts) {
|
|
8103
|
+
if (noSt)
|
|
8104
|
+
err(0);
|
|
8105
|
+
break;
|
|
8106
|
+
}
|
|
8107
|
+
}
|
|
8108
|
+
if (resize)
|
|
8109
|
+
cbuf(bt + 131072);
|
|
8110
|
+
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
|
|
8111
|
+
var lpos = pos;
|
|
8112
|
+
for (;; lpos = pos) {
|
|
8113
|
+
var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
|
|
8114
|
+
pos += c & 15;
|
|
8115
|
+
if (pos > tbts) {
|
|
8116
|
+
if (noSt)
|
|
8117
|
+
err(0);
|
|
8118
|
+
break;
|
|
8119
|
+
}
|
|
8120
|
+
if (!c)
|
|
8121
|
+
err(2);
|
|
8122
|
+
if (sym < 256)
|
|
8123
|
+
buf[bt++] = sym;
|
|
8124
|
+
else if (sym == 256) {
|
|
8125
|
+
lpos = pos, lm = null;
|
|
8126
|
+
break;
|
|
8127
|
+
} else {
|
|
8128
|
+
var add = sym - 254;
|
|
8129
|
+
if (sym > 264) {
|
|
8130
|
+
var i2 = sym - 257, b = fleb[i2];
|
|
8131
|
+
add = bits(dat, pos, (1 << b) - 1) + fl[i2];
|
|
8132
|
+
pos += b;
|
|
8133
|
+
}
|
|
8134
|
+
var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
|
|
8135
|
+
if (!d)
|
|
8136
|
+
err(3);
|
|
8137
|
+
pos += d & 15;
|
|
8138
|
+
var dt = fd[dsym];
|
|
8139
|
+
if (dsym > 3) {
|
|
8140
|
+
var b = fdeb[dsym];
|
|
8141
|
+
dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
|
|
8142
|
+
}
|
|
8143
|
+
if (pos > tbts) {
|
|
8144
|
+
if (noSt)
|
|
8145
|
+
err(0);
|
|
8146
|
+
break;
|
|
8147
|
+
}
|
|
8148
|
+
if (resize)
|
|
8149
|
+
cbuf(bt + 131072);
|
|
8150
|
+
var end = bt + add;
|
|
8151
|
+
if (bt < dt) {
|
|
8152
|
+
var shift = dl - dt, dend = Math.min(dt, end);
|
|
8153
|
+
if (shift + bt < 0)
|
|
8154
|
+
err(3);
|
|
8155
|
+
for (;bt < dend; ++bt)
|
|
8156
|
+
buf[bt] = dict[shift + bt];
|
|
8157
|
+
}
|
|
8158
|
+
for (;bt < end; ++bt)
|
|
8159
|
+
buf[bt] = buf[bt - dt];
|
|
8160
|
+
}
|
|
8161
|
+
}
|
|
8162
|
+
st.l = lm, st.p = lpos, st.b = bt, st.f = final;
|
|
8163
|
+
if (lm)
|
|
8164
|
+
final = 1, st.m = lbt, st.d = dm, st.n = dbt;
|
|
8165
|
+
} while (!final);
|
|
8166
|
+
return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
|
|
8167
|
+
};
|
|
8168
|
+
var et = /* @__PURE__ */ new u8(0);
|
|
8169
|
+
var b2 = function(d, b) {
|
|
8170
|
+
return d[b] | d[b + 1] << 8;
|
|
8171
|
+
};
|
|
8172
|
+
var b4 = function(d, b) {
|
|
8173
|
+
return (d[b] | d[b + 1] << 8 | d[b + 2] << 16 | d[b + 3] << 24) >>> 0;
|
|
8174
|
+
};
|
|
8175
|
+
var b8 = function(d, b) {
|
|
8176
|
+
return b4(d, b) + b4(d, b + 4) * 4294967296;
|
|
8177
|
+
};
|
|
8178
|
+
function inflateSync(data, opts) {
|
|
8179
|
+
return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);
|
|
8180
|
+
}
|
|
8181
|
+
var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder;
|
|
8182
|
+
var tds = 0;
|
|
8183
|
+
try {
|
|
8184
|
+
td.decode(et, { stream: true });
|
|
8185
|
+
tds = 1;
|
|
8186
|
+
} catch (e) {}
|
|
8187
|
+
var dutf8 = function(d) {
|
|
8188
|
+
for (var r = "", i2 = 0;; ) {
|
|
8189
|
+
var c = d[i2++];
|
|
8190
|
+
var eb = (c > 127) + (c > 223) + (c > 239);
|
|
8191
|
+
if (i2 + eb > d.length)
|
|
8192
|
+
return { s: r, r: slc(d, i2 - 1) };
|
|
8193
|
+
if (!eb)
|
|
8194
|
+
r += String.fromCharCode(c);
|
|
8195
|
+
else if (eb == 3) {
|
|
8196
|
+
c = ((c & 15) << 18 | (d[i2++] & 63) << 12 | (d[i2++] & 63) << 6 | d[i2++] & 63) - 65536, r += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
|
|
8197
|
+
} else if (eb & 1)
|
|
8198
|
+
r += String.fromCharCode((c & 31) << 6 | d[i2++] & 63);
|
|
8199
|
+
else
|
|
8200
|
+
r += String.fromCharCode((c & 15) << 12 | (d[i2++] & 63) << 6 | d[i2++] & 63);
|
|
8201
|
+
}
|
|
8202
|
+
};
|
|
8203
|
+
function strFromU8(dat, latin1) {
|
|
8204
|
+
if (latin1) {
|
|
8205
|
+
var r = "";
|
|
8206
|
+
for (var i2 = 0;i2 < dat.length; i2 += 16384)
|
|
8207
|
+
r += String.fromCharCode.apply(null, dat.subarray(i2, i2 + 16384));
|
|
8208
|
+
return r;
|
|
8209
|
+
} else if (td) {
|
|
8210
|
+
return td.decode(dat);
|
|
8211
|
+
} else {
|
|
8212
|
+
var _a2 = dutf8(dat), s = _a2.s, r = _a2.r;
|
|
8213
|
+
if (r.length)
|
|
8214
|
+
err(8);
|
|
8215
|
+
return s;
|
|
8216
|
+
}
|
|
8217
|
+
}
|
|
8218
|
+
var slzh = function(d, b) {
|
|
8219
|
+
return b + 30 + b2(d, b + 26) + b2(d, b + 28);
|
|
8220
|
+
};
|
|
8221
|
+
var zh = function(d, b, z) {
|
|
8222
|
+
var fnl = b2(d, b + 28), efl = b2(d, b + 30), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl;
|
|
8223
|
+
var _a2 = z64hs(d, es, efl, z, b4(d, b + 20), b4(d, b + 24), b4(d, b + 42)), sc = _a2[0], su = _a2[1], off = _a2[2];
|
|
8224
|
+
return [b2(d, b + 10), sc, su, fn, es + efl + b2(d, b + 32), off];
|
|
8225
|
+
};
|
|
8226
|
+
var z64hs = function(d, b, l, z, sc, su, off) {
|
|
8227
|
+
var nsc = sc == 4294967295, nsu = su == 4294967295, noff = off == 4294967295, e = b + l;
|
|
8228
|
+
var nf = nsc + nsu + noff;
|
|
8229
|
+
if (z && nf) {
|
|
8230
|
+
for (;b + 4 < e; b += 4 + b2(d, b + 2)) {
|
|
8231
|
+
if (b2(d, b) == 1) {
|
|
8232
|
+
return [
|
|
8233
|
+
nsc ? b8(d, b + 4 + 8 * nsu) : sc,
|
|
8234
|
+
nsu ? b8(d, b + 4) : su,
|
|
8235
|
+
noff ? b8(d, b + 4 + 8 * (nsu + nsc)) : off,
|
|
8236
|
+
1
|
|
8237
|
+
];
|
|
8238
|
+
}
|
|
8239
|
+
}
|
|
8240
|
+
if (z < 2)
|
|
8241
|
+
err(13);
|
|
8242
|
+
}
|
|
8243
|
+
return [sc, su, off, 0];
|
|
8244
|
+
};
|
|
8245
|
+
function unzipSync(data, opts) {
|
|
8246
|
+
var files = {};
|
|
8247
|
+
var e = data.length - 22;
|
|
8248
|
+
for (;b4(data, e) != 101010256; --e) {
|
|
8249
|
+
if (!e || data.length - e > 65558)
|
|
8250
|
+
err(13);
|
|
8251
|
+
}
|
|
8252
|
+
var c = b2(data, e + 8);
|
|
8253
|
+
if (!c)
|
|
8254
|
+
return {};
|
|
8255
|
+
var o = b4(data, e + 16);
|
|
8256
|
+
var z = b4(data, e - 20) == 117853008;
|
|
8257
|
+
if (z) {
|
|
8258
|
+
var ze = b4(data, e - 12);
|
|
8259
|
+
z = b4(data, ze) == 101075792;
|
|
8260
|
+
if (z) {
|
|
8261
|
+
c = b4(data, ze + 32);
|
|
8262
|
+
o = b4(data, ze + 48);
|
|
8263
|
+
}
|
|
8264
|
+
}
|
|
8265
|
+
var fltr = opts && opts.filter;
|
|
8266
|
+
for (var i2 = 0;i2 < c; ++i2) {
|
|
8267
|
+
var _a2 = zh(data, o, z), c_2 = _a2[0], sc = _a2[1], su = _a2[2], fn = _a2[3], no = _a2[4], off = _a2[5], b = slzh(data, off);
|
|
8268
|
+
o = no;
|
|
8269
|
+
if (!fltr || fltr({
|
|
8270
|
+
name: fn,
|
|
8271
|
+
size: sc,
|
|
8272
|
+
originalSize: su,
|
|
8273
|
+
compression: c_2
|
|
8274
|
+
})) {
|
|
8275
|
+
if (!c_2)
|
|
8276
|
+
files[fn] = slc(data, b, b + sc);
|
|
8277
|
+
else if (c_2 == 8)
|
|
8278
|
+
files[fn] = inflateSync(data.subarray(b, b + sc), { out: new u8(su) });
|
|
8279
|
+
else
|
|
8280
|
+
err(14, "unknown compression type " + c_2);
|
|
8281
|
+
}
|
|
8282
|
+
}
|
|
8283
|
+
return files;
|
|
8284
|
+
}
|
|
8285
|
+
|
|
8286
|
+
// src/utils/chunked-export.ts
|
|
10113
8287
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
10114
8288
|
function startOfUtcDay(d) {
|
|
10115
8289
|
return new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), 0, 0, 0, 0));
|
|
@@ -10153,41 +8327,38 @@ async function forEachExportEntry(api, from, to, onEntry) {
|
|
|
10153
8327
|
from: chunkFrom,
|
|
10154
8328
|
to: chunkTo
|
|
10155
8329
|
});
|
|
10156
|
-
} catch (
|
|
10157
|
-
if (
|
|
10158
|
-
const body = await
|
|
10159
|
-
throw new Error(`Audit export failed for ${isoDay} (HTTP ${
|
|
8330
|
+
} catch (err2) {
|
|
8331
|
+
if (err2 instanceof ResponseError) {
|
|
8332
|
+
const body = await err2.response.text().catch(() => "");
|
|
8333
|
+
throw new Error(`Audit export failed for ${isoDay} (HTTP ${err2.response.status}): ${body.slice(0, 500)}`);
|
|
10160
8334
|
}
|
|
10161
|
-
throw new Error(`Audit export failed for ${isoDay}: ${
|
|
8335
|
+
throw new Error(`Audit export failed for ${isoDay}: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
10162
8336
|
}
|
|
10163
8337
|
const dayBuffer = Buffer2.from(await response.raw.arrayBuffer());
|
|
10164
8338
|
if (dayBuffer.byteLength === 0)
|
|
10165
8339
|
continue;
|
|
10166
8340
|
let dayHadEntries = false;
|
|
10167
|
-
const
|
|
10168
|
-
|
|
10169
|
-
if (entry.isDirectory)
|
|
8341
|
+
for (const [entryName, entryData] of Object.entries(unzipSync(new Uint8Array(dayBuffer)))) {
|
|
8342
|
+
if (entryName.endsWith("/"))
|
|
10170
8343
|
continue;
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
const
|
|
10174
|
-
|
|
10175
|
-
for (const innerEntry of nested.getEntries()) {
|
|
10176
|
-
if (innerEntry.isDirectory)
|
|
8344
|
+
if (/\.zip$/i.test(entryName)) {
|
|
8345
|
+
const outerBase = basenameNoExt(entryName);
|
|
8346
|
+
for (const [innerName, innerData] of Object.entries(unzipSync(entryData))) {
|
|
8347
|
+
if (innerName.endsWith("/"))
|
|
10177
8348
|
continue;
|
|
10178
|
-
const innerBase = basenameNoExt(
|
|
8349
|
+
const innerBase = basenameNoExt(innerName);
|
|
10179
8350
|
onEntry({
|
|
10180
8351
|
isoDay,
|
|
10181
8352
|
preferredName: `${innerBase}_${outerBase}.txt`,
|
|
10182
|
-
data:
|
|
8353
|
+
data: Buffer2.from(innerData)
|
|
10183
8354
|
});
|
|
10184
8355
|
dayHadEntries = true;
|
|
10185
8356
|
}
|
|
10186
8357
|
} else {
|
|
10187
8358
|
onEntry({
|
|
10188
8359
|
isoDay,
|
|
10189
|
-
preferredName: basename2(
|
|
10190
|
-
data: entryData
|
|
8360
|
+
preferredName: basename2(entryName),
|
|
8361
|
+
data: Buffer2.from(entryData)
|
|
10191
8362
|
});
|
|
10192
8363
|
dayHadEntries = true;
|
|
10193
8364
|
}
|
|
@@ -10266,8 +8437,8 @@ function parseDailyEvents(data, isoDay, fileName) {
|
|
|
10266
8437
|
let parsed;
|
|
10267
8438
|
try {
|
|
10268
8439
|
parsed = JSON.parse(text);
|
|
10269
|
-
} catch (
|
|
10270
|
-
throw new Error(`Audit export for ${isoDay} returned a file (${fileName}) that is not valid JSON: ${
|
|
8440
|
+
} catch (err2) {
|
|
8441
|
+
throw new Error(`Audit export for ${isoDay} returned a file (${fileName}) that is not valid JSON: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
10271
8442
|
}
|
|
10272
8443
|
if (Array.isArray(parsed))
|
|
10273
8444
|
return parsed;
|
|
@@ -10743,4 +8914,4 @@ export {
|
|
|
10743
8914
|
registerCommands
|
|
10744
8915
|
};
|
|
10745
8916
|
|
|
10746
|
-
//# debugId=
|
|
8917
|
+
//# debugId=CB93B8471D4DB1E864756E2164756E21
|