openpgp
Version:
OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.
4 lines (3 loc) • 8.1 kB
JavaScript
/*! OpenPGP.js v6.3.1 - 2026-06-04 - 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,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(e){if("default"!==e&&!(e in r)){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}}))})),Object.freeze(r)}function t(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var e,n,a,o,i,f;var u=function(){if(f)return i;f=1;const r=function(){if(n)return e;function r(r){this.name="Bzip2Error",this.message=r,this.stack=Error().stack}n=1,r.prototype=Error();var t=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)&&t("No magic number found");var e=r(8)-48;return(e<1||e>9)&&t("Not a BZIP archive"),e},a.decompress=function(r,e,n,a,o){for(var i=-1,f="",u=0;u<6;u++)f+=r(8).toString(16);if("177245385090"==f)return(0|r(32))!==o&&t("Error in bzip2: crc32 do not match"),r(null),null;"314159265359"!=f&&t("Invalid bzip data");var s=0|r(32);r(1)&&t("unsupported obsolete version");var l=r(24);l>a&&t("Initial position larger than buffer size");var c=r(16),y=0;for(u=0;u<16;u++)if(c&1<<15-u){var d=r(16);for(m=0;m<16;m++)d&1<<15-m&&(this.symToByte[y++]=16*u+m)}var b=r(3);(b<2||b>6)&&t("Invalid bzip data");var h=r(15);for(0==h&&t("Invalid bzip data"),u=0;u<b;u++)this.mtfSymbol[u]=u;for(u=0;u<h;u++){for(var m=0;r(1);m++)m>=b&&t("Invalid bzip data");var p=this.mtfSymbol[m];for(d=m-1;d>=0;d--)this.mtfSymbol[d+1]=this.mtfSymbol[d];this.mtfSymbol[0]=p,this.selectors[u]=p}var v,w,I,z,g=y+2,A=[],S=new Uint8Array(258),E=new Uint16Array(21);for(m=0;m<b;m++){for(c=r(5),u=0;u<g;u++){for(;(c<1||c>20)&&t("Invalid bzip data"),r(1);)r(1)?c--:c++;S[u]=c}var C,R;for(C=R=S[0],u=1;u<g;u++)S[u]>R?R=S[u]:S[u]<C&&(C=S[u]);(v=A[m]={}).permute=new Int32Array(258),v.limit=new Int32Array(21),v.base=new Int32Array(21),v.minLen=C,v.maxLen=R;var B=v.base,O=v.limit,T=0;for(u=C;u<=R;u++)for(c=0;c<g;c++)S[c]==u&&(v.permute[T++]=c);for(u=C;u<=R;u++)E[u]=O[u]=0;for(u=0;u<g;u++)E[S[u]]++;for(T=c=0,u=C;u<R;u++)T+=E[u],O[u]=T-1,T<<=1,B[u+1]=T-(c+=E[u]);O[R]=T+E[R]-1,B[C]=0}for(u=0;u<256;u++)this.mtfSymbol[u]=u,this.byteCount[u]=0;for(w=I=g=z=0;;){for(g--||(g=49,z>=h&&t("Invalid bzip data"),B=(v=A[this.selectors[z++]]).base,O=v.limit),m=r(u=v.minLen);u>v.maxLen&&t("Invalid bzip data"),!(m<=O[u]);)u++,m=m<<1|r(1);((m-=B[u])<0||m>=258)&&t("Invalid bzip data");var _=v.permute[m];if(0!=_&&1!=_){if(w)for(w=0,I+c>a&&t("Invalid bzip data"),p=this.symToByte[this.mtfSymbol[0]],this.byteCount[p]+=c;c--;)n[I++]=p;if(_>y)break;for(I>=a&&t("Invalid bzip data"),u=_-1,p=this.mtfSymbol[u],d=u-1;d>=0;d--)this.mtfSymbol[d+1]=this.mtfSymbol[d];this.mtfSymbol[0]=p,p=this.symToByte[p],this.byteCount[p]++,n[I++]=p}else w||(w=1,c=0),c+=0==_?w:2*w,w<<=1}for((l<0||l>=I)&&t("Invalid bzip data"),m=0,u=0;u<256;u++)d=m+this.byteCount[u],this.byteCount[u]=m,m=d;for(u=0;u<I;u++)p=255&n[u],n[this.byteCount[p]]|=u<<8,this.byteCount[p]++;var j,k,U,L=0,P=0,x=0;for(I&&(P=255&(L=n[l]),L>>=8,x=-1);I;){for(I--,k=P,P=255&(L=n[L]),L>>=8,3==x++?(j=P,U=k,P=-1):(j=1,U=P);j--;)i=4294967295&(i<<8^this.crcTable[255&(i>>24^U)]),e(U);P!=k&&(x=0)}return(0|(i=~i>>>0))!=(0|s)&&t("Error in bzip2: crc32 do not match"),4294967295&(i^(o<<1|o>>>31))},e=a}(),t=function(){if(o)return a;o=1;var r=[0,1,3,7,15,31,63,127,255];return a=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 u=8-e;0===e&&i>0&&o.bytesRead++,i>=u?(f<<=u,f|=r[u]&a[n++],e=0,i-=u):(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 i=function(e){const n=[];let a=0,o=0,i=!1,f=!1,u=null,s=null;let l,c=0;function y(t){if(!i)try{return function(t){if(o){const e=1e5*o,n=new Int32Array(e),a=[],i=function(r){a.push(r)};return s=r.decompress(u,i,n,e,s),null===s?(o=0,!1):(t(new Uint8Array(a)),!0)}return o=r.header(u),s=0,!1}((function(r){t.enqueue(r),null!==r&&(c+=r.length)}))}catch(r){return t.error(r),i=!0,!0}}return new ReadableStream({start(){l=e.getReader()},async pull(r){try{for(;;){for(;!(f||u&&a-u.bytesRead+1>=25e3+1e5*(o||4));){const{value:r,done:e}=await l.read();e?f=!0:(n.push(r),a+=r.length,null===u&&(u=t((function(){return n.shift()}))))}for(;f?u&&a>u.bytesRead:u&&a-u.bytesRead+1>=25e3+1e5*(o||4);)if(y(r))return;if(f&&!i&&(!u||a<=u.bytesRead))return void(null===s?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__*/r({__proto__:null,default:/*@__PURE__*/t(u)},[u]);export{s as i};
//# sourceMappingURL=unbzip2-stream.min.mjs.map