@zip.js/zip.js 2.8.1 → 2.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/deno.json +1 -1
- package/dist/README.md +5 -1
- package/dist/zip-core.js +2324 -2606
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core.js +31 -537
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-native.js +8251 -0
- package/dist/zip-fs-native.min.js +1 -0
- package/dist/zip-fs.js +2887 -2854
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +5712 -0
- package/dist/zip-legacy.min.js +1 -0
- package/dist/zip-native.js +5750 -0
- package/dist/zip-native.min.js +1 -0
- package/dist/zip-web-worker-native.js +1 -0
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +2884 -2848
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +8243 -0
- package/index-native.js +31 -0
- package/index-native.min.js +1 -0
- package/index.cjs +2887 -2854
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +1 -4
- package/lib/core/codec-worker.js +17 -21
- package/lib/core/configuration.js +2 -3
- package/lib/core/io.js +2 -1
- package/lib/core/streams/aes-crypto-stream.js +2 -4
- package/lib/core/streams/codec-stream.js +2 -1
- package/lib/core/streams/zlib-js/README.md +1 -0
- package/lib/core/streams/zlib-js/zlib-streams.min.js +1 -0
- package/lib/core/streams/{zlib → zlib-wasm}/zlib-streams-loader.js +1 -2
- package/lib/core/streams/{zlib → zlib-wasm}/zlib-streams.js +4 -0
- package/lib/core/{web-worker.js → web-worker-base.js} +7 -12
- package/lib/core/web-worker-inline-native.js +1 -0
- package/lib/core/web-worker-inline-wasm.js +1 -0
- package/lib/core/web-worker-native.js +40 -0
- package/lib/core/web-worker-wasm.js +47 -0
- package/lib/core/zip-fs.js +3 -6
- package/lib/core/zip-reader.js +6 -11
- package/lib/core/zip-writer.js +3 -6
- package/lib/zip-core-base.js +61 -0
- package/lib/zip-core-native.js +30 -0
- package/lib/zip-core-reader.js +46 -0
- package/lib/zip-core-wasm.js +30 -0
- package/lib/zip-core-writer.js +43 -0
- package/lib/zip-core.js +2 -79
- package/lib/zip-fs-core-native.js +30 -0
- package/lib/{zip-fs-core.js → zip-fs-core-wasm.js} +1 -1
- package/lib/{zip-fs.js → zip-fs-native.js} +2 -4
- package/lib/zip-fs-wasm.js +35 -0
- package/lib/{zip.js → zip-legacy.js} +3 -4
- package/lib/zip-module-native.js +39 -0
- package/lib/zip-module-wasm.js +63 -0
- package/lib/zip-native.js +35 -0
- package/lib/zip-wasm.js +35 -0
- package/package.json +64 -11
- package/lib/core/web-worker-inline.js +0 -1
- /package/lib/core/streams/{zlib → zlib-wasm}/README.md +0 -0
- /package/lib/core/streams/{zlib → zlib-wasm}/zlib-streams.wasm +0 -0
package/lib/zip-wasm.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
this list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
notice, this list of conditions and the following disclaimer in
|
|
12
|
+
the documentation and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
15
|
+
derived from this software without specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
18
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
20
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
21
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
22
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
23
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
26
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import { configure } from "./core/configuration.js";
|
|
30
|
+
import { configureWebWorker } from "./core/web-worker-inline-wasm.js";
|
|
31
|
+
|
|
32
|
+
configureWebWorker(configure);
|
|
33
|
+
|
|
34
|
+
export * from "./zip-core-wasm.js";
|
|
35
|
+
export * from "./zip-module-wasm.js";
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A JavaScript library to zip and unzip files in the browser, Deno and Node.js",
|
|
4
4
|
"author": "Gildas Lormeau",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
|
-
"version": "2.8.
|
|
6
|
+
"version": "2.8.3",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"zip",
|
|
@@ -25,11 +25,12 @@
|
|
|
25
25
|
"multi-core",
|
|
26
26
|
"split-zip",
|
|
27
27
|
"usdz",
|
|
28
|
-
"deflate64"
|
|
28
|
+
"deflate64",
|
|
29
|
+
"wasm"
|
|
29
30
|
],
|
|
30
31
|
"engines": {
|
|
31
32
|
"deno": ">=1.0.0",
|
|
32
|
-
"node": ">=
|
|
33
|
+
"node": ">=18.0.0",
|
|
33
34
|
"bun": ">=0.7.0"
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
@@ -58,34 +59,86 @@
|
|
|
58
59
|
"default": "./index.cjs"
|
|
59
60
|
}
|
|
60
61
|
},
|
|
62
|
+
"./index-native.js": {
|
|
63
|
+
"import": {
|
|
64
|
+
"types": "./index.d.ts",
|
|
65
|
+
"default": "./index-native.js"
|
|
66
|
+
},
|
|
67
|
+
"require": {
|
|
68
|
+
"types": "./index.d.ts",
|
|
69
|
+
"default": "./index-native.cjs"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
61
72
|
"./index.min.js": {
|
|
62
73
|
"import": {
|
|
63
74
|
"types": "./index.d.ts",
|
|
64
75
|
"default": "./index.min.js"
|
|
65
76
|
}
|
|
66
77
|
},
|
|
78
|
+
"./index-native.min.js": {
|
|
79
|
+
"import": {
|
|
80
|
+
"types": "./index.d.ts",
|
|
81
|
+
"default": "./index-native.min.js"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"./lib/zip-core-reader.js": {
|
|
85
|
+
"import": {
|
|
86
|
+
"types": "./index.d.ts",
|
|
87
|
+
"default": "./lib/zip-core-reader.js"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"./lib/zip-core-writer.js": {
|
|
91
|
+
"import": {
|
|
92
|
+
"types": "./index.d.ts",
|
|
93
|
+
"default": "./lib/zip-core-writer.js"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
67
96
|
"./lib/zip-fs.js": {
|
|
68
97
|
"import": {
|
|
69
98
|
"types": "./index.d.ts",
|
|
70
|
-
"default": "./lib/zip-fs.js"
|
|
99
|
+
"default": "./lib/zip-fs-wasm.js"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"./lib/zip-fs-native.js": {
|
|
103
|
+
"import": {
|
|
104
|
+
"types": "./index.d.ts",
|
|
105
|
+
"default": "./lib/zip-fs-native.js"
|
|
71
106
|
}
|
|
72
107
|
},
|
|
73
108
|
"./lib/zip-core.js": {
|
|
74
109
|
"import": {
|
|
75
110
|
"types": "./index.d.ts",
|
|
76
|
-
"default": "./lib/zip-core.js"
|
|
111
|
+
"default": "./lib/zip-core-wasm.js"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"./lib/zip-core-native.js": {
|
|
115
|
+
"import": {
|
|
116
|
+
"types": "./index.d.ts",
|
|
117
|
+
"default": "./lib/zip-core-native.js"
|
|
77
118
|
}
|
|
78
119
|
},
|
|
79
120
|
"./lib/zip-fs-core.js": {
|
|
80
121
|
"import": {
|
|
81
122
|
"types": "./index.d.ts",
|
|
82
|
-
"default": "./lib/zip-fs-core.js"
|
|
123
|
+
"default": "./lib/zip-fs-core-wasm.js"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"./lib/zip-fs-core-native.js": {
|
|
127
|
+
"import": {
|
|
128
|
+
"types": "./index.d.ts",
|
|
129
|
+
"default": "./lib/zip-fs-core-native.js"
|
|
83
130
|
}
|
|
84
131
|
},
|
|
85
132
|
"./lib/zip.js": {
|
|
86
133
|
"import": {
|
|
87
134
|
"types": "./index.d.ts",
|
|
88
|
-
"default": "./lib/zip.js"
|
|
135
|
+
"default": "./lib/zip-wasm.js"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"./lib/zip-native.js": {
|
|
139
|
+
"import": {
|
|
140
|
+
"types": "./index.d.ts",
|
|
141
|
+
"default": "./lib/zip-native.js"
|
|
89
142
|
}
|
|
90
143
|
}
|
|
91
144
|
},
|
|
@@ -100,10 +153,10 @@
|
|
|
100
153
|
"devDependencies": {
|
|
101
154
|
"@rollup/plugin-replace": "^6.0.2",
|
|
102
155
|
"@rollup/plugin-terser": "^0.4.4",
|
|
103
|
-
"eslint": "^9.
|
|
156
|
+
"eslint": "^9.36.0",
|
|
104
157
|
"http-server": "^14.1.1",
|
|
105
|
-
"rollup": "^4.
|
|
106
|
-
"typedoc": "^0.28.
|
|
107
|
-
"typedoc-plugin-markdown": "^4.
|
|
158
|
+
"rollup": "^4.52.3",
|
|
159
|
+
"typedoc": "^0.28.13",
|
|
160
|
+
"typedoc-plugin-markdown": "^4.9.0"
|
|
108
161
|
}
|
|
109
162
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function t(t){t({workerURI:()=>"data:text/javascript,"+encodeURIComponent('(t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){"use strict";const{Array:t,Object:e,Number:n,Math:s,Error:r,Uint8Array:o,Uint16Array:i,Uint32Array:c,Int32Array:a,Map:h,DataView:l,Promise:u,TextEncoder:f,crypto:w,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:g,DecompressionStream:b}=self,S=[];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)1&e?e=e>>>1^3988292384:e>>>=1;S[t]=e}class v{constructor(t){this.t=t||-1}append(t){let e=0|this.t;for(let n=0,s=0|t.length;s>n;n++)e=e>>>8^S[255&(e^t[n])];this.t=e}get(){return~this.t}}class k extends d{constructor(){let t;const e=new v;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new l(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}const z="undefined",C="function",A={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=A.o(n);return 32===s?t.concat(e):A.i(e,s,0|n,t.slice(0,t.length-1))},h(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+A.o(n)},l(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,s.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=A.u(e,t[n-1]&2147483648>>e-1,1)),t},u:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,o:t=>s.round(t/1099511627776)||32,i(t,e,n,s){for(void 0===s&&(s=[]);e>=32;e-=32)s.push(n),n=0;if(0===e)return s.concat(t);for(let r=0;r<t.length;r++)s.push(n|t[r]>>>e),n=t[r]<<32-e;const r=t.length?t[t.length-1]:0,o=A.o(r);return s.push(A.u(e+o&31,e+o>32?n:s.pop(),1)),s}},x={bytes:{p(t){const e=A.h(t)/8,n=new o(e);let s;for(let r=0;e>r;r++)3&r||(s=t[r/4]),n[r]=s>>>24,s<<=8;return n},m(t){const e=[];let n,s=0;for(n=0;n<t.length;n++)s=s<<8|t[n],3&~n||(e.push(s),s=0);return 3&n&&e.push(A.u(8*(3&n),s)),e}}},I=class{constructor(t){const e=this;e.blockSize=512,e.S=[1732584193,4023233417,2562383102,271733878,3285377520],e.v=[1518500249,1859775393,2400959708,3395469782],t?(e.k=t.k.slice(0),e.C=t.C.slice(0),e.A=t.A):e.reset()}reset(){const t=this;return t.k=t.S.slice(0),t.C=[],t.A=0,t}update(t){const e=this;"string"==typeof t&&(t=x.I.m(t));const n=e.C=A.concat(e.C,t),s=e.A,o=e.A=s+A.h(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const i=new c(n);let a=0;for(let t=e.blockSize+s-(e.blockSize+s&e.blockSize-1);o>=t;t+=e.blockSize)e.R(i.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),e}P(){const t=this;let e=t.C;const n=t.k;e=A.concat(e,[A.u(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(s.floor(t.A/4294967296)),e.push(0|t.A);e.length;)t.R(e.splice(0,16));return t.reset(),n}U(t,e,n,s){return t>19?t>39?t>59?t>79?void 0:e^n^s:e&n|e&s|n&s:e^n^s:e&n|~e&s}V(t,e){return e<<t|e>>>32-t}R(e){const n=this,r=n.k,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let i=r[0],c=r[1],a=r[2],h=r[3],l=r[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.V(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.V(5,i)+n.U(t,c,a,h)+l+o[t]+n.v[s.floor(t/20)]|0;l=h,h=a,a=n.V(30,c),c=i,i=e}r[0]=r[0]+i|0,r[1]=r[1]+c|0,r[2]=r[2]+a|0,r[3]=r[3]+h|0,r[4]=r[4]+l|0}},R={getRandomValues(t){const e=new c(t.buffer),n=t=>{let e=987654321;const n=4294967295;return()=>(e=36969*(65535&e)+(e>>16)&n,(((e<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n)/4294967296+.5)*(s.random()>.5?1:-1))};for(let r,o=0;o<t.length;o+=4){const t=n(4294967296*(r||s.random()));r=987654071*t(),e[o/4]=4294967296*t()|0}return t}},P={importKey:t=>new P._(x.bytes.m(t)),B(t,e,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let i,c,a,h,u;const f=new ArrayBuffer(o),w=new l(f);let p=0;const d=A;for(e=x.bytes.m(e),u=1;(o||1)>p;u++){for(i=c=t.encrypt(d.concat(e,[u])),a=1;n>a;a++)for(c=t.encrypt(c),h=0;h<c.length;h++)i[h]^=c[h];for(a=0;(o||1)>p&&a<i.length;a++)w.setInt32(p,i[a]),p+=4}return f.slice(0,s/8)},_:class{constructor(t){const e=this,n=e.D=I,s=[[],[]];e.M=[new n,new n];const r=e.M[0].blockSize/32;t.length>r&&(t=(new n).update(t).P());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.M[0].update(s[0]),e.M[1].update(s[1]),e.K=new n(e.M[0])}reset(){const t=this;t.K=new t.D(t.M[0]),t.W=!1}update(t){this.W=!0,this.K.update(t)}digest(){const t=this,e=t.K.P(),n=new t.D(t.M[1]).update(e).P();return t.reset(),n}encrypt(t){if(this.W)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},U=typeof w!=z&&typeof w.getRandomValues==C,V="Invalid password",_="Invalid signature",B="zipjs-abort-check-password";function D(t){return U?w.getRandomValues(t):R.getRandomValues(t)}const M=16,K={name:"PBKDF2"},W=e.assign({hash:{name:"HMAC"}},K),E=e.assign({iterations:1e3,hash:{name:"SHA-1"}},K),L=["deriveBits"],O=[8,12,16],T=[16,24,32],j=10,H=[0,0,0,0],Z=typeof w!=z,F=Z&&w.subtle,N=Z&&typeof F!=z,q=x.bytes,G=class{constructor(t){const e=this;e.L=[[[],[],[],[],[]],[[],[],[],[],[]]],e.L[0][0][0]||e.O();const n=e.L[0][4],s=e.L[1],o=t.length;let i,c,a,h=1;if(4!==o&&6!==o&&8!==o)throw new r("invalid aes key size");for(e.v=[c=t.slice(0),a=[]],i=o;4*o+28>i;i++){let t=c[i-1];(i%o===0||8===o&&i%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],i%o===0&&(t=t<<8^t>>>24^h<<24,h=h<<1^283*(h>>7))),c[i]=c[i-o]^t}for(let t=0;i;t++,i--){const e=c[3&t?i:i-4];a[t]=4>=i||4>t?e:s[0][n[e>>>24]]^s[1][n[e>>16&255]]^s[2][n[e>>8&255]]^s[3][n[255&e]]}}encrypt(t){return this.T(t,0)}decrypt(t){return this.T(t,1)}O(){const t=this.L[0],e=this.L[1],n=t[4],s=e[4],r=[],o=[];let i,c,a,h;for(let t=0;256>t;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let l=i=0;!n[l];l^=c||1,i=o[i]||1){let o=i^i<<1^i<<2^i<<3^i<<4;o=o>>8^255&o^99,n[l]=o,s[o]=l,h=r[a=r[c=r[l]]];let u=16843009*h^65537*a^257*c^16843008*l,f=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][l]=f=f<<24^f>>>8,e[n][o]=u=u<<24^u>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}T(t,e){if(4!==t.length)throw new r("invalid aes block size");const n=this.v[e],s=n.length/4-2,o=[0,0,0,0],i=this.L[e],c=i[0],a=i[1],h=i[2],l=i[3],u=i[4];let f,w,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],g=t[e?1:3]^n[3],b=4;for(let t=0;s>t;t++)f=c[d>>>24]^a[y>>16&255]^h[m>>8&255]^l[255&g]^n[b],w=c[y>>>24]^a[m>>16&255]^h[g>>8&255]^l[255&d]^n[b+1],p=c[m>>>24]^a[g>>16&255]^h[d>>8&255]^l[255&y]^n[b+2],g=c[g>>>24]^a[d>>16&255]^h[y>>8&255]^l[255&m]^n[b+3],b+=4,d=f,y=w,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=u[d>>>24]<<24^u[y>>16&255]<<16^u[m>>8&255]<<8^u[255&g]^n[b++],f=d,d=y,y=m,m=g,g=f;return o}},J=class{constructor(t,e){this.j=t,this.H=e,this.Z=e}reset(){this.Z=this.H}update(t){return this.F(this.j,t,this.Z)}N(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,s=255&t;255===e?(e=0,255===n?(n=0,255===s?s=0:++s):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=s}return t}q(t){0===(t[0]=this.N(t[0]))&&(t[1]=this.N(t[1]))}F(t,e,n){let s;if(!(s=e.length))return[];const r=A.h(e);for(let r=0;s>r;r+=4){this.q(n);const s=t.encrypt(n);e[r]^=s[0],e[r+1]^=s[1],e[r+2]^=s[2],e[r+3]^=s[3]}return A.l(e,r)}},Q=P._;let X=Z&&N&&typeof F.importKey==C,Y=Z&&N&&typeof F.deriveBits==C;class $ extends d{constructor({password:t,rawPassword:n,signed:s,encryptionStrength:i,checkPasswordOnly:c}){super({start(){e.assign(this,{ready:new u(t=>this.G=t),password:st(t,n),signed:s,J:i-1,pending:new o})},async transform(t,e){const n=this,{password:s,J:i,G:a,ready:h}=n;s?(await(async(t,e,n,s)=>{const o=await nt(t,e,n,ot(s,0,O[e])),i=ot(s,O[e]);if(o[0]!=i[0]||o[1]!=i[1])throw new r(V)})(n,i,s,ot(t,0,O[i]+2)),t=ot(t,O[i]+2),c?e.error(new r(B)):a()):await h;const l=new o(t.length-j-(t.length-j)%M);e.enqueue(et(n,t,l,0,j,!0))},async flush(t){const{signed:e,X:n,Y:s,pending:i,ready:c}=this;if(s&&n){await c;const a=ot(i,0,i.length-j),h=ot(i,i.length-j);let l=new o;if(a.length){const t=ct(q,a);s.update(t);const e=n.update(t);l=it(q,e)}if(e){const t=ot(it(q,s.digest()),0,j);for(let e=0;j>e;e++)if(t[e]!=h[e])throw new r(_)}t.enqueue(l)}}})}}class tt extends d{constructor({password:t,rawPassword:n,encryptionStrength:s}){let r;super({start(){e.assign(this,{ready:new u(t=>this.G=t),password:st(t,n),J:s-1,pending:new o})},async transform(t,e){const n=this,{password:s,J:r,G:i,ready:c}=n;let a=new o;s?(a=await(async(t,e,n)=>{const s=D(new o(O[e]));return rt(s,await nt(t,e,n,s))})(n,r,s),i()):await c;const h=new o(a.length+t.length-t.length%M);h.set(a,0),e.enqueue(et(n,t,h,a.length,0))},async flush(t){const{X:e,Y:n,pending:s,ready:i}=this;if(n&&e){await i;let c=new o;if(s.length){const t=e.update(ct(q,s));n.update(t),c=it(q,t)}r.signature=it(q,n.digest()).slice(0,j),t.enqueue(rt(c,r.signature))}}}),r=this}}function et(t,e,n,s,r,i){const{X:c,Y:a,pending:h}=t,l=e.length-r;let u;for(h.length&&(e=rt(h,e),n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,l-l%M)),u=0;l-M>=u;u+=M){const t=ct(q,ot(e,u,u+M));i&&a.update(t);const r=c.update(t);i||a.update(r),n.set(it(q,r),u+s)}return t.pending=ot(e,u),n}async function nt(n,s,r,i){n.password=null;const c=await(async(t,e,n,s,r)=>{if(!X)return P.importKey(e);try{return await F.importKey("raw",e,n,!1,r)}catch(t){return X=!1,P.importKey(e)}})(0,r,W,0,L),a=await(async(t,e,n)=>{if(!Y)return P.B(e,t.salt,E.iterations,n);try{return await F.deriveBits(t,e,n)}catch(s){return Y=!1,P.B(e,t.salt,E.iterations,n)}})(e.assign({salt:i},E),c,8*(2*T[s]+2)),h=new o(a),l=ct(q,ot(h,0,T[s])),u=ct(q,ot(h,T[s],2*T[s])),f=ot(h,2*T[s]);return e.assign(n,{keys:{key:l,$:u,passwordVerification:f},X:new J(new G(l),t.from(H)),Y:new Q(u)}),f}function st(t,e){return void 0===e?(t=>{if(typeof f==z){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new f).encode(t)})(t):e}function rt(t,e){let n=t;return t.length+e.length&&(n=new o(t.length+e.length),n.set(t,0),n.set(e,t.length)),n}function ot(t,e,n){return t.subarray(e,n)}function it(t,e){return t.p(e)}function ct(t,e){return t.m(e)}class at extends d{constructor({password:t,passwordVerification:n,checkPasswordOnly:s}){super({start(){e.assign(this,{password:t,passwordVerification:n}),ft(this,t)},transform(t,e){const n=this;if(n.password){const e=lt(n,t.subarray(0,12));if(n.password=null,e.at(-1)!=n.passwordVerification)throw new r(V);t=t.subarray(12)}s?e.error(new r(B)):e.enqueue(lt(n,t))}})}}class ht extends d{constructor({password:t,passwordVerification:n}){super({start(){e.assign(this,{password:t,passwordVerification:n}),ft(this,t)},transform(t,e){const n=this;let s,r;if(n.password){n.password=null;const e=D(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(ut(n,e),0),r=12}else s=new o(t.length),r=0;s.set(ut(n,t),r),e.enqueue(s)}})}}function lt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=pt(t)^e[s],wt(t,n[s]);return n}function ut(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=pt(t)^e[s],wt(t,e[s]);return n}function ft(t,n){const s=[305419896,591751049,878082192];e.assign(t,{keys:s,tt:new v(s[0]),et:new v(s[2])});for(let e=0;e<n.length;e++)wt(t,n.charCodeAt(e))}function wt(t,e){let[n,r,o]=t.keys;t.tt.append([e]),n=~t.tt.get(),r=yt(s.imul(yt(r+dt(n)),134775813)+1),t.et.append([r>>>24]),o=~t.et.get(),t.keys=[n,r,o]}function pt(t){const e=2|t.keys[2];return dt(s.imul(e,1^e)>>>8)}function dt(t){return 255&t}function yt(t){return 4294967295&t}class mt extends d{constructor(t,{chunkSize:e,nt:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:i,zipCrypto:c,signed:a,level:h}=t,u=this;let f,w,p=super.readable;o&&!c||!a||(f=new k,p=vt(p,f)),r&&(p=St(p,i,{level:h,chunkSize:e},s,n,s)),o&&(c?p=vt(p,new ht(t)):(w=new tt(t),p=vt(p,w))),bt(u,p,()=>{let t;o&&!c&&(t=w.signature),o&&!c||!a||(t=new l(f.value.buffer).getUint32(0)),u.signature=t})}}class gt extends d{constructor(t,{chunkSize:e,st:n,DecompressionStream:s}){super({});const{zipCrypto:o,encrypted:i,signed:c,signature:a,compressed:h,useCompressionStream:u,rt:f}=t;let w,p,d=super.readable;i&&(o?d=vt(d,new at(t)):(p=new $(t),d=vt(d,p))),h&&(d=St(d,u,{chunkSize:e,rt:f},s,n,s)),i&&!o||!c||(w=new k,d=vt(d,w)),bt(this,d,()=>{if((!i||o)&&c){const t=new l(w.value.buffer);if(a!=t.getUint32(0,!1))throw new r(_)}})}}function bt(t,n,s){n=vt(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function St(t,e,n,s,r,o){const i=e&&s?s:r||o,c=n.rt?"deflate64-raw":"deflate-raw";try{t=vt(t,new i(c,n))}catch(s){if(!e)throw s;if(r)t=vt(t,new r(c,n));else{if(!o)throw s;t=vt(t,new o(c,n))}}return t}function vt(t,e){return t.pipeThrough(e)}const kt="data",zt="close";class Ct extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let i;o.startsWith("deflate")?i=mt:o.startsWith("inflate")&&(i=gt),s.outputSize=0;let c=0;const a=new i(t,n),h=super.readable,l=new d({transform(t,e){t&&t.length&&(c+=t.length,e.enqueue(t))},flush(){e.assign(s,{inputSize:c})}}),u=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),s.outputSize+=e.length,t.outputSize&&s.outputSize>t.outputSize))throw new r("Invalid uncompressed size")},flush(){const{signature:t}=a;e.assign(s,{signature:t,inputSize:c})}});e.defineProperty(s,"readable",{get:()=>h.pipeThrough(l).pipeThrough(a).pipeThrough(u)})}}class At extends d{constructor(t){let e;super({transform:function n(s,r){if(e){const t=new o(e.length+s.length);t.set(e),t.set(s,e.length),s=t,e=null}s.length>t?(r.enqueue(s.slice(0,t)),n(s.slice(t),r)):e=s},flush(t){e&&e.length&&t.enqueue(e)}})}}let xt,It,Rt,Pt;function Ut(t,e,n={}){const i="number"==typeof n.level?n.level:-1,c="number"==typeof n.ot?n.ot:65536,a="number"==typeof n.it?n.it:65536;return new d({start(){let n;if(this.ct=It(c),this.in=It(a),this.it=a,this.ht=new o(c),t?(this.lt=xt.deflate_process,this.ut=xt.deflate_last_consumed,this.ft=xt.deflate_end,this.wt=xt.deflate_new(),n="gzip"===e?xt.deflate_init_gzip(this.wt,i):"deflate-raw"===e?xt.deflate_init_raw(this.wt,i):xt.deflate_init(this.wt,i)):"deflate64-raw"===e?(this.lt=xt.inflate9_process,this.ut=xt.inflate9_last_consumed,this.ft=xt.inflate9_end,this.wt=xt.inflate9_new(),n=xt.inflate9_init_raw(this.wt)):(this.lt=xt.inflate_process,this.ut=xt.inflate_last_consumed,this.ft=xt.inflate_end,this.wt=xt.inflate_new(),n="deflate-raw"===e?xt.inflate_init_raw(this.wt):"gzip"===e?xt.inflate_init_gzip(this.wt):xt.inflate_init(this.wt)),0!==n)throw new r("init failed:"+n)},transform(e,n){try{const i=e,a=new o(Pt.buffer),h=this.lt,l=this.ut,u=this.ct,f=this.ht;let w=0;for(;w<i.length;){const e=s.min(i.length-w,32768);this.in&&this.it>=e||(this.in&&Rt&&Rt(this.in),this.in=It(e),this.it=e),a.set(i.subarray(w,w+e),this.in);const o=h(this.wt,this.in,e,u,c,0);if(!t&&0>o)throw new r("process error:"+o);const p=16777215&o;p&&(f.set(a.subarray(u,u+p),0),n.enqueue(f.slice(0,p)));const d=l(this.wt);if(0===d)break;w+=d}}catch(t){this.ft&&this.wt&&this.ft(this.wt),this.in&&Rt&&Rt(this.in),this.ct&&Rt&&Rt(this.ct),n.error(t)}},flush(e){try{const n=new o(Pt.buffer),s=this.lt,i=this.ct,a=this.ht;for(;;){const o=s(this.wt,0,0,i,c,4);if(!t&&0>o)throw new r("process error:"+o);const h=16777215&o,l=o>>24&255;if(h&&(a.set(n.subarray(i,i+h),0),e.enqueue(a.slice(0,h))),1===l||0===h)break}}catch(t){e.error(t)}finally{if(this.ft&&this.wt){const t=this.ft(this.wt);0!==t&&e.error(new r("end error:"+t))}this.in&&Rt&&Rt(this.in),this.ct&&Rt&&Rt(this.ct)}}})}class Vt{constructor(t="deflate",e){return Ut(!0,t,e)}}class _t{constructor(t="deflate",e){return Ut(!1,t,e)}}let Bt=!1;const Dt=new h,Mt=new h;let Kt,Wt=0;async function Et(t){try{const{options:e,config:s}=t;Bt||e.useCompressionStream||await(async(t,{baseURI:e})=>{if(!Bt){let s,r;try{try{r=new URL(t,e)}catch(t){}const n=await fetch(r);s=await n.arrayBuffer()}catch(e){if(!t.startsWith("data:application/wasm;base64,"))throw e;s=(t=>{const e=t.split(",")[1],n=atob(e),s=n.length,r=new o(s);for(let t=0;s>t;++t)r[t]=n.charCodeAt(t);return r.buffer})(t)}n=(await WebAssembly.instantiate(s)).instance.exports,xt=n,({malloc:It,free:Rt,memory:Pt}=xt),Bt=!0}var n})(t.config.wasmURI,t.config),s.CompressionStream=self.CompressionStream,s.DecompressionStream=self.DecompressionStream,s.nt=Vt,s.st=_t;const r={highWaterMark:1},i=t.readable||new y({async pull(t){const e=new u(t=>Dt.set(Wt,t));Lt({type:"pull",messageId:Wt}),Wt=(Wt+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await e;t.enqueue(s),r&&t.close()}},r),c=t.writable||new m({async write(t){let e;const s=new u(t=>e=t);Mt.set(Wt,e),Lt({type:kt,value:t,messageId:Wt}),Wt=(Wt+1)%n.MAX_SAFE_INTEGER,await s}},r),a=new Ct(e,s);Kt=new AbortController;const{signal:h}=Kt;await i.pipeThrough(a).pipeThrough(new At(s.chunkSize)).pipeTo(c,{signal:h,preventClose:!0,preventAbort:!0}),await c.getWriter().close();const{signature:l,inputSize:f,outputSize:w}=a;Lt({type:zt,result:{signature:l,inputSize:f,outputSize:w}})}catch(t){t.outputSize=0,Ot(t)}}function Lt(t){let{value:e}=t;if(e)if(e.length)try{e=new o(e),t.value=e.buffer,p(t,[t.value])}catch(e){p(t)}else p(t);else p(t)}function Ot(t=new r("Unknown error")){const{message:e,stack:n,code:s,name:o,outputSize:i}=t;p({error:{message:e,stack:n,code:s,name:o,outputSize:i}})}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&Et(t),e==kt){const t=Dt.get(n);Dt.delete(n),t({value:new o(s),done:r})}if("ack"==e){const t=Mt.get(n);Mt.delete(n),t()}e==zt&&Kt.abort()}catch(t){Ot(t)}})});\n')})}export{t as configureWebWorker};
|
|
File without changes
|
|
File without changes
|