@zip.js/zip.js 2.6.33 → 2.6.35
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/z-worker-fflate.js +1 -1
- package/dist/z-worker-pako.js +1 -1
- package/dist/z-worker.js +1 -1
- package/dist/zip-fs-full.js +2483 -2364
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +1241 -1122
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +1238 -1119
- package/dist/zip-full.min.js +1 -1
- package/dist/zip-no-worker-deflate.min.js +1 -1
- package/dist/zip-no-worker-inflate.min.js +1 -1
- package/dist/zip-no-worker.min.js +1 -1
- package/dist/zip.js +1242 -1123
- package/dist/zip.min.js +1 -1
- package/index-fflate.js +3 -1
- package/index.cjs +2483 -2364
- package/index.d.ts +51 -6
- package/index.js +3 -1
- package/lib/core/codec-pool.js +2 -2
- package/lib/core/codec-worker.js +321 -0
- package/lib/core/configuration.js +3 -3
- package/lib/core/constants.js +6 -5
- package/lib/core/io.js +68 -1
- package/lib/core/streams/aes-crypto-stream.js +2 -0
- package/lib/core/streams/codec-stream.js +60 -13
- package/lib/core/streams/codecs/sjcl.js +1 -1
- package/lib/core/streams/stream-adapter.js +55 -0
- package/lib/core/streams/zip-crypto-stream.js +1 -0
- package/lib/core/streams/zip-entry-stream.js +1 -0
- package/lib/core/util/stream-codec-shim.js +2 -0
- package/lib/core/z-worker-core.js +21 -11
- package/lib/core/zip-entry.js +2 -1
- package/lib/core/zip-fs-core.js +1 -0
- package/lib/core/zip-reader.js +7 -5
- package/lib/core/zip-writer.js +88 -42
- package/lib/z-worker-inline.js +1 -1
- package/lib/zip.js +1 -1
- package/package.json +5 -5
- package/tests/all/test-http-split-zip.js +37 -0
- package/tests/all/test-split-zip.js +25 -22
- package/tests/tests-data.js +2 -1
- package/lib/core/codec-interface.js +0 -115
- package/lib/core/codec-pool-worker.js +0 -293
package/dist/zip-full.js
CHANGED
|
@@ -4257,37 +4257,50 @@
|
|
|
4257
4257
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4258
4258
|
*/
|
|
4259
4259
|
|
|
4260
|
-
const
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
t = (t >>> 1) ^ 0xEDB88320;
|
|
4266
|
-
} else {
|
|
4267
|
-
t = t >>> 1;
|
|
4268
|
-
}
|
|
4269
|
-
}
|
|
4270
|
-
table[i] = t;
|
|
4271
|
-
}
|
|
4260
|
+
const MAX_32_BITS = 0xffffffff;
|
|
4261
|
+
const MAX_16_BITS = 0xffff;
|
|
4262
|
+
const COMPRESSION_METHOD_DEFLATE = 0x08;
|
|
4263
|
+
const COMPRESSION_METHOD_STORE = 0x00;
|
|
4264
|
+
const COMPRESSION_METHOD_AES = 0x63;
|
|
4272
4265
|
|
|
4273
|
-
|
|
4266
|
+
const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50;
|
|
4267
|
+
const SPLIT_ZIP_FILE_SIGNATURE = 0x08074b50;
|
|
4268
|
+
const DATA_DESCRIPTOR_RECORD_SIGNATURE = SPLIT_ZIP_FILE_SIGNATURE;
|
|
4269
|
+
const CENTRAL_FILE_HEADER_SIGNATURE = 0x02014b50;
|
|
4270
|
+
const END_OF_CENTRAL_DIR_SIGNATURE = 0x06054b50;
|
|
4271
|
+
const ZIP64_END_OF_CENTRAL_DIR_SIGNATURE = 0x06064b50;
|
|
4272
|
+
const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE = 0x07064b50;
|
|
4273
|
+
const END_OF_CENTRAL_DIR_LENGTH = 22;
|
|
4274
|
+
const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH = 20;
|
|
4275
|
+
const ZIP64_END_OF_CENTRAL_DIR_LENGTH = 56;
|
|
4276
|
+
const ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH = END_OF_CENTRAL_DIR_LENGTH + ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH + ZIP64_END_OF_CENTRAL_DIR_LENGTH;
|
|
4274
4277
|
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
+
const EXTRAFIELD_TYPE_ZIP64 = 0x0001;
|
|
4279
|
+
const EXTRAFIELD_TYPE_AES = 0x9901;
|
|
4280
|
+
const EXTRAFIELD_TYPE_NTFS = 0x000a;
|
|
4281
|
+
const EXTRAFIELD_TYPE_NTFS_TAG1 = 0x0001;
|
|
4282
|
+
const EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP = 0x5455;
|
|
4283
|
+
const EXTRAFIELD_TYPE_UNICODE_PATH = 0x7075;
|
|
4284
|
+
const EXTRAFIELD_TYPE_UNICODE_COMMENT = 0x6375;
|
|
4278
4285
|
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
this.crc = crc;
|
|
4285
|
-
}
|
|
4286
|
+
const BITFLAG_ENCRYPTED = 0x01;
|
|
4287
|
+
const BITFLAG_LEVEL = 0x06;
|
|
4288
|
+
const BITFLAG_DATA_DESCRIPTOR = 0x0008;
|
|
4289
|
+
const BITFLAG_LANG_ENCODING_FLAG = 0x0800;
|
|
4290
|
+
const FILE_ATTR_MSDOS_DIR_MASK = 0x10;
|
|
4286
4291
|
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4292
|
+
const VERSION_DEFLATE = 0x14;
|
|
4293
|
+
const VERSION_ZIP64 = 0x2D;
|
|
4294
|
+
const VERSION_AES = 0x33;
|
|
4295
|
+
|
|
4296
|
+
const DIRECTORY_SIGNATURE = "/";
|
|
4297
|
+
|
|
4298
|
+
const MAX_DATE = new Date(2107, 11, 31);
|
|
4299
|
+
const MIN_DATE = new Date(1980, 0, 1);
|
|
4300
|
+
|
|
4301
|
+
const UNDEFINED_VALUE = undefined;
|
|
4302
|
+
const UNDEFINED_TYPE$1 = "undefined";
|
|
4303
|
+
const FUNCTION_TYPE$1 = "function";
|
|
4291
4304
|
|
|
4292
4305
|
/*
|
|
4293
4306
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
@@ -4317,21 +4330,25 @@
|
|
|
4317
4330
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4318
4331
|
*/
|
|
4319
4332
|
|
|
4320
|
-
class
|
|
4333
|
+
class StreamAdapter {
|
|
4321
4334
|
|
|
4322
|
-
constructor() {
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4335
|
+
constructor(Codec) {
|
|
4336
|
+
return class extends TransformStream {
|
|
4337
|
+
constructor(options) {
|
|
4338
|
+
const codec = new Codec(options);
|
|
4339
|
+
super({
|
|
4340
|
+
transform(chunk, controller) {
|
|
4341
|
+
controller.enqueue(codec.append(chunk));
|
|
4342
|
+
},
|
|
4343
|
+
flush(controller) {
|
|
4344
|
+
const chunk = codec.flush();
|
|
4345
|
+
if (chunk) {
|
|
4346
|
+
controller.enqueue(chunk);
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
});
|
|
4333
4350
|
}
|
|
4334
|
-
}
|
|
4351
|
+
};
|
|
4335
4352
|
}
|
|
4336
4353
|
}
|
|
4337
4354
|
|
|
@@ -4363,94 +4380,397 @@
|
|
|
4363
4380
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4364
4381
|
*/
|
|
4365
4382
|
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4383
|
+
const MINIMUM_CHUNK_SIZE = 64;
|
|
4384
|
+
let maxWorkers = 2;
|
|
4385
|
+
try {
|
|
4386
|
+
if (typeof navigator != UNDEFINED_TYPE$1 && navigator.hardwareConcurrency) {
|
|
4387
|
+
maxWorkers = navigator.hardwareConcurrency;
|
|
4388
|
+
}
|
|
4389
|
+
} catch (_error) {
|
|
4390
|
+
// ignored
|
|
4391
|
+
}
|
|
4392
|
+
const DEFAULT_CONFIGURATION = {
|
|
4393
|
+
chunkSize: 512 * 1024,
|
|
4394
|
+
maxWorkers,
|
|
4395
|
+
terminateWorkerTimeout: 5000,
|
|
4396
|
+
useWebWorkers: true,
|
|
4397
|
+
useCompressionStream: true,
|
|
4398
|
+
workerScripts: UNDEFINED_VALUE,
|
|
4399
|
+
CompressionStreamNative: typeof CompressionStream != UNDEFINED_TYPE$1 && CompressionStream,
|
|
4400
|
+
DecompressionStreamNative: typeof DecompressionStream != UNDEFINED_TYPE$1 && DecompressionStream
|
|
4401
|
+
};
|
|
4402
|
+
|
|
4403
|
+
const config = Object.assign({}, DEFAULT_CONFIGURATION);
|
|
4404
|
+
|
|
4405
|
+
function getConfiguration() {
|
|
4406
|
+
return config;
|
|
4407
|
+
}
|
|
4408
|
+
|
|
4409
|
+
function getChunkSize(config) {
|
|
4410
|
+
return Math.max(config.chunkSize, MINIMUM_CHUNK_SIZE);
|
|
4411
|
+
}
|
|
4412
|
+
|
|
4413
|
+
function configure(configuration) {
|
|
4414
|
+
const {
|
|
4415
|
+
baseURL,
|
|
4416
|
+
chunkSize,
|
|
4417
|
+
maxWorkers,
|
|
4418
|
+
terminateWorkerTimeout,
|
|
4419
|
+
useCompressionStream,
|
|
4420
|
+
useWebWorkers,
|
|
4421
|
+
Deflate,
|
|
4422
|
+
Inflate,
|
|
4423
|
+
CompressionStream,
|
|
4424
|
+
DecompressionStream,
|
|
4425
|
+
workerScripts
|
|
4426
|
+
} = configuration;
|
|
4427
|
+
setIfDefined("baseURL", baseURL);
|
|
4428
|
+
setIfDefined("chunkSize", chunkSize);
|
|
4429
|
+
setIfDefined("maxWorkers", maxWorkers);
|
|
4430
|
+
setIfDefined("terminateWorkerTimeout", terminateWorkerTimeout);
|
|
4431
|
+
setIfDefined("useCompressionStream", useCompressionStream);
|
|
4432
|
+
setIfDefined("useWebWorkers", useWebWorkers);
|
|
4433
|
+
if (Deflate) {
|
|
4434
|
+
config.CompressionStream = new StreamAdapter(Deflate);
|
|
4435
|
+
}
|
|
4436
|
+
if (Inflate) {
|
|
4437
|
+
config.DecompressionStream = new StreamAdapter(Inflate);
|
|
4438
|
+
}
|
|
4439
|
+
setIfDefined("CompressionStream", CompressionStream);
|
|
4440
|
+
setIfDefined("DecompressionStream", DecompressionStream);
|
|
4441
|
+
if (workerScripts !== UNDEFINED_VALUE) {
|
|
4442
|
+
const { deflate, inflate } = workerScripts;
|
|
4443
|
+
if (deflate || inflate) {
|
|
4444
|
+
if (!config.workerScripts) {
|
|
4445
|
+
config.workerScripts = {};
|
|
4446
|
+
}
|
|
4447
|
+
}
|
|
4448
|
+
if (deflate) {
|
|
4449
|
+
if (!Array.isArray(deflate)) {
|
|
4450
|
+
throw new Error("workerScripts.deflate must be an array");
|
|
4451
|
+
}
|
|
4452
|
+
config.workerScripts.deflate = deflate;
|
|
4453
|
+
}
|
|
4454
|
+
if (inflate) {
|
|
4455
|
+
if (!Array.isArray(inflate)) {
|
|
4456
|
+
throw new Error("workerScripts.inflate must be an array");
|
|
4457
|
+
}
|
|
4458
|
+
config.workerScripts.inflate = inflate;
|
|
4372
4459
|
}
|
|
4373
|
-
return result;
|
|
4374
|
-
} else {
|
|
4375
|
-
return new TextEncoder().encode(value);
|
|
4376
4460
|
}
|
|
4377
4461
|
}
|
|
4378
4462
|
|
|
4379
|
-
|
|
4463
|
+
function setIfDefined(propertyName, propertyValue) {
|
|
4464
|
+
if (propertyValue !== UNDEFINED_VALUE) {
|
|
4465
|
+
config[propertyName] = propertyValue;
|
|
4466
|
+
}
|
|
4467
|
+
}
|
|
4380
4468
|
|
|
4381
|
-
/*// deno-lint-ignore-file no-this-alias *
|
|
4469
|
+
function e(e){const t=()=>URL.createObjectURL(new Blob(['const{Array:e,Object:t,Math:n,Error:r,Uint8Array:s,Uint16Array:i,Uint32Array:o,Int32Array:c,Map:f,DataView:a,Promise:l,TextEncoder:u,crypto:w,postMessage:h,TransformStream:d,ReadableStream:p,WritableStream:y,CompressionStream:m,DecompressionStream:b}=self;class g{constructor(e){return class extends d{constructor(t){const n=new e(t);super({transform(e,t){t.enqueue(n.append(e))},flush(e){const t=n.flush();t&&e.enqueue(t)}})}}}}const k=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;k[e]=t}class v{constructor(e){this.t=e||-1}append(e){let t=0|this.t;for(let n=0,r=0|e.length;r>n;n++)t=t>>>8^k[255&(t^e[n])];this.t=t}get(){return~this.t}}class S extends d{constructor(){const e=new v;super({transform(t){e.append(t)},flush(t){const n=new s(4);new a(n.buffer).setUint32(0,e.get()),t.enqueue(n)}})}}const z={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],r=z.i(n);return 32===r?e.concat(t):z.o(t,r,0|n,e.slice(0,e.length-1))},l(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+z.i(n)},u(e,t){if(32*e.length<t)return e;const r=(e=e.slice(0,n.ceil(t/32))).length;return t&=31,r>0&&t&&(e[r-1]=z.h(t,e[r-1]&2147483648>>t-1,1)),e},h:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,i:e=>n.round(e/1099511627776)||32,o(e,t,n,r){for(void 0===r&&(r=[]);t>=32;t-=32)r.push(n),n=0;if(0===t)return r.concat(e);for(let s=0;s<e.length;s++)r.push(n|e[s]>>>t),n=e[s]<<32-t;const s=e.length?e[e.length-1]:0,i=z.i(s);return r.push(z.h(t+i&31,t+i>32?n:r.pop(),1)),r}},_={p:{m(e){const t=z.l(e)/8,n=new s(t);let r;for(let s=0;t>s;s++)0==(3&s)&&(r=e[s/4]),n[s]=r>>>24,r<<=8;return n},g(e){const t=[];let n,r=0;for(n=0;n<e.length;n++)r=r<<8|e[n],3==(3&n)&&(t.push(r),r=0);return 3&n&&t.push(z.h(8*(3&n),r)),t}}},C={k:function(e){e?(this.v=e.v.slice(0),this.S=e.S.slice(0),this._=e._):this.reset()}};C.k.prototype={blockSize:512,reset(){const e=this;return e.v=this.C.slice(0),e.S=[],e._=0,e},update(e){const t=this;"string"==typeof e&&(e=_.I.g(e));const n=t.S=z.concat(t.S,e),s=t._,i=t._=s+z.l(e);if(i>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new o(n);let f=0;for(let e=t.blockSize+s-(t.blockSize+s&t.blockSize-1);i>=e;e+=t.blockSize)t.A(c.subarray(16*f,16*(f+1))),f+=1;return n.splice(0,16*f),t},D(){const e=this;let t=e.S;const r=e.v;t=z.concat(t,[z.h(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(n.floor(e._/4294967296)),t.push(0|e._);t.length;)e.A(t.splice(0,16));return e.reset(),r},C:[1732584193,4023233417,2562383102,271733878,3285377520],V:[1518500249,1859775393,2400959708,3395469782],R:(e,t,n,r)=>e>19?e>39?e>59?e>79?void 0:t^n^r:t&n|t&r|n&r:t^n^r:t&n|~t&r,B:(e,t)=>t<<e|t>>>32-e,A(t){const r=this,s=r.v,i=e(80);for(let e=0;16>e;e++)i[e]=t[e];let o=s[0],c=s[1],f=s[2],a=s[3],l=s[4];for(let e=0;79>=e;e++){16>e||(i[e]=r.B(1,i[e-3]^i[e-8]^i[e-14]^i[e-16]));const t=r.B(5,o)+r.R(e,c,f,a)+l+i[e]+r.V[n.floor(e/20)]|0;l=a,a=f,f=r.B(30,c),c=o,o=t}s[0]=s[0]+o|0,s[1]=s[1]+c|0,s[2]=s[2]+f|0,s[3]=s[3]+a|0,s[4]=s[4]+l|0}};const I={getRandomValues(e){const t=new o(e.buffer),r=e=>{let t=987654321;const r=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&r,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&r)&r)/4294967296+.5)*(n.random()>.5?1:-1))};for(let s,i=0;i<e.length;i+=4){const e=r(4294967296*(s||n.random()));s=987654071*e(),t[i/4]=4294967296*e()|0}return e}},x={importKey:e=>new x.M(_.p.g(e)),K(e,t,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const i=1+(s>>5)<<2;let o,c,f,l,u;const w=new ArrayBuffer(i),h=new a(w);let d=0;const p=z;for(t=_.p.g(t),u=1;(i||1)>d;u++){for(o=c=e.encrypt(p.concat(t,[u])),f=1;n>f;f++)for(c=e.encrypt(c),l=0;l<c.length;l++)o[l]^=c[l];for(f=0;(i||1)>d&&f<o.length;f++)h.setInt32(d,o[f]),d+=4}return w.slice(0,s/8)},M:class{constructor(e){const t=this,n=t.N=C.k,r=[[],[]],s=n.prototype.blockSize/32;t.P=[new n,new n],e.length>s&&(e=n.hash(e));for(let t=0;s>t;t++)r[0][t]=909522486^e[t],r[1][t]=1549556828^e[t];t.P[0].update(r[0]),t.P[1].update(r[1]),t.U=new n(t.P[0])}reset(){const e=this;e.U=new e.N(e.P[0]),e.T=!1}update(e){this.T=!0,this.U.update(e)}digest(){const e=this,t=e.U.D(),n=new e.N(e.P[1]).update(t).D();return e.reset(),n}encrypt(e){if(this.T)throw new r("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},A=void 0!==w&&"function"==typeof w.getRandomValues;function D(e){return A?w.getRandomValues(e):I.getRandomValues(e)}const V={name:"PBKDF2"},R=t.assign({hash:{name:"HMAC"}},V),B=t.assign({iterations:1e3,hash:{name:"SHA-1"}},V),E=["deriveBits"],M=[8,12,16],K=[16,24,32],N=[0,0,0,0],P=void 0!==w,U=P&&w.subtle,T=P&&void 0!==U,W=P&&T&&"function"==typeof U.importKey,H=P&&T&&"function"==typeof U.deriveBits,L=_.p,j=class{constructor(e){const t=this;t.W=[[[],[],[],[],[]],[[],[],[],[],[]]],t.W[0][0][0]||t.H();const n=t.W[0][4],s=t.W[1],i=e.length;let o,c,f,a=1;if(4!==i&&6!==i&&8!==i)throw new r("invalid aes key size");for(t.V=[c=e.slice(0),f=[]],o=i;4*i+28>o;o++){let e=c[o-1];(o%i==0||8===i&&o%i==4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],o%i==0&&(e=e<<8^e>>>24^a<<24,a=a<<1^283*(a>>7))),c[o]=c[o-i]^e}for(let e=0;o;e++,o--){const t=c[3&e?o:o-4];f[e]=4>=o||4>e?t:s[0][n[t>>>24]]^s[1][n[t>>16&255]]^s[2][n[t>>8&255]]^s[3][n[255&t]]}}encrypt(e){return this.L(e,0)}decrypt(e){return this.L(e,1)}H(){const e=this.W[0],t=this.W[1],n=e[4],r=t[4],s=[],i=[];let o,c,f,a;for(let e=0;256>e;e++)i[(s[e]=e<<1^283*(e>>7))^e]=e;for(let l=o=0;!n[l];l^=c||1,o=i[o]||1){let i=o^o<<1^o<<2^o<<3^o<<4;i=i>>8^255&i^99,n[l]=i,r[i]=l,a=s[f=s[c=s[l]]];let u=16843009*a^65537*f^257*c^16843008*l,w=257*s[i]^16843008*i;for(let n=0;4>n;n++)e[n][l]=w=w<<24^w>>>8,t[n][i]=u=u<<24^u>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}L(e,t){if(4!==e.length)throw new r("invalid aes block size");const n=this.V[t],s=n.length/4-2,i=[0,0,0,0],o=this.W[t],c=o[0],f=o[1],a=o[2],l=o[3],u=o[4];let w,h,d,p=e[0]^n[0],y=e[t?3:1]^n[1],m=e[2]^n[2],b=e[t?1:3]^n[3],g=4;for(let e=0;s>e;e++)w=c[p>>>24]^f[y>>16&255]^a[m>>8&255]^l[255&b]^n[g],h=c[y>>>24]^f[m>>16&255]^a[b>>8&255]^l[255&p]^n[g+1],d=c[m>>>24]^f[b>>16&255]^a[p>>8&255]^l[255&y]^n[g+2],b=c[b>>>24]^f[p>>16&255]^a[y>>8&255]^l[255&m]^n[g+3],g+=4,p=w,y=h,m=d;for(let e=0;4>e;e++)i[t?3&-e:e]=u[p>>>24]<<24^u[y>>16&255]<<16^u[m>>8&255]<<8^u[255&b]^n[g++],w=p,p=y,y=m,m=b,b=w;return i}},F=class{constructor(e,t){this.j=e,this.F=t,this.O=t}reset(){this.O=this.F}update(e){return this.q(this.j,e,this.O)}G(e){if(255==(e>>24&255)){let t=e>>16&255,n=e>>8&255,r=255&e;255===t?(t=0,255===n?(n=0,255===r?r=0:++r):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=r}else e+=1<<24;return e}J(e){0===(e[0]=this.G(e[0]))&&(e[1]=this.G(e[1]))}q(e,t,n){let r;if(!(r=t.length))return[];const s=z.l(t);for(let s=0;r>s;s+=4){this.J(n);const r=e.encrypt(n);t[s]^=r[0],t[s+1]^=r[1],t[s+2]^=r[2],t[s+3]^=r[3]}return z.u(t,s)}},O=x.M;class q extends d{constructor(e,n,i){super({start(){t.assign(this,{ready:new l((e=>this.X=e)),password:e,signed:n,Y:i-1,pending:new s})},async transform(e,t){const n=this,{password:i,Y:o,X:c,ready:f}=n;i?(await(async(e,t,n,s)=>{const i=await Q(e,t,n,Y(s,0,M[t])),o=Y(s,M[t]);if(i[0]!=o[0]||i[1]!=o[1])throw new r("Invalid password")})(n,o,i,Y(e,0,M[o]+2)),e=Y(e,M[o]+2),c()):await f;const a=new s(e.length-10-(e.length-10)%16);t.enqueue(J(n,e,a,0,10,!0))},async flush(e){const{signed:t,Z:n,$:i,pending:o,ready:c}=this;await c;const f=Y(o,0,o.length-10),a=Y(o,o.length-10);let l=new s;if(f.length){const e=$(L,f);i.update(e);const t=n.update(e);l=Z(L,t)}if(t){const e=Y(Z(L,i.digest()),0,10);for(let t=0;10>t;t++)if(e[t]!=a[t])throw new r("Invalid signature")}e.enqueue(l)}})}}class G extends d{constructor(e,n){let r;super({start(){t.assign(this,{ready:new l((e=>this.X=e)),password:e,Y:n-1,pending:new s})},async transform(e,t){const n=this,{password:r,Y:i,X:o,ready:c}=n;let f=new s;r?(f=await(async(e,t,n)=>{const r=D(new s(M[t]));return X(r,await Q(e,t,n,r))})(n,i,r),o()):await c;const a=new s(f.length+e.length-e.length%16);a.set(f,0),t.enqueue(J(n,e,a,f.length,0))},async flush(e){const{Z:t,$:n,pending:i,ready:o}=this;await o;let c=new s;if(i.length){const e=t.update($(L,i));n.update(e),c=Z(L,e)}r.signature=Z(L,n.digest()).slice(0,10),e.enqueue(X(c,r.signature))}}),r=this}}function J(e,t,n,r,i,o){const{Z:c,$:f,pending:a}=e,l=t.length-i;let u;for(a.length&&(t=X(a,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new s(t)).set(n,0)}return e})(n,l-l%16)),u=0;l-16>=u;u+=16){const e=$(L,Y(t,u,u+16));o&&f.update(e);const s=c.update(e);o||f.update(s),n.set(Z(L,s),u+r)}return e.pending=Y(t,u),n}async function Q(n,r,i,o){n.password=null;const c=(e=>{if(void 0===u){const t=new s((e=unescape(encodeURIComponent(e))).length);for(let n=0;n<t.length;n++)t[n]=e.charCodeAt(n);return t}return(new u).encode(e)})(i),f=await((e,t,n,r,s)=>W?U.importKey("raw",t,n,!1,s):x.importKey(t))(0,c,R,0,E),a=await(async(e,t,n)=>H?await U.deriveBits(e,t,n):x.K(t,e.salt,B.iterations,n))(t.assign({salt:o},B),f,8*(2*K[r]+2)),l=new s(a),w=$(L,Y(l,0,K[r])),h=$(L,Y(l,K[r],2*K[r])),d=Y(l,2*K[r]);return t.assign(n,{keys:{key:w,ee:h,passwordVerification:d},Z:new F(new j(w),e.from(N)),$:new O(h)}),d}function X(e,t){let n=e;return e.length+t.length&&(n=new s(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function Y(e,t,n){return e.subarray(t,n)}function Z(e,t){return e.m(t)}function $(e,t){return e.g(t)}class ee extends d{constructor(e,n){super({start(){t.assign(this,{password:e,passwordVerification:n}),se(this,e)},transform(e,t){const n=this;if(n.password){const t=ne(n,e.subarray(0,12));if(n.password=null,t[11]!=n.passwordVerification)throw new r("Invalid password");e=e.subarray(12)}t.enqueue(ne(n,e))}})}}class te extends d{constructor(e,n){super({start(){t.assign(this,{password:e,passwordVerification:n}),se(this,e)},transform(e,t){const n=this;let r,i;if(n.password){n.password=null;const t=D(new s(12));t[11]=n.passwordVerification,r=new s(e.length+t.length),r.set(re(n,t),0),i=12}else r=new s(e.length),i=0;r.set(re(n,e),i),t.enqueue(r)}})}}function ne(e,t){const n=new s(t.length);for(let r=0;r<t.length;r++)n[r]=oe(e)^t[r],ie(e,n[r]);return n}function re(e,t){const n=new s(t.length);for(let r=0;r<t.length;r++)n[r]=oe(e)^t[r],ie(e,t[r]);return n}function se(e,n){const r=[305419896,591751049,878082192];t.assign(e,{keys:r,te:new v(r[0]),ne:new v(r[2])});for(let t=0;t<n.length;t++)ie(e,n.charCodeAt(t))}function ie(e,t){let[r,s,i]=e.keys;e.te.append([t]),r=~e.te.get(),s=fe(n.imul(fe(s+ce(r)),134775813)+1),e.ne.append([s>>>24]),i=~e.ne.get(),e.keys=[r,s,i]}function oe(e){const t=2|e.keys[2];return ce(n.imul(t,1^t)>>>8)}function ce(e){return 255&e}function fe(e){return 4294967295&e}class ae extends d{constructor(e,{chunkSize:t,CompressionStream:n,re:r}){super({});const{compressed:s,encrypted:i,useCompressionStream:o,password:c,passwordVerification:f,encryptionStrength:l,zipCrypto:u,signed:w,level:h}=e,d=this;let p,y,m=ue(super.readable);i&&!u||!w||([m,p]=m.tee(),p=de(p,new S)),s&&(m=he(m,o,{level:h,chunkSize:t},r,n)),i&&(u?m=de(m,new te(c,f)):(y=new G(c,l),m=de(m,y))),we(d,m,(async()=>{let e;i&&!u&&(e=y.signature),i&&!u||!w||(e=await p.getReader().read(),e=new a(e.value.buffer).getUint32(0)),d.signature=e}))}}class le extends d{constructor(e,{chunkSize:t,DecompressionStream:n,se:s}){super({});const{zipCrypto:i,encrypted:o,password:c,passwordVerification:f,signed:l,signature:u,encryptionStrength:w,compressed:h,useCompressionStream:d}=e;let p,y,m=ue(super.readable);o&&(i?m=de(m,new ee(c,f)):(y=new q(c,l,w),m=de(m,y))),h&&(m=he(m,d,{chunkSize:t},s,n)),o&&!i||!l||([m,p]=m.tee(),p=de(p,new S)),we(this,m,(async()=>{if((!o||i)&&l){const e=await p.getReader().read(),t=new a(e.value.buffer);if(u!=t.getUint32(0,!1))throw new r("Invalid signature")}}))}}function ue(e){return de(e,new d({transform(e,t){e&&e.length&&t.enqueue(e)}}))}function we(e,n,r){n=de(n,new d({flush:r})),t.defineProperty(e,"readable",{get:()=>n})}function he(e,t,n,r,s){try{e=de(e,new(t&&r?r:s)("deflate-raw",n))}catch(r){if(!t)throw r;e=de(e,new s("deflate-raw",n))}return e}function de(e,t){return e.pipeThrough(t)}class pe extends d{constructor(e,n){super({});const r=this,{codecType:s}=e;let i;s.startsWith("deflate")?i=ae:s.startsWith("inflate")&&(i=le);let o=0;const c=new i(e,n),f=super.readable,a=new d({transform(e,t){e&&e.length&&(o+=e.length,t.enqueue(e))},flush(){const{signature:e}=c;t.assign(r,{signature:e,size:o})}});t.defineProperty(r,"readable",{get:()=>f.pipeThrough(c).pipeThrough(a)})}}const ye=new f,me=new f;let be=0;async function ge(e){try{const{options:t,scripts:n,config:r}=e;n&&n.length&&importScripts.apply(void 0,n),self.initCodec&&self.initCodec(),r.re=self.CompressionStream,r.se=self.DecompressionStream,self.Deflate&&(r.CompressionStream=new g(self.Deflate)),self.Inflate&&(r.DecompressionStream=new g(self.Inflate));const s={highWaterMark:1,size:()=>r.chunkSize},i=e.readable||new p({async pull(e){const t=new l((e=>ye.set(be,e)));ke({type:"pull",messageId:be}),be=(be+1)%Number.MAX_SAFE_INTEGER;const{value:n,done:r}=await t;e.enqueue(n),r&&e.close()}},s),o=e.writable||new y({async write(e){let t;const n=new l((e=>t=e));me.set(be,t),ke({type:"data",data:e,messageId:be}),be=(be+1)%Number.MAX_SAFE_INTEGER,await n}},s),c=new pe(t,r);await i.pipeThrough(c).pipeTo(o,{ie:!0});try{await o.close()}catch(e){}const{signature:f,size:a}=c;ke({type:"close",result:{signature:f,size:a}})}catch(e){ve(e)}}function ke(e){if(e.data){let{data:t}=e;if(t&&t.length)try{t=new s(t),e.data=t.buffer,h(e,[e.data])}catch(t){h(e)}else h(e)}else h(e)}function ve(e){const{message:t,stack:n,code:r,name:s}=e;h({error:{message:t,stack:n,code:r,name:s}})}function Se(t){return ze(t.map((([t,n])=>new e(t).fill(n,0,t))))}function ze(t){return t.reduce(((t,n)=>t.concat(e.isArray(n)?ze(n):n)),[])}addEventListener("message",(e=>{const t=e.data,{type:n,messageId:r,data:i,done:o}=t;try{if("start"==n&&ge(t),"data"==n){const e=ye.get(r);ye.delete(r),e({value:new s(i),done:o})}if("ack"==n){const e=me.get(r);me.delete(r),e()}}catch(e){ve(e)}}));const _e=[0,1,2,3].concat(...Se([[2,4],[2,5],[4,6],[4,7],[8,8],[8,9],[16,10],[16,11],[32,12],[32,13],[64,14],[64,15],[2,0],[1,16],[1,17],[2,18],[2,19],[4,20],[4,21],[8,22],[8,23],[16,24],[16,25],[32,26],[32,27],[64,28],[64,29]]));function Ce(){const e=this;function t(e,t){let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1}e.oe=r=>{const s=e.ce,i=e.ae.fe,o=e.ae.le;let c,f,a,l=-1;for(r.ue=0,r.we=573,c=0;o>c;c++)0!==s[2*c]?(r.he[++r.ue]=l=c,r.de[c]=0):s[2*c+1]=0;for(;2>r.ue;)a=r.he[++r.ue]=2>l?++l:0,s[2*a]=1,r.de[a]=0,r.pe--,i&&(r.ye-=i[2*a+1]);for(e.me=l,c=n.floor(r.ue/2);c>=1;c--)r.be(s,c);a=o;do{c=r.he[1],r.he[1]=r.he[r.ue--],r.be(s,1),f=r.he[1],r.he[--r.we]=c,r.he[--r.we]=f,s[2*a]=s[2*c]+s[2*f],r.de[a]=n.max(r.de[c],r.de[f])+1,s[2*c+1]=s[2*f+1]=a,r.he[1]=a++,r.be(s,1)}while(r.ue>=2);r.he[--r.we]=r.he[1],(t=>{const n=e.ce,r=e.ae.fe,s=e.ae.ge,i=e.ae.ke,o=e.ae.ve;let c,f,a,l,u,w,h=0;for(l=0;15>=l;l++)t.Se[l]=0;for(n[2*t.he[t.we]+1]=0,c=t.we+1;573>c;c++)f=t.he[c],l=n[2*n[2*f+1]+1]+1,l>o&&(l=o,h++),n[2*f+1]=l,f>e.me||(t.Se[l]++,u=0,i>f||(u=s[f-i]),w=n[2*f],t.pe+=w*(l+u),r&&(t.ye+=w*(r[2*f+1]+u)));if(0!==h){do{for(l=o-1;0===t.Se[l];)l--;t.Se[l]--,t.Se[l+1]+=2,t.Se[o]--,h-=2}while(h>0);for(l=o;0!==l;l--)for(f=t.Se[l];0!==f;)a=t.he[--c],a>e.me||(n[2*a+1]!=l&&(t.pe+=(l-n[2*a+1])*n[2*a],n[2*a+1]=l),f--)}})(r),((e,n,r)=>{const s=[];let i,o,c,f=0;for(i=1;15>=i;i++)s[i]=f=f+r[i-1]<<1;for(o=0;n>=o;o++)c=e[2*o+1],0!==c&&(e[2*o]=t(s[c]++,c))})(s,e.me,r.Se)}}function Ie(e,t,n,r,s){const i=this;i.fe=e,i.ge=t,i.ke=n,i.le=r,i.ve=s}Ce.ze=[0,1,2,3,4,5,6,7].concat(...Se([[2,8],[2,9],[2,10],[2,11],[4,12],[4,13],[4,14],[4,15],[8,16],[8,17],[8,18],[8,19],[16,20],[16,21],[16,22],[16,23],[32,24],[32,25],[32,26],[31,27],[1,28]])),Ce._e=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,0],Ce.Ce=[0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576],Ce.Ie=e=>256>e?_e[e]:_e[256+(e>>>7)],Ce.xe=[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],Ce.Ae=[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],Ce.De=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Ce.Ve=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];const xe=Se([[144,8],[112,9],[24,7],[8,8]]);Ie.Re=ze([12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,19,275,147,403,83,339,211,467,51,307,179,435,115,371,243,499,11,267,139,395,75,331,203,459,43,299,171,427,107,363,235,491,27,283,155,411,91,347,219,475,59,315,187,443,123,379,251,507,7,263,135,391,71,327,199,455,39,295,167,423,103,359,231,487,23,279,151,407,87,343,215,471,55,311,183,439,119,375,247,503,15,271,143,399,79,335,207,463,47,303,175,431,111,367,239,495,31,287,159,415,95,351,223,479,63,319,191,447,127,383,255,511,0,64,32,96,16,80,48,112,8,72,40,104,24,88,56,120,4,68,36,100,20,84,52,116,3,131,67,195,35,163,99,227].map(((e,t)=>[e,xe[t]])));const Ae=Se([[30,5]]);function De(e,t,n,r,s){const i=this;i.Be=e,i.Ee=t,i.Me=n,i.Ke=r,i.Ne=s}Ie.Pe=ze([0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30,1,17,9,25,5,21,13,29,3,19,11,27,7,23].map(((e,t)=>[e,Ae[t]]))),Ie.Ue=new Ie(Ie.Re,Ce.xe,257,286,15),Ie.Te=new Ie(Ie.Pe,Ce.Ae,0,30,15),Ie.We=new Ie(null,Ce.De,0,19,7);const Ve=[new De(0,0,0,0,0),new De(4,4,8,4,1),new De(4,5,16,8,1),new De(4,6,32,32,1),new De(4,4,16,16,2),new De(8,16,32,32,2),new De(8,16,128,128,2),new De(8,32,128,256,2),new De(32,128,258,1024,2),new De(32,258,258,4096,2)],Re=["need dictionary","stream end","","","stream error","data error","","buffer error","",""];function Be(e,t,n,r){const s=e[2*t],i=e[2*n];return i>s||s==i&&r[t]<=r[n]}function Ee(){const e=this;let t,r,o,c,f,a,l,u,w,h,d,p,y,m,b,g,k,v,S,z,_,C,I,x,A,D,V,R,B,E,M,K,N;const P=new Ce,U=new Ce,T=new Ce;let W,H,L,j,F,O;function q(){let t;for(t=0;286>t;t++)M[2*t]=0;for(t=0;30>t;t++)K[2*t]=0;for(t=0;19>t;t++)N[2*t]=0;M[512]=1,e.pe=e.ye=0,H=L=0}function G(e,t){let n,r=-1,s=e[1],i=0,o=7,c=4;0===s&&(o=138,c=3),e[2*(t+1)+1]=65535;for(let f=0;t>=f;f++)n=s,s=e[2*(f+1)+1],++i<o&&n==s||(c>i?N[2*n]+=i:0!==n?(n!=r&&N[2*n]++,N[32]++):i>10?N[36]++:N[34]++,i=0,r=n,0===s?(o=138,c=3):n==s?(o=6,c=3):(o=7,c=4))}function J(t){e.He[e.pending++]=t}function Q(e){J(255&e),J(e>>>8&255)}function X(e,t){let n;const r=t;O>16-r?(n=e,F|=n<<O&65535,Q(F),F=n>>>16-O,O+=r-16):(F|=e<<O&65535,O+=r)}function Y(e,t){const n=2*e;X(65535&t[n],65535&t[n+1])}function Z(e,t){let n,r,s=-1,i=e[1],o=0,c=7,f=4;for(0===i&&(c=138,f=3),n=0;t>=n;n++)if(r=i,i=e[2*(n+1)+1],++o>=c||r!=i){if(f>o)do{Y(r,N)}while(0!=--o);else 0!==r?(r!=s&&(Y(r,N),o--),Y(16,N),X(o-3,2)):o>10?(Y(18,N),X(o-11,7)):(Y(17,N),X(o-3,3));o=0,s=r,0===i?(c=138,f=3):r==i?(c=6,f=3):(c=7,f=4)}}function $(){16==O?(Q(F),F=0,O=0):8>O||(J(255&F),F>>>=8,O-=8)}function ee(t,r){let s,i,o;if(e.Le[H]=t,e.je[H]=255&r,H++,0===t?M[2*r]++:(L++,t--,M[2*(Ce.ze[r]+256+1)]++,K[2*Ce.Ie(t)]++),0==(8191&H)&&V>2){for(s=8*H,i=_-k,o=0;30>o;o++)s+=K[2*o]*(5+Ce.Ae[o]);if(s>>>=3,L<n.floor(H/2)&&s<n.floor(i/2))return!0}return H==W-1}function te(t,n){let r,s,i,o,c=0;if(0!==H)do{r=e.Le[c],s=e.je[c],c++,0===r?Y(s,t):(i=Ce.ze[s],Y(i+256+1,t),o=Ce.xe[i],0!==o&&(s-=Ce._e[i],X(s,o)),r--,i=Ce.Ie(r),Y(i,n),o=Ce.Ae[i],0!==o&&(r-=Ce.Ce[i],X(r,o)))}while(H>c);Y(256,t),j=t[513]}function ne(){O>8?Q(F):O>0&&J(255&F),F=0,O=0}function re(t,n,r){X(0+(r?1:0),3),((t,n)=>{ne(),j=8,Q(n),Q(~n),e.He.set(u.subarray(t,t+n),e.pending),e.pending+=n})(t,n)}function se(n){((t,n,r)=>{let s,i,o=0;V>0?(P.oe(e),U.oe(e),o=(()=>{let t;for(G(M,P.me),G(K,U.me),T.oe(e),t=18;t>=3&&0===N[2*Ce.Ve[t]+1];t--);return e.pe+=14+3*(t+1),t})(),s=e.pe+3+7>>>3,i=e.ye+3+7>>>3,i>s||(s=i)):s=i=n+5,n+4>s||-1==t?i==s?(X(2+(r?1:0),3),te(Ie.Re,Ie.Pe)):(X(4+(r?1:0),3),((e,t,n)=>{let r;for(X(e-257,5),X(t-1,5),X(n-4,4),r=0;n>r;r++)X(N[2*Ce.Ve[r]+1],3);Z(M,e-1),Z(K,t-1)})(P.me+1,U.me+1,o+1),te(M,K)):re(t,n,r),q(),r&&ne()})(0>k?-1:k,_-k,n),k=_,t.Fe()}function ie(){let e,n,r,s;do{if(s=w-I-_,0===s&&0===_&&0===I)s=f;else if(-1==s)s--;else if(_>=f+f-262){u.set(u.subarray(f,f+f),0),C-=f,_-=f,k-=f,e=y,r=e;do{n=65535&d[--r],d[r]=f>n?0:n-f}while(0!=--e);e=f,r=e;do{n=65535&h[--r],h[r]=f>n?0:n-f}while(0!=--e);s+=f}if(0===t.Oe)return;e=t.qe(u,_+I,s),I+=e,3>I||(p=255&u[_],p=(p<<g^255&u[_+1])&b)}while(262>I&&0!==t.Oe)}function oe(e){let t,n,r=A,s=_,i=x;const o=_>f-262?_-(f-262):0;let c=E;const a=l,w=_+258;let d=u[s+i-1],p=u[s+i];B>x||(r>>=2),c>I&&(c=I);do{if(t=e,u[t+i]==p&&u[t+i-1]==d&&u[t]==u[s]&&u[++t]==u[s+1]){s+=2,t++;do{}while(u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&w>s);if(n=258-(w-s),s=w-258,n>i){if(C=e,i=n,n>=c)break;d=u[s+i-1],p=u[s+i]}}}while((e=65535&h[e&a])>o&&0!=--r);return i>I?I:i}e.de=[],e.Se=[],e.he=[],M=[],K=[],N=[],e.be=(t,n)=>{const r=e.he,s=r[n];let i=n<<1;for(;i<=e.ue&&(i<e.ue&&Be(t,r[i+1],r[i],e.de)&&i++,!Be(t,s,r[i],e.de));)r[n]=r[i],n=i,i<<=1;r[n]=s},e.Ge=(t,S,C,H,L,G)=>(H||(H=8),L||(L=8),G||(G=0),t.Je=null,-1==S&&(S=6),1>L||L>9||8!=H||9>C||C>15||0>S||S>9||0>G||G>2?-2:(t.Qe=e,a=C,f=1<<a,l=f-1,m=L+7,y=1<<m,b=y-1,g=n.floor((m+3-1)/3),u=new s(2*f),h=[],d=[],W=1<<L+6,e.He=new s(4*W),o=4*W,e.Le=new i(W),e.je=new s(W),V=S,R=G,(t=>(t.Xe=t.Ye=0,t.Je=null,e.pending=0,e.Ze=0,r=113,c=0,P.ce=M,P.ae=Ie.Ue,U.ce=K,U.ae=Ie.Te,T.ce=N,T.ae=Ie.We,F=0,O=0,j=8,q(),(()=>{w=2*f,d[y-1]=0;for(let e=0;y-1>e;e++)d[e]=0;D=Ve[V].Ee,B=Ve[V].Be,E=Ve[V].Me,A=Ve[V].Ke,_=0,k=0,I=0,v=x=2,z=0,p=0})(),0))(t))),e.$e=()=>42!=r&&113!=r&&666!=r?-2:(e.je=null,e.Le=null,e.He=null,d=null,h=null,u=null,e.Qe=null,113==r?-3:0),e.et=(e,t,n)=>{let r=0;return-1==t&&(t=6),0>t||t>9||0>n||n>2?-2:(Ve[V].Ne!=Ve[t].Ne&&0!==e.Xe&&(r=e.tt(1)),V!=t&&(V=t,D=Ve[V].Ee,B=Ve[V].Be,E=Ve[V].Me,A=Ve[V].Ke),R=n,r)},e.nt=(e,t,n)=>{let s,i=n,o=0;if(!t||42!=r)return-2;if(3>i)return 0;for(i>f-262&&(i=f-262,o=n-i),u.set(t.subarray(o,o+i),0),_=i,k=i,p=255&u[0],p=(p<<g^255&u[1])&b,s=0;i-3>=s;s++)p=(p<<g^255&u[s+2])&b,h[s&l]=d[p],d[p]=s;return 0},e.tt=(n,s)=>{let i,w,m,A,B;if(s>4||0>s)return-2;if(!n.rt||!n.st&&0!==n.Oe||666==r&&4!=s)return n.Je=Re[4],-2;if(0===n.it)return n.Je=Re[7],-5;var E;if(t=n,A=c,c=s,42==r&&(w=8+(a-8<<4)<<8,m=(V-1&255)>>1,m>3&&(m=3),w|=m<<6,0!==_&&(w|=32),w+=31-w%31,r=113,J((E=w)>>8&255),J(255&E)),0!==e.pending){if(t.Fe(),0===t.it)return c=-1,0}else if(0===t.Oe&&A>=s&&4!=s)return t.Je=Re[7],-5;if(666==r&&0!==t.Oe)return n.Je=Re[7],-5;if(0!==t.Oe||0!==I||0!=s&&666!=r){switch(B=-1,Ve[V].Ne){case 0:B=(e=>{let n,r=65535;for(r>o-5&&(r=o-5);;){if(1>=I){if(ie(),0===I&&0==e)return 0;if(0===I)break}if(_+=I,I=0,n=k+r,(0===_||_>=n)&&(I=_-n,_=n,se(!1),0===t.it))return 0;if(_-k>=f-262&&(se(!1),0===t.it))return 0}return se(4==e),0===t.it?4==e?2:0:4==e?3:1})(s);break;case 1:B=(e=>{let n,r=0;for(;;){if(262>I){if(ie(),262>I&&0==e)return 0;if(0===I)break}if(3>I||(p=(p<<g^255&u[_+2])&b,r=65535&d[p],h[_&l]=d[p],d[p]=_),0===r||(_-r&65535)>f-262||2!=R&&(v=oe(r)),3>v)n=ee(0,255&u[_]),I--,_++;else if(n=ee(_-C,v-3),I-=v,v>D||3>I)_+=v,v=0,p=255&u[_],p=(p<<g^255&u[_+1])&b;else{v--;do{_++,p=(p<<g^255&u[_+2])&b,r=65535&d[p],h[_&l]=d[p],d[p]=_}while(0!=--v);_++}if(n&&(se(!1),0===t.it))return 0}return se(4==e),0===t.it?4==e?2:0:4==e?3:1})(s);break;case 2:B=(e=>{let n,r,s=0;for(;;){if(262>I){if(ie(),262>I&&0==e)return 0;if(0===I)break}if(3>I||(p=(p<<g^255&u[_+2])&b,s=65535&d[p],h[_&l]=d[p],d[p]=_),x=v,S=C,v=2,0!==s&&D>x&&f-262>=(_-s&65535)&&(2!=R&&(v=oe(s)),5>=v&&(1==R||3==v&&_-C>4096)&&(v=2)),3>x||v>x)if(0!==z){if(n=ee(0,255&u[_-1]),n&&se(!1),_++,I--,0===t.it)return 0}else z=1,_++,I--;else{r=_+I-3,n=ee(_-1-S,x-3),I-=x-1,x-=2;do{++_>r||(p=(p<<g^255&u[_+2])&b,s=65535&d[p],h[_&l]=d[p],d[p]=_)}while(0!=--x);if(z=0,v=2,_++,n&&(se(!1),0===t.it))return 0}}return 0!==z&&(n=ee(0,255&u[_-1]),z=0),se(4==e),0===t.it?4==e?2:0:4==e?3:1})(s)}if(2!=B&&3!=B||(r=666),0==B||2==B)return 0===t.it&&(c=-1),0;if(1==B){if(1==s)X(2,3),Y(256,Ie.Re),$(),9>1+j+10-O&&(X(2,3),Y(256,Ie.Re),$()),j=7;else if(re(0,0,!1),3==s)for(i=0;y>i;i++)d[i]=0;if(t.Fe(),0===t.it)return c=-1,0}}return 4!=s?0:1}}function Me(){const e=this;e.ot=0,e.ct=0,e.Oe=0,e.Xe=0,e.it=0,e.Ye=0}function Ke(e){const t=new Me,i=(o=e&&e.chunkSize?e.chunkSize:65536)+5*(n.floor(o/16383)+1);var o;const c=new s(i);let f=e?e.level:-1;void 0===f&&(f=-1),t.Ge(f),t.rt=c,this.append=(e,n)=>{let o,f,a=0,l=0,u=0;const w=[];if(e.length){t.ot=0,t.st=e,t.Oe=e.length;do{if(t.ct=0,t.it=i,o=t.tt(0),0!=o)throw new r("deflating: "+t.Je);t.ct&&(t.ct==i?w.push(new s(c)):w.push(c.slice(0,t.ct))),u+=t.ct,n&&t.ot>0&&t.ot!=a&&(n(t.ot),a=t.ot)}while(t.Oe>0||0===t.it);return w.length>1?(f=new s(u),w.forEach((e=>{f.set(e,l),l+=e.length}))):f=w[0]||new s,f}},this.flush=()=>{let e,n,o=0,f=0;const a=[];do{if(t.ct=0,t.it=i,e=t.tt(4),1!=e&&0!=e)throw new r("deflating: "+t.Je);i-t.it>0&&a.push(c.slice(0,t.ct)),f+=t.ct}while(t.Oe>0||0===t.it);return t.$e(),n=new s(f),a.forEach((e=>{n.set(e,o),o+=e.length})),n}}Me.prototype={Ge(e,t){const n=this;return n.Qe=new Ee,t||(t=15),n.Qe.Ge(n,e,t)},tt(e){const t=this;return t.Qe?t.Qe.tt(t,e):-2},$e(){const e=this;if(!e.Qe)return-2;const t=e.Qe.$e();return e.Qe=null,t},et(e,t){const n=this;return n.Qe?n.Qe.et(n,e,t):-2},nt(e,t){const n=this;return n.Qe?n.Qe.nt(n,e,t):-2},qe(e,t,n){const r=this;let s=r.Oe;return s>n&&(s=n),0===s?0:(r.Oe-=s,e.set(r.st.subarray(r.ot,r.ot+s),t),r.ot+=s,r.Xe+=s,s)},Fe(){const e=this;let t=e.Qe.pending;t>e.it&&(t=e.it),0!==t&&(e.rt.set(e.Qe.He.subarray(e.Qe.Ze,e.Qe.Ze+t),e.ct),e.ct+=t,e.Qe.Ze+=t,e.Ye+=t,e.it-=t,e.Qe.pending-=t,0===e.Qe.pending&&(e.Qe.Ze=0))}};const Ne=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],Pe=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],Ue=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],Te=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],We=[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,112,112],He=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],Le=[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];function je(){let e,t,n,r,s,i;function o(e,t,o,c,f,a,l,u,w,h,d){let p,y,m,b,g,k,v,S,z,_,C,I,x,A,D;_=0,g=o;do{n[e[t+_]]++,_++,g--}while(0!==g);if(n[0]==o)return l[0]=-1,u[0]=0,0;for(S=u[0],k=1;15>=k&&0===n[k];k++);for(v=k,k>S&&(S=k),g=15;0!==g&&0===n[g];g--);for(m=g,S>g&&(S=g),u[0]=S,A=1<<k;g>k;k++,A<<=1)if(0>(A-=n[k]))return-3;if(0>(A-=n[g]))return-3;for(n[g]+=A,i[1]=k=0,_=1,x=2;0!=--g;)i[x]=k+=n[_],x++,_++;g=0,_=0;do{0!==(k=e[t+_])&&(d[i[k]++]=g),_++}while(++g<o);for(o=i[m],i[0]=g=0,_=0,b=-1,I=-S,s[0]=0,C=0,D=0;m>=v;v++)for(p=n[v];0!=p--;){for(;v>I+S;){if(b++,I+=S,D=m-I,D=D>S?S:D,(y=1<<(k=v-I))>p+1&&(y-=p+1,x=v,D>k))for(;++k<D&&(y<<=1)>n[++x];)y-=n[x];if(D=1<<k,h[0]+D>1440)return-3;s[b]=C=h[0],h[0]+=D,0!==b?(i[b]=g,r[0]=k,r[1]=S,k=g>>>I-S,r[2]=C-s[b-1]-k,w.set(r,3*(s[b-1]+k))):l[0]=C}for(r[1]=v-I,o>_?d[_]<c?(r[0]=256>d[_]?0:96,r[2]=d[_++]):(r[0]=a[d[_]-c]+16+64,r[2]=f[d[_++]-c]):r[0]=192,y=1<<v-I,k=g>>>I;D>k;k+=y)w.set(r,3*(C+k));for(k=1<<v-1;0!=(g&k);k>>>=1)g^=k;for(g^=k,z=(1<<I)-1;(g&z)!=i[b];)b--,I-=S,z=(1<<I)-1}return 0!==A&&1!=m?-5:0}function f(o){let f;for(e||(e=[],t=[],n=new c(16),r=[],s=new c(15),i=new c(16)),t.length<o&&(t=[]),f=0;o>f;f++)t[f]=0;for(f=0;16>f;f++)n[f]=0;for(f=0;3>f;f++)r[f]=0;s.set(n.subarray(0,15),0),i.set(n.subarray(0,16),0)}this.ft=(n,r,s,i,c)=>{let a;return f(19),e[0]=0,a=o(n,0,19,19,null,null,s,r,i,e,t),-3==a?c.Je="oversubscribed dynamic bit lengths tree":-5!=a&&0!==r[0]||(c.Je="incomplete dynamic bit lengths tree",a=-3),a},this.lt=(n,r,s,i,c,a,l,u,w)=>{let h;return f(288),e[0]=0,h=o(s,0,n,257,Te,We,a,i,u,e,t),0!=h||0===i[0]?(-3==h?w.Je="oversubscribed literal/length tree":-4!=h&&(w.Je="incomplete literal/length tree",h=-3),h):(f(288),h=o(s,n,r,0,He,Le,l,c,u,e,t),0!=h||0===c[0]&&n>257?(-3==h?w.Je="oversubscribed distance tree":-5==h?(w.Je="incomplete distance tree",h=-3):-4!=h&&(w.Je="empty distance tree with lengths",h=-3),h):0)}}function Fe(){const e=this;let t,n,r,s,i=0,o=0,c=0,f=0,a=0,l=0,u=0,w=0,h=0,d=0;function p(e,t,n,r,s,i,o,c){let f,a,l,u,w,h,d,p,y,m,b,g,k,v,S,z;d=c.ot,p=c.Oe,w=o.ut,h=o.wt,y=o.write,m=y<o.read?o.read-y-1:o.end-y,b=Ne[e],g=Ne[t];do{for(;20>h;)p--,w|=(255&c.ht(d++))<<h,h+=8;if(f=w&b,a=n,l=r,z=3*(l+f),0!==(u=a[z]))for(;;){if(w>>=a[z+1],h-=a[z+1],0!=(16&u)){for(u&=15,k=a[z+2]+(w&Ne[u]),w>>=u,h-=u;15>h;)p--,w|=(255&c.ht(d++))<<h,h+=8;for(f=w&g,a=s,l=i,z=3*(l+f),u=a[z];;){if(w>>=a[z+1],h-=a[z+1],0!=(16&u)){for(u&=15;u>h;)p--,w|=(255&c.ht(d++))<<h,h+=8;if(v=a[z+2]+(w&Ne[u]),w>>=u,h-=u,m-=k,v>y){S=y-v;do{S+=o.end}while(0>S);if(u=o.end-S,k>u){if(k-=u,y-S>0&&u>y-S)do{o.dt[y++]=o.dt[S++]}while(0!=--u);else o.dt.set(o.dt.subarray(S,S+u),y),y+=u,S+=u,u=0;S=0}}else S=y-v,y-S>0&&2>y-S?(o.dt[y++]=o.dt[S++],o.dt[y++]=o.dt[S++],k-=2):(o.dt.set(o.dt.subarray(S,S+2),y),y+=2,S+=2,k-=2);if(y-S>0&&k>y-S)do{o.dt[y++]=o.dt[S++]}while(0!=--k);else o.dt.set(o.dt.subarray(S,S+k),y),y+=k,S+=k,k=0;break}if(0!=(64&u))return c.Je="invalid distance code",k=c.Oe-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ut=w,o.wt=h,c.Oe=p,c.Xe+=d-c.ot,c.ot=d,o.write=y,-3;f+=a[z+2],f+=w&Ne[u],z=3*(l+f),u=a[z]}break}if(0!=(64&u))return 0!=(32&u)?(k=c.Oe-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ut=w,o.wt=h,c.Oe=p,c.Xe+=d-c.ot,c.ot=d,o.write=y,1):(c.Je="invalid literal/length code",k=c.Oe-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ut=w,o.wt=h,c.Oe=p,c.Xe+=d-c.ot,c.ot=d,o.write=y,-3);if(f+=a[z+2],f+=w&Ne[u],z=3*(l+f),0===(u=a[z])){w>>=a[z+1],h-=a[z+1],o.dt[y++]=a[z+2],m--;break}}else w>>=a[z+1],h-=a[z+1],o.dt[y++]=a[z+2],m--}while(m>=258&&p>=10);return k=c.Oe-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ut=w,o.wt=h,c.Oe=p,c.Xe+=d-c.ot,c.ot=d,o.write=y,0}e.init=(e,i,o,c,f,a)=>{t=0,u=e,w=i,r=o,h=c,s=f,d=a,n=null},e.yt=(e,y,m)=>{let b,g,k,v,S,z,_,C=0,I=0,x=0;for(x=y.ot,v=y.Oe,C=e.ut,I=e.wt,S=e.write,z=S<e.read?e.read-S-1:e.end-S;;)switch(t){case 0:if(z>=258&&v>=10&&(e.ut=C,e.wt=I,y.Oe=v,y.Xe+=x-y.ot,y.ot=x,e.write=S,m=p(u,w,r,h,s,d,e,y),x=y.ot,v=y.Oe,C=e.ut,I=e.wt,S=e.write,z=S<e.read?e.read-S-1:e.end-S,0!=m)){t=1==m?7:9;break}c=u,n=r,o=h,t=1;case 1:for(b=c;b>I;){if(0===v)return e.ut=C,e.wt=I,y.Oe=v,y.Xe+=x-y.ot,y.ot=x,e.write=S,e.bt(y,m);m=0,v--,C|=(255&y.ht(x++))<<I,I+=8}if(g=3*(o+(C&Ne[b])),C>>>=n[g+1],I-=n[g+1],k=n[g],0===k){f=n[g+2],t=6;break}if(0!=(16&k)){a=15&k,i=n[g+2],t=2;break}if(0==(64&k)){c=k,o=g/3+n[g+2];break}if(0!=(32&k)){t=7;break}return t=9,y.Je="invalid literal/length code",m=-3,e.ut=C,e.wt=I,y.Oe=v,y.Xe+=x-y.ot,y.ot=x,e.write=S,e.bt(y,m);case 2:for(b=a;b>I;){if(0===v)return e.ut=C,e.wt=I,y.Oe=v,y.Xe+=x-y.ot,y.ot=x,e.write=S,e.bt(y,m);m=0,v--,C|=(255&y.ht(x++))<<I,I+=8}i+=C&Ne[b],C>>=b,I-=b,c=w,n=s,o=d,t=3;case 3:for(b=c;b>I;){if(0===v)return e.ut=C,e.wt=I,y.Oe=v,y.Xe+=x-y.ot,y.ot=x,e.write=S,e.bt(y,m);m=0,v--,C|=(255&y.ht(x++))<<I,I+=8}if(g=3*(o+(C&Ne[b])),C>>=n[g+1],I-=n[g+1],k=n[g],0!=(16&k)){a=15&k,l=n[g+2],t=4;break}if(0==(64&k)){c=k,o=g/3+n[g+2];break}return t=9,y.Je="invalid distance code",m=-3,e.ut=C,e.wt=I,y.Oe=v,y.Xe+=x-y.ot,y.ot=x,e.write=S,e.bt(y,m);case 4:for(b=a;b>I;){if(0===v)return e.ut=C,e.wt=I,y.Oe=v,y.Xe+=x-y.ot,y.ot=x,e.write=S,e.bt(y,m);m=0,v--,C|=(255&y.ht(x++))<<I,I+=8}l+=C&Ne[b],C>>=b,I-=b,t=5;case 5:for(_=S-l;0>_;)_+=e.end;for(;0!==i;){if(0===z&&(S==e.end&&0!==e.read&&(S=0,z=S<e.read?e.read-S-1:e.end-S),0===z&&(e.write=S,m=e.bt(y,m),S=e.write,z=S<e.read?e.read-S-1:e.end-S,S==e.end&&0!==e.read&&(S=0,z=S<e.read?e.read-S-1:e.end-S),0===z)))return e.ut=C,e.wt=I,y.Oe=v,y.Xe+=x-y.ot,y.ot=x,e.write=S,e.bt(y,m);e.dt[S++]=e.dt[_++],z--,_==e.end&&(_=0),i--}t=0;break;case 6:if(0===z&&(S==e.end&&0!==e.read&&(S=0,z=S<e.read?e.read-S-1:e.end-S),0===z&&(e.write=S,m=e.bt(y,m),S=e.write,z=S<e.read?e.read-S-1:e.end-S,S==e.end&&0!==e.read&&(S=0,z=S<e.read?e.read-S-1:e.end-S),0===z)))return e.ut=C,e.wt=I,y.Oe=v,y.Xe+=x-y.ot,y.ot=x,e.write=S,e.bt(y,m);m=0,e.dt[S++]=f,z--,t=0;break;case 7:if(I>7&&(I-=8,v++,x--),e.write=S,m=e.bt(y,m),S=e.write,z=S<e.read?e.read-S-1:e.end-S,e.read!=e.write)return e.ut=C,e.wt=I,y.Oe=v,y.Xe+=x-y.ot,y.ot=x,e.write=S,e.bt(y,m);t=8;case 8:return m=1,e.ut=C,e.wt=I,y.Oe=v,y.Xe+=x-y.ot,y.ot=x,e.write=S,e.bt(y,m);case 9:return m=-3,e.ut=C,e.wt=I,y.Oe=v,y.Xe+=x-y.ot,y.ot=x,e.write=S,e.bt(y,m);default:return m=-2,e.ut=C,e.wt=I,y.Oe=v,y.Xe+=x-y.ot,y.ot=x,e.write=S,e.bt(y,m)}},e.gt=()=>{}}je.kt=(e,t,n,r)=>(e[0]=9,t[0]=5,n[0]=Pe,r[0]=Ue,0);const Oe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function qe(e,t){const n=this;let r,i=0,o=0,f=0,a=0;const l=[0],u=[0],w=new Fe;let h=0,d=new c(4320);const p=new je;n.wt=0,n.ut=0,n.dt=new s(t),n.end=t,n.read=0,n.write=0,n.reset=(e,t)=>{t&&(t[0]=0),6==i&&w.gt(e),i=0,n.wt=0,n.ut=0,n.read=n.write=0},n.reset(e,null),n.bt=(e,t)=>{let r,s,i;return s=e.ct,i=n.read,r=(i>n.write?n.end:n.write)-i,r>e.it&&(r=e.it),0!==r&&-5==t&&(t=0),e.it-=r,e.Ye+=r,e.rt.set(n.dt.subarray(i,i+r),s),s+=r,i+=r,i==n.end&&(i=0,n.write==n.end&&(n.write=0),r=n.write-i,r>e.it&&(r=e.it),0!==r&&-5==t&&(t=0),e.it-=r,e.Ye+=r,e.rt.set(n.dt.subarray(i,i+r),s),s+=r,i+=r),e.ct=s,n.read=i,t},n.yt=(e,t)=>{let s,c,y,m,b,g,k,v;for(m=e.ot,b=e.Oe,c=n.ut,y=n.wt,g=n.write,k=g<n.read?n.read-g-1:n.end-g;;){let S,z,_,C,I,x,A,D;switch(i){case 0:for(;3>y;){if(0===b)return n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);t=0,b--,c|=(255&e.ht(m++))<<y,y+=8}switch(s=7&c,h=1&s,s>>>1){case 0:c>>>=3,y-=3,s=7&y,c>>>=s,y-=s,i=1;break;case 1:S=[],z=[],_=[[]],C=[[]],je.kt(S,z,_,C),w.init(S[0],z[0],_[0],0,C[0],0),c>>>=3,y-=3,i=6;break;case 2:c>>>=3,y-=3,i=3;break;case 3:return c>>>=3,y-=3,i=9,e.Je="invalid block type",t=-3,n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t)}break;case 1:for(;32>y;){if(0===b)return n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);t=0,b--,c|=(255&e.ht(m++))<<y,y+=8}if((~c>>>16&65535)!=(65535&c))return i=9,e.Je="invalid stored block lengths",t=-3,n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);o=65535&c,c=y=0,i=0!==o?2:0!==h?7:0;break;case 2:if(0===b)return n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);if(0===k&&(g==n.end&&0!==n.read&&(g=0,k=g<n.read?n.read-g-1:n.end-g),0===k&&(n.write=g,t=n.bt(e,t),g=n.write,k=g<n.read?n.read-g-1:n.end-g,g==n.end&&0!==n.read&&(g=0,k=g<n.read?n.read-g-1:n.end-g),0===k)))return n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);if(t=0,s=o,s>b&&(s=b),s>k&&(s=k),n.dt.set(e.qe(m,s),g),m+=s,b-=s,g+=s,k-=s,0!=(o-=s))break;i=0!==h?7:0;break;case 3:for(;14>y;){if(0===b)return n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);t=0,b--,c|=(255&e.ht(m++))<<y,y+=8}if(f=s=16383&c,(31&s)>29||(s>>5&31)>29)return i=9,e.Je="too many length or distance symbols",t=-3,n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);if(s=258+(31&s)+(s>>5&31),!r||r.length<s)r=[];else for(v=0;s>v;v++)r[v]=0;c>>>=14,y-=14,a=0,i=4;case 4:for(;4+(f>>>10)>a;){for(;3>y;){if(0===b)return n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);t=0,b--,c|=(255&e.ht(m++))<<y,y+=8}r[Oe[a++]]=7&c,c>>>=3,y-=3}for(;19>a;)r[Oe[a++]]=0;if(l[0]=7,s=p.ft(r,l,u,d,e),0!=s)return-3==(t=s)&&(r=null,i=9),n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);a=0,i=5;case 5:for(;s=f,258+(31&s)+(s>>5&31)>a;){let o,w;for(s=l[0];s>y;){if(0===b)return n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);t=0,b--,c|=(255&e.ht(m++))<<y,y+=8}if(s=d[3*(u[0]+(c&Ne[s]))+1],w=d[3*(u[0]+(c&Ne[s]))+2],16>w)c>>>=s,y-=s,r[a++]=w;else{for(v=18==w?7:w-14,o=18==w?11:3;s+v>y;){if(0===b)return n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);t=0,b--,c|=(255&e.ht(m++))<<y,y+=8}if(c>>>=s,y-=s,o+=c&Ne[v],c>>>=v,y-=v,v=a,s=f,v+o>258+(31&s)+(s>>5&31)||16==w&&1>v)return r=null,i=9,e.Je="invalid bit length repeat",t=-3,n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);w=16==w?r[v-1]:0;do{r[v++]=w}while(0!=--o);a=v}}if(u[0]=-1,I=[],x=[],A=[],D=[],I[0]=9,x[0]=6,s=f,s=p.lt(257+(31&s),1+(s>>5&31),r,I,x,A,D,d,e),0!=s)return-3==s&&(r=null,i=9),t=s,n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);w.init(I[0],x[0],d,A[0],d,D[0]),i=6;case 6:if(n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,1!=(t=w.yt(n,e,t)))return n.bt(e,t);if(t=0,w.gt(e),m=e.ot,b=e.Oe,c=n.ut,y=n.wt,g=n.write,k=g<n.read?n.read-g-1:n.end-g,0===h){i=0;break}i=7;case 7:if(n.write=g,t=n.bt(e,t),g=n.write,k=g<n.read?n.read-g-1:n.end-g,n.read!=n.write)return n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);i=8;case 8:return t=1,n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);case 9:return t=-3,n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t);default:return t=-2,n.ut=c,n.wt=y,e.Oe=b,e.Xe+=m-e.ot,e.ot=m,n.write=g,n.bt(e,t)}}},n.gt=e=>{n.reset(e,null),n.dt=null,d=null},n.vt=(e,t,r)=>{n.dt.set(e.subarray(t,t+r),0),n.read=n.write=r},n.St=()=>1==i?1:0}const Ge=[0,0,255,255];function Je(){const e=this;function t(e){return e&&e.zt?(e.Xe=e.Ye=0,e.Je=null,e.zt.mode=7,e.zt._t.reset(e,null),0):-2}e.mode=0,e.method=0,e.Ct=[0],e.It=0,e.marker=0,e.xt=0,e.At=t=>(e._t&&e._t.gt(t),e._t=null,0),e.Dt=(n,r)=>(n.Je=null,e._t=null,8>r||r>15?(e.At(n),-2):(e.xt=r,n.zt._t=new qe(n,1<<r),t(n),0)),e.Vt=(e,t)=>{let n,r;if(!e||!e.zt||!e.st)return-2;const s=e.zt;for(t=4==t?-5:0,n=-5;;)switch(s.mode){case 0:if(0===e.Oe)return n;if(n=t,e.Oe--,e.Xe++,8!=(15&(s.method=e.ht(e.ot++)))){s.mode=13,e.Je="unknown compression method",s.marker=5;break}if(8+(s.method>>4)>s.xt){s.mode=13,e.Je="invalid win size",s.marker=5;break}s.mode=1;case 1:if(0===e.Oe)return n;if(n=t,e.Oe--,e.Xe++,r=255&e.ht(e.ot++),((s.method<<8)+r)%31!=0){s.mode=13,e.Je="incorrect header check",s.marker=5;break}if(0==(32&r)){s.mode=7;break}s.mode=2;case 2:if(0===e.Oe)return n;n=t,e.Oe--,e.Xe++,s.It=(255&e.ht(e.ot++))<<24&4278190080,s.mode=3;case 3:if(0===e.Oe)return n;n=t,e.Oe--,e.Xe++,s.It+=(255&e.ht(e.ot++))<<16&16711680,s.mode=4;case 4:if(0===e.Oe)return n;n=t,e.Oe--,e.Xe++,s.It+=(255&e.ht(e.ot++))<<8&65280,s.mode=5;case 5:return 0===e.Oe?n:(n=t,e.Oe--,e.Xe++,s.It+=255&e.ht(e.ot++),s.mode=6,2);case 6:return s.mode=13,e.Je="need dictionary",s.marker=0,-2;case 7:if(n=s._t.yt(e,n),-3==n){s.mode=13,s.marker=0;break}if(0==n&&(n=t),1!=n)return n;n=t,s._t.reset(e,s.Ct),s.mode=12;case 12:return e.Oe=0,1;case 13:return-3;default:return-2}},e.Rt=(e,t,n)=>{let r=0,s=n;if(!e||!e.zt||6!=e.zt.mode)return-2;const i=e.zt;return s<1<<i.xt||(s=(1<<i.xt)-1,r=n-s),i._t.vt(t,r,s),i.mode=7,0},e.Bt=e=>{let n,r,s,i,o;if(!e||!e.zt)return-2;const c=e.zt;if(13!=c.mode&&(c.mode=13,c.marker=0),0===(n=e.Oe))return-5;for(r=e.ot,s=c.marker;0!==n&&4>s;)e.ht(r)==Ge[s]?s++:s=0!==e.ht(r)?0:4-s,r++,n--;return e.Xe+=r-e.ot,e.ot=r,e.Oe=n,c.marker=s,4!=s?-3:(i=e.Xe,o=e.Ye,t(e),e.Xe=i,e.Ye=o,c.mode=7,0)},e.Et=e=>e&&e.zt&&e.zt._t?e.zt._t.St():-2}function Qe(){}function Xe(e){const t=new Qe,i=e&&e.chunkSize?n.floor(2*e.chunkSize):131072,o=new s(i);let c=!1;t.Dt(),t.rt=o,this.append=(e,n)=>{const f=[];let a,l,u=0,w=0,h=0;if(0!==e.length){t.ot=0,t.st=e,t.Oe=e.length;do{if(t.ct=0,t.it=i,0!==t.Oe||c||(t.ot=0,c=!0),a=t.Vt(0),c&&-5===a){if(0!==t.Oe)throw new r("inflating: bad input")}else if(0!==a&&1!==a)throw new r("inflating: "+t.Je);if((c||1===a)&&t.Oe===e.length)throw new r("inflating: bad input");t.ct&&(t.ct===i?f.push(new s(o)):f.push(o.slice(0,t.ct))),h+=t.ct,n&&t.ot>0&&t.ot!=u&&(n(t.ot),u=t.ot)}while(t.Oe>0||0===t.it);return f.length>1?(l=new s(h),f.forEach((e=>{l.set(e,w),w+=e.length}))):l=f[0]||new s,l}},this.flush=()=>{t.At()}}Qe.prototype={Dt(e){const t=this;return t.zt=new Je,e||(e=15),t.zt.Dt(t,e)},Vt(e){const t=this;return t.zt?t.zt.Vt(t,e):-2},At(){const e=this;if(!e.zt)return-2;const t=e.zt.At(e);return e.zt=null,t},Bt(){const e=this;return e.zt?e.zt.Bt(e):-2},Rt(e,t){const n=this;return n.zt?n.zt.Rt(n,e,t):-2},ht(e){return this.st[e]},qe(e,t){return this.st.subarray(e,e+t)}},self.initCodec=()=>{self.Deflate=Ke,self.Inflate=Xe};\n'],{type:"text/javascript"}));e({workerScripts:{inflate:[t],deflate:[t]}});}
|
|
4382
4470
|
|
|
4383
4471
|
/*
|
|
4384
|
-
|
|
4385
|
-
* license or under the GNU GPL, version 2.0.
|
|
4386
|
-
*/
|
|
4472
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
4387
4473
|
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
* Crush to remove comments, shorten variable names and
|
|
4391
|
-
* generally reduce transmission size.
|
|
4392
|
-
*
|
|
4393
|
-
* @author Emily Stark
|
|
4394
|
-
* @author Mike Hamburg
|
|
4395
|
-
* @author Dan Boneh
|
|
4396
|
-
*/
|
|
4474
|
+
Redistribution and use in source and binary forms, with or without
|
|
4475
|
+
modification, are permitted provided that the following conditions are met:
|
|
4397
4476
|
|
|
4398
|
-
|
|
4477
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
4478
|
+
this list of conditions and the following disclaimer.
|
|
4399
4479
|
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
* @author Mike Hamburg
|
|
4404
|
-
* @author Dan Boneh
|
|
4405
|
-
*/
|
|
4480
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
4481
|
+
notice, this list of conditions and the following disclaimer in
|
|
4482
|
+
the documentation and/or other materials provided with the distribution.
|
|
4406
4483
|
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
* array of words, 32 bits at a time. Since the words are double-precision
|
|
4421
|
-
* floating point numbers, they fit some extra data. We use this (in a private,
|
|
4422
|
-
* possibly-changing manner) to encode the number of bits actually present
|
|
4423
|
-
* in the last word of the array.
|
|
4424
|
-
* </p>
|
|
4425
|
-
*
|
|
4426
|
-
* <p>
|
|
4427
|
-
* Because bitwise ops clear this out-of-band data, these arrays can be passed
|
|
4428
|
-
* to ciphers like AES which want arrays of words.
|
|
4429
|
-
* </p>
|
|
4484
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
4485
|
+
derived from this software without specific prior written permission.
|
|
4486
|
+
|
|
4487
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4488
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4489
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4490
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4491
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4492
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4493
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4494
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4495
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4496
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4430
4497
|
*/
|
|
4431
|
-
const bitArray = {
|
|
4432
|
-
/**
|
|
4433
|
-
* Concatenate two bit arrays.
|
|
4434
|
-
* @param {bitArray} a1 The first array.
|
|
4435
|
-
* @param {bitArray} a2 The second array.
|
|
4436
|
-
* @return {bitArray} The concatenation of a1 and a2.
|
|
4437
|
-
*/
|
|
4438
|
-
concat(a1, a2) {
|
|
4439
|
-
if (a1.length === 0 || a2.length === 0) {
|
|
4440
|
-
return a1.concat(a2);
|
|
4441
|
-
}
|
|
4442
4498
|
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
} else {
|
|
4447
|
-
return bitArray._shiftRight(a2, shift, last | 0, a1.slice(0, a1.length - 1));
|
|
4448
|
-
}
|
|
4449
|
-
},
|
|
4499
|
+
function getMimeType() {
|
|
4500
|
+
return "application/octet-stream";
|
|
4501
|
+
}
|
|
4450
4502
|
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4503
|
+
function initShimAsyncCodec(library, options = {}, registerDataHandler) {
|
|
4504
|
+
return {
|
|
4505
|
+
Deflate: createCodecClass(library.Deflate, options.deflate, registerDataHandler),
|
|
4506
|
+
Inflate: createCodecClass(library.Inflate, options.inflate, registerDataHandler)
|
|
4507
|
+
};
|
|
4508
|
+
}
|
|
4509
|
+
|
|
4510
|
+
function createCodecClass(constructor, constructorOptions, registerDataHandler) {
|
|
4511
|
+
return class {
|
|
4512
|
+
|
|
4513
|
+
constructor(options) {
|
|
4514
|
+
const codecAdapter = this;
|
|
4515
|
+
const onData = data => {
|
|
4516
|
+
if (codecAdapter.pendingData) {
|
|
4517
|
+
const { pendingData } = codecAdapter;
|
|
4518
|
+
codecAdapter.pendingData = new Uint8Array(pendingData.length + data.length);
|
|
4519
|
+
pendingData.set(pendingData, 0);
|
|
4520
|
+
pendingData.set(data, pendingData.length);
|
|
4521
|
+
} else {
|
|
4522
|
+
codecAdapter.pendingData = new Uint8Array(data);
|
|
4523
|
+
}
|
|
4524
|
+
};
|
|
4525
|
+
if (Object.hasOwn(options, "level") && options.level === undefined) {
|
|
4526
|
+
delete options.level;
|
|
4527
|
+
}
|
|
4528
|
+
codecAdapter.codec = new constructor(Object.assign({}, constructorOptions, options));
|
|
4529
|
+
registerDataHandler(codecAdapter.codec, onData);
|
|
4530
|
+
}
|
|
4531
|
+
append(data) {
|
|
4532
|
+
this.codec.push(data);
|
|
4533
|
+
return getResponse(this);
|
|
4534
|
+
}
|
|
4535
|
+
flush() {
|
|
4536
|
+
this.codec.push(new Uint8Array(), true);
|
|
4537
|
+
return getResponse(this);
|
|
4538
|
+
}
|
|
4539
|
+
};
|
|
4540
|
+
|
|
4541
|
+
function getResponse(codec) {
|
|
4542
|
+
if (codec.pendingData) {
|
|
4543
|
+
const output = codec.pendingData;
|
|
4544
|
+
codec.pendingData = null;
|
|
4545
|
+
return output;
|
|
4546
|
+
} else {
|
|
4547
|
+
return new Uint8Array();
|
|
4548
|
+
}
|
|
4549
|
+
}
|
|
4550
|
+
}
|
|
4551
|
+
|
|
4552
|
+
/*
|
|
4553
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
4554
|
+
|
|
4555
|
+
Redistribution and use in source and binary forms, with or without
|
|
4556
|
+
modification, are permitted provided that the following conditions are met:
|
|
4557
|
+
|
|
4558
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
4559
|
+
this list of conditions and the following disclaimer.
|
|
4560
|
+
|
|
4561
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
4562
|
+
notice, this list of conditions and the following disclaimer in
|
|
4563
|
+
the documentation and/or other materials provided with the distribution.
|
|
4564
|
+
|
|
4565
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
4566
|
+
derived from this software without specific prior written permission.
|
|
4567
|
+
|
|
4568
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4569
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4570
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4571
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4572
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4573
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4574
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4575
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4576
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4577
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4578
|
+
*/
|
|
4579
|
+
|
|
4580
|
+
const table = [];
|
|
4581
|
+
for (let i = 0; i < 256; i++) {
|
|
4582
|
+
let t = i;
|
|
4583
|
+
for (let j = 0; j < 8; j++) {
|
|
4584
|
+
if (t & 1) {
|
|
4585
|
+
t = (t >>> 1) ^ 0xEDB88320;
|
|
4586
|
+
} else {
|
|
4587
|
+
t = t >>> 1;
|
|
4588
|
+
}
|
|
4589
|
+
}
|
|
4590
|
+
table[i] = t;
|
|
4591
|
+
}
|
|
4592
|
+
|
|
4593
|
+
class Crc32 {
|
|
4594
|
+
|
|
4595
|
+
constructor(crc) {
|
|
4596
|
+
this.crc = crc || -1;
|
|
4597
|
+
}
|
|
4598
|
+
|
|
4599
|
+
append(data) {
|
|
4600
|
+
let crc = this.crc | 0;
|
|
4601
|
+
for (let offset = 0, length = data.length | 0; offset < length; offset++) {
|
|
4602
|
+
crc = (crc >>> 8) ^ table[(crc ^ data[offset]) & 0xFF];
|
|
4603
|
+
}
|
|
4604
|
+
this.crc = crc;
|
|
4605
|
+
}
|
|
4606
|
+
|
|
4607
|
+
get() {
|
|
4608
|
+
return ~this.crc;
|
|
4609
|
+
}
|
|
4610
|
+
}
|
|
4611
|
+
|
|
4612
|
+
/*
|
|
4613
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
4614
|
+
|
|
4615
|
+
Redistribution and use in source and binary forms, with or without
|
|
4616
|
+
modification, are permitted provided that the following conditions are met:
|
|
4617
|
+
|
|
4618
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
4619
|
+
this list of conditions and the following disclaimer.
|
|
4620
|
+
|
|
4621
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
4622
|
+
notice, this list of conditions and the following disclaimer in
|
|
4623
|
+
the documentation and/or other materials provided with the distribution.
|
|
4624
|
+
|
|
4625
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
4626
|
+
derived from this software without specific prior written permission.
|
|
4627
|
+
|
|
4628
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4629
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4630
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4631
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4632
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4633
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4634
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4635
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4636
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4637
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4638
|
+
*/
|
|
4639
|
+
|
|
4640
|
+
class Crc32Stream extends TransformStream {
|
|
4641
|
+
|
|
4642
|
+
constructor() {
|
|
4643
|
+
const crc32 = new Crc32();
|
|
4644
|
+
super({
|
|
4645
|
+
transform(chunk) {
|
|
4646
|
+
crc32.append(chunk);
|
|
4647
|
+
},
|
|
4648
|
+
flush(controller) {
|
|
4649
|
+
const value = new Uint8Array(4);
|
|
4650
|
+
const dataView = new DataView(value.buffer);
|
|
4651
|
+
dataView.setUint32(0, crc32.get());
|
|
4652
|
+
controller.enqueue(value);
|
|
4653
|
+
}
|
|
4654
|
+
});
|
|
4655
|
+
}
|
|
4656
|
+
}
|
|
4657
|
+
|
|
4658
|
+
/*
|
|
4659
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
4660
|
+
|
|
4661
|
+
Redistribution and use in source and binary forms, with or without
|
|
4662
|
+
modification, are permitted provided that the following conditions are met:
|
|
4663
|
+
|
|
4664
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
4665
|
+
this list of conditions and the following disclaimer.
|
|
4666
|
+
|
|
4667
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
4668
|
+
notice, this list of conditions and the following disclaimer in
|
|
4669
|
+
the documentation and/or other materials provided with the distribution.
|
|
4670
|
+
|
|
4671
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
4672
|
+
derived from this software without specific prior written permission.
|
|
4673
|
+
|
|
4674
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4675
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4676
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4677
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4678
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4679
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4680
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4681
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4682
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4683
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4684
|
+
*/
|
|
4685
|
+
|
|
4686
|
+
function encodeText(value) {
|
|
4687
|
+
if (typeof TextEncoder == "undefined") {
|
|
4688
|
+
value = unescape(encodeURIComponent(value));
|
|
4689
|
+
const result = new Uint8Array(value.length);
|
|
4690
|
+
for (let i = 0; i < result.length; i++) {
|
|
4691
|
+
result[i] = value.charCodeAt(i);
|
|
4692
|
+
}
|
|
4693
|
+
return result;
|
|
4694
|
+
} else {
|
|
4695
|
+
return new TextEncoder().encode(value);
|
|
4696
|
+
}
|
|
4697
|
+
}
|
|
4698
|
+
|
|
4699
|
+
// Derived from https://github.com/xqdoo00o/jszip/blob/master/lib/sjcl.js and https://github.com/bitwiseshiftleft/sjcl
|
|
4700
|
+
|
|
4701
|
+
// deno-lint-ignore-file no-this-alias
|
|
4702
|
+
|
|
4703
|
+
/*
|
|
4704
|
+
* SJCL is open. You can use, modify and redistribute it under a BSD
|
|
4705
|
+
* license or under the GNU GPL, version 2.0.
|
|
4706
|
+
*/
|
|
4707
|
+
|
|
4708
|
+
/** @fileOverview Javascript cryptography implementation.
|
|
4709
|
+
*
|
|
4710
|
+
* Crush to remove comments, shorten variable names and
|
|
4711
|
+
* generally reduce transmission size.
|
|
4712
|
+
*
|
|
4713
|
+
* @author Emily Stark
|
|
4714
|
+
* @author Mike Hamburg
|
|
4715
|
+
* @author Dan Boneh
|
|
4716
|
+
*/
|
|
4717
|
+
|
|
4718
|
+
/*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
|
|
4719
|
+
|
|
4720
|
+
/** @fileOverview Arrays of bits, encoded as arrays of Numbers.
|
|
4721
|
+
*
|
|
4722
|
+
* @author Emily Stark
|
|
4723
|
+
* @author Mike Hamburg
|
|
4724
|
+
* @author Dan Boneh
|
|
4725
|
+
*/
|
|
4726
|
+
|
|
4727
|
+
/**
|
|
4728
|
+
* Arrays of bits, encoded as arrays of Numbers.
|
|
4729
|
+
* @namespace
|
|
4730
|
+
* @description
|
|
4731
|
+
* <p>
|
|
4732
|
+
* These objects are the currency accepted by SJCL's crypto functions.
|
|
4733
|
+
* </p>
|
|
4734
|
+
*
|
|
4735
|
+
* <p>
|
|
4736
|
+
* Most of our crypto primitives operate on arrays of 4-byte words internally,
|
|
4737
|
+
* but many of them can take arguments that are not a multiple of 4 bytes.
|
|
4738
|
+
* This library encodes arrays of bits (whose size need not be a multiple of 8
|
|
4739
|
+
* bits) as arrays of 32-bit words. The bits are packed, big-endian, into an
|
|
4740
|
+
* array of words, 32 bits at a time. Since the words are double-precision
|
|
4741
|
+
* floating point numbers, they fit some extra data. We use this (in a private,
|
|
4742
|
+
* possibly-changing manner) to encode the number of bits actually present
|
|
4743
|
+
* in the last word of the array.
|
|
4744
|
+
* </p>
|
|
4745
|
+
*
|
|
4746
|
+
* <p>
|
|
4747
|
+
* Because bitwise ops clear this out-of-band data, these arrays can be passed
|
|
4748
|
+
* to ciphers like AES which want arrays of words.
|
|
4749
|
+
* </p>
|
|
4750
|
+
*/
|
|
4751
|
+
const bitArray = {
|
|
4752
|
+
/**
|
|
4753
|
+
* Concatenate two bit arrays.
|
|
4754
|
+
* @param {bitArray} a1 The first array.
|
|
4755
|
+
* @param {bitArray} a2 The second array.
|
|
4756
|
+
* @return {bitArray} The concatenation of a1 and a2.
|
|
4757
|
+
*/
|
|
4758
|
+
concat(a1, a2) {
|
|
4759
|
+
if (a1.length === 0 || a2.length === 0) {
|
|
4760
|
+
return a1.concat(a2);
|
|
4761
|
+
}
|
|
4762
|
+
|
|
4763
|
+
const last = a1[a1.length - 1], shift = bitArray.getPartial(last);
|
|
4764
|
+
if (shift === 32) {
|
|
4765
|
+
return a1.concat(a2);
|
|
4766
|
+
} else {
|
|
4767
|
+
return bitArray._shiftRight(a2, shift, last | 0, a1.slice(0, a1.length - 1));
|
|
4768
|
+
}
|
|
4769
|
+
},
|
|
4770
|
+
|
|
4771
|
+
/**
|
|
4772
|
+
* Find the length of an array of bits.
|
|
4773
|
+
* @param {bitArray} a The array.
|
|
4454
4774
|
* @return {Number} The length of a, in bits.
|
|
4455
4775
|
*/
|
|
4456
4776
|
bitLength(a) {
|
|
@@ -5188,58 +5508,15 @@
|
|
|
5188
5508
|
return result;
|
|
5189
5509
|
}
|
|
5190
5510
|
|
|
5191
|
-
encrypt(data) {
|
|
5192
|
-
if (!this._updated) {
|
|
5193
|
-
this.update(data);
|
|
5194
|
-
return this.digest(data);
|
|
5195
|
-
} else {
|
|
5196
|
-
throw new Error("encrypt on already updated hmac called!");
|
|
5197
|
-
}
|
|
5198
|
-
}
|
|
5199
|
-
};
|
|
5200
|
-
|
|
5201
|
-
/*
|
|
5202
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
5203
|
-
|
|
5204
|
-
Redistribution and use in source and binary forms, with or without
|
|
5205
|
-
modification, are permitted provided that the following conditions are met:
|
|
5206
|
-
|
|
5207
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
5208
|
-
this list of conditions and the following disclaimer.
|
|
5209
|
-
|
|
5210
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
5211
|
-
notice, this list of conditions and the following disclaimer in
|
|
5212
|
-
the documentation and/or other materials provided with the distribution.
|
|
5213
|
-
|
|
5214
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
5215
|
-
derived from this software without specific prior written permission.
|
|
5216
|
-
|
|
5217
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
5218
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
5219
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
5220
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
5221
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
5222
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
5223
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
5224
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
5225
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
5226
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5227
|
-
*/
|
|
5228
|
-
|
|
5229
|
-
/* global crypto */
|
|
5230
|
-
|
|
5231
|
-
const GET_RANDOM_VALUES_SUPPORTED = typeof crypto != "undefined" && typeof crypto.getRandomValues == "function";
|
|
5232
|
-
|
|
5233
|
-
const ERR_INVALID_PASSWORD = "Invalid password";
|
|
5234
|
-
const ERR_INVALID_SIGNATURE = "Invalid signature";
|
|
5235
|
-
|
|
5236
|
-
function getRandomValues(array) {
|
|
5237
|
-
if (GET_RANDOM_VALUES_SUPPORTED) {
|
|
5238
|
-
return crypto.getRandomValues(array);
|
|
5239
|
-
} else {
|
|
5240
|
-
return random.getRandomValues(array);
|
|
5511
|
+
encrypt(data) {
|
|
5512
|
+
if (!this._updated) {
|
|
5513
|
+
this.update(data);
|
|
5514
|
+
return this.digest(data);
|
|
5515
|
+
} else {
|
|
5516
|
+
throw new Error("encrypt on already updated hmac called!");
|
|
5517
|
+
}
|
|
5241
5518
|
}
|
|
5242
|
-
}
|
|
5519
|
+
};
|
|
5243
5520
|
|
|
5244
5521
|
/*
|
|
5245
5522
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
@@ -5269,253 +5546,19 @@
|
|
|
5269
5546
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5270
5547
|
*/
|
|
5271
5548
|
|
|
5272
|
-
|
|
5273
|
-
const RAW_FORMAT = "raw";
|
|
5274
|
-
const PBKDF2_ALGORITHM = { name: "PBKDF2" };
|
|
5275
|
-
const HASH_ALGORITHM = { name: "HMAC" };
|
|
5276
|
-
const HASH_FUNCTION = "SHA-1";
|
|
5277
|
-
const BASE_KEY_ALGORITHM = Object.assign({ hash: HASH_ALGORITHM }, PBKDF2_ALGORITHM);
|
|
5278
|
-
const DERIVED_BITS_ALGORITHM = Object.assign({ iterations: 1000, hash: { name: HASH_FUNCTION } }, PBKDF2_ALGORITHM);
|
|
5279
|
-
const DERIVED_BITS_USAGE = ["deriveBits"];
|
|
5280
|
-
const SALT_LENGTH = [8, 12, 16];
|
|
5281
|
-
const KEY_LENGTH = [16, 24, 32];
|
|
5282
|
-
const SIGNATURE_LENGTH = 10;
|
|
5283
|
-
const COUNTER_DEFAULT_VALUE = [0, 0, 0, 0];
|
|
5284
|
-
const UNDEFINED_TYPE$1 = "undefined";
|
|
5285
|
-
const FUNCTION_TYPE = "function";
|
|
5286
|
-
const CRYPTO_API_SUPPORTED = typeof crypto != UNDEFINED_TYPE$1;
|
|
5287
|
-
const subtle = CRYPTO_API_SUPPORTED && crypto.subtle;
|
|
5288
|
-
const SUBTLE_API_SUPPORTED = CRYPTO_API_SUPPORTED && typeof subtle != UNDEFINED_TYPE$1;
|
|
5289
|
-
const IMPORT_KEY_SUPPORTED = CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof subtle.importKey == FUNCTION_TYPE;
|
|
5290
|
-
const DERIVE_BITS_SUPPORTED = CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof subtle.deriveBits == FUNCTION_TYPE;
|
|
5291
|
-
const codecBytes = codec.bytes;
|
|
5292
|
-
const Aes = cipher.aes;
|
|
5293
|
-
const CtrGladman = mode.ctrGladman;
|
|
5294
|
-
const HmacSha1 = misc.hmacSha1;
|
|
5295
|
-
|
|
5296
|
-
class AESDecryptionStream extends TransformStream {
|
|
5297
|
-
|
|
5298
|
-
constructor(password, signed, strength) {
|
|
5299
|
-
super({
|
|
5300
|
-
start() {
|
|
5301
|
-
Object.assign(this, {
|
|
5302
|
-
ready: new Promise(resolve => this.resolveReady = resolve),
|
|
5303
|
-
password,
|
|
5304
|
-
signed,
|
|
5305
|
-
strength: strength - 1,
|
|
5306
|
-
pending: new Uint8Array()
|
|
5307
|
-
});
|
|
5308
|
-
},
|
|
5309
|
-
async transform(chunk, controller) {
|
|
5310
|
-
const aesCrypto = this;
|
|
5311
|
-
const {
|
|
5312
|
-
password,
|
|
5313
|
-
strength,
|
|
5314
|
-
resolveReady,
|
|
5315
|
-
ready
|
|
5316
|
-
} = aesCrypto;
|
|
5317
|
-
if (password) {
|
|
5318
|
-
await createDecryptionKeys(aesCrypto, strength, password, subarray(chunk, 0, SALT_LENGTH[strength] + 2));
|
|
5319
|
-
chunk = subarray(chunk, SALT_LENGTH[strength] + 2);
|
|
5320
|
-
resolveReady();
|
|
5321
|
-
} else {
|
|
5322
|
-
await ready;
|
|
5323
|
-
}
|
|
5324
|
-
const output = new Uint8Array(chunk.length - SIGNATURE_LENGTH - ((chunk.length - SIGNATURE_LENGTH) % BLOCK_LENGTH));
|
|
5325
|
-
controller.enqueue(append(aesCrypto, chunk, output, 0, SIGNATURE_LENGTH, true));
|
|
5326
|
-
},
|
|
5327
|
-
async flush(controller) {
|
|
5328
|
-
const {
|
|
5329
|
-
signed,
|
|
5330
|
-
ctr,
|
|
5331
|
-
hmac,
|
|
5332
|
-
pending,
|
|
5333
|
-
ready
|
|
5334
|
-
} = this;
|
|
5335
|
-
await ready;
|
|
5336
|
-
const chunkToDecrypt = subarray(pending, 0, pending.length - SIGNATURE_LENGTH);
|
|
5337
|
-
const originalSignature = subarray(pending, pending.length - SIGNATURE_LENGTH);
|
|
5338
|
-
let decryptedChunkArray = new Uint8Array();
|
|
5339
|
-
if (chunkToDecrypt.length) {
|
|
5340
|
-
const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
|
|
5341
|
-
hmac.update(encryptedChunk);
|
|
5342
|
-
const decryptedChunk = ctr.update(encryptedChunk);
|
|
5343
|
-
decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
|
|
5344
|
-
}
|
|
5345
|
-
if (signed) {
|
|
5346
|
-
const signature = subarray(fromBits(codecBytes, hmac.digest()), 0, SIGNATURE_LENGTH);
|
|
5347
|
-
for (let indexSignature = 0; indexSignature < SIGNATURE_LENGTH; indexSignature++) {
|
|
5348
|
-
if (signature[indexSignature] != originalSignature[indexSignature]) {
|
|
5349
|
-
throw new Error(ERR_INVALID_SIGNATURE);
|
|
5350
|
-
}
|
|
5351
|
-
}
|
|
5352
|
-
}
|
|
5353
|
-
controller.enqueue(decryptedChunkArray);
|
|
5354
|
-
}
|
|
5355
|
-
});
|
|
5356
|
-
}
|
|
5357
|
-
}
|
|
5358
|
-
|
|
5359
|
-
class AESEncryptionStream extends TransformStream {
|
|
5360
|
-
|
|
5361
|
-
constructor(password, strength) {
|
|
5362
|
-
let stream;
|
|
5363
|
-
super({
|
|
5364
|
-
start() {
|
|
5365
|
-
Object.assign(this, {
|
|
5366
|
-
ready: new Promise(resolve => this.resolveReady = resolve),
|
|
5367
|
-
password,
|
|
5368
|
-
strength: strength - 1,
|
|
5369
|
-
pending: new Uint8Array()
|
|
5370
|
-
});
|
|
5371
|
-
},
|
|
5372
|
-
async transform(chunk, controller) {
|
|
5373
|
-
const aesCrypto = this;
|
|
5374
|
-
const {
|
|
5375
|
-
password,
|
|
5376
|
-
strength,
|
|
5377
|
-
resolveReady,
|
|
5378
|
-
ready
|
|
5379
|
-
} = aesCrypto;
|
|
5380
|
-
let preamble = new Uint8Array();
|
|
5381
|
-
if (password) {
|
|
5382
|
-
preamble = await createEncryptionKeys(aesCrypto, strength, password);
|
|
5383
|
-
resolveReady();
|
|
5384
|
-
} else {
|
|
5385
|
-
await ready;
|
|
5386
|
-
}
|
|
5387
|
-
const output = new Uint8Array(preamble.length + chunk.length - (chunk.length % BLOCK_LENGTH));
|
|
5388
|
-
output.set(preamble, 0);
|
|
5389
|
-
controller.enqueue(append(aesCrypto, chunk, output, preamble.length, 0));
|
|
5390
|
-
},
|
|
5391
|
-
async flush(controller) {
|
|
5392
|
-
const {
|
|
5393
|
-
ctr,
|
|
5394
|
-
hmac,
|
|
5395
|
-
pending,
|
|
5396
|
-
ready
|
|
5397
|
-
} = this;
|
|
5398
|
-
await ready;
|
|
5399
|
-
let encryptedChunkArray = new Uint8Array();
|
|
5400
|
-
if (pending.length) {
|
|
5401
|
-
const encryptedChunk = ctr.update(toBits(codecBytes, pending));
|
|
5402
|
-
hmac.update(encryptedChunk);
|
|
5403
|
-
encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
|
|
5404
|
-
}
|
|
5405
|
-
stream.signature = fromBits(codecBytes, hmac.digest()).slice(0, SIGNATURE_LENGTH);
|
|
5406
|
-
controller.enqueue(concat(encryptedChunkArray, stream.signature));
|
|
5407
|
-
}
|
|
5408
|
-
});
|
|
5409
|
-
stream = this;
|
|
5410
|
-
}
|
|
5411
|
-
}
|
|
5412
|
-
|
|
5413
|
-
function append(aesCrypto, input, output, paddingStart, paddingEnd, verifySignature) {
|
|
5414
|
-
const {
|
|
5415
|
-
ctr,
|
|
5416
|
-
hmac,
|
|
5417
|
-
pending
|
|
5418
|
-
} = aesCrypto;
|
|
5419
|
-
const inputLength = input.length - paddingEnd;
|
|
5420
|
-
if (pending.length) {
|
|
5421
|
-
input = concat(pending, input);
|
|
5422
|
-
output = expand(output, inputLength - (inputLength % BLOCK_LENGTH));
|
|
5423
|
-
}
|
|
5424
|
-
let offset;
|
|
5425
|
-
for (offset = 0; offset <= inputLength - BLOCK_LENGTH; offset += BLOCK_LENGTH) {
|
|
5426
|
-
const inputChunk = toBits(codecBytes, subarray(input, offset, offset + BLOCK_LENGTH));
|
|
5427
|
-
if (verifySignature) {
|
|
5428
|
-
hmac.update(inputChunk);
|
|
5429
|
-
}
|
|
5430
|
-
const outputChunk = ctr.update(inputChunk);
|
|
5431
|
-
if (!verifySignature) {
|
|
5432
|
-
hmac.update(outputChunk);
|
|
5433
|
-
}
|
|
5434
|
-
output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
|
|
5435
|
-
}
|
|
5436
|
-
aesCrypto.pending = subarray(input, offset);
|
|
5437
|
-
return output;
|
|
5438
|
-
}
|
|
5439
|
-
|
|
5440
|
-
async function createDecryptionKeys(decrypt, strength, password, preamble) {
|
|
5441
|
-
const passwordVerificationKey = await createKeys$1(decrypt, strength, password, subarray(preamble, 0, SALT_LENGTH[strength]));
|
|
5442
|
-
const passwordVerification = subarray(preamble, SALT_LENGTH[strength]);
|
|
5443
|
-
if (passwordVerificationKey[0] != passwordVerification[0] || passwordVerificationKey[1] != passwordVerification[1]) {
|
|
5444
|
-
throw new Error(ERR_INVALID_PASSWORD);
|
|
5445
|
-
}
|
|
5446
|
-
}
|
|
5447
|
-
|
|
5448
|
-
async function createEncryptionKeys(encrypt, strength, password) {
|
|
5449
|
-
const salt = getRandomValues(new Uint8Array(SALT_LENGTH[strength]));
|
|
5450
|
-
const passwordVerification = await createKeys$1(encrypt, strength, password, salt);
|
|
5451
|
-
return concat(salt, passwordVerification);
|
|
5452
|
-
}
|
|
5453
|
-
|
|
5454
|
-
async function createKeys$1(aesCrypto, strength, password, salt) {
|
|
5455
|
-
aesCrypto.password = null;
|
|
5456
|
-
const encodedPassword = encodeText(password);
|
|
5457
|
-
const baseKey = await importKey(RAW_FORMAT, encodedPassword, BASE_KEY_ALGORITHM, false, DERIVED_BITS_USAGE);
|
|
5458
|
-
const derivedBits = await deriveBits(Object.assign({ salt }, DERIVED_BITS_ALGORITHM), baseKey, 8 * ((KEY_LENGTH[strength] * 2) + 2));
|
|
5459
|
-
const compositeKey = new Uint8Array(derivedBits);
|
|
5460
|
-
const key = toBits(codecBytes, subarray(compositeKey, 0, KEY_LENGTH[strength]));
|
|
5461
|
-
const authentication = toBits(codecBytes, subarray(compositeKey, KEY_LENGTH[strength], KEY_LENGTH[strength] * 2));
|
|
5462
|
-
const passwordVerification = subarray(compositeKey, KEY_LENGTH[strength] * 2);
|
|
5463
|
-
Object.assign(aesCrypto, {
|
|
5464
|
-
keys: {
|
|
5465
|
-
key,
|
|
5466
|
-
authentication,
|
|
5467
|
-
passwordVerification
|
|
5468
|
-
},
|
|
5469
|
-
ctr: new CtrGladman(new Aes(key), Array.from(COUNTER_DEFAULT_VALUE)),
|
|
5470
|
-
hmac: new HmacSha1(authentication)
|
|
5471
|
-
});
|
|
5472
|
-
return passwordVerification;
|
|
5473
|
-
}
|
|
5474
|
-
|
|
5475
|
-
function importKey(format, password, algorithm, extractable, keyUsages) {
|
|
5476
|
-
if (IMPORT_KEY_SUPPORTED) {
|
|
5477
|
-
return subtle.importKey(format, password, algorithm, extractable, keyUsages);
|
|
5478
|
-
} else {
|
|
5479
|
-
return misc.importKey(password);
|
|
5480
|
-
}
|
|
5481
|
-
}
|
|
5482
|
-
|
|
5483
|
-
async function deriveBits(algorithm, baseKey, length) {
|
|
5484
|
-
if (DERIVE_BITS_SUPPORTED) {
|
|
5485
|
-
return await subtle.deriveBits(algorithm, baseKey, length);
|
|
5486
|
-
} else {
|
|
5487
|
-
return misc.pbkdf2(baseKey, algorithm.salt, DERIVED_BITS_ALGORITHM.iterations, length);
|
|
5488
|
-
}
|
|
5489
|
-
}
|
|
5490
|
-
|
|
5491
|
-
function concat(leftArray, rightArray) {
|
|
5492
|
-
let array = leftArray;
|
|
5493
|
-
if (leftArray.length + rightArray.length) {
|
|
5494
|
-
array = new Uint8Array(leftArray.length + rightArray.length);
|
|
5495
|
-
array.set(leftArray, 0);
|
|
5496
|
-
array.set(rightArray, leftArray.length);
|
|
5497
|
-
}
|
|
5498
|
-
return array;
|
|
5499
|
-
}
|
|
5549
|
+
/* global crypto */
|
|
5500
5550
|
|
|
5501
|
-
|
|
5502
|
-
if (length && length > inputArray.length) {
|
|
5503
|
-
const array = inputArray;
|
|
5504
|
-
inputArray = new Uint8Array(length);
|
|
5505
|
-
inputArray.set(array, 0);
|
|
5506
|
-
}
|
|
5507
|
-
return inputArray;
|
|
5508
|
-
}
|
|
5551
|
+
const GET_RANDOM_VALUES_SUPPORTED = typeof crypto != "undefined" && typeof crypto.getRandomValues == "function";
|
|
5509
5552
|
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
}
|
|
5553
|
+
const ERR_INVALID_PASSWORD = "Invalid password";
|
|
5554
|
+
const ERR_INVALID_SIGNATURE = "Invalid signature";
|
|
5513
5555
|
|
|
5514
|
-
function
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5556
|
+
function getRandomValues(array) {
|
|
5557
|
+
if (GET_RANDOM_VALUES_SUPPORTED) {
|
|
5558
|
+
return crypto.getRandomValues(array);
|
|
5559
|
+
} else {
|
|
5560
|
+
return random.getRandomValues(array);
|
|
5561
|
+
}
|
|
5519
5562
|
}
|
|
5520
5563
|
|
|
5521
5564
|
/*
|
|
@@ -5546,257 +5589,255 @@
|
|
|
5546
5589
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5547
5590
|
*/
|
|
5548
5591
|
|
|
5549
|
-
const
|
|
5592
|
+
const BLOCK_LENGTH = 16;
|
|
5593
|
+
const RAW_FORMAT = "raw";
|
|
5594
|
+
const PBKDF2_ALGORITHM = { name: "PBKDF2" };
|
|
5595
|
+
const HASH_ALGORITHM = { name: "HMAC" };
|
|
5596
|
+
const HASH_FUNCTION = "SHA-1";
|
|
5597
|
+
const BASE_KEY_ALGORITHM = Object.assign({ hash: HASH_ALGORITHM }, PBKDF2_ALGORITHM);
|
|
5598
|
+
const DERIVED_BITS_ALGORITHM = Object.assign({ iterations: 1000, hash: { name: HASH_FUNCTION } }, PBKDF2_ALGORITHM);
|
|
5599
|
+
const DERIVED_BITS_USAGE = ["deriveBits"];
|
|
5600
|
+
const SALT_LENGTH = [8, 12, 16];
|
|
5601
|
+
const KEY_LENGTH = [16, 24, 32];
|
|
5602
|
+
const SIGNATURE_LENGTH = 10;
|
|
5603
|
+
const COUNTER_DEFAULT_VALUE = [0, 0, 0, 0];
|
|
5604
|
+
const UNDEFINED_TYPE = "undefined";
|
|
5605
|
+
const FUNCTION_TYPE = "function";
|
|
5606
|
+
// deno-lint-ignore valid-typeof
|
|
5607
|
+
const CRYPTO_API_SUPPORTED = typeof crypto != UNDEFINED_TYPE;
|
|
5608
|
+
const subtle = CRYPTO_API_SUPPORTED && crypto.subtle;
|
|
5609
|
+
const SUBTLE_API_SUPPORTED = CRYPTO_API_SUPPORTED && typeof subtle != UNDEFINED_TYPE;
|
|
5610
|
+
const IMPORT_KEY_SUPPORTED = CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof subtle.importKey == FUNCTION_TYPE;
|
|
5611
|
+
const DERIVE_BITS_SUPPORTED = CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof subtle.deriveBits == FUNCTION_TYPE;
|
|
5612
|
+
const codecBytes = codec.bytes;
|
|
5613
|
+
const Aes = cipher.aes;
|
|
5614
|
+
const CtrGladman = mode.ctrGladman;
|
|
5615
|
+
const HmacSha1 = misc.hmacSha1;
|
|
5550
5616
|
|
|
5551
|
-
class
|
|
5617
|
+
class AESDecryptionStream extends TransformStream {
|
|
5552
5618
|
|
|
5553
|
-
constructor(password,
|
|
5619
|
+
constructor(password, signed, strength) {
|
|
5554
5620
|
super({
|
|
5555
5621
|
start() {
|
|
5556
5622
|
Object.assign(this, {
|
|
5623
|
+
ready: new Promise(resolve => this.resolveReady = resolve),
|
|
5557
5624
|
password,
|
|
5558
|
-
|
|
5625
|
+
signed,
|
|
5626
|
+
strength: strength - 1,
|
|
5627
|
+
pending: new Uint8Array()
|
|
5559
5628
|
});
|
|
5560
|
-
createKeys(this, password);
|
|
5561
5629
|
},
|
|
5562
|
-
transform(chunk, controller) {
|
|
5563
|
-
const
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5630
|
+
async transform(chunk, controller) {
|
|
5631
|
+
const aesCrypto = this;
|
|
5632
|
+
const {
|
|
5633
|
+
password,
|
|
5634
|
+
strength,
|
|
5635
|
+
resolveReady,
|
|
5636
|
+
ready
|
|
5637
|
+
} = aesCrypto;
|
|
5638
|
+
if (password) {
|
|
5639
|
+
await createDecryptionKeys(aesCrypto, strength, password, subarray(chunk, 0, SALT_LENGTH[strength] + 2));
|
|
5640
|
+
chunk = subarray(chunk, SALT_LENGTH[strength] + 2);
|
|
5641
|
+
resolveReady();
|
|
5642
|
+
} else {
|
|
5643
|
+
await ready;
|
|
5644
|
+
}
|
|
5645
|
+
const output = new Uint8Array(chunk.length - SIGNATURE_LENGTH - ((chunk.length - SIGNATURE_LENGTH) % BLOCK_LENGTH));
|
|
5646
|
+
controller.enqueue(append(aesCrypto, chunk, output, 0, SIGNATURE_LENGTH, true));
|
|
5647
|
+
},
|
|
5648
|
+
async flush(controller) {
|
|
5649
|
+
const {
|
|
5650
|
+
signed,
|
|
5651
|
+
ctr,
|
|
5652
|
+
hmac,
|
|
5653
|
+
pending,
|
|
5654
|
+
ready
|
|
5655
|
+
} = this;
|
|
5656
|
+
await ready;
|
|
5657
|
+
const chunkToDecrypt = subarray(pending, 0, pending.length - SIGNATURE_LENGTH);
|
|
5658
|
+
const originalSignature = subarray(pending, pending.length - SIGNATURE_LENGTH);
|
|
5659
|
+
let decryptedChunkArray = new Uint8Array();
|
|
5660
|
+
if (chunkToDecrypt.length) {
|
|
5661
|
+
const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
|
|
5662
|
+
hmac.update(encryptedChunk);
|
|
5663
|
+
const decryptedChunk = ctr.update(encryptedChunk);
|
|
5664
|
+
decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
|
|
5665
|
+
}
|
|
5666
|
+
if (signed) {
|
|
5667
|
+
const signature = subarray(fromBits(codecBytes, hmac.digest()), 0, SIGNATURE_LENGTH);
|
|
5668
|
+
for (let indexSignature = 0; indexSignature < SIGNATURE_LENGTH; indexSignature++) {
|
|
5669
|
+
if (signature[indexSignature] != originalSignature[indexSignature]) {
|
|
5670
|
+
throw new Error(ERR_INVALID_SIGNATURE);
|
|
5671
|
+
}
|
|
5569
5672
|
}
|
|
5570
|
-
chunk = chunk.subarray(HEADER_LENGTH);
|
|
5571
5673
|
}
|
|
5572
|
-
controller.enqueue(
|
|
5674
|
+
controller.enqueue(decryptedChunkArray);
|
|
5573
5675
|
}
|
|
5574
5676
|
});
|
|
5575
5677
|
}
|
|
5576
5678
|
}
|
|
5577
5679
|
|
|
5578
|
-
class
|
|
5680
|
+
class AESEncryptionStream extends TransformStream {
|
|
5579
5681
|
|
|
5580
|
-
constructor(password,
|
|
5682
|
+
constructor(password, strength) {
|
|
5683
|
+
// deno-lint-ignore prefer-const
|
|
5684
|
+
let stream;
|
|
5581
5685
|
super({
|
|
5582
5686
|
start() {
|
|
5583
5687
|
Object.assign(this, {
|
|
5688
|
+
ready: new Promise(resolve => this.resolveReady = resolve),
|
|
5584
5689
|
password,
|
|
5585
|
-
|
|
5690
|
+
strength: strength - 1,
|
|
5691
|
+
pending: new Uint8Array()
|
|
5586
5692
|
});
|
|
5587
|
-
createKeys(this, password);
|
|
5588
5693
|
},
|
|
5589
|
-
transform(chunk, controller) {
|
|
5590
|
-
const
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5694
|
+
async transform(chunk, controller) {
|
|
5695
|
+
const aesCrypto = this;
|
|
5696
|
+
const {
|
|
5697
|
+
password,
|
|
5698
|
+
strength,
|
|
5699
|
+
resolveReady,
|
|
5700
|
+
ready
|
|
5701
|
+
} = aesCrypto;
|
|
5702
|
+
let preamble = new Uint8Array();
|
|
5703
|
+
if (password) {
|
|
5704
|
+
preamble = await createEncryptionKeys(aesCrypto, strength, password);
|
|
5705
|
+
resolveReady();
|
|
5600
5706
|
} else {
|
|
5601
|
-
|
|
5602
|
-
offset = 0;
|
|
5707
|
+
await ready;
|
|
5603
5708
|
}
|
|
5604
|
-
output.
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
updateKeys(target, input[index]);
|
|
5625
|
-
}
|
|
5626
|
-
return output;
|
|
5627
|
-
}
|
|
5628
|
-
|
|
5629
|
-
function createKeys(target, password) {
|
|
5630
|
-
const keys = [0x12345678, 0x23456789, 0x34567890];
|
|
5631
|
-
Object.assign(target, {
|
|
5632
|
-
keys,
|
|
5633
|
-
crcKey0: new Crc32(keys[0]),
|
|
5634
|
-
crcKey2: new Crc32(keys[2]),
|
|
5635
|
-
});
|
|
5636
|
-
for (let index = 0; index < password.length; index++) {
|
|
5637
|
-
updateKeys(target, password.charCodeAt(index));
|
|
5638
|
-
}
|
|
5639
|
-
}
|
|
5640
|
-
|
|
5641
|
-
function updateKeys(target, byte) {
|
|
5642
|
-
let [key0, key1, key2] = target.keys;
|
|
5643
|
-
target.crcKey0.append([byte]);
|
|
5644
|
-
key0 = ~target.crcKey0.get();
|
|
5645
|
-
key1 = getInt32(Math.imul(getInt32(key1 + getInt8(key0)), 134775813) + 1);
|
|
5646
|
-
target.crcKey2.append([key1 >>> 24]);
|
|
5647
|
-
key2 = ~target.crcKey2.get();
|
|
5648
|
-
target.keys = [key0, key1, key2];
|
|
5649
|
-
}
|
|
5650
|
-
|
|
5651
|
-
function getByte(target) {
|
|
5652
|
-
const temp = target.keys[2] | 2;
|
|
5653
|
-
return getInt8(Math.imul(temp, (temp ^ 1)) >>> 8);
|
|
5654
|
-
}
|
|
5655
|
-
|
|
5656
|
-
function getInt8(number) {
|
|
5657
|
-
return number & 0xFF;
|
|
5658
|
-
}
|
|
5659
|
-
|
|
5660
|
-
function getInt32(number) {
|
|
5661
|
-
return number & 0xFFFFFFFF;
|
|
5662
|
-
}
|
|
5663
|
-
|
|
5664
|
-
/*
|
|
5665
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
5666
|
-
|
|
5667
|
-
Redistribution and use in source and binary forms, with or without
|
|
5668
|
-
modification, are permitted provided that the following conditions are met:
|
|
5669
|
-
|
|
5670
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
5671
|
-
this list of conditions and the following disclaimer.
|
|
5672
|
-
|
|
5673
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
5674
|
-
notice, this list of conditions and the following disclaimer in
|
|
5675
|
-
the documentation and/or other materials provided with the distribution.
|
|
5676
|
-
|
|
5677
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
5678
|
-
derived from this software without specific prior written permission.
|
|
5679
|
-
|
|
5680
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
5681
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
5682
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
5683
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
5684
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
5685
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
5686
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
5687
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
5688
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
5689
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5690
|
-
*/
|
|
5691
|
-
|
|
5692
|
-
const COMPRESSION_FORMAT = "deflate-raw";
|
|
5693
|
-
|
|
5694
|
-
class DeflateStream extends TransformStream {
|
|
5695
|
-
|
|
5696
|
-
constructor(options, { chunkSize, CompressionStream, CompressionStreamNative }) {
|
|
5697
|
-
super({});
|
|
5698
|
-
const { compressed, encrypted, useCompressionStream, password, passwordVerification, encryptionStrength, zipCrypto, signed, level } = options;
|
|
5699
|
-
const stream = this;
|
|
5700
|
-
let crc32Stream, encryptionStream;
|
|
5701
|
-
let readable = filterEmptyChunks(super.readable);
|
|
5702
|
-
if ((!encrypted || zipCrypto) && signed) {
|
|
5703
|
-
[readable, crc32Stream] = readable.tee();
|
|
5704
|
-
crc32Stream = pipeThrough(crc32Stream, new Crc32Stream());
|
|
5705
|
-
}
|
|
5706
|
-
if (compressed) {
|
|
5707
|
-
readable = pipeThroughCommpressionStream(readable, useCompressionStream, { level, chunkSize }, CompressionStreamNative, CompressionStream);
|
|
5708
|
-
}
|
|
5709
|
-
if (encrypted) {
|
|
5710
|
-
if (zipCrypto) {
|
|
5711
|
-
readable = pipeThrough(readable, new ZipCryptoEncryptionStream(password, passwordVerification));
|
|
5712
|
-
} else {
|
|
5713
|
-
encryptionStream = new AESEncryptionStream(password, encryptionStrength);
|
|
5714
|
-
readable = pipeThrough(readable, encryptionStream);
|
|
5715
|
-
}
|
|
5716
|
-
}
|
|
5717
|
-
setReadable(stream, readable, async () => {
|
|
5718
|
-
let signature;
|
|
5719
|
-
if (encrypted && !zipCrypto) {
|
|
5720
|
-
signature = encryptionStream.signature;
|
|
5721
|
-
}
|
|
5722
|
-
if ((!encrypted || zipCrypto) && signed) {
|
|
5723
|
-
signature = await crc32Stream.getReader().read();
|
|
5724
|
-
signature = new DataView(signature.value.buffer).getUint32(0);
|
|
5709
|
+
const output = new Uint8Array(preamble.length + chunk.length - (chunk.length % BLOCK_LENGTH));
|
|
5710
|
+
output.set(preamble, 0);
|
|
5711
|
+
controller.enqueue(append(aesCrypto, chunk, output, preamble.length, 0));
|
|
5712
|
+
},
|
|
5713
|
+
async flush(controller) {
|
|
5714
|
+
const {
|
|
5715
|
+
ctr,
|
|
5716
|
+
hmac,
|
|
5717
|
+
pending,
|
|
5718
|
+
ready
|
|
5719
|
+
} = this;
|
|
5720
|
+
await ready;
|
|
5721
|
+
let encryptedChunkArray = new Uint8Array();
|
|
5722
|
+
if (pending.length) {
|
|
5723
|
+
const encryptedChunk = ctr.update(toBits(codecBytes, pending));
|
|
5724
|
+
hmac.update(encryptedChunk);
|
|
5725
|
+
encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
|
|
5726
|
+
}
|
|
5727
|
+
stream.signature = fromBits(codecBytes, hmac.digest()).slice(0, SIGNATURE_LENGTH);
|
|
5728
|
+
controller.enqueue(concat(encryptedChunkArray, stream.signature));
|
|
5725
5729
|
}
|
|
5726
|
-
stream.signature = signature;
|
|
5727
5730
|
});
|
|
5731
|
+
stream = this;
|
|
5728
5732
|
}
|
|
5729
5733
|
}
|
|
5730
5734
|
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
readable = pipeThroughCommpressionStream(readable, useCompressionStream, { chunkSize }, DecompressionStreamNative, DecompressionStream);
|
|
5735
|
+
function append(aesCrypto, input, output, paddingStart, paddingEnd, verifySignature) {
|
|
5736
|
+
const {
|
|
5737
|
+
ctr,
|
|
5738
|
+
hmac,
|
|
5739
|
+
pending
|
|
5740
|
+
} = aesCrypto;
|
|
5741
|
+
const inputLength = input.length - paddingEnd;
|
|
5742
|
+
if (pending.length) {
|
|
5743
|
+
input = concat(pending, input);
|
|
5744
|
+
output = expand(output, inputLength - (inputLength % BLOCK_LENGTH));
|
|
5745
|
+
}
|
|
5746
|
+
let offset;
|
|
5747
|
+
for (offset = 0; offset <= inputLength - BLOCK_LENGTH; offset += BLOCK_LENGTH) {
|
|
5748
|
+
const inputChunk = toBits(codecBytes, subarray(input, offset, offset + BLOCK_LENGTH));
|
|
5749
|
+
if (verifySignature) {
|
|
5750
|
+
hmac.update(inputChunk);
|
|
5748
5751
|
}
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
+
const outputChunk = ctr.update(inputChunk);
|
|
5753
|
+
if (!verifySignature) {
|
|
5754
|
+
hmac.update(outputChunk);
|
|
5752
5755
|
}
|
|
5753
|
-
|
|
5754
|
-
if ((!encrypted || zipCrypto) && signed) {
|
|
5755
|
-
const streamSignature = await crc32Stream.getReader().read();
|
|
5756
|
-
const dataViewSignature = new DataView(streamSignature.value.buffer);
|
|
5757
|
-
if (signature != dataViewSignature.getUint32(0, false)) {
|
|
5758
|
-
throw new Error(ERR_INVALID_SIGNATURE);
|
|
5759
|
-
}
|
|
5760
|
-
}
|
|
5761
|
-
});
|
|
5756
|
+
output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
|
|
5762
5757
|
}
|
|
5758
|
+
aesCrypto.pending = subarray(input, offset);
|
|
5759
|
+
return output;
|
|
5763
5760
|
}
|
|
5764
5761
|
|
|
5765
|
-
function
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
}
|
|
5772
|
-
}));
|
|
5762
|
+
async function createDecryptionKeys(decrypt, strength, password, preamble) {
|
|
5763
|
+
const passwordVerificationKey = await createKeys$1(decrypt, strength, password, subarray(preamble, 0, SALT_LENGTH[strength]));
|
|
5764
|
+
const passwordVerification = subarray(preamble, SALT_LENGTH[strength]);
|
|
5765
|
+
if (passwordVerificationKey[0] != passwordVerification[0] || passwordVerificationKey[1] != passwordVerification[1]) {
|
|
5766
|
+
throw new Error(ERR_INVALID_PASSWORD);
|
|
5767
|
+
}
|
|
5773
5768
|
}
|
|
5774
5769
|
|
|
5775
|
-
function
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5770
|
+
async function createEncryptionKeys(encrypt, strength, password) {
|
|
5771
|
+
const salt = getRandomValues(new Uint8Array(SALT_LENGTH[strength]));
|
|
5772
|
+
const passwordVerification = await createKeys$1(encrypt, strength, password, salt);
|
|
5773
|
+
return concat(salt, passwordVerification);
|
|
5774
|
+
}
|
|
5775
|
+
|
|
5776
|
+
async function createKeys$1(aesCrypto, strength, password, salt) {
|
|
5777
|
+
aesCrypto.password = null;
|
|
5778
|
+
const encodedPassword = encodeText(password);
|
|
5779
|
+
const baseKey = await importKey(RAW_FORMAT, encodedPassword, BASE_KEY_ALGORITHM, false, DERIVED_BITS_USAGE);
|
|
5780
|
+
const derivedBits = await deriveBits(Object.assign({ salt }, DERIVED_BITS_ALGORITHM), baseKey, 8 * ((KEY_LENGTH[strength] * 2) + 2));
|
|
5781
|
+
const compositeKey = new Uint8Array(derivedBits);
|
|
5782
|
+
const key = toBits(codecBytes, subarray(compositeKey, 0, KEY_LENGTH[strength]));
|
|
5783
|
+
const authentication = toBits(codecBytes, subarray(compositeKey, KEY_LENGTH[strength], KEY_LENGTH[strength] * 2));
|
|
5784
|
+
const passwordVerification = subarray(compositeKey, KEY_LENGTH[strength] * 2);
|
|
5785
|
+
Object.assign(aesCrypto, {
|
|
5786
|
+
keys: {
|
|
5787
|
+
key,
|
|
5788
|
+
authentication,
|
|
5789
|
+
passwordVerification
|
|
5790
|
+
},
|
|
5791
|
+
ctr: new CtrGladman(new Aes(key), Array.from(COUNTER_DEFAULT_VALUE)),
|
|
5792
|
+
hmac: new HmacSha1(authentication)
|
|
5781
5793
|
});
|
|
5794
|
+
return passwordVerification;
|
|
5782
5795
|
}
|
|
5783
5796
|
|
|
5784
|
-
function
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
if (useCompressionStream) {
|
|
5790
|
-
readable = pipeThrough(readable, new CodecStream(COMPRESSION_FORMAT, options));
|
|
5791
|
-
} else {
|
|
5792
|
-
throw error;
|
|
5793
|
-
}
|
|
5797
|
+
function importKey(format, password, algorithm, extractable, keyUsages) {
|
|
5798
|
+
if (IMPORT_KEY_SUPPORTED) {
|
|
5799
|
+
return subtle.importKey(format, password, algorithm, extractable, keyUsages);
|
|
5800
|
+
} else {
|
|
5801
|
+
return misc.importKey(password);
|
|
5794
5802
|
}
|
|
5795
|
-
return readable;
|
|
5796
5803
|
}
|
|
5797
5804
|
|
|
5798
|
-
function
|
|
5799
|
-
|
|
5805
|
+
async function deriveBits(algorithm, baseKey, length) {
|
|
5806
|
+
if (DERIVE_BITS_SUPPORTED) {
|
|
5807
|
+
return await subtle.deriveBits(algorithm, baseKey, length);
|
|
5808
|
+
} else {
|
|
5809
|
+
return misc.pbkdf2(baseKey, algorithm.salt, DERIVED_BITS_ALGORITHM.iterations, length);
|
|
5810
|
+
}
|
|
5811
|
+
}
|
|
5812
|
+
|
|
5813
|
+
function concat(leftArray, rightArray) {
|
|
5814
|
+
let array = leftArray;
|
|
5815
|
+
if (leftArray.length + rightArray.length) {
|
|
5816
|
+
array = new Uint8Array(leftArray.length + rightArray.length);
|
|
5817
|
+
array.set(leftArray, 0);
|
|
5818
|
+
array.set(rightArray, leftArray.length);
|
|
5819
|
+
}
|
|
5820
|
+
return array;
|
|
5821
|
+
}
|
|
5822
|
+
|
|
5823
|
+
function expand(inputArray, length) {
|
|
5824
|
+
if (length && length > inputArray.length) {
|
|
5825
|
+
const array = inputArray;
|
|
5826
|
+
inputArray = new Uint8Array(length);
|
|
5827
|
+
inputArray.set(array, 0);
|
|
5828
|
+
}
|
|
5829
|
+
return inputArray;
|
|
5830
|
+
}
|
|
5831
|
+
|
|
5832
|
+
function subarray(array, begin, end) {
|
|
5833
|
+
return array.subarray(begin, end);
|
|
5834
|
+
}
|
|
5835
|
+
|
|
5836
|
+
function fromBits(codecBytes, chunk) {
|
|
5837
|
+
return codecBytes.fromBits(chunk);
|
|
5838
|
+
}
|
|
5839
|
+
function toBits(codecBytes, chunk) {
|
|
5840
|
+
return codecBytes.toBits(chunk);
|
|
5800
5841
|
}
|
|
5801
5842
|
|
|
5802
5843
|
/*
|
|
@@ -5827,195 +5868,120 @@
|
|
|
5827
5868
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5828
5869
|
*/
|
|
5829
5870
|
|
|
5830
|
-
|
|
5831
|
-
* This program is based on JZlib 1.0.2 ymnk, JCraft,Inc.
|
|
5832
|
-
* JZlib is based on zlib-1.1.3, so all credit should go authors
|
|
5833
|
-
* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
|
5834
|
-
* and contributors of zlib.
|
|
5835
|
-
*/
|
|
5836
|
-
|
|
5837
|
-
/* global TransformStream */
|
|
5871
|
+
const HEADER_LENGTH = 12;
|
|
5838
5872
|
|
|
5839
|
-
class
|
|
5873
|
+
class ZipCryptoDecryptionStream extends TransformStream {
|
|
5840
5874
|
|
|
5841
|
-
constructor(
|
|
5842
|
-
const codec = new Codec(options);
|
|
5875
|
+
constructor(password, passwordVerification) {
|
|
5843
5876
|
super({
|
|
5844
|
-
|
|
5845
|
-
|
|
5877
|
+
start() {
|
|
5878
|
+
Object.assign(this, {
|
|
5879
|
+
password,
|
|
5880
|
+
passwordVerification
|
|
5881
|
+
});
|
|
5882
|
+
createKeys(this, password);
|
|
5846
5883
|
},
|
|
5847
|
-
|
|
5848
|
-
const
|
|
5849
|
-
if (
|
|
5850
|
-
|
|
5884
|
+
transform(chunk, controller) {
|
|
5885
|
+
const zipCrypto = this;
|
|
5886
|
+
if (zipCrypto.password) {
|
|
5887
|
+
const decryptedHeader = decrypt(zipCrypto, chunk.subarray(0, HEADER_LENGTH));
|
|
5888
|
+
zipCrypto.password = null;
|
|
5889
|
+
if (decryptedHeader[HEADER_LENGTH - 1] != zipCrypto.passwordVerification) {
|
|
5890
|
+
throw new Error(ERR_INVALID_PASSWORD);
|
|
5891
|
+
}
|
|
5892
|
+
chunk = chunk.subarray(HEADER_LENGTH);
|
|
5851
5893
|
}
|
|
5894
|
+
controller.enqueue(decrypt(zipCrypto, chunk));
|
|
5852
5895
|
}
|
|
5853
5896
|
});
|
|
5854
5897
|
}
|
|
5855
5898
|
}
|
|
5856
5899
|
|
|
5857
|
-
|
|
5858
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
5859
|
-
|
|
5860
|
-
Redistribution and use in source and binary forms, with or without
|
|
5861
|
-
modification, are permitted provided that the following conditions are met:
|
|
5862
|
-
|
|
5863
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
5864
|
-
this list of conditions and the following disclaimer.
|
|
5865
|
-
|
|
5866
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
5867
|
-
notice, this list of conditions and the following disclaimer in
|
|
5868
|
-
the documentation and/or other materials provided with the distribution.
|
|
5869
|
-
|
|
5870
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
5871
|
-
derived from this software without specific prior written permission.
|
|
5872
|
-
|
|
5873
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
5874
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
5875
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
5876
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
5877
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
5878
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
5879
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
5880
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
5881
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
5882
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5883
|
-
*/
|
|
5884
|
-
|
|
5885
|
-
const CODEC_DEFLATE = "deflate";
|
|
5886
|
-
const CODEC_INFLATE = "inflate";
|
|
5887
|
-
const MESSAGE_EVENT_TYPE = "message";
|
|
5888
|
-
const MESSAGE_START = "start";
|
|
5889
|
-
const MESSAGE_PULL = "pull";
|
|
5890
|
-
const MESSAGE_DATA = "data";
|
|
5891
|
-
const MESSAGE_ACK_DATA = "ack";
|
|
5892
|
-
const MESSAGE_CLOSE = "close";
|
|
5893
|
-
|
|
5894
|
-
class Codec {
|
|
5900
|
+
class ZipCryptoEncryptionStream extends TransformStream {
|
|
5895
5901
|
|
|
5896
|
-
constructor(
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5902
|
+
constructor(password, passwordVerification) {
|
|
5903
|
+
super({
|
|
5904
|
+
start() {
|
|
5905
|
+
Object.assign(this, {
|
|
5906
|
+
password,
|
|
5907
|
+
passwordVerification
|
|
5908
|
+
});
|
|
5909
|
+
createKeys(this, password);
|
|
5910
|
+
},
|
|
5911
|
+
transform(chunk, controller) {
|
|
5912
|
+
const zipCrypto = this;
|
|
5913
|
+
let output;
|
|
5914
|
+
let offset;
|
|
5915
|
+
if (zipCrypto.password) {
|
|
5916
|
+
zipCrypto.password = null;
|
|
5917
|
+
const header = getRandomValues(new Uint8Array(HEADER_LENGTH));
|
|
5918
|
+
header[HEADER_LENGTH - 1] = zipCrypto.passwordVerification;
|
|
5919
|
+
output = new Uint8Array(chunk.length + header.length);
|
|
5920
|
+
output.set(encrypt(zipCrypto, header), 0);
|
|
5921
|
+
offset = HEADER_LENGTH;
|
|
5922
|
+
} else {
|
|
5923
|
+
output = new Uint8Array(chunk.length);
|
|
5924
|
+
offset = 0;
|
|
5925
|
+
}
|
|
5926
|
+
output.set(encrypt(zipCrypto, chunk), offset);
|
|
5927
|
+
controller.enqueue(output);
|
|
5928
|
+
}
|
|
5910
5929
|
});
|
|
5911
5930
|
}
|
|
5931
|
+
}
|
|
5912
5932
|
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
options,
|
|
5919
|
-
config
|
|
5920
|
-
} = this;
|
|
5921
|
-
const stream = new CodecStream(options, config);
|
|
5922
|
-
let size = 0;
|
|
5923
|
-
await readable
|
|
5924
|
-
.pipeThrough(stream)
|
|
5925
|
-
.pipeThrough(new TransformStream({
|
|
5926
|
-
transform(chunk, controller) {
|
|
5927
|
-
if (chunk && chunk.length) {
|
|
5928
|
-
size += chunk.length;
|
|
5929
|
-
controller.enqueue(chunk);
|
|
5930
|
-
}
|
|
5931
|
-
}
|
|
5932
|
-
}))
|
|
5933
|
-
.pipeTo(writable, { preventClose: true, preventAbort: true });
|
|
5934
|
-
const { signature } = stream;
|
|
5935
|
-
return { size, signature };
|
|
5933
|
+
function decrypt(target, input) {
|
|
5934
|
+
const output = new Uint8Array(input.length);
|
|
5935
|
+
for (let index = 0; index < input.length; index++) {
|
|
5936
|
+
output[index] = getByte(target) ^ input[index];
|
|
5937
|
+
updateKeys(target, output[index]);
|
|
5936
5938
|
}
|
|
5939
|
+
return output;
|
|
5937
5940
|
}
|
|
5938
5941
|
|
|
5939
|
-
function
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
}
|
|
5942
|
+
function encrypt(target, input) {
|
|
5943
|
+
const output = new Uint8Array(input.length);
|
|
5944
|
+
for (let index = 0; index < input.length; index++) {
|
|
5945
|
+
output[index] = getByte(target) ^ input[index];
|
|
5946
|
+
updateKeys(target, input[index]);
|
|
5947
|
+
}
|
|
5948
|
+
return output;
|
|
5945
5949
|
}
|
|
5946
5950
|
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
the documentation and/or other materials provided with the distribution.
|
|
5959
|
-
|
|
5960
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
5961
|
-
derived from this software without specific prior written permission.
|
|
5962
|
-
|
|
5963
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
5964
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
5965
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
5966
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
5967
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
5968
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
5969
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
5970
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
5971
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
5972
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5973
|
-
*/
|
|
5974
|
-
|
|
5975
|
-
const MAX_32_BITS = 0xffffffff;
|
|
5976
|
-
const MAX_16_BITS = 0xffff;
|
|
5977
|
-
const COMPRESSION_METHOD_DEFLATE = 0x08;
|
|
5978
|
-
const COMPRESSION_METHOD_STORE = 0x00;
|
|
5979
|
-
const COMPRESSION_METHOD_AES = 0x63;
|
|
5980
|
-
|
|
5981
|
-
const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50;
|
|
5982
|
-
const DATA_DESCRIPTOR_RECORD_SIGNATURE = 0x08074b50;
|
|
5983
|
-
const CENTRAL_FILE_HEADER_SIGNATURE = 0x02014b50;
|
|
5984
|
-
const END_OF_CENTRAL_DIR_SIGNATURE = 0x06054b50;
|
|
5985
|
-
const ZIP64_END_OF_CENTRAL_DIR_SIGNATURE = 0x06064b50;
|
|
5986
|
-
const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE = 0x07064b50;
|
|
5987
|
-
const END_OF_CENTRAL_DIR_LENGTH = 22;
|
|
5988
|
-
const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH = 20;
|
|
5989
|
-
const ZIP64_END_OF_CENTRAL_DIR_LENGTH = 56;
|
|
5990
|
-
const ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH = END_OF_CENTRAL_DIR_LENGTH + ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH + ZIP64_END_OF_CENTRAL_DIR_LENGTH;
|
|
5991
|
-
|
|
5992
|
-
const ZIP64_TOTAL_NUMBER_OF_DISKS = 1;
|
|
5993
|
-
|
|
5994
|
-
const EXTRAFIELD_TYPE_ZIP64 = 0x0001;
|
|
5995
|
-
const EXTRAFIELD_TYPE_AES = 0x9901;
|
|
5996
|
-
const EXTRAFIELD_TYPE_NTFS = 0x000a;
|
|
5997
|
-
const EXTRAFIELD_TYPE_NTFS_TAG1 = 0x0001;
|
|
5998
|
-
const EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP = 0x5455;
|
|
5999
|
-
const EXTRAFIELD_TYPE_UNICODE_PATH = 0x7075;
|
|
6000
|
-
const EXTRAFIELD_TYPE_UNICODE_COMMENT = 0x6375;
|
|
6001
|
-
|
|
6002
|
-
const BITFLAG_ENCRYPTED = 0x01;
|
|
6003
|
-
const BITFLAG_LEVEL = 0x06;
|
|
6004
|
-
const BITFLAG_DATA_DESCRIPTOR = 0x0008;
|
|
6005
|
-
const BITFLAG_LANG_ENCODING_FLAG = 0x0800;
|
|
6006
|
-
const FILE_ATTR_MSDOS_DIR_MASK = 0x10;
|
|
5951
|
+
function createKeys(target, password) {
|
|
5952
|
+
const keys = [0x12345678, 0x23456789, 0x34567890];
|
|
5953
|
+
Object.assign(target, {
|
|
5954
|
+
keys,
|
|
5955
|
+
crcKey0: new Crc32(keys[0]),
|
|
5956
|
+
crcKey2: new Crc32(keys[2]),
|
|
5957
|
+
});
|
|
5958
|
+
for (let index = 0; index < password.length; index++) {
|
|
5959
|
+
updateKeys(target, password.charCodeAt(index));
|
|
5960
|
+
}
|
|
5961
|
+
}
|
|
6007
5962
|
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
5963
|
+
function updateKeys(target, byte) {
|
|
5964
|
+
let [key0, key1, key2] = target.keys;
|
|
5965
|
+
target.crcKey0.append([byte]);
|
|
5966
|
+
key0 = ~target.crcKey0.get();
|
|
5967
|
+
key1 = getInt32(Math.imul(getInt32(key1 + getInt8(key0)), 134775813) + 1);
|
|
5968
|
+
target.crcKey2.append([key1 >>> 24]);
|
|
5969
|
+
key2 = ~target.crcKey2.get();
|
|
5970
|
+
target.keys = [key0, key1, key2];
|
|
5971
|
+
}
|
|
6011
5972
|
|
|
6012
|
-
|
|
5973
|
+
function getByte(target) {
|
|
5974
|
+
const temp = target.keys[2] | 2;
|
|
5975
|
+
return getInt8(Math.imul(temp, (temp ^ 1)) >>> 8);
|
|
5976
|
+
}
|
|
6013
5977
|
|
|
6014
|
-
|
|
6015
|
-
|
|
5978
|
+
function getInt8(number) {
|
|
5979
|
+
return number & 0xFF;
|
|
5980
|
+
}
|
|
6016
5981
|
|
|
6017
|
-
|
|
6018
|
-
|
|
5982
|
+
function getInt32(number) {
|
|
5983
|
+
return number & 0xFFFFFFFF;
|
|
5984
|
+
}
|
|
6019
5985
|
|
|
6020
5986
|
/*
|
|
6021
5987
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
@@ -6045,93 +6011,115 @@
|
|
|
6045
6011
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
6046
6012
|
*/
|
|
6047
6013
|
|
|
6048
|
-
const
|
|
6049
|
-
let maxWorkers = 2;
|
|
6050
|
-
try {
|
|
6051
|
-
if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
|
|
6052
|
-
maxWorkers = navigator.hardwareConcurrency;
|
|
6053
|
-
}
|
|
6054
|
-
} catch (_error) {
|
|
6055
|
-
// ignored
|
|
6056
|
-
}
|
|
6057
|
-
const DEFAULT_CONFIGURATION = {
|
|
6058
|
-
chunkSize: 512 * 1024,
|
|
6059
|
-
maxWorkers,
|
|
6060
|
-
terminateWorkerTimeout: 5000,
|
|
6061
|
-
useWebWorkers: true,
|
|
6062
|
-
useCompressionStream: true,
|
|
6063
|
-
workerScripts: UNDEFINED_VALUE,
|
|
6064
|
-
CompressionStreamNative: typeof CompressionStream != UNDEFINED_TYPE && CompressionStream,
|
|
6065
|
-
DecompressionStreamNative: typeof DecompressionStream != UNDEFINED_TYPE && DecompressionStream
|
|
6066
|
-
};
|
|
6014
|
+
const COMPRESSION_FORMAT = "deflate-raw";
|
|
6067
6015
|
|
|
6068
|
-
|
|
6016
|
+
class DeflateStream extends TransformStream {
|
|
6069
6017
|
|
|
6070
|
-
|
|
6071
|
-
|
|
6018
|
+
constructor(options, { chunkSize, CompressionStream, CompressionStreamNative }) {
|
|
6019
|
+
super({});
|
|
6020
|
+
const { compressed, encrypted, useCompressionStream, password, passwordVerification, encryptionStrength, zipCrypto, signed, level } = options;
|
|
6021
|
+
const stream = this;
|
|
6022
|
+
let crc32Stream, encryptionStream;
|
|
6023
|
+
let readable = filterEmptyChunks(super.readable);
|
|
6024
|
+
if ((!encrypted || zipCrypto) && signed) {
|
|
6025
|
+
[readable, crc32Stream] = readable.tee();
|
|
6026
|
+
crc32Stream = pipeThrough(crc32Stream, new Crc32Stream());
|
|
6027
|
+
}
|
|
6028
|
+
if (compressed) {
|
|
6029
|
+
readable = pipeThroughCommpressionStream(readable, useCompressionStream, { level, chunkSize }, CompressionStreamNative, CompressionStream);
|
|
6030
|
+
}
|
|
6031
|
+
if (encrypted) {
|
|
6032
|
+
if (zipCrypto) {
|
|
6033
|
+
readable = pipeThrough(readable, new ZipCryptoEncryptionStream(password, passwordVerification));
|
|
6034
|
+
} else {
|
|
6035
|
+
encryptionStream = new AESEncryptionStream(password, encryptionStrength);
|
|
6036
|
+
readable = pipeThrough(readable, encryptionStream);
|
|
6037
|
+
}
|
|
6038
|
+
}
|
|
6039
|
+
setReadable(stream, readable, async () => {
|
|
6040
|
+
let signature;
|
|
6041
|
+
if (encrypted && !zipCrypto) {
|
|
6042
|
+
signature = encryptionStream.signature;
|
|
6043
|
+
}
|
|
6044
|
+
if ((!encrypted || zipCrypto) && signed) {
|
|
6045
|
+
signature = await crc32Stream.getReader().read();
|
|
6046
|
+
signature = new DataView(signature.value.buffer).getUint32(0);
|
|
6047
|
+
}
|
|
6048
|
+
stream.signature = signature;
|
|
6049
|
+
});
|
|
6050
|
+
}
|
|
6072
6051
|
}
|
|
6073
6052
|
|
|
6074
|
-
|
|
6075
|
-
return Math.max(config.chunkSize, MINIMUM_CHUNK_SIZE);
|
|
6076
|
-
}
|
|
6053
|
+
class InflateStream extends TransformStream {
|
|
6077
6054
|
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
DecompressionStream,
|
|
6090
|
-
workerScripts
|
|
6091
|
-
} = configuration;
|
|
6092
|
-
setIfDefined("baseURL", baseURL);
|
|
6093
|
-
setIfDefined("chunkSize", chunkSize);
|
|
6094
|
-
setIfDefined("maxWorkers", maxWorkers);
|
|
6095
|
-
setIfDefined("terminateWorkerTimeout", terminateWorkerTimeout);
|
|
6096
|
-
setIfDefined("useCompressionStream", useCompressionStream);
|
|
6097
|
-
setIfDefined("useWebWorkers", useWebWorkers);
|
|
6098
|
-
if (Deflate) {
|
|
6099
|
-
config.CompressionStream = getCodecStreamClass(Deflate);
|
|
6100
|
-
}
|
|
6101
|
-
if (Inflate) {
|
|
6102
|
-
config.DecompressionStream = getCodecStreamClass(Inflate);
|
|
6103
|
-
}
|
|
6104
|
-
setIfDefined("CompressionStream", CompressionStream);
|
|
6105
|
-
setIfDefined("DecompressionStream", DecompressionStream);
|
|
6106
|
-
if (workerScripts !== UNDEFINED_VALUE) {
|
|
6107
|
-
const { deflate, inflate } = workerScripts;
|
|
6108
|
-
if (deflate || inflate) {
|
|
6109
|
-
if (!config.workerScripts) {
|
|
6110
|
-
config.workerScripts = {};
|
|
6055
|
+
constructor(options, { chunkSize, DecompressionStream, DecompressionStreamNative }) {
|
|
6056
|
+
super({});
|
|
6057
|
+
const { zipCrypto, encrypted, password, passwordVerification, signed, signature, encryptionStrength, compressed, useCompressionStream } = options;
|
|
6058
|
+
let crc32Stream, decryptionStream;
|
|
6059
|
+
let readable = filterEmptyChunks(super.readable);
|
|
6060
|
+
if (encrypted) {
|
|
6061
|
+
if (zipCrypto) {
|
|
6062
|
+
readable = pipeThrough(readable, new ZipCryptoDecryptionStream(password, passwordVerification));
|
|
6063
|
+
} else {
|
|
6064
|
+
decryptionStream = new AESDecryptionStream(password, signed, encryptionStrength);
|
|
6065
|
+
readable = pipeThrough(readable, decryptionStream);
|
|
6111
6066
|
}
|
|
6112
6067
|
}
|
|
6113
|
-
if (
|
|
6114
|
-
|
|
6115
|
-
throw new Error("workerScripts.deflate must be an array");
|
|
6116
|
-
}
|
|
6117
|
-
config.workerScripts.deflate = deflate;
|
|
6068
|
+
if (compressed) {
|
|
6069
|
+
readable = pipeThroughCommpressionStream(readable, useCompressionStream, { chunkSize }, DecompressionStreamNative, DecompressionStream);
|
|
6118
6070
|
}
|
|
6119
|
-
if (
|
|
6120
|
-
|
|
6121
|
-
|
|
6071
|
+
if ((!encrypted || zipCrypto) && signed) {
|
|
6072
|
+
[readable, crc32Stream] = readable.tee();
|
|
6073
|
+
crc32Stream = pipeThrough(crc32Stream, new Crc32Stream());
|
|
6074
|
+
}
|
|
6075
|
+
setReadable(this, readable, async () => {
|
|
6076
|
+
if ((!encrypted || zipCrypto) && signed) {
|
|
6077
|
+
const streamSignature = await crc32Stream.getReader().read();
|
|
6078
|
+
const dataViewSignature = new DataView(streamSignature.value.buffer);
|
|
6079
|
+
if (signature != dataViewSignature.getUint32(0, false)) {
|
|
6080
|
+
throw new Error(ERR_INVALID_SIGNATURE);
|
|
6081
|
+
}
|
|
6082
|
+
}
|
|
6083
|
+
});
|
|
6084
|
+
}
|
|
6085
|
+
}
|
|
6086
|
+
|
|
6087
|
+
function filterEmptyChunks(readable) {
|
|
6088
|
+
return pipeThrough(readable, new TransformStream({
|
|
6089
|
+
transform(chunk, controller) {
|
|
6090
|
+
if (chunk && chunk.length) {
|
|
6091
|
+
controller.enqueue(chunk);
|
|
6122
6092
|
}
|
|
6123
|
-
config.workerScripts.inflate = inflate;
|
|
6124
6093
|
}
|
|
6125
|
-
}
|
|
6094
|
+
}));
|
|
6126
6095
|
}
|
|
6127
6096
|
|
|
6128
|
-
function
|
|
6129
|
-
|
|
6130
|
-
|
|
6097
|
+
function setReadable(stream, readable, flush) {
|
|
6098
|
+
readable = pipeThrough(readable, new TransformStream({ flush }));
|
|
6099
|
+
Object.defineProperty(stream, "readable", {
|
|
6100
|
+
get() {
|
|
6101
|
+
return readable;
|
|
6102
|
+
}
|
|
6103
|
+
});
|
|
6104
|
+
}
|
|
6105
|
+
|
|
6106
|
+
function pipeThroughCommpressionStream(readable, useCompressionStream, options, CodecStreamNative, CodecStream) {
|
|
6107
|
+
try {
|
|
6108
|
+
const CompressionStream = useCompressionStream && CodecStreamNative ? CodecStreamNative : CodecStream;
|
|
6109
|
+
readable = pipeThrough(readable, new CompressionStream(COMPRESSION_FORMAT, options));
|
|
6110
|
+
} catch (error) {
|
|
6111
|
+
if (useCompressionStream) {
|
|
6112
|
+
readable = pipeThrough(readable, new CodecStream(COMPRESSION_FORMAT, options));
|
|
6113
|
+
} else {
|
|
6114
|
+
throw error;
|
|
6115
|
+
}
|
|
6131
6116
|
}
|
|
6117
|
+
return readable;
|
|
6132
6118
|
}
|
|
6133
6119
|
|
|
6134
|
-
function e(e){const t=()=>URL.createObjectURL(new Blob(['const{Array:e,Object:t,Math:n,Error:r,Uint8Array:s,Uint16Array:i,Uint32Array:o,Int32Array:c,Map:f,DataView:a,Promise:l,TextEncoder:u,crypto:w,postMessage:h,TransformStream:d,ReadableStream:p,WritableStream:y,CompressionStream:m,DecompressionStream:b}=self,g=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;g[e]=t}class k{constructor(e){this.t=e||-1}append(e){let t=0|this.t;for(let n=0,r=0|e.length;r>n;n++)t=t>>>8^g[255&(t^e[n])];this.t=t}get(){return~this.t}}class v extends d{constructor(){const e=new k;super({transform(t){e.append(t)},flush(t){const n=new s(4);new a(n.buffer).setUint32(0,e.get()),t.enqueue(n)}})}}const S={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],r=S.i(n);return 32===r?e.concat(t):S.o(t,r,0|n,e.slice(0,e.length-1))},l(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+S.i(n)},u(e,t){if(32*e.length<t)return e;const r=(e=e.slice(0,n.ceil(t/32))).length;return t&=31,r>0&&t&&(e[r-1]=S.h(t,e[r-1]&2147483648>>t-1,1)),e},h:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,i:e=>n.round(e/1099511627776)||32,o(e,t,n,r){for(void 0===r&&(r=[]);t>=32;t-=32)r.push(n),n=0;if(0===t)return r.concat(e);for(let s=0;s<e.length;s++)r.push(n|e[s]>>>t),n=e[s]<<32-t;const s=e.length?e[e.length-1]:0,i=S.i(s);return r.push(S.h(t+i&31,t+i>32?n:r.pop(),1)),r}},C={p:{m(e){const t=S.l(e)/8,n=new s(t);let r;for(let s=0;t>s;s++)0==(3&s)&&(r=e[s/4]),n[s]=r>>>24,r<<=8;return n},g(e){const t=[];let n,r=0;for(n=0;n<e.length;n++)r=r<<8|e[n],3==(3&n)&&(t.push(r),r=0);return 3&n&&t.push(S.h(8*(3&n),r)),t}}},z={k:function(e){e?(this.v=e.v.slice(0),this.S=e.S.slice(0),this.C=e.C):this.reset()}};z.k.prototype={blockSize:512,reset(){const e=this;return e.v=this._.slice(0),e.S=[],e.C=0,e},update(e){const t=this;"string"==typeof e&&(e=C.I.g(e));const n=t.S=S.concat(t.S,e),s=t.C,i=t.C=s+S.l(e);if(i>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new o(n);let f=0;for(let e=t.blockSize+s-(t.blockSize+s&t.blockSize-1);i>=e;e+=t.blockSize)t.A(c.subarray(16*f,16*(f+1))),f+=1;return n.splice(0,16*f),t},D(){const e=this;let t=e.S;const r=e.v;t=S.concat(t,[S.h(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(n.floor(e.C/4294967296)),t.push(0|e.C);t.length;)e.A(t.splice(0,16));return e.reset(),r},_:[1732584193,4023233417,2562383102,271733878,3285377520],V:[1518500249,1859775393,2400959708,3395469782],R:(e,t,n,r)=>e>19?e>39?e>59?e>79?void 0:t^n^r:t&n|t&r|n&r:t^n^r:t&n|~t&r,B:(e,t)=>t<<e|t>>>32-e,A(t){const r=this,s=r.v,i=e(80);for(let e=0;16>e;e++)i[e]=t[e];let o=s[0],c=s[1],f=s[2],a=s[3],l=s[4];for(let e=0;79>=e;e++){16>e||(i[e]=r.B(1,i[e-3]^i[e-8]^i[e-14]^i[e-16]));const t=r.B(5,o)+r.R(e,c,f,a)+l+i[e]+r.V[n.floor(e/20)]|0;l=a,a=f,f=r.B(30,c),c=o,o=t}s[0]=s[0]+o|0,s[1]=s[1]+c|0,s[2]=s[2]+f|0,s[3]=s[3]+a|0,s[4]=s[4]+l|0}};const _={getRandomValues(e){const t=new o(e.buffer),r=e=>{let t=987654321;const r=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&r,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&r)&r)/4294967296+.5)*(n.random()>.5?1:-1))};for(let s,i=0;i<e.length;i+=4){const e=r(4294967296*(s||n.random()));s=987654071*e(),t[i/4]=4294967296*e()|0}return e}},I={importKey:e=>new I.M(C.p.g(e)),K(e,t,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const i=1+(s>>5)<<2;let o,c,f,l,u;const w=new ArrayBuffer(i),h=new a(w);let d=0;const p=S;for(t=C.p.g(t),u=1;(i||1)>d;u++){for(o=c=e.encrypt(p.concat(t,[u])),f=1;n>f;f++)for(c=e.encrypt(c),l=0;l<c.length;l++)o[l]^=c[l];for(f=0;(i||1)>d&&f<o.length;f++)h.setInt32(d,o[f]),d+=4}return w.slice(0,s/8)},M:class{constructor(e){const t=this,n=t.N=z.k,r=[[],[]],s=n.prototype.blockSize/32;t.P=[new n,new n],e.length>s&&(e=n.hash(e));for(let t=0;s>t;t++)r[0][t]=909522486^e[t],r[1][t]=1549556828^e[t];t.P[0].update(r[0]),t.P[1].update(r[1]),t.U=new n(t.P[0])}reset(){const e=this;e.U=new e.N(e.P[0]),e.T=!1}update(e){this.T=!0,this.U.update(e)}digest(){const e=this,t=e.U.D(),n=new e.N(e.P[1]).update(t).D();return e.reset(),n}encrypt(e){if(this.T)throw new r("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},x=void 0!==w&&"function"==typeof w.getRandomValues;function A(e){return x?w.getRandomValues(e):_.getRandomValues(e)}const D={name:"PBKDF2"},V=t.assign({hash:{name:"HMAC"}},D),R=t.assign({iterations:1e3,hash:{name:"SHA-1"}},D),B=["deriveBits"],E=[8,12,16],M=[16,24,32],K=[0,0,0,0],N=void 0!==w,P=N&&w.subtle,U=N&&void 0!==P,T=N&&U&&"function"==typeof P.importKey,W=N&&U&&"function"==typeof P.deriveBits,H=C.p,L=class{constructor(e){const t=this;t.W=[[[],[],[],[],[]],[[],[],[],[],[]]],t.W[0][0][0]||t.H();const n=t.W[0][4],s=t.W[1],i=e.length;let o,c,f,a=1;if(4!==i&&6!==i&&8!==i)throw new r("invalid aes key size");for(t.V=[c=e.slice(0),f=[]],o=i;4*i+28>o;o++){let e=c[o-1];(o%i==0||8===i&&o%i==4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],o%i==0&&(e=e<<8^e>>>24^a<<24,a=a<<1^283*(a>>7))),c[o]=c[o-i]^e}for(let e=0;o;e++,o--){const t=c[3&e?o:o-4];f[e]=4>=o||4>e?t:s[0][n[t>>>24]]^s[1][n[t>>16&255]]^s[2][n[t>>8&255]]^s[3][n[255&t]]}}encrypt(e){return this.L(e,0)}decrypt(e){return this.L(e,1)}H(){const e=this.W[0],t=this.W[1],n=e[4],r=t[4],s=[],i=[];let o,c,f,a;for(let e=0;256>e;e++)i[(s[e]=e<<1^283*(e>>7))^e]=e;for(let l=o=0;!n[l];l^=c||1,o=i[o]||1){let i=o^o<<1^o<<2^o<<3^o<<4;i=i>>8^255&i^99,n[l]=i,r[i]=l,a=s[f=s[c=s[l]]];let u=16843009*a^65537*f^257*c^16843008*l,w=257*s[i]^16843008*i;for(let n=0;4>n;n++)e[n][l]=w=w<<24^w>>>8,t[n][i]=u=u<<24^u>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}L(e,t){if(4!==e.length)throw new r("invalid aes block size");const n=this.V[t],s=n.length/4-2,i=[0,0,0,0],o=this.W[t],c=o[0],f=o[1],a=o[2],l=o[3],u=o[4];let w,h,d,p=e[0]^n[0],y=e[t?3:1]^n[1],m=e[2]^n[2],b=e[t?1:3]^n[3],g=4;for(let e=0;s>e;e++)w=c[p>>>24]^f[y>>16&255]^a[m>>8&255]^l[255&b]^n[g],h=c[y>>>24]^f[m>>16&255]^a[b>>8&255]^l[255&p]^n[g+1],d=c[m>>>24]^f[b>>16&255]^a[p>>8&255]^l[255&y]^n[g+2],b=c[b>>>24]^f[p>>16&255]^a[y>>8&255]^l[255&m]^n[g+3],g+=4,p=w,y=h,m=d;for(let e=0;4>e;e++)i[t?3&-e:e]=u[p>>>24]<<24^u[y>>16&255]<<16^u[m>>8&255]<<8^u[255&b]^n[g++],w=p,p=y,y=m,m=b,b=w;return i}},j=class{constructor(e,t){this.j=e,this.F=t,this.O=t}reset(){this.O=this.F}update(e){return this.q(this.j,e,this.O)}G(e){if(255==(e>>24&255)){let t=e>>16&255,n=e>>8&255,r=255&e;255===t?(t=0,255===n?(n=0,255===r?r=0:++r):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=r}else e+=1<<24;return e}J(e){0===(e[0]=this.G(e[0]))&&(e[1]=this.G(e[1]))}q(e,t,n){let r;if(!(r=t.length))return[];const s=S.l(t);for(let s=0;r>s;s+=4){this.J(n);const r=e.encrypt(n);t[s]^=r[0],t[s+1]^=r[1],t[s+2]^=r[2],t[s+3]^=r[3]}return S.u(t,s)}},F=I.M;class O extends d{constructor(e,n,i){super({start(){t.assign(this,{ready:new l((e=>this.X=e)),password:e,signed:n,Y:i-1,pending:new s})},async transform(e,t){const n=this,{password:i,Y:o,X:c,ready:f}=n;i?(await(async(e,t,n,s)=>{const i=await J(e,t,n,X(s,0,E[t])),o=X(s,E[t]);if(i[0]!=o[0]||i[1]!=o[1])throw new r("Invalid password")})(n,o,i,X(e,0,E[o]+2)),e=X(e,E[o]+2),c()):await f;const a=new s(e.length-10-(e.length-10)%16);t.enqueue(G(n,e,a,0,10,!0))},async flush(e){const{signed:t,Z:n,$:i,pending:o,ready:c}=this;await c;const f=X(o,0,o.length-10),a=X(o,o.length-10);let l=new s;if(f.length){const e=Z(H,f);i.update(e);const t=n.update(e);l=Y(H,t)}if(t){const e=X(Y(H,i.digest()),0,10);for(let t=0;10>t;t++)if(e[t]!=a[t])throw new r("Invalid signature")}e.enqueue(l)}})}}class q extends d{constructor(e,n){let r;super({start(){t.assign(this,{ready:new l((e=>this.X=e)),password:e,Y:n-1,pending:new s})},async transform(e,t){const n=this,{password:r,Y:i,X:o,ready:c}=n;let f=new s;r?(f=await(async(e,t,n)=>{const r=A(new s(E[t]));return Q(r,await J(e,t,n,r))})(n,i,r),o()):await c;const a=new s(f.length+e.length-e.length%16);a.set(f,0),t.enqueue(G(n,e,a,f.length,0))},async flush(e){const{Z:t,$:n,pending:i,ready:o}=this;await o;let c=new s;if(i.length){const e=t.update(Z(H,i));n.update(e),c=Y(H,e)}r.signature=Y(H,n.digest()).slice(0,10),e.enqueue(Q(c,r.signature))}}),r=this}}function G(e,t,n,r,i,o){const{Z:c,$:f,pending:a}=e,l=t.length-i;let u;for(a.length&&(t=Q(a,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new s(t)).set(n,0)}return e})(n,l-l%16)),u=0;l-16>=u;u+=16){const e=Z(H,X(t,u,u+16));o&&f.update(e);const s=c.update(e);o||f.update(s),n.set(Y(H,s),u+r)}return e.pending=X(t,u),n}async function J(n,r,i,o){n.password=null;const c=(e=>{if(void 0===u){const t=new s((e=unescape(encodeURIComponent(e))).length);for(let n=0;n<t.length;n++)t[n]=e.charCodeAt(n);return t}return(new u).encode(e)})(i),f=await((e,t,n,r,s)=>T?P.importKey("raw",t,n,!1,s):I.importKey(t))(0,c,V,0,B),a=await(async(e,t,n)=>W?await P.deriveBits(e,t,n):I.K(t,e.salt,R.iterations,n))(t.assign({salt:o},R),f,8*(2*M[r]+2)),l=new s(a),w=Z(H,X(l,0,M[r])),h=Z(H,X(l,M[r],2*M[r])),d=X(l,2*M[r]);return t.assign(n,{keys:{key:w,ee:h,passwordVerification:d},Z:new j(new L(w),e.from(K)),$:new F(h)}),d}function Q(e,t){let n=e;return e.length+t.length&&(n=new s(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function X(e,t,n){return e.subarray(t,n)}function Y(e,t){return e.m(t)}function Z(e,t){return e.g(t)}class $ extends d{constructor(e,n){super({start(){t.assign(this,{password:e,passwordVerification:n}),re(this,e)},transform(e,t){const n=this;if(n.password){const t=te(n,e.subarray(0,12));if(n.password=null,t[11]!=n.passwordVerification)throw new r("Invalid password");e=e.subarray(12)}t.enqueue(te(n,e))}})}}class ee extends d{constructor(e,n){super({start(){t.assign(this,{password:e,passwordVerification:n}),re(this,e)},transform(e,t){const n=this;let r,i;if(n.password){n.password=null;const t=A(new s(12));t[11]=n.passwordVerification,r=new s(e.length+t.length),r.set(ne(n,t),0),i=12}else r=new s(e.length),i=0;r.set(ne(n,e),i),t.enqueue(r)}})}}function te(e,t){const n=new s(t.length);for(let r=0;r<t.length;r++)n[r]=ie(e)^t[r],se(e,n[r]);return n}function ne(e,t){const n=new s(t.length);for(let r=0;r<t.length;r++)n[r]=ie(e)^t[r],se(e,t[r]);return n}function re(e,n){const r=[305419896,591751049,878082192];t.assign(e,{keys:r,te:new k(r[0]),ne:new k(r[2])});for(let t=0;t<n.length;t++)se(e,n.charCodeAt(t))}function se(e,t){let[r,s,i]=e.keys;e.te.append([t]),r=~e.te.get(),s=ce(n.imul(ce(s+oe(r)),134775813)+1),e.ne.append([s>>>24]),i=~e.ne.get(),e.keys=[r,s,i]}function ie(e){const t=2|e.keys[2];return oe(n.imul(t,1^t)>>>8)}function oe(e){return 255&e}function ce(e){return 4294967295&e}class fe extends d{constructor(e,{chunkSize:t,CompressionStream:n,re:r}){super({});const{compressed:s,encrypted:i,useCompressionStream:o,password:c,passwordVerification:f,encryptionStrength:l,zipCrypto:u,signed:w,level:h}=e,d=this;let p,y,m=le(super.readable);i&&!u||!w||([m,p]=m.tee(),p=he(p,new v)),s&&(m=we(m,o,{level:h,chunkSize:t},r,n)),i&&(u?m=he(m,new ee(c,f)):(y=new q(c,l),m=he(m,y))),ue(d,m,(async()=>{let e;i&&!u&&(e=y.signature),i&&!u||!w||(e=await p.getReader().read(),e=new a(e.value.buffer).getUint32(0)),d.signature=e}))}}class ae extends d{constructor(e,{chunkSize:t,DecompressionStream:n,se:s}){super({});const{zipCrypto:i,encrypted:o,password:c,passwordVerification:f,signed:l,signature:u,encryptionStrength:w,compressed:h,useCompressionStream:d}=e;let p,y,m=le(super.readable);o&&(i?m=he(m,new $(c,f)):(y=new O(c,l,w),m=he(m,y))),h&&(m=we(m,d,{chunkSize:t},s,n)),o&&!i||!l||([m,p]=m.tee(),p=he(p,new v)),ue(this,m,(async()=>{if((!o||i)&&l){const e=await p.getReader().read(),t=new a(e.value.buffer);if(u!=t.getUint32(0,!1))throw new r("Invalid signature")}}))}}function le(e){return he(e,new d({transform(e,t){e&&e.length&&t.enqueue(e)}}))}function ue(e,n,r){n=he(n,new d({flush:r})),t.defineProperty(e,"readable",{get:()=>n})}function we(e,t,n,r,s){try{e=he(e,new(t&&r?r:s)("deflate-raw",n))}catch(r){if(!t)throw r;e=he(e,new s("deflate-raw",n))}return e}function he(e,t){return e.pipeThrough(t)}class de extends d{constructor(e,t){const n=new e(t);super({transform(e,t){t.enqueue(n.append(e))},flush(e){const t=n.flush();t&&e.enqueue(t)}})}}class pe{constructor(e,n,r,s){const{codecType:i}=r;let o;i.startsWith("deflate")?o=fe:i.startsWith("inflate")&&(o=ae),t.assign(this,{ie:o,readable:e,writable:n,options:r,config:s})}async oe(){const{ie:e,readable:t,writable:n,options:r,config:s}=this,i=new e(r,s);let o=0;await t.pipeThrough(i).pipeThrough(new d({transform(e,t){e&&e.length&&(o+=e.length,t.enqueue(e))}})).pipeTo(n,{ce:!0,fe:!0});const{signature:c}=i;return{size:o,signature:c}}}function ye(e){return class extends de{constructor(t,n){super(e,n)}}}const me=new f,be=new f;let ge,ke=0;async function ve(e){try{const{options:t,scripts:n,config:r}=e;n&&n.length&&importScripts.apply(void 0,n),self.initCodec&&self.initCodec(),r.re=self.CompressionStream,r.se=self.DecompressionStream,self.Deflate&&(r.CompressionStream=ye(self.Deflate)),self.Inflate&&(r.DecompressionStream=ye(self.Inflate));const s={highWaterMark:1,size:()=>r.chunkSize},i=e.readable||new p({async pull(e){let t=new l((e=>me.set(ke,e)));Se({type:"pull",messageId:ke}),ke=(ke+1)%Number.MAX_SAFE_INTEGER;const{value:n,done:r}=await t;e.enqueue(n),r&&e.close()}},s),o=e.writable||new y({async write(e){let t;const n=new l((e=>t=e));be.set(ke,t),Se({type:"data",data:e,messageId:ke}),ke=(ke+1)%Number.MAX_SAFE_INTEGER,await n}},s);ge=new pe(i,o,t,r);const c=await ge.oe();try{await o.close()}catch(e){}Se({type:"close",result:c})}catch(e){Ce(e)}}function Se(e){if(e.data){let{data:t}=e;if(t&&t.length)try{t=new s(t),e.data=t.buffer,h(e,[e.data])}catch(t){h(e)}else h(e)}else h(e)}function Ce(e){const{message:t,stack:n,code:r,name:s}=e;h({error:{message:t,stack:n,code:r,name:s}})}function ze(t){return _e(t.map((([t,n])=>new e(t).fill(n,0,t))))}function _e(t){return t.reduce(((t,n)=>t.concat(e.isArray(n)?_e(n):n)),[])}addEventListener("message",(async e=>{const t=e.data,{type:n,messageId:r,data:i,done:o}=t;try{if("start"==n&&ve(t),"data"==n){const e=me.get(r);me.delete(r),e({value:new s(i),done:o})}if("ack"==n){const e=be.get(r);be.delete(r),e()}}catch(e){Ce(e)}}));const Ie=[0,1,2,3].concat(...ze([[2,4],[2,5],[4,6],[4,7],[8,8],[8,9],[16,10],[16,11],[32,12],[32,13],[64,14],[64,15],[2,0],[1,16],[1,17],[2,18],[2,19],[4,20],[4,21],[8,22],[8,23],[16,24],[16,25],[32,26],[32,27],[64,28],[64,29]]));function xe(){const e=this;function t(e,t){let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1}e.ae=r=>{const s=e.le,i=e.we.ue,o=e.we.he;let c,f,a,l=-1;for(r.de=0,r.pe=573,c=0;o>c;c++)0!==s[2*c]?(r.ye[++r.de]=l=c,r.me[c]=0):s[2*c+1]=0;for(;2>r.de;)a=r.ye[++r.de]=2>l?++l:0,s[2*a]=1,r.me[a]=0,r.be--,i&&(r.ge-=i[2*a+1]);for(e.ke=l,c=n.floor(r.de/2);c>=1;c--)r.ve(s,c);a=o;do{c=r.ye[1],r.ye[1]=r.ye[r.de--],r.ve(s,1),f=r.ye[1],r.ye[--r.pe]=c,r.ye[--r.pe]=f,s[2*a]=s[2*c]+s[2*f],r.me[a]=n.max(r.me[c],r.me[f])+1,s[2*c+1]=s[2*f+1]=a,r.ye[1]=a++,r.ve(s,1)}while(r.de>=2);r.ye[--r.pe]=r.ye[1],(t=>{const n=e.le,r=e.we.ue,s=e.we.Se,i=e.we.Ce,o=e.we.ze;let c,f,a,l,u,w,h=0;for(l=0;15>=l;l++)t._e[l]=0;for(n[2*t.ye[t.pe]+1]=0,c=t.pe+1;573>c;c++)f=t.ye[c],l=n[2*n[2*f+1]+1]+1,l>o&&(l=o,h++),n[2*f+1]=l,f>e.ke||(t._e[l]++,u=0,i>f||(u=s[f-i]),w=n[2*f],t.be+=w*(l+u),r&&(t.ge+=w*(r[2*f+1]+u)));if(0!==h){do{for(l=o-1;0===t._e[l];)l--;t._e[l]--,t._e[l+1]+=2,t._e[o]--,h-=2}while(h>0);for(l=o;0!==l;l--)for(f=t._e[l];0!==f;)a=t.ye[--c],a>e.ke||(n[2*a+1]!=l&&(t.be+=(l-n[2*a+1])*n[2*a],n[2*a+1]=l),f--)}})(r),((e,n,r)=>{const s=[];let i,o,c,f=0;for(i=1;15>=i;i++)s[i]=f=f+r[i-1]<<1;for(o=0;n>=o;o++)c=e[2*o+1],0!==c&&(e[2*o]=t(s[c]++,c))})(s,e.ke,r._e)}}function Ae(e,t,n,r,s){const i=this;i.ue=e,i.Se=t,i.Ce=n,i.he=r,i.ze=s}xe.Ie=[0,1,2,3,4,5,6,7].concat(...ze([[2,8],[2,9],[2,10],[2,11],[4,12],[4,13],[4,14],[4,15],[8,16],[8,17],[8,18],[8,19],[16,20],[16,21],[16,22],[16,23],[32,24],[32,25],[32,26],[31,27],[1,28]])),xe.xe=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,0],xe.Ae=[0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576],xe.De=e=>256>e?Ie[e]:Ie[256+(e>>>7)],xe.Ve=[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],xe.Re=[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],xe.Be=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],xe.Ee=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];const De=ze([[144,8],[112,9],[24,7],[8,8]]);Ae.Me=_e([12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,19,275,147,403,83,339,211,467,51,307,179,435,115,371,243,499,11,267,139,395,75,331,203,459,43,299,171,427,107,363,235,491,27,283,155,411,91,347,219,475,59,315,187,443,123,379,251,507,7,263,135,391,71,327,199,455,39,295,167,423,103,359,231,487,23,279,151,407,87,343,215,471,55,311,183,439,119,375,247,503,15,271,143,399,79,335,207,463,47,303,175,431,111,367,239,495,31,287,159,415,95,351,223,479,63,319,191,447,127,383,255,511,0,64,32,96,16,80,48,112,8,72,40,104,24,88,56,120,4,68,36,100,20,84,52,116,3,131,67,195,35,163,99,227].map(((e,t)=>[e,De[t]])));const Ve=ze([[30,5]]);function Re(e,t,n,r,s){const i=this;i.Ke=e,i.Ne=t,i.Pe=n,i.Ue=r,i.Te=s}Ae.We=_e([0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30,1,17,9,25,5,21,13,29,3,19,11,27,7,23].map(((e,t)=>[e,Ve[t]]))),Ae.He=new Ae(Ae.Me,xe.Ve,257,286,15),Ae.Le=new Ae(Ae.We,xe.Re,0,30,15),Ae.je=new Ae(null,xe.Be,0,19,7);const Be=[new Re(0,0,0,0,0),new Re(4,4,8,4,1),new Re(4,5,16,8,1),new Re(4,6,32,32,1),new Re(4,4,16,16,2),new Re(8,16,32,32,2),new Re(8,16,128,128,2),new Re(8,32,128,256,2),new Re(32,128,258,1024,2),new Re(32,258,258,4096,2)],Ee=["need dictionary","stream end","","","stream error","data error","","buffer error","",""];function Me(e,t,n,r){const s=e[2*t],i=e[2*n];return i>s||s==i&&r[t]<=r[n]}function Ke(){const e=this;let t,r,o,c,f,a,l,u,w,h,d,p,y,m,b,g,k,v,S,C,z,_,I,x,A,D,V,R,B,E,M,K,N;const P=new xe,U=new xe,T=new xe;let W,H,L,j,F,O;function q(){let t;for(t=0;286>t;t++)M[2*t]=0;for(t=0;30>t;t++)K[2*t]=0;for(t=0;19>t;t++)N[2*t]=0;M[512]=1,e.be=e.ge=0,H=L=0}function G(e,t){let n,r=-1,s=e[1],i=0,o=7,c=4;0===s&&(o=138,c=3),e[2*(t+1)+1]=65535;for(let f=0;t>=f;f++)n=s,s=e[2*(f+1)+1],++i<o&&n==s||(c>i?N[2*n]+=i:0!==n?(n!=r&&N[2*n]++,N[32]++):i>10?N[36]++:N[34]++,i=0,r=n,0===s?(o=138,c=3):n==s?(o=6,c=3):(o=7,c=4))}function J(t){e.Fe[e.pending++]=t}function Q(e){J(255&e),J(e>>>8&255)}function X(e,t){let n;const r=t;O>16-r?(n=e,F|=n<<O&65535,Q(F),F=n>>>16-O,O+=r-16):(F|=e<<O&65535,O+=r)}function Y(e,t){const n=2*e;X(65535&t[n],65535&t[n+1])}function Z(e,t){let n,r,s=-1,i=e[1],o=0,c=7,f=4;for(0===i&&(c=138,f=3),n=0;t>=n;n++)if(r=i,i=e[2*(n+1)+1],++o>=c||r!=i){if(f>o)do{Y(r,N)}while(0!=--o);else 0!==r?(r!=s&&(Y(r,N),o--),Y(16,N),X(o-3,2)):o>10?(Y(18,N),X(o-11,7)):(Y(17,N),X(o-3,3));o=0,s=r,0===i?(c=138,f=3):r==i?(c=6,f=3):(c=7,f=4)}}function $(){16==O?(Q(F),F=0,O=0):8>O||(J(255&F),F>>>=8,O-=8)}function ee(t,r){let s,i,o;if(e.Oe[H]=t,e.qe[H]=255&r,H++,0===t?M[2*r]++:(L++,t--,M[2*(xe.Ie[r]+256+1)]++,K[2*xe.De(t)]++),0==(8191&H)&&V>2){for(s=8*H,i=z-k,o=0;30>o;o++)s+=K[2*o]*(5+xe.Re[o]);if(s>>>=3,L<n.floor(H/2)&&s<n.floor(i/2))return!0}return H==W-1}function te(t,n){let r,s,i,o,c=0;if(0!==H)do{r=e.Oe[c],s=e.qe[c],c++,0===r?Y(s,t):(i=xe.Ie[s],Y(i+256+1,t),o=xe.Ve[i],0!==o&&(s-=xe.xe[i],X(s,o)),r--,i=xe.De(r),Y(i,n),o=xe.Re[i],0!==o&&(r-=xe.Ae[i],X(r,o)))}while(H>c);Y(256,t),j=t[513]}function ne(){O>8?Q(F):O>0&&J(255&F),F=0,O=0}function re(t,n,r){X(0+(r?1:0),3),((t,n)=>{ne(),j=8,Q(n),Q(~n),e.Fe.set(u.subarray(t,t+n),e.pending),e.pending+=n})(t,n)}function se(n){((t,n,r)=>{let s,i,o=0;V>0?(P.ae(e),U.ae(e),o=(()=>{let t;for(G(M,P.ke),G(K,U.ke),T.ae(e),t=18;t>=3&&0===N[2*xe.Ee[t]+1];t--);return e.be+=14+3*(t+1),t})(),s=e.be+3+7>>>3,i=e.ge+3+7>>>3,i>s||(s=i)):s=i=n+5,n+4>s||-1==t?i==s?(X(2+(r?1:0),3),te(Ae.Me,Ae.We)):(X(4+(r?1:0),3),((e,t,n)=>{let r;for(X(e-257,5),X(t-1,5),X(n-4,4),r=0;n>r;r++)X(N[2*xe.Ee[r]+1],3);Z(M,e-1),Z(K,t-1)})(P.ke+1,U.ke+1,o+1),te(M,K)):re(t,n,r),q(),r&&ne()})(0>k?-1:k,z-k,n),k=z,t.Ge()}function ie(){let e,n,r,s;do{if(s=w-I-z,0===s&&0===z&&0===I)s=f;else if(-1==s)s--;else if(z>=f+f-262){u.set(u.subarray(f,f+f),0),_-=f,z-=f,k-=f,e=y,r=e;do{n=65535&d[--r],d[r]=f>n?0:n-f}while(0!=--e);e=f,r=e;do{n=65535&h[--r],h[r]=f>n?0:n-f}while(0!=--e);s+=f}if(0===t.Je)return;e=t.Qe(u,z+I,s),I+=e,3>I||(p=255&u[z],p=(p<<g^255&u[z+1])&b)}while(262>I&&0!==t.Je)}function oe(e){let t,n,r=A,s=z,i=x;const o=z>f-262?z-(f-262):0;let c=E;const a=l,w=z+258;let d=u[s+i-1],p=u[s+i];B>x||(r>>=2),c>I&&(c=I);do{if(t=e,u[t+i]==p&&u[t+i-1]==d&&u[t]==u[s]&&u[++t]==u[s+1]){s+=2,t++;do{}while(u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&w>s);if(n=258-(w-s),s=w-258,n>i){if(_=e,i=n,n>=c)break;d=u[s+i-1],p=u[s+i]}}}while((e=65535&h[e&a])>o&&0!=--r);return i>I?I:i}e.me=[],e._e=[],e.ye=[],M=[],K=[],N=[],e.ve=(t,n)=>{const r=e.ye,s=r[n];let i=n<<1;for(;i<=e.de&&(i<e.de&&Me(t,r[i+1],r[i],e.me)&&i++,!Me(t,s,r[i],e.me));)r[n]=r[i],n=i,i<<=1;r[n]=s},e.Xe=(t,S,_,H,L,G)=>(H||(H=8),L||(L=8),G||(G=0),t.Ye=null,-1==S&&(S=6),1>L||L>9||8!=H||9>_||_>15||0>S||S>9||0>G||G>2?-2:(t.Ze=e,a=_,f=1<<a,l=f-1,m=L+7,y=1<<m,b=y-1,g=n.floor((m+3-1)/3),u=new s(2*f),h=[],d=[],W=1<<L+6,e.Fe=new s(4*W),o=4*W,e.Oe=new i(W),e.qe=new s(W),V=S,R=G,(t=>(t.$e=t.et=0,t.Ye=null,e.pending=0,e.tt=0,r=113,c=0,P.le=M,P.we=Ae.He,U.le=K,U.we=Ae.Le,T.le=N,T.we=Ae.je,F=0,O=0,j=8,q(),(()=>{w=2*f,d[y-1]=0;for(let e=0;y-1>e;e++)d[e]=0;D=Be[V].Ne,B=Be[V].Ke,E=Be[V].Pe,A=Be[V].Ue,z=0,k=0,I=0,v=x=2,C=0,p=0})(),0))(t))),e.nt=()=>42!=r&&113!=r&&666!=r?-2:(e.qe=null,e.Oe=null,e.Fe=null,d=null,h=null,u=null,e.Ze=null,113==r?-3:0),e.rt=(e,t,n)=>{let r=0;return-1==t&&(t=6),0>t||t>9||0>n||n>2?-2:(Be[V].Te!=Be[t].Te&&0!==e.$e&&(r=e.st(1)),V!=t&&(V=t,D=Be[V].Ne,B=Be[V].Ke,E=Be[V].Pe,A=Be[V].Ue),R=n,r)},e.it=(e,t,n)=>{let s,i=n,o=0;if(!t||42!=r)return-2;if(3>i)return 0;for(i>f-262&&(i=f-262,o=n-i),u.set(t.subarray(o,o+i),0),z=i,k=i,p=255&u[0],p=(p<<g^255&u[1])&b,s=0;i-3>=s;s++)p=(p<<g^255&u[s+2])&b,h[s&l]=d[p],d[p]=s;return 0},e.st=(n,s)=>{let i,w,m,A,B;if(s>4||0>s)return-2;if(!n.ot||!n.ct&&0!==n.Je||666==r&&4!=s)return n.Ye=Ee[4],-2;if(0===n.ft)return n.Ye=Ee[7],-5;var E;if(t=n,A=c,c=s,42==r&&(w=8+(a-8<<4)<<8,m=(V-1&255)>>1,m>3&&(m=3),w|=m<<6,0!==z&&(w|=32),w+=31-w%31,r=113,J((E=w)>>8&255),J(255&E)),0!==e.pending){if(t.Ge(),0===t.ft)return c=-1,0}else if(0===t.Je&&A>=s&&4!=s)return t.Ye=Ee[7],-5;if(666==r&&0!==t.Je)return n.Ye=Ee[7],-5;if(0!==t.Je||0!==I||0!=s&&666!=r){switch(B=-1,Be[V].Te){case 0:B=(e=>{let n,r=65535;for(r>o-5&&(r=o-5);;){if(1>=I){if(ie(),0===I&&0==e)return 0;if(0===I)break}if(z+=I,I=0,n=k+r,(0===z||z>=n)&&(I=z-n,z=n,se(!1),0===t.ft))return 0;if(z-k>=f-262&&(se(!1),0===t.ft))return 0}return se(4==e),0===t.ft?4==e?2:0:4==e?3:1})(s);break;case 1:B=(e=>{let n,r=0;for(;;){if(262>I){if(ie(),262>I&&0==e)return 0;if(0===I)break}if(3>I||(p=(p<<g^255&u[z+2])&b,r=65535&d[p],h[z&l]=d[p],d[p]=z),0===r||(z-r&65535)>f-262||2!=R&&(v=oe(r)),3>v)n=ee(0,255&u[z]),I--,z++;else if(n=ee(z-_,v-3),I-=v,v>D||3>I)z+=v,v=0,p=255&u[z],p=(p<<g^255&u[z+1])&b;else{v--;do{z++,p=(p<<g^255&u[z+2])&b,r=65535&d[p],h[z&l]=d[p],d[p]=z}while(0!=--v);z++}if(n&&(se(!1),0===t.ft))return 0}return se(4==e),0===t.ft?4==e?2:0:4==e?3:1})(s);break;case 2:B=(e=>{let n,r,s=0;for(;;){if(262>I){if(ie(),262>I&&0==e)return 0;if(0===I)break}if(3>I||(p=(p<<g^255&u[z+2])&b,s=65535&d[p],h[z&l]=d[p],d[p]=z),x=v,S=_,v=2,0!==s&&D>x&&f-262>=(z-s&65535)&&(2!=R&&(v=oe(s)),5>=v&&(1==R||3==v&&z-_>4096)&&(v=2)),3>x||v>x)if(0!==C){if(n=ee(0,255&u[z-1]),n&&se(!1),z++,I--,0===t.ft)return 0}else C=1,z++,I--;else{r=z+I-3,n=ee(z-1-S,x-3),I-=x-1,x-=2;do{++z>r||(p=(p<<g^255&u[z+2])&b,s=65535&d[p],h[z&l]=d[p],d[p]=z)}while(0!=--x);if(C=0,v=2,z++,n&&(se(!1),0===t.ft))return 0}}return 0!==C&&(n=ee(0,255&u[z-1]),C=0),se(4==e),0===t.ft?4==e?2:0:4==e?3:1})(s)}if(2!=B&&3!=B||(r=666),0==B||2==B)return 0===t.ft&&(c=-1),0;if(1==B){if(1==s)X(2,3),Y(256,Ae.Me),$(),9>1+j+10-O&&(X(2,3),Y(256,Ae.Me),$()),j=7;else if(re(0,0,!1),3==s)for(i=0;y>i;i++)d[i]=0;if(t.Ge(),0===t.ft)return c=-1,0}}return 4!=s?0:1}}function Ne(){const e=this;e.lt=0,e.ut=0,e.Je=0,e.$e=0,e.ft=0,e.et=0}function Pe(e){const t=new Ne,i=(o=e&&e.chunkSize?e.chunkSize:65536)+5*(n.floor(o/16383)+1);var o;const c=new s(i);let f=e?e.level:-1;void 0===f&&(f=-1),t.Xe(f),t.ot=c,this.append=(e,n)=>{let o,f,a=0,l=0,u=0;const w=[];if(e.length){t.lt=0,t.ct=e,t.Je=e.length;do{if(t.ut=0,t.ft=i,o=t.st(0),0!=o)throw new r("deflating: "+t.Ye);t.ut&&(t.ut==i?w.push(new s(c)):w.push(c.slice(0,t.ut))),u+=t.ut,n&&t.lt>0&&t.lt!=a&&(n(t.lt),a=t.lt)}while(t.Je>0||0===t.ft);return w.length>1?(f=new s(u),w.forEach((e=>{f.set(e,l),l+=e.length}))):f=w[0]||new s,f}},this.flush=()=>{let e,n,o=0,f=0;const a=[];do{if(t.ut=0,t.ft=i,e=t.st(4),1!=e&&0!=e)throw new r("deflating: "+t.Ye);i-t.ft>0&&a.push(c.slice(0,t.ut)),f+=t.ut}while(t.Je>0||0===t.ft);return t.nt(),n=new s(f),a.forEach((e=>{n.set(e,o),o+=e.length})),n}}Ne.prototype={Xe(e,t){const n=this;return n.Ze=new Ke,t||(t=15),n.Ze.Xe(n,e,t)},st(e){const t=this;return t.Ze?t.Ze.st(t,e):-2},nt(){const e=this;if(!e.Ze)return-2;const t=e.Ze.nt();return e.Ze=null,t},rt(e,t){const n=this;return n.Ze?n.Ze.rt(n,e,t):-2},it(e,t){const n=this;return n.Ze?n.Ze.it(n,e,t):-2},Qe(e,t,n){const r=this;let s=r.Je;return s>n&&(s=n),0===s?0:(r.Je-=s,e.set(r.ct.subarray(r.lt,r.lt+s),t),r.lt+=s,r.$e+=s,s)},Ge(){const e=this;let t=e.Ze.pending;t>e.ft&&(t=e.ft),0!==t&&(e.ot.set(e.Ze.Fe.subarray(e.Ze.tt,e.Ze.tt+t),e.ut),e.ut+=t,e.Ze.tt+=t,e.et+=t,e.ft-=t,e.Ze.pending-=t,0===e.Ze.pending&&(e.Ze.tt=0))}};const Ue=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],Te=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],We=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],He=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Le=[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,112,112],je=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],Fe=[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];function Oe(){let e,t,n,r,s,i;function o(e,t,o,c,f,a,l,u,w,h,d){let p,y,m,b,g,k,v,S,C,z,_,I,x,A,D;z=0,g=o;do{n[e[t+z]]++,z++,g--}while(0!==g);if(n[0]==o)return l[0]=-1,u[0]=0,0;for(S=u[0],k=1;15>=k&&0===n[k];k++);for(v=k,k>S&&(S=k),g=15;0!==g&&0===n[g];g--);for(m=g,S>g&&(S=g),u[0]=S,A=1<<k;g>k;k++,A<<=1)if(0>(A-=n[k]))return-3;if(0>(A-=n[g]))return-3;for(n[g]+=A,i[1]=k=0,z=1,x=2;0!=--g;)i[x]=k+=n[z],x++,z++;g=0,z=0;do{0!==(k=e[t+z])&&(d[i[k]++]=g),z++}while(++g<o);for(o=i[m],i[0]=g=0,z=0,b=-1,I=-S,s[0]=0,_=0,D=0;m>=v;v++)for(p=n[v];0!=p--;){for(;v>I+S;){if(b++,I+=S,D=m-I,D=D>S?S:D,(y=1<<(k=v-I))>p+1&&(y-=p+1,x=v,D>k))for(;++k<D&&(y<<=1)>n[++x];)y-=n[x];if(D=1<<k,h[0]+D>1440)return-3;s[b]=_=h[0],h[0]+=D,0!==b?(i[b]=g,r[0]=k,r[1]=S,k=g>>>I-S,r[2]=_-s[b-1]-k,w.set(r,3*(s[b-1]+k))):l[0]=_}for(r[1]=v-I,o>z?d[z]<c?(r[0]=256>d[z]?0:96,r[2]=d[z++]):(r[0]=a[d[z]-c]+16+64,r[2]=f[d[z++]-c]):r[0]=192,y=1<<v-I,k=g>>>I;D>k;k+=y)w.set(r,3*(_+k));for(k=1<<v-1;0!=(g&k);k>>>=1)g^=k;for(g^=k,C=(1<<I)-1;(g&C)!=i[b];)b--,I-=S,C=(1<<I)-1}return 0!==A&&1!=m?-5:0}function f(o){let f;for(e||(e=[],t=[],n=new c(16),r=[],s=new c(15),i=new c(16)),t.length<o&&(t=[]),f=0;o>f;f++)t[f]=0;for(f=0;16>f;f++)n[f]=0;for(f=0;3>f;f++)r[f]=0;s.set(n.subarray(0,15),0),i.set(n.subarray(0,16),0)}this.wt=(n,r,s,i,c)=>{let a;return f(19),e[0]=0,a=o(n,0,19,19,null,null,s,r,i,e,t),-3==a?c.Ye="oversubscribed dynamic bit lengths tree":-5!=a&&0!==r[0]||(c.Ye="incomplete dynamic bit lengths tree",a=-3),a},this.ht=(n,r,s,i,c,a,l,u,w)=>{let h;return f(288),e[0]=0,h=o(s,0,n,257,He,Le,a,i,u,e,t),0!=h||0===i[0]?(-3==h?w.Ye="oversubscribed literal/length tree":-4!=h&&(w.Ye="incomplete literal/length tree",h=-3),h):(f(288),h=o(s,n,r,0,je,Fe,l,c,u,e,t),0!=h||0===c[0]&&n>257?(-3==h?w.Ye="oversubscribed distance tree":-5==h?(w.Ye="incomplete distance tree",h=-3):-4!=h&&(w.Ye="empty distance tree with lengths",h=-3),h):0)}}function qe(){const e=this;let t,n,r,s,i=0,o=0,c=0,f=0,a=0,l=0,u=0,w=0,h=0,d=0;function p(e,t,n,r,s,i,o,c){let f,a,l,u,w,h,d,p,y,m,b,g,k,v,S,C;d=c.lt,p=c.Je,w=o.dt,h=o.yt,y=o.write,m=y<o.read?o.read-y-1:o.end-y,b=Ue[e],g=Ue[t];do{for(;20>h;)p--,w|=(255&c.bt(d++))<<h,h+=8;if(f=w&b,a=n,l=r,C=3*(l+f),0!==(u=a[C]))for(;;){if(w>>=a[C+1],h-=a[C+1],0!=(16&u)){for(u&=15,k=a[C+2]+(w&Ue[u]),w>>=u,h-=u;15>h;)p--,w|=(255&c.bt(d++))<<h,h+=8;for(f=w&g,a=s,l=i,C=3*(l+f),u=a[C];;){if(w>>=a[C+1],h-=a[C+1],0!=(16&u)){for(u&=15;u>h;)p--,w|=(255&c.bt(d++))<<h,h+=8;if(v=a[C+2]+(w&Ue[u]),w>>=u,h-=u,m-=k,v>y){S=y-v;do{S+=o.end}while(0>S);if(u=o.end-S,k>u){if(k-=u,y-S>0&&u>y-S)do{o.gt[y++]=o.gt[S++]}while(0!=--u);else o.gt.set(o.gt.subarray(S,S+u),y),y+=u,S+=u,u=0;S=0}}else S=y-v,y-S>0&&2>y-S?(o.gt[y++]=o.gt[S++],o.gt[y++]=o.gt[S++],k-=2):(o.gt.set(o.gt.subarray(S,S+2),y),y+=2,S+=2,k-=2);if(y-S>0&&k>y-S)do{o.gt[y++]=o.gt[S++]}while(0!=--k);else o.gt.set(o.gt.subarray(S,S+k),y),y+=k,S+=k,k=0;break}if(0!=(64&u))return c.Ye="invalid distance code",k=c.Je-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.dt=w,o.yt=h,c.Je=p,c.$e+=d-c.lt,c.lt=d,o.write=y,-3;f+=a[C+2],f+=w&Ue[u],C=3*(l+f),u=a[C]}break}if(0!=(64&u))return 0!=(32&u)?(k=c.Je-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.dt=w,o.yt=h,c.Je=p,c.$e+=d-c.lt,c.lt=d,o.write=y,1):(c.Ye="invalid literal/length code",k=c.Je-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.dt=w,o.yt=h,c.Je=p,c.$e+=d-c.lt,c.lt=d,o.write=y,-3);if(f+=a[C+2],f+=w&Ue[u],C=3*(l+f),0===(u=a[C])){w>>=a[C+1],h-=a[C+1],o.gt[y++]=a[C+2],m--;break}}else w>>=a[C+1],h-=a[C+1],o.gt[y++]=a[C+2],m--}while(m>=258&&p>=10);return k=c.Je-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.dt=w,o.yt=h,c.Je=p,c.$e+=d-c.lt,c.lt=d,o.write=y,0}e.init=(e,i,o,c,f,a)=>{t=0,u=e,w=i,r=o,h=c,s=f,d=a,n=null},e.kt=(e,y,m)=>{let b,g,k,v,S,C,z,_=0,I=0,x=0;for(x=y.lt,v=y.Je,_=e.dt,I=e.yt,S=e.write,C=S<e.read?e.read-S-1:e.end-S;;)switch(t){case 0:if(C>=258&&v>=10&&(e.dt=_,e.yt=I,y.Je=v,y.$e+=x-y.lt,y.lt=x,e.write=S,m=p(u,w,r,h,s,d,e,y),x=y.lt,v=y.Je,_=e.dt,I=e.yt,S=e.write,C=S<e.read?e.read-S-1:e.end-S,0!=m)){t=1==m?7:9;break}c=u,n=r,o=h,t=1;case 1:for(b=c;b>I;){if(0===v)return e.dt=_,e.yt=I,y.Je=v,y.$e+=x-y.lt,y.lt=x,e.write=S,e.vt(y,m);m=0,v--,_|=(255&y.bt(x++))<<I,I+=8}if(g=3*(o+(_&Ue[b])),_>>>=n[g+1],I-=n[g+1],k=n[g],0===k){f=n[g+2],t=6;break}if(0!=(16&k)){a=15&k,i=n[g+2],t=2;break}if(0==(64&k)){c=k,o=g/3+n[g+2];break}if(0!=(32&k)){t=7;break}return t=9,y.Ye="invalid literal/length code",m=-3,e.dt=_,e.yt=I,y.Je=v,y.$e+=x-y.lt,y.lt=x,e.write=S,e.vt(y,m);case 2:for(b=a;b>I;){if(0===v)return e.dt=_,e.yt=I,y.Je=v,y.$e+=x-y.lt,y.lt=x,e.write=S,e.vt(y,m);m=0,v--,_|=(255&y.bt(x++))<<I,I+=8}i+=_&Ue[b],_>>=b,I-=b,c=w,n=s,o=d,t=3;case 3:for(b=c;b>I;){if(0===v)return e.dt=_,e.yt=I,y.Je=v,y.$e+=x-y.lt,y.lt=x,e.write=S,e.vt(y,m);m=0,v--,_|=(255&y.bt(x++))<<I,I+=8}if(g=3*(o+(_&Ue[b])),_>>=n[g+1],I-=n[g+1],k=n[g],0!=(16&k)){a=15&k,l=n[g+2],t=4;break}if(0==(64&k)){c=k,o=g/3+n[g+2];break}return t=9,y.Ye="invalid distance code",m=-3,e.dt=_,e.yt=I,y.Je=v,y.$e+=x-y.lt,y.lt=x,e.write=S,e.vt(y,m);case 4:for(b=a;b>I;){if(0===v)return e.dt=_,e.yt=I,y.Je=v,y.$e+=x-y.lt,y.lt=x,e.write=S,e.vt(y,m);m=0,v--,_|=(255&y.bt(x++))<<I,I+=8}l+=_&Ue[b],_>>=b,I-=b,t=5;case 5:for(z=S-l;0>z;)z+=e.end;for(;0!==i;){if(0===C&&(S==e.end&&0!==e.read&&(S=0,C=S<e.read?e.read-S-1:e.end-S),0===C&&(e.write=S,m=e.vt(y,m),S=e.write,C=S<e.read?e.read-S-1:e.end-S,S==e.end&&0!==e.read&&(S=0,C=S<e.read?e.read-S-1:e.end-S),0===C)))return e.dt=_,e.yt=I,y.Je=v,y.$e+=x-y.lt,y.lt=x,e.write=S,e.vt(y,m);e.gt[S++]=e.gt[z++],C--,z==e.end&&(z=0),i--}t=0;break;case 6:if(0===C&&(S==e.end&&0!==e.read&&(S=0,C=S<e.read?e.read-S-1:e.end-S),0===C&&(e.write=S,m=e.vt(y,m),S=e.write,C=S<e.read?e.read-S-1:e.end-S,S==e.end&&0!==e.read&&(S=0,C=S<e.read?e.read-S-1:e.end-S),0===C)))return e.dt=_,e.yt=I,y.Je=v,y.$e+=x-y.lt,y.lt=x,e.write=S,e.vt(y,m);m=0,e.gt[S++]=f,C--,t=0;break;case 7:if(I>7&&(I-=8,v++,x--),e.write=S,m=e.vt(y,m),S=e.write,C=S<e.read?e.read-S-1:e.end-S,e.read!=e.write)return e.dt=_,e.yt=I,y.Je=v,y.$e+=x-y.lt,y.lt=x,e.write=S,e.vt(y,m);t=8;case 8:return m=1,e.dt=_,e.yt=I,y.Je=v,y.$e+=x-y.lt,y.lt=x,e.write=S,e.vt(y,m);case 9:return m=-3,e.dt=_,e.yt=I,y.Je=v,y.$e+=x-y.lt,y.lt=x,e.write=S,e.vt(y,m);default:return m=-2,e.dt=_,e.yt=I,y.Je=v,y.$e+=x-y.lt,y.lt=x,e.write=S,e.vt(y,m)}},e.St=()=>{}}Oe.Ct=(e,t,n,r)=>(e[0]=9,t[0]=5,n[0]=Te,r[0]=We,0);const Ge=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function Je(e,t){const n=this;let r,i=0,o=0,f=0,a=0;const l=[0],u=[0],w=new qe;let h=0,d=new c(4320);const p=new Oe;n.yt=0,n.dt=0,n.gt=new s(t),n.end=t,n.read=0,n.write=0,n.reset=(e,t)=>{t&&(t[0]=0),6==i&&w.St(e),i=0,n.yt=0,n.dt=0,n.read=n.write=0},n.reset(e,null),n.vt=(e,t)=>{let r,s,i;return s=e.ut,i=n.read,r=(i>n.write?n.end:n.write)-i,r>e.ft&&(r=e.ft),0!==r&&-5==t&&(t=0),e.ft-=r,e.et+=r,e.ot.set(n.gt.subarray(i,i+r),s),s+=r,i+=r,i==n.end&&(i=0,n.write==n.end&&(n.write=0),r=n.write-i,r>e.ft&&(r=e.ft),0!==r&&-5==t&&(t=0),e.ft-=r,e.et+=r,e.ot.set(n.gt.subarray(i,i+r),s),s+=r,i+=r),e.ut=s,n.read=i,t},n.kt=(e,t)=>{let s,c,y,m,b,g,k,v;for(m=e.lt,b=e.Je,c=n.dt,y=n.yt,g=n.write,k=g<n.read?n.read-g-1:n.end-g;;){let S,C,z,_,I,x,A,D;switch(i){case 0:for(;3>y;){if(0===b)return n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);t=0,b--,c|=(255&e.bt(m++))<<y,y+=8}switch(s=7&c,h=1&s,s>>>1){case 0:c>>>=3,y-=3,s=7&y,c>>>=s,y-=s,i=1;break;case 1:S=[],C=[],z=[[]],_=[[]],Oe.Ct(S,C,z,_),w.init(S[0],C[0],z[0],0,_[0],0),c>>>=3,y-=3,i=6;break;case 2:c>>>=3,y-=3,i=3;break;case 3:return c>>>=3,y-=3,i=9,e.Ye="invalid block type",t=-3,n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t)}break;case 1:for(;32>y;){if(0===b)return n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);t=0,b--,c|=(255&e.bt(m++))<<y,y+=8}if((~c>>>16&65535)!=(65535&c))return i=9,e.Ye="invalid stored block lengths",t=-3,n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);o=65535&c,c=y=0,i=0!==o?2:0!==h?7:0;break;case 2:if(0===b)return n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);if(0===k&&(g==n.end&&0!==n.read&&(g=0,k=g<n.read?n.read-g-1:n.end-g),0===k&&(n.write=g,t=n.vt(e,t),g=n.write,k=g<n.read?n.read-g-1:n.end-g,g==n.end&&0!==n.read&&(g=0,k=g<n.read?n.read-g-1:n.end-g),0===k)))return n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);if(t=0,s=o,s>b&&(s=b),s>k&&(s=k),n.gt.set(e.Qe(m,s),g),m+=s,b-=s,g+=s,k-=s,0!=(o-=s))break;i=0!==h?7:0;break;case 3:for(;14>y;){if(0===b)return n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);t=0,b--,c|=(255&e.bt(m++))<<y,y+=8}if(f=s=16383&c,(31&s)>29||(s>>5&31)>29)return i=9,e.Ye="too many length or distance symbols",t=-3,n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);if(s=258+(31&s)+(s>>5&31),!r||r.length<s)r=[];else for(v=0;s>v;v++)r[v]=0;c>>>=14,y-=14,a=0,i=4;case 4:for(;4+(f>>>10)>a;){for(;3>y;){if(0===b)return n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);t=0,b--,c|=(255&e.bt(m++))<<y,y+=8}r[Ge[a++]]=7&c,c>>>=3,y-=3}for(;19>a;)r[Ge[a++]]=0;if(l[0]=7,s=p.wt(r,l,u,d,e),0!=s)return-3==(t=s)&&(r=null,i=9),n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);a=0,i=5;case 5:for(;s=f,258+(31&s)+(s>>5&31)>a;){let o,w;for(s=l[0];s>y;){if(0===b)return n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);t=0,b--,c|=(255&e.bt(m++))<<y,y+=8}if(s=d[3*(u[0]+(c&Ue[s]))+1],w=d[3*(u[0]+(c&Ue[s]))+2],16>w)c>>>=s,y-=s,r[a++]=w;else{for(v=18==w?7:w-14,o=18==w?11:3;s+v>y;){if(0===b)return n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);t=0,b--,c|=(255&e.bt(m++))<<y,y+=8}if(c>>>=s,y-=s,o+=c&Ue[v],c>>>=v,y-=v,v=a,s=f,v+o>258+(31&s)+(s>>5&31)||16==w&&1>v)return r=null,i=9,e.Ye="invalid bit length repeat",t=-3,n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);w=16==w?r[v-1]:0;do{r[v++]=w}while(0!=--o);a=v}}if(u[0]=-1,I=[],x=[],A=[],D=[],I[0]=9,x[0]=6,s=f,s=p.ht(257+(31&s),1+(s>>5&31),r,I,x,A,D,d,e),0!=s)return-3==s&&(r=null,i=9),t=s,n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);w.init(I[0],x[0],d,A[0],d,D[0]),i=6;case 6:if(n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,1!=(t=w.kt(n,e,t)))return n.vt(e,t);if(t=0,w.St(e),m=e.lt,b=e.Je,c=n.dt,y=n.yt,g=n.write,k=g<n.read?n.read-g-1:n.end-g,0===h){i=0;break}i=7;case 7:if(n.write=g,t=n.vt(e,t),g=n.write,k=g<n.read?n.read-g-1:n.end-g,n.read!=n.write)return n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);i=8;case 8:return t=1,n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);case 9:return t=-3,n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t);default:return t=-2,n.dt=c,n.yt=y,e.Je=b,e.$e+=m-e.lt,e.lt=m,n.write=g,n.vt(e,t)}}},n.St=e=>{n.reset(e,null),n.gt=null,d=null},n.zt=(e,t,r)=>{n.gt.set(e.subarray(t,t+r),0),n.read=n.write=r},n._t=()=>1==i?1:0}const Qe=[0,0,255,255];function Xe(){const e=this;function t(e){return e&&e.It?(e.$e=e.et=0,e.Ye=null,e.It.mode=7,e.It.xt.reset(e,null),0):-2}e.mode=0,e.method=0,e.At=[0],e.Dt=0,e.marker=0,e.Vt=0,e.Rt=t=>(e.xt&&e.xt.St(t),e.xt=null,0),e.Bt=(n,r)=>(n.Ye=null,e.xt=null,8>r||r>15?(e.Rt(n),-2):(e.Vt=r,n.It.xt=new Je(n,1<<r),t(n),0)),e.Et=(e,t)=>{let n,r;if(!e||!e.It||!e.ct)return-2;const s=e.It;for(t=4==t?-5:0,n=-5;;)switch(s.mode){case 0:if(0===e.Je)return n;if(n=t,e.Je--,e.$e++,8!=(15&(s.method=e.bt(e.lt++)))){s.mode=13,e.Ye="unknown compression method",s.marker=5;break}if(8+(s.method>>4)>s.Vt){s.mode=13,e.Ye="invalid win size",s.marker=5;break}s.mode=1;case 1:if(0===e.Je)return n;if(n=t,e.Je--,e.$e++,r=255&e.bt(e.lt++),((s.method<<8)+r)%31!=0){s.mode=13,e.Ye="incorrect header check",s.marker=5;break}if(0==(32&r)){s.mode=7;break}s.mode=2;case 2:if(0===e.Je)return n;n=t,e.Je--,e.$e++,s.Dt=(255&e.bt(e.lt++))<<24&4278190080,s.mode=3;case 3:if(0===e.Je)return n;n=t,e.Je--,e.$e++,s.Dt+=(255&e.bt(e.lt++))<<16&16711680,s.mode=4;case 4:if(0===e.Je)return n;n=t,e.Je--,e.$e++,s.Dt+=(255&e.bt(e.lt++))<<8&65280,s.mode=5;case 5:return 0===e.Je?n:(n=t,e.Je--,e.$e++,s.Dt+=255&e.bt(e.lt++),s.mode=6,2);case 6:return s.mode=13,e.Ye="need dictionary",s.marker=0,-2;case 7:if(n=s.xt.kt(e,n),-3==n){s.mode=13,s.marker=0;break}if(0==n&&(n=t),1!=n)return n;n=t,s.xt.reset(e,s.At),s.mode=12;case 12:return e.Je=0,1;case 13:return-3;default:return-2}},e.Mt=(e,t,n)=>{let r=0,s=n;if(!e||!e.It||6!=e.It.mode)return-2;const i=e.It;return s<1<<i.Vt||(s=(1<<i.Vt)-1,r=n-s),i.xt.zt(t,r,s),i.mode=7,0},e.Kt=e=>{let n,r,s,i,o;if(!e||!e.It)return-2;const c=e.It;if(13!=c.mode&&(c.mode=13,c.marker=0),0===(n=e.Je))return-5;for(r=e.lt,s=c.marker;0!==n&&4>s;)e.bt(r)==Qe[s]?s++:s=0!==e.bt(r)?0:4-s,r++,n--;return e.$e+=r-e.lt,e.lt=r,e.Je=n,c.marker=s,4!=s?-3:(i=e.$e,o=e.et,t(e),e.$e=i,e.et=o,c.mode=7,0)},e.Nt=e=>e&&e.It&&e.It.xt?e.It.xt._t():-2}function Ye(){}function Ze(e){const t=new Ye,i=e&&e.chunkSize?n.floor(2*e.chunkSize):131072,o=new s(i);let c=!1;t.Bt(),t.ot=o,this.append=(e,n)=>{const f=[];let a,l,u=0,w=0,h=0;if(0!==e.length){t.lt=0,t.ct=e,t.Je=e.length;do{if(t.ut=0,t.ft=i,0!==t.Je||c||(t.lt=0,c=!0),a=t.Et(0),c&&-5===a){if(0!==t.Je)throw new r("inflating: bad input")}else if(0!==a&&1!==a)throw new r("inflating: "+t.Ye);if((c||1===a)&&t.Je===e.length)throw new r("inflating: bad input");t.ut&&(t.ut===i?f.push(new s(o)):f.push(o.slice(0,t.ut))),h+=t.ut,n&&t.lt>0&&t.lt!=u&&(n(t.lt),u=t.lt)}while(t.Je>0||0===t.ft);return f.length>1?(l=new s(h),f.forEach((e=>{l.set(e,w),w+=e.length}))):l=f[0]||new s,l}},this.flush=()=>{t.Rt()}}Ye.prototype={Bt(e){const t=this;return t.It=new Xe,e||(e=15),t.It.Bt(t,e)},Et(e){const t=this;return t.It?t.It.Et(t,e):-2},Rt(){const e=this;if(!e.It)return-2;const t=e.It.Rt(e);return e.It=null,t},Kt(){const e=this;return e.It?e.It.Kt(e):-2},Mt(e,t){const n=this;return n.It?n.It.Mt(n,e,t):-2},bt(e){return this.ct[e]},Qe(e,t){return this.ct.subarray(e,e+t)}},self.initCodec=()=>{self.Deflate=Pe,self.Inflate=Ze};\n'],{type:"text/javascript"}));e({workerScripts:{inflate:[t],deflate:[t]}});}
|
|
6120
|
+
function pipeThrough(readable, transformStream) {
|
|
6121
|
+
return readable.pipeThrough(transformStream);
|
|
6122
|
+
}
|
|
6135
6123
|
|
|
6136
6124
|
/*
|
|
6137
6125
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
@@ -6161,56 +6149,50 @@
|
|
|
6161
6149
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
6162
6150
|
*/
|
|
6163
6151
|
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
};
|
|
6173
|
-
}
|
|
6152
|
+
const MESSAGE_EVENT_TYPE = "message";
|
|
6153
|
+
const MESSAGE_START = "start";
|
|
6154
|
+
const MESSAGE_PULL = "pull";
|
|
6155
|
+
const MESSAGE_DATA = "data";
|
|
6156
|
+
const MESSAGE_ACK_DATA = "ack";
|
|
6157
|
+
const MESSAGE_CLOSE = "close";
|
|
6158
|
+
const CODEC_DEFLATE = "deflate";
|
|
6159
|
+
const CODEC_INFLATE = "inflate";
|
|
6174
6160
|
|
|
6175
|
-
|
|
6176
|
-
return class {
|
|
6161
|
+
class CodecStream extends TransformStream {
|
|
6177
6162
|
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6163
|
+
constructor(options, config) {
|
|
6164
|
+
super({});
|
|
6165
|
+
const codec = this;
|
|
6166
|
+
const { codecType } = options;
|
|
6167
|
+
let Stream;
|
|
6168
|
+
if (codecType.startsWith(CODEC_DEFLATE)) {
|
|
6169
|
+
Stream = DeflateStream;
|
|
6170
|
+
} else if (codecType.startsWith(CODEC_INFLATE)) {
|
|
6171
|
+
Stream = InflateStream;
|
|
6172
|
+
}
|
|
6173
|
+
let size = 0;
|
|
6174
|
+
const stream = new Stream(options, config);
|
|
6175
|
+
const readable = super.readable;
|
|
6176
|
+
const transformStream = new TransformStream({
|
|
6177
|
+
transform(chunk, controller) {
|
|
6178
|
+
if (chunk && chunk.length) {
|
|
6179
|
+
size += chunk.length;
|
|
6180
|
+
controller.enqueue(chunk);
|
|
6188
6181
|
}
|
|
6189
|
-
}
|
|
6190
|
-
|
|
6191
|
-
|
|
6182
|
+
},
|
|
6183
|
+
flush() {
|
|
6184
|
+
const { signature } = stream;
|
|
6185
|
+
Object.assign(codec, {
|
|
6186
|
+
signature,
|
|
6187
|
+
size
|
|
6188
|
+
});
|
|
6192
6189
|
}
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
}
|
|
6200
|
-
flush() {
|
|
6201
|
-
this.codec.push(new Uint8Array(), true);
|
|
6202
|
-
return getResponse(this);
|
|
6203
|
-
}
|
|
6204
|
-
};
|
|
6205
|
-
|
|
6206
|
-
function getResponse(codec) {
|
|
6207
|
-
if (codec.pendingData) {
|
|
6208
|
-
const output = codec.pendingData;
|
|
6209
|
-
codec.pendingData = null;
|
|
6210
|
-
return output;
|
|
6211
|
-
} else {
|
|
6212
|
-
return new Uint8Array();
|
|
6213
|
-
}
|
|
6190
|
+
});
|
|
6191
|
+
Object.defineProperty(codec, "readable", {
|
|
6192
|
+
get() {
|
|
6193
|
+
return readable.pipeThrough(stream).pipeThrough(transformStream);
|
|
6194
|
+
}
|
|
6195
|
+
});
|
|
6214
6196
|
}
|
|
6215
6197
|
}
|
|
6216
6198
|
|
|
@@ -6242,25 +6224,26 @@
|
|
|
6242
6224
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
6243
6225
|
*/
|
|
6244
6226
|
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
let transferStreamsSupported = true;
|
|
6227
|
+
// deno-lint-ignore valid-typeof
|
|
6228
|
+
const WEB_WORKERS_SUPPORTED = typeof Worker != UNDEFINED_TYPE$1;
|
|
6248
6229
|
|
|
6249
6230
|
class CodecWorker {
|
|
6250
6231
|
|
|
6251
6232
|
constructor(workerData, stream, workerOptions, onTaskFinished) {
|
|
6252
6233
|
const { readable, writable } = stream;
|
|
6253
6234
|
const { options, config, streamOptions, useWebWorkers, transferStreams, scripts } = workerOptions;
|
|
6235
|
+
const { signal } = streamOptions;
|
|
6254
6236
|
Object.assign(workerData, {
|
|
6255
6237
|
busy: true,
|
|
6256
|
-
readable,
|
|
6238
|
+
readable: readable.pipeThrough(new ReadableStreamHooks(readable, streamOptions, config), { signal }),
|
|
6257
6239
|
writable,
|
|
6258
6240
|
options: Object.assign({}, options),
|
|
6259
6241
|
scripts,
|
|
6260
6242
|
transferStreams,
|
|
6261
6243
|
terminate() {
|
|
6262
|
-
|
|
6263
|
-
|
|
6244
|
+
const { worker, busy } = workerData;
|
|
6245
|
+
if (worker && !busy) {
|
|
6246
|
+
worker.terminate();
|
|
6264
6247
|
workerData.interface = null;
|
|
6265
6248
|
}
|
|
6266
6249
|
},
|
|
@@ -6269,30 +6252,34 @@
|
|
|
6269
6252
|
onTaskFinished(workerData);
|
|
6270
6253
|
}
|
|
6271
6254
|
});
|
|
6272
|
-
|
|
6255
|
+
return (useWebWorkers && WEB_WORKERS_SUPPORTED ? createWebWorkerInterface : createWorkerInterface)(workerData, config);
|
|
6256
|
+
}
|
|
6257
|
+
}
|
|
6258
|
+
|
|
6259
|
+
class ReadableStreamHooks extends TransformStream {
|
|
6260
|
+
|
|
6261
|
+
constructor(readableSource, { onstart, onprogress, size, onend }, { chunkSize }) {
|
|
6273
6262
|
let chunkOffset = 0;
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6263
|
+
super({
|
|
6264
|
+
start() {
|
|
6265
|
+
if (onstart) {
|
|
6266
|
+
callHandler(onstart, size);
|
|
6267
|
+
}
|
|
6268
|
+
},
|
|
6269
|
+
async transform(chunk, controller) {
|
|
6270
|
+
chunkOffset += chunk.length;
|
|
6271
|
+
if (onprogress) {
|
|
6272
|
+
await callHandler(onprogress, chunkOffset, size);
|
|
6273
|
+
}
|
|
6274
|
+
controller.enqueue(chunk);
|
|
6275
|
+
},
|
|
6276
|
+
flush() {
|
|
6277
|
+
readableSource.size = chunkOffset;
|
|
6278
|
+
if (onend) {
|
|
6279
|
+
callHandler(onend, chunkOffset);
|
|
6280
|
+
}
|
|
6289
6281
|
}
|
|
6290
|
-
};
|
|
6291
|
-
workerData.readable = readable.pipeThrough(new TransformStream(transformer, { highWaterMark: 1, size: () => config.chunkSize }), { signal });
|
|
6292
|
-
if (workersSupported === UNDEFINED_VALUE) {
|
|
6293
|
-
workersSupported = typeof Worker != UNDEFINED_TYPE;
|
|
6294
|
-
}
|
|
6295
|
-
return useWebWorkers && workersSupported ? createWebWorkerInterface(workerData, config) : createWorkerInterface(workerData, config);
|
|
6282
|
+
}, { highWaterMark: 1, size: () => chunkSize });
|
|
6296
6283
|
}
|
|
6297
6284
|
}
|
|
6298
6285
|
|
|
@@ -6305,186 +6292,209 @@
|
|
|
6305
6292
|
}
|
|
6306
6293
|
|
|
6307
6294
|
function createWorkerInterface(workerData, config) {
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
const codec = {
|
|
6311
|
-
async run() {
|
|
6312
|
-
try {
|
|
6313
|
-
return await interfaceCodec.run();
|
|
6314
|
-
} finally {
|
|
6315
|
-
onTaskFinished();
|
|
6316
|
-
}
|
|
6317
|
-
}
|
|
6295
|
+
return {
|
|
6296
|
+
run: () => runWorker$1(workerData, config)
|
|
6318
6297
|
};
|
|
6319
|
-
return codec;
|
|
6320
6298
|
}
|
|
6321
6299
|
|
|
6322
6300
|
function createWebWorkerInterface(workerData, { baseURL, chunkSize }) {
|
|
6323
|
-
const workerOptions = { type: "module" };
|
|
6324
|
-
Object.assign(workerData, {
|
|
6325
|
-
streams: {},
|
|
6326
|
-
result: new Promise((resolve, reject) => {
|
|
6327
|
-
workerData.resolveResult = resolve;
|
|
6328
|
-
workerData.rejectResult = reject;
|
|
6329
|
-
})
|
|
6330
|
-
});
|
|
6331
6301
|
if (!workerData.interface) {
|
|
6332
|
-
|
|
6333
|
-
workerData.
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
workerData.worker = getWorker({});
|
|
6337
|
-
} catch (_error) {
|
|
6338
|
-
classicWorkersSupported = false;
|
|
6339
|
-
workerData.worker = getWorker(workerOptions);
|
|
6340
|
-
}
|
|
6341
|
-
}
|
|
6342
|
-
workerData.worker.addEventListener(MESSAGE_EVENT_TYPE, onMessage, false);
|
|
6343
|
-
workerData.interface = {
|
|
6344
|
-
async run() {
|
|
6345
|
-
const { readable, options } = workerData;
|
|
6346
|
-
const writer = workerData.writable.getWriter();
|
|
6347
|
-
let resolveStreamClosed, streamClosed;
|
|
6348
|
-
streamClosed = new Promise(resolve => resolveStreamClosed = resolve);
|
|
6349
|
-
const writable = new WritableStream({
|
|
6350
|
-
async write(chunk) {
|
|
6351
|
-
await writer.ready;
|
|
6352
|
-
await writer.write(chunk);
|
|
6353
|
-
},
|
|
6354
|
-
async close() {
|
|
6355
|
-
writer.releaseLock();
|
|
6356
|
-
resolveStreamClosed();
|
|
6357
|
-
},
|
|
6358
|
-
abort(reason) {
|
|
6359
|
-
writer.abort(reason);
|
|
6360
|
-
}
|
|
6361
|
-
});
|
|
6362
|
-
const scripts = workerData.scripts.slice(1);
|
|
6363
|
-
const message = { type: MESSAGE_START, scripts, options, config: { chunkSize } };
|
|
6364
|
-
if (workerData.transferStreams && transferStreamsSupported) {
|
|
6365
|
-
const streamsTransferred = sendMessage({ ...message, readable, writable });
|
|
6366
|
-
if (!streamsTransferred) {
|
|
6367
|
-
transferStreamsSupported = false;
|
|
6368
|
-
initStreams(readable, writable);
|
|
6369
|
-
}
|
|
6370
|
-
} else {
|
|
6371
|
-
sendMessage(message);
|
|
6372
|
-
initStreams(readable, writable);
|
|
6373
|
-
}
|
|
6374
|
-
const result = await workerData.result;
|
|
6375
|
-
try {
|
|
6376
|
-
await writable.close();
|
|
6377
|
-
} catch (_error) {
|
|
6378
|
-
// ignored
|
|
6379
|
-
}
|
|
6380
|
-
await streamClosed;
|
|
6381
|
-
return result;
|
|
6302
|
+
Object.assign(workerData, {
|
|
6303
|
+
worker: getWebWorker(workerData.scripts[0], baseURL, workerData),
|
|
6304
|
+
interface: {
|
|
6305
|
+
run: () => runWebWorker(workerData, { chunkSize })
|
|
6382
6306
|
}
|
|
6383
|
-
};
|
|
6307
|
+
});
|
|
6384
6308
|
}
|
|
6385
6309
|
return workerData.interface;
|
|
6310
|
+
}
|
|
6311
|
+
|
|
6312
|
+
async function runWorker$1({ options, readable, writable, onTaskFinished }, config) {
|
|
6313
|
+
const codecStream = new CodecStream(options, config);
|
|
6314
|
+
try {
|
|
6315
|
+
await readable.pipeThrough(codecStream).pipeTo(writable, { preventClose: true, preventAbort: true });
|
|
6316
|
+
const {
|
|
6317
|
+
signature,
|
|
6318
|
+
size
|
|
6319
|
+
} = codecStream;
|
|
6320
|
+
return {
|
|
6321
|
+
signature,
|
|
6322
|
+
size
|
|
6323
|
+
};
|
|
6324
|
+
} finally {
|
|
6325
|
+
onTaskFinished();
|
|
6326
|
+
}
|
|
6327
|
+
}
|
|
6386
6328
|
|
|
6387
|
-
|
|
6388
|
-
|
|
6329
|
+
async function runWebWorker(workerData, config) {
|
|
6330
|
+
let resolveResult, rejectResult;
|
|
6331
|
+
const result = new Promise((resolve, reject) => {
|
|
6332
|
+
resolveResult = resolve;
|
|
6333
|
+
rejectResult = reject;
|
|
6334
|
+
});
|
|
6335
|
+
Object.assign(workerData, {
|
|
6336
|
+
reader: null,
|
|
6337
|
+
writer: null,
|
|
6338
|
+
resolveResult,
|
|
6339
|
+
rejectResult,
|
|
6340
|
+
result
|
|
6341
|
+
});
|
|
6342
|
+
const { readable, options } = workerData;
|
|
6343
|
+
const { writable, closed } = detectClosedStream(workerData.writable);
|
|
6344
|
+
const streamsTransferred = sendMessage({
|
|
6345
|
+
type: MESSAGE_START,
|
|
6346
|
+
scripts: workerData.scripts.slice(1),
|
|
6347
|
+
options,
|
|
6348
|
+
config,
|
|
6349
|
+
readable,
|
|
6350
|
+
writable
|
|
6351
|
+
}, workerData);
|
|
6352
|
+
if (!streamsTransferred) {
|
|
6353
|
+
Object.assign(workerData, {
|
|
6389
6354
|
reader: readable.getReader(),
|
|
6390
6355
|
writer: writable.getWriter()
|
|
6391
6356
|
});
|
|
6392
6357
|
}
|
|
6358
|
+
const resultValue = await result;
|
|
6359
|
+
try {
|
|
6360
|
+
await writable.close();
|
|
6361
|
+
} catch (_error) {
|
|
6362
|
+
// ignored
|
|
6363
|
+
}
|
|
6364
|
+
await closed;
|
|
6365
|
+
return resultValue;
|
|
6366
|
+
}
|
|
6393
6367
|
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6368
|
+
function detectClosedStream(writableSource) {
|
|
6369
|
+
const writer = writableSource.getWriter();
|
|
6370
|
+
let resolveStreamClosed;
|
|
6371
|
+
const closed = new Promise(resolve => resolveStreamClosed = resolve);
|
|
6372
|
+
const writable = new WritableStream({
|
|
6373
|
+
async write(chunk) {
|
|
6374
|
+
await writer.ready;
|
|
6375
|
+
await writer.write(chunk);
|
|
6376
|
+
},
|
|
6377
|
+
close() {
|
|
6378
|
+
writer.releaseLock();
|
|
6379
|
+
resolveStreamClosed();
|
|
6380
|
+
},
|
|
6381
|
+
abort(reason) {
|
|
6382
|
+
writer.abort(reason);
|
|
6399
6383
|
}
|
|
6384
|
+
});
|
|
6385
|
+
return { writable, closed };
|
|
6386
|
+
}
|
|
6387
|
+
|
|
6388
|
+
let classicWorkersSupported = true;
|
|
6389
|
+
let transferStreamsSupported = true;
|
|
6390
|
+
|
|
6391
|
+
function getWebWorker(url, baseURL, workerData) {
|
|
6392
|
+
const workerOptions = { type: "module" };
|
|
6393
|
+
let scriptUrl, worker;
|
|
6394
|
+
if (typeof url == FUNCTION_TYPE$1) {
|
|
6395
|
+
url = url();
|
|
6396
|
+
}
|
|
6397
|
+
try {
|
|
6398
|
+
scriptUrl = new URL(url, baseURL);
|
|
6399
|
+
} catch (_error) {
|
|
6400
|
+
scriptUrl = url;
|
|
6401
|
+
}
|
|
6402
|
+
if (classicWorkersSupported) {
|
|
6400
6403
|
try {
|
|
6401
|
-
|
|
6404
|
+
worker = new Worker(scriptUrl);
|
|
6402
6405
|
} catch (_error) {
|
|
6403
|
-
|
|
6406
|
+
classicWorkersSupported = false;
|
|
6407
|
+
worker = new Worker(scriptUrl, workerOptions);
|
|
6404
6408
|
}
|
|
6405
|
-
|
|
6409
|
+
} else {
|
|
6410
|
+
worker = new Worker(scriptUrl, workerOptions);
|
|
6406
6411
|
}
|
|
6412
|
+
worker.addEventListener(MESSAGE_EVENT_TYPE, event => onMessage(event, workerData));
|
|
6413
|
+
return worker;
|
|
6414
|
+
}
|
|
6407
6415
|
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
data = new Uint8Array(data);
|
|
6417
|
-
}
|
|
6418
|
-
message.data = data.buffer;
|
|
6419
|
-
transferrables.push(message.data);
|
|
6416
|
+
function sendMessage(message, { worker, writer, onTaskFinished, transferStreams }) {
|
|
6417
|
+
try {
|
|
6418
|
+
let { data, readable, writable } = message;
|
|
6419
|
+
const transferrables = [];
|
|
6420
|
+
if (data) {
|
|
6421
|
+
const { buffer, length } = data;
|
|
6422
|
+
if (length != buffer.byteLength) {
|
|
6423
|
+
data = new Uint8Array(data);
|
|
6420
6424
|
}
|
|
6425
|
+
message.data = data.buffer;
|
|
6426
|
+
transferrables.push(message.data);
|
|
6427
|
+
}
|
|
6428
|
+
if (transferStreams && transferStreamsSupported) {
|
|
6421
6429
|
if (readable) {
|
|
6422
6430
|
transferrables.push(readable);
|
|
6423
6431
|
}
|
|
6424
6432
|
if (writable) {
|
|
6425
6433
|
transferrables.push(writable);
|
|
6426
6434
|
}
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6435
|
+
} else {
|
|
6436
|
+
message.readable = message.writable = null;
|
|
6437
|
+
}
|
|
6438
|
+
if (transferrables.length) {
|
|
6439
|
+
try {
|
|
6440
|
+
worker.postMessage(message, transferrables);
|
|
6441
|
+
return true;
|
|
6442
|
+
} catch (_error) {
|
|
6443
|
+
transferStreamsSupported = false;
|
|
6444
|
+
message.readable = message.writable = null;
|
|
6436
6445
|
worker.postMessage(message);
|
|
6437
6446
|
}
|
|
6438
|
-
}
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6447
|
+
} else {
|
|
6448
|
+
worker.postMessage(message);
|
|
6449
|
+
}
|
|
6450
|
+
} catch (error) {
|
|
6451
|
+
if (writer) {
|
|
6452
|
+
writer.releaseLock();
|
|
6444
6453
|
}
|
|
6454
|
+
onTaskFinished();
|
|
6455
|
+
throw error;
|
|
6445
6456
|
}
|
|
6457
|
+
}
|
|
6446
6458
|
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
Object.assign(error, { stack, code, name });
|
|
6458
|
-
close(error);
|
|
6459
|
-
} else {
|
|
6460
|
-
if (type == MESSAGE_PULL) {
|
|
6461
|
-
const { value, done } = await reader.read();
|
|
6462
|
-
sendMessage({ type: MESSAGE_DATA, data: value, done, messageId });
|
|
6463
|
-
}
|
|
6464
|
-
if (type == MESSAGE_DATA) {
|
|
6465
|
-
await writer.ready;
|
|
6466
|
-
await writer.write(new Uint8Array(data));
|
|
6467
|
-
sendMessage({ type: MESSAGE_ACK_DATA, messageId });
|
|
6468
|
-
}
|
|
6469
|
-
if (type == MESSAGE_CLOSE) {
|
|
6470
|
-
close(null, result);
|
|
6471
|
-
}
|
|
6472
|
-
}
|
|
6473
|
-
} catch (error) {
|
|
6459
|
+
async function onMessage(event, workerData) {
|
|
6460
|
+
const message = event.data;
|
|
6461
|
+
const { reader, writer, resolveResult, rejectResult, onTaskFinished } = workerData;
|
|
6462
|
+
const { type, data, messageId, result } = message;
|
|
6463
|
+
const reponseError = message.error;
|
|
6464
|
+
try {
|
|
6465
|
+
if (reponseError) {
|
|
6466
|
+
const { message, stack, code, name } = reponseError;
|
|
6467
|
+
const error = new Error(message);
|
|
6468
|
+
Object.assign(error, { stack, code, name });
|
|
6474
6469
|
close(error);
|
|
6475
|
-
}
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
rejectResult(error);
|
|
6480
|
-
} else {
|
|
6481
|
-
resolveResult(result);
|
|
6470
|
+
} else {
|
|
6471
|
+
if (type == MESSAGE_PULL) {
|
|
6472
|
+
const { value, done } = await reader.read();
|
|
6473
|
+
sendMessage({ type: MESSAGE_DATA, data: value, done, messageId }, workerData);
|
|
6482
6474
|
}
|
|
6483
|
-
if (
|
|
6484
|
-
writer.
|
|
6475
|
+
if (type == MESSAGE_DATA) {
|
|
6476
|
+
await writer.ready;
|
|
6477
|
+
await writer.write(new Uint8Array(data));
|
|
6478
|
+
sendMessage({ type: MESSAGE_ACK_DATA, messageId }, workerData);
|
|
6485
6479
|
}
|
|
6486
|
-
|
|
6480
|
+
if (type == MESSAGE_CLOSE) {
|
|
6481
|
+
close(null, result);
|
|
6482
|
+
}
|
|
6483
|
+
}
|
|
6484
|
+
} catch (error) {
|
|
6485
|
+
close(error);
|
|
6486
|
+
}
|
|
6487
|
+
|
|
6488
|
+
function close(error, result) {
|
|
6489
|
+
if (error) {
|
|
6490
|
+
rejectResult(error);
|
|
6491
|
+
} else {
|
|
6492
|
+
resolveResult(result);
|
|
6487
6493
|
}
|
|
6494
|
+
if (writer) {
|
|
6495
|
+
writer.releaseLock();
|
|
6496
|
+
}
|
|
6497
|
+
onTaskFinished();
|
|
6488
6498
|
}
|
|
6489
6499
|
}
|
|
6490
6500
|
|
|
@@ -6610,9 +6620,11 @@
|
|
|
6610
6620
|
*/
|
|
6611
6621
|
|
|
6612
6622
|
/* global Blob, atob, btoa, XMLHttpRequest, URL, fetch, ReadableStream, WritableStream, FileReader, TransformStream, Response */
|
|
6623
|
+
// deno-lint-ignore-file no-this-alias
|
|
6613
6624
|
|
|
6614
6625
|
const ERR_HTTP_STATUS = "HTTP error ";
|
|
6615
6626
|
const ERR_HTTP_RANGE = "HTTP Range not supported";
|
|
6627
|
+
const ERR_ITERATOR_COMPLETED_TOO_SOON = "Writer iterator completed too soon";
|
|
6616
6628
|
|
|
6617
6629
|
const CONTENT_TYPE_TEXT_PLAIN = "text/plain";
|
|
6618
6630
|
const HTTP_HEADER_CONTENT_LENGTH = "Content-Length";
|
|
@@ -7145,6 +7157,69 @@
|
|
|
7145
7157
|
}
|
|
7146
7158
|
}
|
|
7147
7159
|
|
|
7160
|
+
class SplitZipWriter extends Stream {
|
|
7161
|
+
|
|
7162
|
+
constructor(writerGenerator, maxSize = 4294967296) {
|
|
7163
|
+
super();
|
|
7164
|
+
const zipWriter = this;
|
|
7165
|
+
Object.assign(zipWriter, {
|
|
7166
|
+
diskNumber: 0,
|
|
7167
|
+
diskOffset: 0,
|
|
7168
|
+
size: 0,
|
|
7169
|
+
availableSize: maxSize
|
|
7170
|
+
});
|
|
7171
|
+
let diskSourceWriter, diskWritable, diskWriter;
|
|
7172
|
+
const writable = new WritableStream({
|
|
7173
|
+
async write(chunk) {
|
|
7174
|
+
if (!diskWriter) {
|
|
7175
|
+
const { value, done } = await writerGenerator.next();
|
|
7176
|
+
if (done && !value) {
|
|
7177
|
+
throw new Error(ERR_ITERATOR_COMPLETED_TOO_SOON);
|
|
7178
|
+
} else {
|
|
7179
|
+
diskSourceWriter = value;
|
|
7180
|
+
diskSourceWriter.size = 0;
|
|
7181
|
+
diskWritable = value.writable;
|
|
7182
|
+
diskWriter = diskWritable.getWriter();
|
|
7183
|
+
}
|
|
7184
|
+
await this.write(chunk);
|
|
7185
|
+
} else if (diskSourceWriter.size + chunk.length >= maxSize) {
|
|
7186
|
+
const chunkLength = maxSize - diskSourceWriter.size;
|
|
7187
|
+
await writeChunk(chunk.slice(0, chunkLength));
|
|
7188
|
+
await closeDisk();
|
|
7189
|
+
zipWriter.diskOffset += diskSourceWriter.size;
|
|
7190
|
+
zipWriter.diskNumber++;
|
|
7191
|
+
diskWriter = null;
|
|
7192
|
+
await this.write(chunk.slice(chunkLength));
|
|
7193
|
+
} else if (chunk.length) {
|
|
7194
|
+
await writeChunk(chunk);
|
|
7195
|
+
}
|
|
7196
|
+
zipWriter.availableSize = maxSize - diskSourceWriter.size;
|
|
7197
|
+
},
|
|
7198
|
+
async close() {
|
|
7199
|
+
await diskWriter.ready;
|
|
7200
|
+
await closeDisk();
|
|
7201
|
+
}
|
|
7202
|
+
});
|
|
7203
|
+
Object.defineProperty(zipWriter, PROPERTY_NAME_WRITABLE, {
|
|
7204
|
+
get() {
|
|
7205
|
+
return writable;
|
|
7206
|
+
}
|
|
7207
|
+
});
|
|
7208
|
+
|
|
7209
|
+
async function writeChunk(chunk) {
|
|
7210
|
+
await diskWriter.ready;
|
|
7211
|
+
await diskWriter.write(chunk);
|
|
7212
|
+
diskSourceWriter.size += chunk.length;
|
|
7213
|
+
zipWriter.size += chunk.length;
|
|
7214
|
+
}
|
|
7215
|
+
|
|
7216
|
+
async function closeDisk() {
|
|
7217
|
+
diskWritable.size = diskSourceWriter.size;
|
|
7218
|
+
await diskWriter.close();
|
|
7219
|
+
}
|
|
7220
|
+
}
|
|
7221
|
+
}
|
|
7222
|
+
|
|
7148
7223
|
function isHttpFamily(url) {
|
|
7149
7224
|
const { baseURL } = getConfiguration();
|
|
7150
7225
|
const { protocol } = new URL(url, baseURL);
|
|
@@ -7276,7 +7351,8 @@
|
|
|
7276
7351
|
"rawExtraField", "bitFlag", "extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment",
|
|
7277
7352
|
"extraFieldAES", "filenameUTF8", "commentUTF8", "offset", "zip64", "compressionMethod",
|
|
7278
7353
|
"extraFieldNTFS", "lastAccessDate", "creationDate", "extraFieldExtendedTimestamp",
|
|
7279
|
-
"version", "versionMadeBy", "msDosCompatible", "internalFileAttribute", "externalFileAttribute"
|
|
7354
|
+
"version", "versionMadeBy", "msDosCompatible", "internalFileAttribute", "externalFileAttribute",
|
|
7355
|
+
"diskNumberStart"];
|
|
7280
7356
|
|
|
7281
7357
|
class Entry {
|
|
7282
7358
|
|
|
@@ -7314,7 +7390,6 @@
|
|
|
7314
7390
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
7315
7391
|
*/
|
|
7316
7392
|
|
|
7317
|
-
const SPLIT_ZIP_FILE_SIGNATURE = 0x08074b50;
|
|
7318
7393
|
const ERR_BAD_FORMAT = "File format is not recognized";
|
|
7319
7394
|
const ERR_EOCDR_NOT_FOUND = "End of central directory not found";
|
|
7320
7395
|
const ERR_EOCDR_ZIP64_NOT_FOUND = "End of Zip64 central directory not found";
|
|
@@ -7387,15 +7462,16 @@
|
|
|
7387
7462
|
throw new Error(ERR_EOCDR_NOT_FOUND);
|
|
7388
7463
|
}
|
|
7389
7464
|
}
|
|
7390
|
-
const { lastDiskNumber } = reader;
|
|
7391
7465
|
const endOfDirectoryView = getDataView$1(endOfDirectoryInfo);
|
|
7392
7466
|
let directoryDataLength = getUint32(endOfDirectoryView, 12);
|
|
7393
7467
|
let directoryDataOffset = getUint32(endOfDirectoryView, 16);
|
|
7394
7468
|
const commentOffset = endOfDirectoryInfo.offset;
|
|
7395
7469
|
const commentLength = getUint16(endOfDirectoryView, 20);
|
|
7396
7470
|
const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
|
|
7397
|
-
|
|
7398
|
-
|
|
7471
|
+
const lastDiskNumber = getUint16(endOfDirectoryView, 4);
|
|
7472
|
+
const expectedLastDiskNumber = reader.lastDiskNumber || 0;
|
|
7473
|
+
let diskNumber = getUint16(endOfDirectoryView, 6);
|
|
7474
|
+
if (expectedLastDiskNumber != lastDiskNumber) {
|
|
7399
7475
|
throw new Error(ERR_SPLIT_ZIP_FILE);
|
|
7400
7476
|
}
|
|
7401
7477
|
let filesLength = getUint16(endOfDirectoryView, 8);
|
|
@@ -7564,7 +7640,7 @@
|
|
|
7564
7640
|
compressedSize
|
|
7565
7641
|
} = zipEntry;
|
|
7566
7642
|
const localDirectory = zipEntry.localDirectory = {};
|
|
7567
|
-
|
|
7643
|
+
const dataArray = await readUint8Array(reader, offset, 30, diskNumberStart);
|
|
7568
7644
|
const dataView = getDataView$1(dataArray);
|
|
7569
7645
|
let password = getOptionValue$1(zipEntry, options, "password");
|
|
7570
7646
|
password = password && password.length && password;
|
|
@@ -7935,7 +8011,7 @@
|
|
|
7935
8011
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (make sure 'keepOrder' is set to 'true')";
|
|
7936
8012
|
|
|
7937
8013
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
7938
|
-
const EXTRAFIELD_LENGTH_ZIP64 =
|
|
8014
|
+
const EXTRAFIELD_LENGTH_ZIP64 = 28;
|
|
7939
8015
|
|
|
7940
8016
|
let workers = 0;
|
|
7941
8017
|
const pendingEntries = [];
|
|
@@ -7943,14 +8019,26 @@
|
|
|
7943
8019
|
class ZipWriter {
|
|
7944
8020
|
|
|
7945
8021
|
constructor(writer, options = {}) {
|
|
8022
|
+
if (writer.writable === UNDEFINED_VALUE && typeof writer.next == FUNCTION_TYPE$1) {
|
|
8023
|
+
writer = new SplitZipWriter(writer);
|
|
8024
|
+
}
|
|
7946
8025
|
if (writer instanceof WritableStream) {
|
|
7947
8026
|
writer = { writable: writer };
|
|
7948
8027
|
}
|
|
7949
8028
|
if (writer.writable.size === UNDEFINED_VALUE) {
|
|
7950
8029
|
writer.writable.size = 0;
|
|
7951
8030
|
}
|
|
8031
|
+
const splitZipFile = writer instanceof SplitZipWriter;
|
|
8032
|
+
if (!splitZipFile) {
|
|
8033
|
+
Object.assign(writer, {
|
|
8034
|
+
diskNumber: 0,
|
|
8035
|
+
diskOffset: 0,
|
|
8036
|
+
availableSize: Infinity
|
|
8037
|
+
});
|
|
8038
|
+
}
|
|
7952
8039
|
Object.assign(this, {
|
|
7953
8040
|
writer,
|
|
8041
|
+
addSplitZipSignature: splitZipFile,
|
|
7954
8042
|
options,
|
|
7955
8043
|
config: getConfiguration(),
|
|
7956
8044
|
files: new Map(),
|
|
@@ -8202,10 +8290,21 @@
|
|
|
8202
8290
|
releaseLockWriter = () => delete zipWriter.lockWriter;
|
|
8203
8291
|
}
|
|
8204
8292
|
await initStream(fileWriter);
|
|
8293
|
+
const { writable, diskNumber } = writer;
|
|
8294
|
+
let { diskOffset } = writer;
|
|
8295
|
+
if (zipWriter.addSplitZipSignature) {
|
|
8296
|
+
delete zipWriter.addSplitZipSignature;
|
|
8297
|
+
const signatureArray = new Uint8Array(4);
|
|
8298
|
+
const signatureArrayView = new DataView(signatureArray.buffer);
|
|
8299
|
+
setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
|
|
8300
|
+
await writeData(writable, signatureArray);
|
|
8301
|
+
zipWriter.offset += 4;
|
|
8302
|
+
}
|
|
8205
8303
|
if (!bufferedWrite) {
|
|
8206
8304
|
await lockPreviousFileEntry;
|
|
8207
8305
|
}
|
|
8208
8306
|
writingEntryData = true;
|
|
8307
|
+
fileEntry.diskNumberStart = diskNumber;
|
|
8209
8308
|
fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, zipWriter.config, options);
|
|
8210
8309
|
writingEntryData = false;
|
|
8211
8310
|
files.set(name, fileEntry);
|
|
@@ -8216,7 +8315,6 @@
|
|
|
8216
8315
|
await lockPreviousFileEntry;
|
|
8217
8316
|
await requestLockWriter();
|
|
8218
8317
|
writingBufferedEntryData = true;
|
|
8219
|
-
const { writable } = writer;
|
|
8220
8318
|
if (!dataDescriptor) {
|
|
8221
8319
|
const arrayBuffer = await sliceAsArrayBuffer(blob, 0, 26);
|
|
8222
8320
|
const arrayBufferView = new DataView(arrayBuffer);
|
|
@@ -8233,13 +8331,18 @@
|
|
|
8233
8331
|
await writeData(writable, new Uint8Array(arrayBuffer));
|
|
8234
8332
|
blob = blob.slice(arrayBuffer.byteLength);
|
|
8235
8333
|
}
|
|
8334
|
+
fileEntry.diskNumberStart = writer.diskNumber;
|
|
8335
|
+
diskOffset = writer.diskOffset;
|
|
8236
8336
|
await blob.stream().pipeTo(writable, { preventClose: true, signal });
|
|
8337
|
+
writable.size += blob.size;
|
|
8237
8338
|
writingBufferedEntryData = false;
|
|
8238
8339
|
}
|
|
8239
|
-
fileEntry.offset = zipWriter.offset;
|
|
8340
|
+
fileEntry.offset = zipWriter.offset - diskOffset;
|
|
8240
8341
|
if (fileEntry.zip64) {
|
|
8241
|
-
const
|
|
8242
|
-
|
|
8342
|
+
const { rawExtraFieldZip64, offset, diskNumberStart } = fileEntry;
|
|
8343
|
+
const rawExtraFieldZip64View = getDataView(rawExtraFieldZip64);
|
|
8344
|
+
setBigUint64(rawExtraFieldZip64View, 20, BigInt(offset));
|
|
8345
|
+
setUint32(rawExtraFieldZip64View, 28, diskNumberStart);
|
|
8243
8346
|
} else if (fileEntry.offset >= MAX_32_BITS) {
|
|
8244
8347
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
8245
8348
|
}
|
|
@@ -8283,7 +8386,7 @@
|
|
|
8283
8386
|
}
|
|
8284
8387
|
}
|
|
8285
8388
|
|
|
8286
|
-
async function createFileEntry(reader, writer,
|
|
8389
|
+
async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryInfo, config, options) {
|
|
8287
8390
|
const {
|
|
8288
8391
|
headerInfo,
|
|
8289
8392
|
dataDescriptorInfo
|
|
@@ -8328,7 +8431,7 @@
|
|
|
8328
8431
|
useCompressionStream
|
|
8329
8432
|
} = options;
|
|
8330
8433
|
const fileEntry = {
|
|
8331
|
-
lock
|
|
8434
|
+
lock,
|
|
8332
8435
|
versionMadeBy,
|
|
8333
8436
|
zip64,
|
|
8334
8437
|
directory: Boolean(directory),
|
|
@@ -8343,7 +8446,8 @@
|
|
|
8343
8446
|
extendedTimestamp,
|
|
8344
8447
|
msDosCompatible,
|
|
8345
8448
|
internalFileAttribute,
|
|
8346
|
-
externalFileAttribute
|
|
8449
|
+
externalFileAttribute,
|
|
8450
|
+
diskNumberStart
|
|
8347
8451
|
};
|
|
8348
8452
|
let uncompressedSize = 0;
|
|
8349
8453
|
let signature;
|
|
@@ -8615,10 +8719,12 @@
|
|
|
8615
8719
|
}
|
|
8616
8720
|
|
|
8617
8721
|
async function closeFile(zipWriter, comment, options) {
|
|
8618
|
-
const { files } = zipWriter;
|
|
8722
|
+
const { files, writer } = zipWriter;
|
|
8619
8723
|
let offset = 0;
|
|
8620
8724
|
let directoryDataLength = 0;
|
|
8621
|
-
|
|
8725
|
+
const { diskOffset, writable } = writer;
|
|
8726
|
+
let { diskNumber } = writer;
|
|
8727
|
+
let directoryOffset = zipWriter.offset - diskOffset;
|
|
8622
8728
|
let filesLength = files.size;
|
|
8623
8729
|
for (const [, {
|
|
8624
8730
|
rawFilename,
|
|
@@ -8647,7 +8753,7 @@
|
|
|
8647
8753
|
zip64 = true;
|
|
8648
8754
|
}
|
|
8649
8755
|
}
|
|
8650
|
-
const directoryArray = new Uint8Array(directoryDataLength
|
|
8756
|
+
const directoryArray = new Uint8Array(directoryDataLength);
|
|
8651
8757
|
const directoryView = getDataView(directoryArray);
|
|
8652
8758
|
for (const [indexFileEntry, fileEntry] of Array.from(files.values()).entries()) {
|
|
8653
8759
|
const {
|
|
@@ -8666,7 +8772,8 @@
|
|
|
8666
8772
|
internalFileAttribute,
|
|
8667
8773
|
externalFileAttribute,
|
|
8668
8774
|
extendedTimestamp,
|
|
8669
|
-
lastModDate
|
|
8775
|
+
lastModDate,
|
|
8776
|
+
diskNumberStart
|
|
8670
8777
|
} = fileEntry;
|
|
8671
8778
|
let rawExtraFieldExtendedTimestamp;
|
|
8672
8779
|
if (extendedTimestamp) {
|
|
@@ -8685,17 +8792,14 @@
|
|
|
8685
8792
|
arraySet(directoryArray, headerArray, offset + 6);
|
|
8686
8793
|
setUint16(directoryView, offset + 30, extraFieldLength);
|
|
8687
8794
|
setUint16(directoryView, offset + 32, getLength(rawComment));
|
|
8795
|
+
setUint16(directoryView, offset + 34, zip64 ? MAX_16_BITS : diskNumberStart);
|
|
8688
8796
|
setUint16(directoryView, offset + 36, internalFileAttribute);
|
|
8689
8797
|
if (externalFileAttribute) {
|
|
8690
8798
|
setUint32(directoryView, offset + 38, externalFileAttribute);
|
|
8691
8799
|
} else if (directory && msDosCompatible) {
|
|
8692
8800
|
setUint8(directoryView, offset + 38, FILE_ATTR_MSDOS_DIR_MASK);
|
|
8693
8801
|
}
|
|
8694
|
-
|
|
8695
|
-
setUint32(directoryView, offset + 42, MAX_32_BITS);
|
|
8696
|
-
} else {
|
|
8697
|
-
setUint32(directoryView, offset + 42, fileEntryOffset);
|
|
8698
|
-
}
|
|
8802
|
+
setUint32(directoryView, offset + 42, zip64 ? MAX_32_BITS : fileEntryOffset);
|
|
8699
8803
|
arraySet(directoryArray, rawFilename, offset + 46);
|
|
8700
8804
|
arraySet(directoryArray, rawExtraFieldZip64, offset + 46 + getLength(rawFilename));
|
|
8701
8805
|
arraySet(directoryArray, rawExtraFieldAES, offset + 46 + getLength(rawFilename, rawExtraFieldZip64));
|
|
@@ -8712,39 +8816,52 @@
|
|
|
8712
8816
|
}
|
|
8713
8817
|
}
|
|
8714
8818
|
}
|
|
8819
|
+
await initStream(writer);
|
|
8820
|
+
await writeData(writable, directoryArray);
|
|
8821
|
+
const endOfdirectoryArray = new Uint8Array(zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
8822
|
+
const endOfdirectoryView = getDataView(endOfdirectoryArray);
|
|
8823
|
+
let lastDiskNumber = writer.diskNumber;
|
|
8824
|
+
const { availableSize } = writer;
|
|
8825
|
+
if (availableSize < endOfdirectoryArray.length) {
|
|
8826
|
+
lastDiskNumber++;
|
|
8827
|
+
}
|
|
8828
|
+
offset = 0;
|
|
8715
8829
|
if (zip64) {
|
|
8716
|
-
setUint32(
|
|
8717
|
-
setBigUint64(
|
|
8718
|
-
setUint16(
|
|
8719
|
-
setUint16(
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
setBigUint64(
|
|
8723
|
-
setBigUint64(
|
|
8724
|
-
|
|
8725
|
-
setBigUint64(
|
|
8726
|
-
setUint32(
|
|
8830
|
+
setUint32(endOfdirectoryView, 0, ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
|
|
8831
|
+
setBigUint64(endOfdirectoryView, 4, BigInt(44));
|
|
8832
|
+
setUint16(endOfdirectoryView, 12, 45);
|
|
8833
|
+
setUint16(endOfdirectoryView, 14, 45);
|
|
8834
|
+
setUint32(endOfdirectoryView, 16, lastDiskNumber);
|
|
8835
|
+
setUint32(endOfdirectoryView, 20, diskNumber);
|
|
8836
|
+
setBigUint64(endOfdirectoryView, 24, BigInt(filesLength));
|
|
8837
|
+
setBigUint64(endOfdirectoryView, 32, BigInt(filesLength));
|
|
8838
|
+
setBigUint64(endOfdirectoryView, 40, BigInt(directoryDataLength));
|
|
8839
|
+
setBigUint64(endOfdirectoryView, 48, BigInt(directoryOffset));
|
|
8840
|
+
setUint32(endOfdirectoryView, 56, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
|
|
8841
|
+
setBigUint64(endOfdirectoryView, 64, BigInt(directoryOffset) + BigInt(directoryDataLength));
|
|
8842
|
+
setUint32(endOfdirectoryView, 72, lastDiskNumber + 1);
|
|
8843
|
+
diskNumber = MAX_16_BITS;
|
|
8727
8844
|
filesLength = MAX_16_BITS;
|
|
8728
8845
|
directoryOffset = MAX_32_BITS;
|
|
8729
8846
|
directoryDataLength = MAX_32_BITS;
|
|
8730
|
-
offset +=
|
|
8731
|
-
}
|
|
8732
|
-
setUint32(
|
|
8733
|
-
setUint16(
|
|
8734
|
-
setUint16(
|
|
8735
|
-
|
|
8736
|
-
|
|
8847
|
+
offset += ZIP64_END_OF_CENTRAL_DIR_LENGTH + ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH;
|
|
8848
|
+
}
|
|
8849
|
+
setUint32(endOfdirectoryView, offset, END_OF_CENTRAL_DIR_SIGNATURE);
|
|
8850
|
+
setUint16(endOfdirectoryView, offset + 4, lastDiskNumber);
|
|
8851
|
+
setUint16(endOfdirectoryView, offset + 6, diskNumber);
|
|
8852
|
+
setUint16(endOfdirectoryView, offset + 8, filesLength);
|
|
8853
|
+
setUint16(endOfdirectoryView, offset + 10, filesLength);
|
|
8854
|
+
setUint32(endOfdirectoryView, offset + 12, directoryDataLength);
|
|
8855
|
+
setUint32(endOfdirectoryView, offset + 16, directoryOffset);
|
|
8737
8856
|
const commentLength = getLength(comment);
|
|
8738
8857
|
if (commentLength) {
|
|
8739
8858
|
if (commentLength <= MAX_16_BITS) {
|
|
8740
|
-
setUint16(
|
|
8859
|
+
setUint16(endOfdirectoryView, offset + 20, commentLength);
|
|
8741
8860
|
} else {
|
|
8742
8861
|
throw new Error(ERR_INVALID_COMMENT);
|
|
8743
8862
|
}
|
|
8744
8863
|
}
|
|
8745
|
-
|
|
8746
|
-
await initStream(zipWriter.writer);
|
|
8747
|
-
await writeData(writable, directoryArray);
|
|
8864
|
+
await writeData(writable, endOfdirectoryArray);
|
|
8748
8865
|
if (commentLength) {
|
|
8749
8866
|
await writeData(writable, comment);
|
|
8750
8867
|
}
|
|
@@ -8869,6 +8986,7 @@
|
|
|
8869
8986
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
8870
8987
|
exports.ERR_INVALID_SIGNATURE = ERR_INVALID_SIGNATURE;
|
|
8871
8988
|
exports.ERR_INVALID_VERSION = ERR_INVALID_VERSION;
|
|
8989
|
+
exports.ERR_ITERATOR_COMPLETED_TOO_SOON = ERR_ITERATOR_COMPLETED_TOO_SOON;
|
|
8872
8990
|
exports.ERR_LOCAL_FILE_HEADER_NOT_FOUND = ERR_LOCAL_FILE_HEADER_NOT_FOUND;
|
|
8873
8991
|
exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
|
|
8874
8992
|
exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION;
|
|
@@ -8878,6 +8996,7 @@
|
|
|
8878
8996
|
exports.HttpReader = HttpReader;
|
|
8879
8997
|
exports.Reader = Reader;
|
|
8880
8998
|
exports.SplitZipReader = SplitZipReader;
|
|
8999
|
+
exports.SplitZipWriter = SplitZipWriter;
|
|
8881
9000
|
exports.TextReader = TextReader;
|
|
8882
9001
|
exports.TextWriter = TextWriter;
|
|
8883
9002
|
exports.Uint8ArrayReader = Uint8ArrayReader;
|