2 lines
48 KiB
JavaScript
2 lines
48 KiB
JavaScript
|
|
!function(){"use strict";const{Array:e,Object:t,Number:n,Math:r,Error:i,Uint8Array:o,Uint16Array:a,Uint32Array:l,Int32Array:s,Map:u,DataView:f,Promise:c,TextEncoder:h,crypto:d,postMessage:p,TransformStream:g,ReadableStream:w,WritableStream:_,CompressionStream:b,DecompressionStream:m}=self,y=void 0,v="undefined",k="function",x=[];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;x[e]=t}class S{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,r=0|e.length;r>n;n++)t=t>>>8^x[255&(t^e[n])];this.crc=t}get(){return~this.crc}}class O extends g{constructor(){let e;const t=new S;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new o(4);new f(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}const T={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],r=T.getPartial(n);return 32===r?e.concat(t):T._shiftRight(t,r,0|n,e.slice(0,e.length-1))},bitLength(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+T.getPartial(n)},clamp(e,t){if(32*e.length<t)return e;const n=(e=e.slice(0,r.ceil(t/32))).length;return t&=31,n>0&&t&&(e[n-1]=T.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>r.round(e/1099511627776)||32,_shiftRight(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 i=0;i<e.length;i++)r.push(n|e[i]>>>t),n=e[i]<<32-t;const i=e.length?e[e.length-1]:0,o=T.getPartial(i);return r.push(T.partial(t+o&31,t+o>32?n:r.pop(),1)),r}},z={bytes:{fromBits(e){const t=T.bitLength(e)/8,n=new o(t);let r;for(let i=0;t>i;i++)3&i||(r=e[i/4]),n[i]=r>>>24,r<<=8;return n},toBits(e){const t=[];let n,r=0;for(n=0;n<e.length;n++)r=r<<8|e[n],3&~n||(t.push(r),r=0);return 3&n&&t.push(T.partial(8*(3&n),r)),t}}},A=class{constructor(e){const t=this;t.blockSize=512,t._init=[1732584193,4023233417,2562383102,271733878,3285377520],t._key=[1518500249,1859775393,2400959708,3395469782],e?(t._h=e._h.slice(0),t._buffer=e._buffer.slice(0),t._length=e._length):t.reset()}reset(){const e=this;return e._h=e._init.slice(0),e._buffer=[],e._length=0,e}update(e){const t=this;"string"==typeof e&&(e=z.utf8String.toBits(e));const n=t._buffer=T.concat(t._buffer,e),r=t._length,o=t._length=r+T.bitLength(e);if(o>9007199254740991)throw new i("Cannot hash more than 2^53 - 1 bits");const a=new l(n);let s=0;for(let e=t.blockSize+r-(t.blockSize+r&t.blockSize-1);o>=e;e+=t.blockSize)t._block(a.subarray(16*s,16*(s+1))),s+=1;return n.splice(0,16*s),t}finalize(){const e=this;let t=e._buffer;const n=e._h;t=T.concat(t,[T.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(r.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),n}_f(e,t,n,r){return 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}_S(e,t){return t<<e|t>>>32-e}_block(t){const n=this,i=n._h,o=e(80);for(let e=0;16>e;e++)o[e]=t[e];let a=i[0],l=i[1],s=i[2],u=i[3],f=i[4];for(let e=0;79>=e;e++){16>e||(o[e]=n._S(1,o[e-3]^o[e-8]^o[e-14]^o[e-16]));const t=n._S(5,a)+n._f(e,l,s,u)+f+o[e]+n._key[r.floor(e/20)]|0;f=u,u=s,s=n._S(30,l),l=a,a=t}i[0]=i[0]+a|0,i[1]=i[1]+l|0,i[2]=i[2]+s|0,i[3]=i[3]+u|0,i[4]=i[4]+f|0}},I={getRandomValues(e){const t=new l(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(r.random()>.5?1:-1))};for(let i,o=0;o<e.length;o+=4){const e=n(4294967296*(i||r.random()));i=987654071*e(),t[o/4]=4294967296*e()|0}return e}},D={importKey:e=>new D.hmacSha1(z.bytes.toBits(e)),pbkdf2(e,t,n,r){if(n=n||1e4,0>r||0>n)throw new i("invalid params to pbkdf2");const o=1+(r>>5)<<2;let a,l,s,u,c;const h=new ArrayBuffer(o),d=new f(h);let p=0;const g=T;for(t=z.bytes.toBits(t),c=1;(o||1)>p;c++){for(a=l=e.encrypt(g.concat(t,[c])),s=1;n>s;s++)for(l=e.encrypt(l),u=0;u<l.length;u++)a[u]^=l[u];for(s=0;(o||1)>p&&s<a.length;s++)d.setInt32(p,a[s]),p+=4}return h.slice(0,r/8)},hmacSha1:class{constructor(e){const t=this,n=t._hash=A,r=[[],[]];t._baseHash=[new n,new n];const i=t._baseHa
|