openpgp
Version:
OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.
4 lines (3 loc) • 7.81 kB
JavaScript
/*! OpenPGP.js v6.3.0 - 2025-12-09 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function r(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var t,e,n,a,o,i;var f=function(){if(i)return o;i=1;const r=function(){if(e)return t;function r(r){this.name="Bzip2Error",this.message=r,this.stack=Error().stack}e=1,r.prototype=Error();var n=function(t){throw new r(t)},a={};return a.Bzip2Error=r,a.crcTable=[0,79764919,159529838,222504665,319059676,398814059,445009330,507990021,638119352,583659535,797628118,726387553,890018660,835552979,1015980042,944750013,1276238704,1221641927,1167319070,1095957929,1595256236,1540665371,1452775106,1381403509,1780037320,1859660671,1671105958,1733955601,2031960084,2111593891,1889500026,1952343757,2552477408,2632100695,2443283854,2506133561,2334638140,2414271883,2191915858,2254759653,3190512472,3135915759,3081330742,3009969537,2905550212,2850959411,2762807018,2691435357,3560074640,3505614887,3719321342,3648080713,3342211916,3287746299,3467911202,3396681109,4063920168,4143685023,4223187782,4286162673,3779000052,3858754371,3904687514,3967668269,881225847,809987520,1023691545,969234094,662832811,591600412,771767749,717299826,311336399,374308984,453813921,533576470,25881363,88864420,134795389,214552010,2023205639,2086057648,1897238633,1976864222,1804852699,1867694188,1645340341,1724971778,1587496639,1516133128,1461550545,1406951526,1302016099,1230646740,1142491917,1087903418,2896545431,2825181984,2770861561,2716262478,3215044683,3143675388,3055782693,3001194130,2326604591,2389456536,2200899649,2280525302,2578013683,2640855108,2418763421,2498394922,3769900519,3832873040,3912640137,3992402750,4088425275,4151408268,4197601365,4277358050,3334271071,3263032808,3476998961,3422541446,3585640067,3514407732,3694837229,3640369242,1762451694,1842216281,1619975040,1682949687,2047383090,2127137669,1938468188,2001449195,1325665622,1271206113,1183200824,1111960463,1543535498,1489069629,1434599652,1363369299,622672798,568075817,748617968,677256519,907627842,853037301,1067152940,995781531,51762726,131386257,177728840,240578815,269590778,349224269,429104020,491947555,4046411278,4126034873,4172115296,4234965207,3794477266,3874110821,3953728444,4016571915,3609705398,3555108353,3735388376,3664026991,3290680682,3236090077,3449943556,3378572211,3174993278,3120533705,3032266256,2961025959,2923101090,2868635157,2813903052,2742672763,2604032198,2683796849,2461293480,2524268063,2284983834,2364738477,2175806836,2238787779,1569362073,1498123566,1409854455,1355396672,1317987909,1246755826,1192025387,1137557660,2072149281,2135122070,1912620623,1992383480,1753615357,1816598090,1627664531,1707420964,295390185,358241886,404320391,483945776,43990325,106832002,186451547,266083308,932423249,861060070,1041341759,986742920,613929101,542559546,756411363,701822548,3316196985,3244833742,3425377559,3370778784,3601682597,3530312978,3744426955,3689838204,3819031489,3881883254,3928223919,4007849240,4037393693,4100235434,4180117107,4259748804,2310601993,2373574846,2151335527,2231098320,2596047829,2659030626,2470359227,2550115596,2947551409,2876312838,2788305887,2733848168,3165939309,3094707162,3040238851,2985771188],a.array=function(r){var t=0,e=0,n=[0,1,3,7,15,31,63,127,255];return function(a){for(var o=0;a>0;){var i=8-t;a>=i?(o<<=i,o|=n[i]&r[e++],t=0,a-=i):(o<<=a,o|=(r[e]&n[a]<<8-a-t)>>8-a-t,t+=a,a=0)}return o}},a.simple=function(r,t){var e=a.array(r),n=!1,o=1e5*a.header(e),i=new Int32Array(o);do{n=a.decompress(e,t,i,o)}while(!n)},a.header=function(r){this.byteCount=new Int32Array(256),this.symToByte=new Uint8Array(256),this.mtfSymbol=new Int32Array(256),this.selectors=new Uint8Array(32768),4348520!=r(24)&&n("No magic number found");var t=r(8)-48;return(t<1||t>9)&&n("Not a BZIP archive"),t},a.decompress=function(r,t,e,a,o){for(var i=-1,f="",s=0;s<6;s++)f+=r(8).toString(16);if("177245385090"==f)return(0|r(32))!==o&&n("Error in bzip2: crc32 do not match"),r(null),null;"314159265359"!=f&&n("Invalid bzip data");var u=0|r(32);r(1)&&n("unsupported obsolete version");var l=r(24);l>a&&n("Initial position larger than buffer size");var d=r(16),y=0;for(s=0;s<16;s++)if(d&1<<15-s){var c=r(16);for(m=0;m<16;m++)c&1<<15-m&&(this.symToByte[y++]=16*s+m)}var b=r(3);(b<2||b>6)&&n("Invalid bzip data");var h=r(15);for(0==h&&n("Invalid bzip data"),s=0;s<b;s++)this.mtfSymbol[s]=s;for(s=0;s<h;s++){for(var m=0;r(1);m++)m>=b&&n("Invalid bzip data");var v=this.mtfSymbol[m];for(c=m-1;c>=0;c--)this.mtfSymbol[c+1]=this.mtfSymbol[c];this.mtfSymbol[0]=v,this.selectors[s]=v}var p,w,I,z,S=y+2,A=[],g=new Uint8Array(258),C=new Uint16Array(21);for(m=0;m<b;m++){for(d=r(5),s=0;s<S;s++){for(;(d<1||d>20)&&n("Invalid bzip data"),r(1);)r(1)?d--:d++;g[s]=d}var R,B;for(R=B=g[0],s=1;s<S;s++)g[s]>B?B=g[s]:g[s]<R&&(R=g[s]);(p=A[m]={}).permute=new Int32Array(258),p.limit=new Int32Array(21),p.base=new Int32Array(21),p.minLen=R,p.maxLen=B;var E=p.base,T=p.limit,_=0;for(s=R;s<=B;s++)for(d=0;d<S;d++)g[d]==s&&(p.permute[_++]=d);for(s=R;s<=B;s++)C[s]=T[s]=0;for(s=0;s<S;s++)C[g[s]]++;for(_=d=0,s=R;s<B;s++)_+=C[s],T[s]=_-1,_<<=1,E[s+1]=_-(d+=C[s]);T[B]=_+C[B]-1,E[R]=0}for(s=0;s<256;s++)this.mtfSymbol[s]=s,this.byteCount[s]=0;for(w=I=S=z=0;;){for(S--||(S=49,z>=h&&n("Invalid bzip data"),E=(p=A[this.selectors[z++]]).base,T=p.limit),m=r(s=p.minLen);s>p.maxLen&&n("Invalid bzip data"),!(m<=T[s]);)s++,m=m<<1|r(1);((m-=E[s])<0||m>=258)&&n("Invalid bzip data");var U=p.permute[m];if(0!=U&&1!=U){if(w)for(w=0,I+d>a&&n("Invalid bzip data"),v=this.symToByte[this.mtfSymbol[0]],this.byteCount[v]+=d;d--;)e[I++]=v;if(U>y)break;for(I>=a&&n("Invalid bzip data"),s=U-1,v=this.mtfSymbol[s],c=s-1;c>=0;c--)this.mtfSymbol[c+1]=this.mtfSymbol[c];this.mtfSymbol[0]=v,v=this.symToByte[v],this.byteCount[v]++,e[I++]=v}else w||(w=1,d=0),d+=0==U?w:2*w,w<<=1}for((l<0||l>=I)&&n("Invalid bzip data"),m=0,s=0;s<256;s++)c=m+this.byteCount[s],this.byteCount[s]=m,m=c;for(s=0;s<I;s++)v=255&e[s],e[this.byteCount[v]]|=s<<8,this.byteCount[v]++;var k,L,x,O=0,j=0,M=0;for(I&&(j=255&(O=e[l]),O>>=8,M=-1);I;){for(I--,L=j,j=255&(O=e[O]),O>>=8,3==M++?(k=j,x=L,j=-1):(k=1,x=j);k--;)i=4294967295&(i<<8^this.crcTable[255&(i>>24^x)]),t(x);j!=L&&(M=0)}return(0|(i=~i>>>0))!=(0|u)&&n("Error in bzip2: crc32 do not match"),4294967295&(i^(o<<1|o>>>31))},t=a}(),f=function(){if(a)return n;a=1;var r=[0,1,3,7,15,31,63,127,255];return n=function(t){var e=0,n=0,a=t(),o=function(i){if(null===i&&0!=e)return e=0,void n++;for(var f=0;i>0;){n>=a.length&&(n=0,a=t());var s=8-e;0===e&&i>0&&o.bytesRead++,i>=s?(f<<=s,f|=r[s]&a[n++],e=0,i-=s):(f<<=i,f|=(a[n]&r[i]<<8-i-e)>>8-i-e,e+=i,i=0)}return f};return o.bytesRead=0,o}}();return o=function(t){const e=[];let n=0,a=0,o=!1,i=!1,s=null,u=null;let l,d=0;function y(t){if(!o)try{return function(t){if(a){const e=1e5*a,n=new Int32Array(e),o=[],i=function(r){o.push(r)};return u=r.decompress(s,i,n,e,u),null===u?(a=0,!1):(t(new Uint8Array(o)),!0)}return a=r.header(s),u=0,!1}((function(r){t.enqueue(r),null!==r&&(d+=r.length)}))}catch(r){return t.error(r),o=!0,!0}}return new ReadableStream({start(){l=t.getReader()},async pull(r){try{for(;;){for(;!(i||s&&n-s.bytesRead+1>=25e3+1e5*(a||4));){const{value:r,done:t}=await l.read();t?i=!0:(e.push(r),n+=r.length,null===s&&(s=f((function(){return e.shift()}))))}for(;i?s&&n>s.bytesRead:s&&n-s.bytesRead+1>=25e3+1e5*(a||4);)if(y(r))return;if(i&&!o&&(!s||n<=s.bytesRead))return void(null===u?r.close():r.error(Error("input stream ended prematurely")))}}catch(t){r.error(t)}},async cancel(r){await l.abort(r)}},{highWaterMark:0})}}(),s=/*#__PURE__*/Object.freeze({__proto__:null,default:/*@__PURE__*/r(f)});export{s as i};
//# sourceMappingURL=unbzip2-stream.min.mjs.map