@blockcerts/blockcerts-verifier 1.68.0 → 1.69.0
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/bundle-stats.html +1 -1
- package/dist/{EcdsaSd2023-CJsktwwK-COovFO-E.js → EcdsaSd2023-Bf8oG6yE-DXSfendb.js} +8 -8
- package/dist/{EcdsaSecp256k1Signature2019-hg62McNW-DMCKToe3.js → EcdsaSecp256k1Signature2019-BALmC57B-DCQW1A4n.js} +1 -1
- package/dist/{Ed25519Signature2020-D3owGts_-BB1fBq0Z.js → Ed25519Signature2020-B6Av-H9i-Bi3NyI0E.js} +5 -5
- package/dist/{MerkleProof2017-BrDGNMx2-Ct7-Dmh5.js → MerkleProof2017-Dy-NSqLc-DHQ59Wvo.js} +1 -1
- package/dist/{MerkleProof2019-D70TTI_--BhNFm4-a.js → MerkleProof2019-0fhn8kLR-C2H_q6nV.js} +2 -2
- package/dist/{checkCredentialSchemaConformity-D7h9tZ1Y-B0tA00kY.js → checkCredentialSchemaConformity-D70pJ-aV-ziU-1LIq.js} +1 -1
- package/dist/controlVerificationMethod-suRC0MnA-D4JcJT1N.js +1 -0
- package/dist/{did-key-common.esm-D_08iodm-FY3lD1HA.js → did-key-common.esm-C8HA3Pjo-CSneo-V8.js} +3 -3
- package/dist/{did-key-ed25519.esm-Cah33z_9-CXstsY-H.js → did-key-ed25519.esm-DysNS-Zl-DSKpuDIg.js} +1 -1
- package/dist/{did-key-secp256k1.esm-C27OwLgS-C9mjnb5S.js → did-key-secp256k1.esm-CLndQyAu-BYDTpSgR.js} +1 -1
- package/dist/{downloadPDF-XZlmMePj.js → downloadPDF-DzV0Jwr0.js} +3 -3
- package/dist/{index-Br-3L8ut-BI4gpx_q.js → index-BC_5sEeg-CEsb2-mf.js} +1 -1
- package/dist/{index-Bxtpkwnp-BkEvuYc3.js → index-BEHg4rC3-AHOWkvj-.js} +15 -15
- package/dist/{index-PZL1xHXK-CH1Nkb1O.js → index-CKc12B0M-CY2IlTam.js} +7 -7
- package/dist/{index.es-B13oYDrC.js → index.es-D_fMtNlx.js} +1 -1
- package/dist/main.js +111 -111
- package/dist/{purify-hA3K4SAZ.js → purify-mEiDmpQD.js} +1 -1
- package/dist/{retrieveVerificationMethodPublicKey-DMLSSemm-uQidviAv.js → retrieveVerificationMethodPublicKey-CogYoUma-CqFMEtDL.js} +1 -1
- package/dist/verifyIssuerProfile-2DvLibZC-DDE-mATS.js +1 -0
- package/dist/{webcrypto.es-CjDwtULr-D7dA51Yn.js → webcrypto.es-CGaF2VaX-TCzLuarM.js} +1 -1
- package/package.json +2 -2
- package/dist/controlVerificationMethod-DPnoI09o-D_Ktjb-C.js +0 -1
- /package/dist/{HashlinkVerifier-BE8mYTIj-dg5WNZnc.js → HashlinkVerifier-CUj0d9D3-dg5WNZnc.js} +0 -0
- /package/dist/{checkRevocationStatusList2021-CtVHNZ7k-XCu3zkCJ.js → checkRevocationStatusList2021-u7qIPszJ-XCu3zkCJ.js} +0 -0
- /package/dist/{elliptic-D7vAoLbk-DQmYEk-8.js → elliptic-e2d4_kYF-DQmYEk-8.js} +0 -0
- /package/dist/{ensureNotRevoked-BEtBmERU-DvMIgM4L.js → ensureNotRevoked-D2jnsCd0-DvMIgM4L.js} +0 -0
- /package/dist/{ensureValidIssuingKey-BrJmJb4L-wu9SdYxL.js → ensureValidIssuingKey-LBboe5mO-wu9SdYxL.js} +0 -0
- /package/dist/{index-CQB1Suna-Dgus2xdV.js → index-DuuEF8T4-Dgus2xdV.js} +0 -0
- /package/dist/{index-BeIcTgye-C0eXpZGn.js → index-qLsUsSDH-C0eXpZGn.js} +0 -0
- /package/dist/{jsonld-D-rUqx_B-CQeQQNYP.js → jsonld-Cuz6c95c-CQeQQNYP.js} +0 -0
- /package/dist/{sha256-BIbQVOZh-C1PUWFZm.js → sha256-mf0I6iCn-C1PUWFZm.js} +0 -0
- /package/dist/{x25519-C5Qlh_Lh-NSl6svWQ.js → x25519-DrRZ9GHv-NSl6svWQ.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as A,
|
|
1
|
+
import{_ as A,K as t,L as e,M as r,N as n}from"./main.js";function i(A,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(e){if("default"!==e&&!(e in A)){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(A,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})}}))})),Object.freeze(A)}function o(A){const{offsetWidth:t,offsetHeight:e}=A;return{width:t,height:e}}function s(A){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},s(A)}var a=Uint8Array,c=Uint16Array,u=Int32Array,l=new a([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,0,0,0]),h=new a([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,0,0]),f=new a([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),B=function(A,t){for(var e=new c(31),r=0;r<31;++r)e[r]=t+=1<<A[r-1];var n=new u(e[30]);for(r=1;r<30;++r)for(var i=e[r];i<e[r+1];++i)n[i]=i-e[r]<<5|r;return{b:e,r:n}},d=B(l,2),g=d.b,p=d.r;g[28]=258,p[258]=28;for(var w=B(h,0),m=w.b,Q=w.r,C=new c(32768),v=0;v<32768;++v){var F=(43690&v)>>1|(21845&v)<<1;F=(61680&(F=(52428&F)>>2|(13107&F)<<2))>>4|(3855&F)<<4,C[v]=((65280&F)>>8|(255&F)<<8)>>1}var y=function(A,t,e){for(var r=A.length,n=0,i=new c(t);n<r;++n)A[n]&&++i[A[n]-1];var o,s=new c(t);for(n=1;n<t;++n)s[n]=s[n-1]+i[n-1]<<1;if(e){o=new c(1<<t);var a=15-t;for(n=0;n<r;++n)if(A[n])for(var u=n<<4|A[n],l=t-A[n],h=s[A[n]-1]++<<l,f=h|(1<<l)-1;h<=f;++h)o[C[h]>>a]=u}else for(o=new c(r),n=0;n<r;++n)A[n]&&(o[n]=C[s[A[n]-1]++]>>15-A[n]);return o},b=new a(288);for(v=0;v<144;++v)b[v]=8;for(v=144;v<256;++v)b[v]=9;for(v=256;v<280;++v)b[v]=7;for(v=280;v<288;++v)b[v]=8;var U=new a(32);for(v=0;v<32;++v)U[v]=5;var L=y(b,9,0),I=y(b,9,1),E=y(U,5,0),x=y(U,5,1),H=function(A){for(var t=A[0],e=1;e<A.length;++e)A[e]>t&&(t=A[e]);return t},N=function(A,t,e){var r=t/8|0;return(A[r]|A[r+1]<<8)>>(7&t)&e},S=function(A,t){var e=t/8|0;return(A[e]|A[e+1]<<8|A[e+2]<<16)>>(7&t)},P=function(A){return(A+7)/8|0},D=function(A,t,e){return(null==e||e>A.length)&&(e=A.length),new a(A.subarray(t,e))},k=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],_=function(A,t,e){var r=new Error(t||k[A]);if(r.code=A,Error.captureStackTrace&&Error.captureStackTrace(r,_),!e)throw r;return r},M=function(A,t,e){e<<=7&t;var r=t/8|0;A[r]|=e,A[r+1]|=e>>8},O=function(A,t,e){e<<=7&t;var r=t/8|0;A[r]|=e,A[r+1]|=e>>8,A[r+2]|=e>>16},K=function(A,t){for(var e=[],r=0;r<A.length;++r)A[r]&&e.push({s:r,f:A[r]});var n=e.length,i=e.slice();if(!n)return{t:X,l:0};if(1==n){var o=new a(e[0].s+1);return o[e[0].s]=1,{t:o,l:1}}e.sort((function(A,t){return A.f-t.f})),e.push({s:-1,f:25001});var s=e[0],u=e[1],l=0,h=1,f=2;for(e[0]={s:-1,f:s.f+u.f,l:s,r:u};h!=n-1;)s=e[e[l].f<e[f].f?l++:f++],u=e[l!=h&&e[l].f<e[f].f?l++:f++],e[h++]={s:-1,f:s.f+u.f,l:s,r:u};var B=i[0].s;for(r=1;r<n;++r)i[r].s>B&&(B=i[r].s);var d=new c(B+1),g=T(e[h-1],d,0);if(g>t){r=0;var p=0,w=g-t,m=1<<w;for(i.sort((function(A,t){return d[t.s]-d[A.s]||A.f-t.f}));r<n;++r){var Q=i[r].s;if(!(d[Q]>t))break;p+=m-(1<<g-d[Q]),d[Q]=t}for(p>>=w;p>0;){var C=i[r].s;d[C]<t?p-=1<<t-d[C]++-1:++r}for(;r>=0&&p;--r){var v=i[r].s;d[v]==t&&(--d[v],++p)}g=t}return{t:new a(d),l:g}},T=function(A,t,e){return-1==A.s?Math.max(T(A.l,t,e+1),T(A.r,t,e+1)):t[A.s]=e},R=function(A){for(var t=A.length;t&&!A[--t];);for(var e=new c(++t),r=0,n=A[0],i=1,o=function(A){e[r++]=A},s=1;s<=t;++s)if(A[s]==n&&s!=t)++i;else{if(!n&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(n),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(n);i=1,n=A[s]}return{c:e.subarray(0,r),n:t}},j=function(A,t){for(var e=0,r=0;r<t.length;++r)e+=A[r]*t[r];return e},G=function(A,t,e){var r=e.length,n=P(t+2);A[n]=255&r,A[n+1]=r>>8,A[n+2]=255^A[n],A[n+3]=255^A[n+1];for(var i=0;i<r;++i)A[n+i+4]=e[i];return 8*(n+4+r)},V=function(A,t,e,r,n,i,o,s,a,u,B){M(t,B++,e),++n[256];for(var d=K(n,15),g=d.t,p=d.l,w=K(i,15),m=w.t,Q=w.l,C=R(g),v=C.c,F=C.n,I=R(m),x=I.c,H=I.n,N=new c(19),S=0;S<v.length;++S)++N[31&v[S]];for(S=0;S<x.length;++S)++N[31&x[S]];for(var P=K(N,7),D=P.t,k=P.l,_=19;_>4&&!D[f[_-1]];--_);var T,V,q,X,J=u+5<<3,W=j(n,b)+j(i,U)+o,z=j(n,g)+j(i,m)+o+14+3*_+j(N,D)+2*N[16]+3*N[17]+7*N[18];if(a>=0&&J<=W&&J<=z)return G(t,B,A.subarray(a,a+u));if(M(t,B,1+(z<W)),B+=2,z<W){T=y(g,p,0),V=g,q=y(m,Q,0),X=m;var Y=y(D,k,0);M(t,B,F-257),M(t,B+5,H-1),M(t,B+10,_-4),B+=14;for(S=0;S<_;++S)M(t,B+3*S,D[f[S]]);B+=3*_;for(var Z=[v,x],$=0;$<2;++$){var AA=Z[$];for(S=0;S<AA.length;++S){var tA=31&AA[S];M(t,B,Y[tA]),B+=D[tA],tA>15&&(M(t,B,AA[S]>>5&127),B+=AA[S]>>12)}}}else T=L,V=b,q=E,X=U;for(S=0;S<s;++S){var eA=r[S];if(eA>255){O(t,B,T[(tA=eA>>18&31)+257]),B+=V[tA+257],tA>7&&(M(t,B,eA>>23&31),B+=l[tA]);var rA=31&eA;O(t,B,q[rA]),B+=X[rA],rA>3&&(O(t,B,eA>>5&8191),B+=h[rA])}else O(t,B,T[eA]),B+=V[eA]}return O(t,B,T[256]),B+V[256]},q=new u([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),X=new a(0),J=function(){var A=1,t=0;return{p:function(e){for(var r=A,n=t,i=0|e.length,o=0;o!=i;){for(var s=Math.min(o+2655,i);o<s;++o)n+=r+=e[o];r=(65535&r)+15*(r>>16),n=(65535&n)+15*(n>>16)}A=r,t=n},d:function(){return(255&(A%=65521))<<24|(65280&A)<<8|(255&(t%=65521))<<8|t>>8}}},W=function(A,t,e,r,n){if(!n&&(n={l:1},t.dictionary)){var i=t.dictionary.subarray(-32768),o=new a(i.length+A.length);o.set(i),o.set(A,i.length),A=o,n.w=i.length}return function(A,t,e,r,n,i){var o=i.z||A.length,s=new a(r+o+5*(1+Math.ceil(o/7e3))+n),f=s.subarray(r,s.length-n),B=i.l,d=7&(i.r||0);if(t){d&&(f[0]=i.r>>3);for(var g=q[t-1],w=g>>13,m=8191&g,C=(1<<e)-1,v=i.p||new c(32768),F=i.h||new c(C+1),y=Math.ceil(e/3),b=2*y,U=function(t){return(A[t]^A[t+1]<<y^A[t+2]<<b)&C},L=new u(25e3),I=new c(288),E=new c(32),x=0,H=0,N=i.i||0,S=0,k=i.w||0,_=0;N+2<o;++N){var M=U(N),O=32767&N,K=F[M];if(v[O]=K,F[M]=O,k<=N){var T=o-N;if((x>7e3||S>24576)&&(T>423||!B)){d=V(A,f,0,L,I,E,H,S,_,N-_,d),S=x=H=0,_=N;for(var R=0;R<286;++R)I[R]=0;for(R=0;R<30;++R)E[R]=0}var j=2,X=0,J=m,W=O-K&32767;if(T>2&&M==U(N-W))for(var z=Math.min(w,T)-1,Y=Math.min(32767,N),Z=Math.min(258,T);W<=Y&&--J&&O!=K;){if(A[N+j]==A[N+j-W]){for(var $=0;$<Z&&A[N+$]==A[N+$-W];++$);if($>j){if(j=$,X=W,$>z)break;var AA=Math.min(W,$-2),tA=0;for(R=0;R<AA;++R){var eA=N-W+R&32767,rA=eA-v[eA]&32767;rA>tA&&(tA=rA,K=eA)}}}W+=(O=K)-(K=v[O])&32767}if(X){L[S++]=268435456|p[j]<<18|Q[X];var nA=31&p[j],iA=31&Q[X];H+=l[nA]+h[iA],++I[257+nA],++E[iA],k=N+j,++x}else L[S++]=A[N],++I[A[N]]}}for(N=Math.max(N,k);N<o;++N)L[S++]=A[N],++I[A[N]];d=V(A,f,B,L,I,E,H,S,_,N-_,d),B||(i.r=7&d|f[d/8|0]<<3,d-=7,i.h=F,i.p=v,i.i=N,i.w=k)}else{for(N=i.w||0;N<o+B;N+=65535){var oA=N+65535;oA>=o&&(f[d/8|0]=B,oA=o),d=G(f,d+1,A.subarray(N,oA))}i.i=o}return D(s,0,r+P(d)+n)}(A,null==t.level?6:t.level,null==t.mem?n.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(A.length)))):20:12+t.mem,e,r,n)},z=function(A,t,e){for(;e;++t)A[t]=e,e>>>=8};function Y(A,t){t||(t={});var e=J();e.p(A);var r=W(A,t,t.dictionary?6:2,4);return function(A,t){var e=t.level,r=0==e?0:e<6?1:9==e?3:2;if(A[0]=120,A[1]=r<<6|(t.dictionary&&32),A[1]|=31-(A[0]<<8|A[1])%31,t.dictionary){var n=J();n.p(t.dictionary),z(A,2,n.d())}}(r,t),z(r,r.length-4,e.d()),r}function Z(A,t){return function(A,t,e,r){var n=A.length;if(!n||t.f&&!t.l)return e||new a(0);var i=!e,o=i||2!=t.i,s=t.i;i&&(e=new a(3*n));var c=function(A){var t=e.length;if(A>t){var r=new a(Math.max(2*t,A));r.set(e),e=r}},u=t.f||0,B=t.p||0,d=t.b||0,p=t.l,w=t.d,Q=t.m,C=t.n,v=8*n;do{if(!p){u=N(A,B,1);var F=N(A,B+1,3);if(B+=3,!F){var b=A[(G=P(B)+4)-4]|A[G-3]<<8,U=G+b;if(U>n){s&&_(0);break}o&&c(d+b),e.set(A.subarray(G,U),d),t.b=d+=b,t.p=B=8*U,t.f=u;continue}if(1==F)p=I,w=x,Q=9,C=5;else if(2==F){var L=N(A,B,31)+257,E=N(A,B+10,15)+4,k=L+N(A,B+5,31)+1;B+=14;for(var M=new a(k),O=new a(19),K=0;K<E;++K)O[f[K]]=N(A,B+3*K,7);B+=3*E;var T=H(O),R=(1<<T)-1,j=y(O,T,1);for(K=0;K<k;){var G,V=j[N(A,B,R)];if(B+=15&V,(G=V>>4)<16)M[K++]=G;else{var q=0,X=0;for(16==G?(X=3+N(A,B,3),B+=2,q=M[K-1]):17==G?(X=3+N(A,B,7),B+=3):18==G&&(X=11+N(A,B,127),B+=7);X--;)M[K++]=q}}var J=M.subarray(0,L),W=M.subarray(L);Q=H(J),C=H(W),p=y(J,Q,1),w=y(W,C,1)}else _(1);if(B>v){s&&_(0);break}}o&&c(d+131072);for(var z=(1<<Q)-1,Y=(1<<C)-1,Z=B;;Z=B){var $=(q=p[S(A,B)&z])>>4;if((B+=15&q)>v){s&&_(0);break}if(q||_(2),$<256)e[d++]=$;else{if(256==$){Z=B,p=null;break}var AA=$-254;if($>264){var tA=l[K=$-257];AA=N(A,B,(1<<tA)-1)+g[K],B+=tA}var eA=w[S(A,B)&Y],rA=eA>>4;if(eA||_(3),B+=15&eA,W=m[rA],rA>3&&(tA=h[rA],W+=S(A,B)&(1<<tA)-1,B+=tA),B>v){s&&_(0);break}o&&c(d+131072);var nA=d+AA;if(d<W){var iA=0-W,oA=Math.min(W,nA);for(iA+d<0&&_(3);d<oA;++d)e[d]=r[iA+d]}for(;d<nA;++d)e[d]=e[d-W]}}t.l=p,t.p=Z,t.b=d,t.f=u,p&&(u=1,t.m=Q,t.d=w,t.n=C)}while(!u);return d!=e.length&&i?D(e,0,d):e.subarray(0,d)}(A.subarray(function(A,t){return(8!=(15&A[0])||A[0]>>4>7||(A[0]<<8|A[1])%31)&&_(6,"invalid zlib data"),(A[1]>>5&1)==+!t&&_(6,"invalid zlib data: "+(32&A[1]?"need":"unexpected")+" dictionary"),2+(A[1]>>3&4)}(A,t),-4),{i:2},t,t)}var $="undefined"!=typeof TextDecoder&&new TextDecoder;try{$.decode(X,{stream:!0})}catch(Ct){}
|
|
2
2
|
/** @license
|
|
3
3
|
*
|
|
4
4
|
* jsPDF - PDF Document creation from JavaScript
|
|
@@ -123,7 +123,7 @@ function(A){var t=function(A){var t,e,r,n,i,o,s,a,c,u;for(e=[],r=0,n=(A+=t="\0\0
|
|
|
123
123
|
* Licensed under the MIT License.
|
|
124
124
|
* http://opensource.org/licenses/mit-license
|
|
125
125
|
*/
|
|
126
|
-
function(A){A.loadFile=function(A,t,e){return function(A,t,e){t=!1!==t,e="function"==typeof e?e:function(){};var r=void 0;try{r=function(A,t,e){var r=new XMLHttpRequest,n=0,i=function(A){var t=A.length,e=[],r=String.fromCharCode;for(n=0;n<t;n+=1)e.push(r(255&A.charCodeAt(n)));return e.join("")};if(r.open("GET",A,!t),r.overrideMimeType("text/plain; charset=x-user-defined"),!1===t&&(r.onload=function(){200===r.status?e(i(this.responseText)):e(void 0)}),r.send(null),t&&200===r.status)return i(r.responseText)}(A,t,e)}catch(A){}return r}(A,t,e)},A.loadImageFile=A.loadFile}(SA.API),function(A){function t(){return(AA.html2canvas?Promise.resolve(AA.html2canvas):Promise.resolve().then((function(){return ye}))).catch((function(A){return Promise.reject(new Error("Could not load html2canvas: "+A))})).then((function(A){return A.default?A.default:A}))}function e(){return(AA.DOMPurify?Promise.resolve(AA.DOMPurify):import("./purify-hA3K4SAZ.js").then((function(A){return A.p}))).catch((function(A){return Promise.reject(new Error("Could not load dompurify: "+A))})).then((function(A){return A.default?A.default:A}))}var r=function(A){var t=s(A);return"undefined"===t?"undefined":"string"===t||A instanceof String?"string":"number"===t||A instanceof Number?"number":"function"===t||A instanceof Function?"function":A&&A.constructor===Array?"array":A&&1===A.nodeType?"element":"object"===t?"object":"unknown"},n=function(A,t){var e=document.createElement(A);for(var r in t.className&&(e.className=t.className),t.innerHTML&&t.dompurify&&(e.innerHTML=t.dompurify.sanitize(t.innerHTML)),t.style)e.style[r]=t.style[r];return e},i=function A(t){var e=Object.assign(A.convert(Promise.resolve()),JSON.parse(JSON.stringify(A.template))),r=A.convert(Promise.resolve(),e);return(r=r.setProgress(1,A,1,[A])).set(t)};(i.prototype=Object.create(Promise.prototype)).constructor=i,i.convert=function(A,t){return A.__proto__=t||i.prototype,A},i.template={prop:{src:null,container:null,overlay:null,canvas:null,img:null,pdf:null,pageSize:null,callback:function(){}},progress:{val:0,state:null,n:0,stack:[]},opt:{filename:"file.pdf",margin:[0,0,0,0],enableLinks:!0,x:0,y:0,html2canvas:{},jsPDF:{},backgroundColor:"transparent"}},i.prototype.from=function(A,t){return this.then((function(){switch(t=t||function(A){switch(r(A)){case"string":return"string";case"element":return"canvas"===A.nodeName.toLowerCase()?"canvas":"element";default:return"unknown"}}(A)){case"string":return this.then(e).then((function(t){return this.set({src:n("div",{innerHTML:A,dompurify:t})})}));case"element":return this.set({src:A});case"canvas":return this.set({canvas:A});case"img":return this.set({img:A});default:return this.error("Unknown source type.")}}))},i.prototype.to=function(A){switch(A){case"container":return this.toContainer();case"canvas":return this.toCanvas();case"img":return this.toImg();case"pdf":return this.toPdf();default:return this.error("Invalid target.")}},i.prototype.toContainer=function(){return this.thenList([function(){return this.prop.src||this.error("Cannot duplicate - no source HTML.")},function(){return this.prop.pageSize||this.setPageSize()}]).then((function(){var A={position:"relative",display:"inline-block",width:("number"!=typeof this.opt.width||isNaN(this.opt.width)||"number"!=typeof this.opt.windowWidth||isNaN(this.opt.windowWidth)?Math.max(this.prop.src.clientWidth,this.prop.src.scrollWidth,this.prop.src.offsetWidth):this.opt.windowWidth)+"px",left:0,right:0,top:0,margin:"auto",backgroundColor:this.opt.backgroundColor},t=function A(t,e){for(var r=3===t.nodeType?document.createTextNode(t.nodeValue):t.cloneNode(!1),n=t.firstChild;n;n=n.nextSibling)!0!==e&&1===n.nodeType&&"SCRIPT"===n.nodeName||r.appendChild(A(n,e));return 1===t.nodeType&&("CANVAS"===t.nodeName?(r.width=t.width,r.height=t.height,r.getContext("2d").drawImage(t,0,0)):"TEXTAREA"!==t.nodeName&&"SELECT"!==t.nodeName||(r.value=t.value),r.addEventListener("load",(function(){r.scrollTop=t.scrollTop,r.scrollLeft=t.scrollLeft}),!0)),r}(this.prop.src,this.opt.html2canvas.javascriptEnabled);"BODY"===t.tagName&&(A.height=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)+"px"),this.prop.overlay=n("div",{className:"html2pdf__overlay",style:{position:"fixed",overflow:"hidden",zIndex:1e3,left:"-100000px",right:0,bottom:0,top:0}}),this.prop.container=n("div",{className:"html2pdf__container",style:A}),this.prop.container.appendChild(t),this.prop.container.firstChild.appendChild(n("div",{style:{clear:"both",border:"0 none transparent",margin:0,padding:0,height:0}})),this.prop.container.style.float="none",this.prop.overlay.appendChild(this.prop.container),document.body.appendChild(this.prop.overlay),this.prop.container.firstChild.style.position="relative",this.prop.container.height=Math.max(this.prop.container.firstChild.clientHeight,this.prop.container.firstChild.scrollHeight,this.prop.container.firstChild.offsetHeight)+"px"}))},i.prototype.toCanvas=function(){var A=[function(){return document.body.contains(this.prop.container)||this.toContainer()}];return this.thenList(A).then(t).then((function(A){var t=Object.assign({},this.opt.html2canvas);return delete t.onrendered,A(this.prop.container,t)})).then((function(A){(this.opt.html2canvas.onrendered||function(){})(A),this.prop.canvas=A,document.body.removeChild(this.prop.overlay)}))},i.prototype.toContext2d=function(){var A=[function(){return document.body.contains(this.prop.container)||this.toContainer()}];return this.thenList(A).then(t).then((function(A){var t=this.opt.jsPDF,e=this.opt.fontFaces,r="number"!=typeof this.opt.width||isNaN(this.opt.width)||"number"!=typeof this.opt.windowWidth||isNaN(this.opt.windowWidth)?1:this.opt.width/this.opt.windowWidth,n=Object.assign({async:!0,allowTaint:!0,scale:r,scrollX:this.opt.scrollX||0,scrollY:this.opt.scrollY||0,backgroundColor:"#ffffff",imageTimeout:15e3,logging:!0,proxy:null,removeContainer:!0,foreignObjectRendering:!1,useCORS:!1},this.opt.html2canvas);if(delete n.onrendered,t.context2d.autoPaging=void 0===this.opt.autoPaging||this.opt.autoPaging,t.context2d.posX=this.opt.x,t.context2d.posY=this.opt.y,t.context2d.margin=this.opt.margin,t.context2d.fontFaces=e,e)for(var i=0;i<e.length;++i){var o=e[i],s=o.src.find((function(A){return"truetype"===A.format}));s&&t.addFont(s.url,o.ref.name,o.ref.style)}return n.windowHeight=n.windowHeight||0,n.windowHeight=0==n.windowHeight?Math.max(this.prop.container.clientHeight,this.prop.container.scrollHeight,this.prop.container.offsetHeight):n.windowHeight,t.context2d.save(!0),A(this.prop.container,n)})).then((function(A){this.opt.jsPDF.context2d.restore(!0),(this.opt.html2canvas.onrendered||function(){})(A),this.prop.canvas=A,document.body.removeChild(this.prop.overlay)}))},i.prototype.toImg=function(){return this.thenList([function(){return this.prop.canvas||this.toCanvas()}]).then((function(){var A=this.prop.canvas.toDataURL("image/"+this.opt.image.type,this.opt.image.quality);this.prop.img=document.createElement("img"),this.prop.img.src=A}))},i.prototype.toPdf=function(){return this.thenList([function(){return this.toContext2d()}]).then((function(){this.prop.pdf=this.prop.pdf||this.opt.jsPDF}))},i.prototype.output=function(A,t,e){return"img"===(e=e||"pdf").toLowerCase()||"image"===e.toLowerCase()?this.outputImg(A,t):this.outputPdf(A,t)},i.prototype.outputPdf=function(A,t){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then((function(){return this.prop.pdf.output(A,t)}))},i.prototype.outputImg=function(A){return this.thenList([function(){return this.prop.img||this.toImg()}]).then((function(){switch(A){case void 0:case"img":return this.prop.img;case"datauristring":case"dataurlstring":return this.prop.img.src;case"datauri":case"dataurl":return document.location.href=this.prop.img.src;default:throw'Image output type "'+A+'" is not supported.'}}))},i.prototype.save=function(A){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).set(A?{filename:A}:null).then((function(){this.prop.pdf.save(this.opt.filename)}))},i.prototype.doCallback=function(){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then((function(){this.prop.callback(this.prop.pdf)}))},i.prototype.set=function(A){if("object"!==r(A))return this;var t=Object.keys(A||{}).map((function(t){if(t in i.template.prop)return function(){this.prop[t]=A[t]};switch(t){case"margin":return this.setMargin.bind(this,A.margin);case"jsPDF":return function(){return this.opt.jsPDF=A.jsPDF,this.setPageSize()};case"pageSize":return this.setPageSize.bind(this,A.pageSize);default:return function(){this.opt[t]=A[t]}}}),this);return this.then((function(){return this.thenList(t)}))},i.prototype.get=function(A,t){return this.then((function(){var e=A in i.template.prop?this.prop[A]:this.opt[A];return t?t(e):e}))},i.prototype.setMargin=function(A){return this.then((function(){switch(r(A)){case"number":A=[A,A,A,A];case"array":if(2===A.length&&(A=[A[0],A[1],A[0],A[1]]),4===A.length)break;default:return this.error("Invalid margin array.")}this.opt.margin=A})).then(this.setPageSize)},i.prototype.setPageSize=function(A){function t(A,t){return Math.floor(A*t/72*96)}return this.then((function(){(A=A||SA.getPageSize(this.opt.jsPDF)).hasOwnProperty("inner")||(A.inner={width:A.width-this.opt.margin[1]-this.opt.margin[3],height:A.height-this.opt.margin[0]-this.opt.margin[2]},A.inner.px={width:t(A.inner.width,A.k),height:t(A.inner.height,A.k)},A.inner.ratio=A.inner.height/A.inner.width),this.prop.pageSize=A}))},i.prototype.setProgress=function(A,t,e,r){return null!=A&&(this.progress.val=A),null!=t&&(this.progress.state=t),null!=e&&(this.progress.n=e),null!=r&&(this.progress.stack=r),this.progress.ratio=this.progress.val/this.progress.state,this},i.prototype.updateProgress=function(A,t,e,r){return this.setProgress(A?this.progress.val+A:null,t||null,e?this.progress.n+e:null,r?this.progress.stack.concat(r):null)},i.prototype.then=function(A,t){var e=this;return this.thenCore(A,t,(function(A,t){return e.updateProgress(null,null,1,[A]),Promise.prototype.then.call(this,(function(t){return e.updateProgress(null,A),t})).then(A,t).then((function(A){return e.updateProgress(1),A}))}))},i.prototype.thenCore=function(A,t,e){e=e||Promise.prototype.then,A&&(A=A.bind(this)),t&&(t=t.bind(this));var r=-1!==Promise.toString().indexOf("[native code]")&&"Promise"===Promise.name?this:i.convert(Object.assign({},this),Promise.prototype),n=e.call(r,A,t);return i.convert(n,this.__proto__)},i.prototype.thenExternal=function(A,t){return Promise.prototype.then.call(this,A,t)},i.prototype.thenList=function(A){var t=this;return A.forEach((function(A){t=t.thenCore(A)})),t},i.prototype.catch=function(A){A&&(A=A.bind(this));var t=Promise.prototype.catch.call(this,A);return i.convert(t,this)},i.prototype.catchExternal=function(A){return Promise.prototype.catch.call(this,A)},i.prototype.error=function(A){return this.then((function(){throw new Error(A)}))},i.prototype.using=i.prototype.set,i.prototype.saveAs=i.prototype.save,i.prototype.export=i.prototype.output,i.prototype.run=i.prototype.then,SA.getPageSize=function(A,t,e){if("object"===s(A)){var r=A;A=r.orientation,t=r.unit||t,e=r.format||e}t=t||"mm",e=e||"a4",A=(""+(A||"P")).toLowerCase();var n,i=(""+e).toLowerCase(),o={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};switch(t){case"pt":n=1;break;case"mm":n=72/25.4;break;case"cm":n=72/2.54;break;case"in":n=72;break;case"px":n=.75;break;case"pc":case"em":n=12;break;case"ex":n=6;break;default:throw"Invalid unit: "+t}var a,c=0,u=0;if(o.hasOwnProperty(i))c=o[i][1]/n,u=o[i][0]/n;else try{c=e[1],u=e[0]}catch(A){throw new Error("Invalid format: "+e)}if("p"===A||"portrait"===A)A="p",u>c&&(a=u,u=c,c=a);else{if("l"!==A&&"landscape"!==A)throw"Invalid orientation: "+A;A="l",c>u&&(a=u,u=c,c=a)}return{width:u,height:c,unit:t,k:n,orientation:A}},A.html=function(A,t){(t=t||{}).callback=t.callback||function(){},t.html2canvas=t.html2canvas||{},t.html2canvas.canvas=t.html2canvas.canvas||this.canvas,t.jsPDF=t.jsPDF||this,t.fontFaces=t.fontFaces?t.fontFaces.map(Et):null;var e=new i(t);return t.worker?e:e.from(A).doCallback()}}(SA.API),SA.API.addJS=function(A){return Ot=A,this.internal.events.subscribe("postPutResources",(function(){_t=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/Names [(EmbeddedJS) "+(_t+1)+" 0 R]"),this.internal.out(">>"),this.internal.out("endobj"),Mt=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/S /JavaScript"),this.internal.out("/JS ("+Ot+")"),this.internal.out(">>"),this.internal.out("endobj")})),this.internal.events.subscribe("putCatalog",(function(){void 0!==_t&&void 0!==Mt&&this.internal.out("/Names <</JavaScript "+_t+" 0 R>>")})),this
|
|
126
|
+
function(A){A.loadFile=function(A,t,e){return function(A,t,e){t=!1!==t,e="function"==typeof e?e:function(){};var r=void 0;try{r=function(A,t,e){var r=new XMLHttpRequest,n=0,i=function(A){var t=A.length,e=[],r=String.fromCharCode;for(n=0;n<t;n+=1)e.push(r(255&A.charCodeAt(n)));return e.join("")};if(r.open("GET",A,!t),r.overrideMimeType("text/plain; charset=x-user-defined"),!1===t&&(r.onload=function(){200===r.status?e(i(this.responseText)):e(void 0)}),r.send(null),t&&200===r.status)return i(r.responseText)}(A,t,e)}catch(A){}return r}(A,t,e)},A.loadImageFile=A.loadFile}(SA.API),function(A){function t(){return(AA.html2canvas?Promise.resolve(AA.html2canvas):Promise.resolve().then((function(){return ye}))).catch((function(A){return Promise.reject(new Error("Could not load html2canvas: "+A))})).then((function(A){return A.default?A.default:A}))}function e(){return(AA.DOMPurify?Promise.resolve(AA.DOMPurify):import("./purify-mEiDmpQD.js").then((function(A){return A.p}))).catch((function(A){return Promise.reject(new Error("Could not load dompurify: "+A))})).then((function(A){return A.default?A.default:A}))}var r=function(A){var t=s(A);return"undefined"===t?"undefined":"string"===t||A instanceof String?"string":"number"===t||A instanceof Number?"number":"function"===t||A instanceof Function?"function":A&&A.constructor===Array?"array":A&&1===A.nodeType?"element":"object"===t?"object":"unknown"},n=function(A,t){var e=document.createElement(A);for(var r in t.className&&(e.className=t.className),t.innerHTML&&t.dompurify&&(e.innerHTML=t.dompurify.sanitize(t.innerHTML)),t.style)e.style[r]=t.style[r];return e},i=function A(t){var e=Object.assign(A.convert(Promise.resolve()),JSON.parse(JSON.stringify(A.template))),r=A.convert(Promise.resolve(),e);return(r=r.setProgress(1,A,1,[A])).set(t)};(i.prototype=Object.create(Promise.prototype)).constructor=i,i.convert=function(A,t){return A.__proto__=t||i.prototype,A},i.template={prop:{src:null,container:null,overlay:null,canvas:null,img:null,pdf:null,pageSize:null,callback:function(){}},progress:{val:0,state:null,n:0,stack:[]},opt:{filename:"file.pdf",margin:[0,0,0,0],enableLinks:!0,x:0,y:0,html2canvas:{},jsPDF:{},backgroundColor:"transparent"}},i.prototype.from=function(A,t){return this.then((function(){switch(t=t||function(A){switch(r(A)){case"string":return"string";case"element":return"canvas"===A.nodeName.toLowerCase()?"canvas":"element";default:return"unknown"}}(A)){case"string":return this.then(e).then((function(t){return this.set({src:n("div",{innerHTML:A,dompurify:t})})}));case"element":return this.set({src:A});case"canvas":return this.set({canvas:A});case"img":return this.set({img:A});default:return this.error("Unknown source type.")}}))},i.prototype.to=function(A){switch(A){case"container":return this.toContainer();case"canvas":return this.toCanvas();case"img":return this.toImg();case"pdf":return this.toPdf();default:return this.error("Invalid target.")}},i.prototype.toContainer=function(){return this.thenList([function(){return this.prop.src||this.error("Cannot duplicate - no source HTML.")},function(){return this.prop.pageSize||this.setPageSize()}]).then((function(){var A={position:"relative",display:"inline-block",width:("number"!=typeof this.opt.width||isNaN(this.opt.width)||"number"!=typeof this.opt.windowWidth||isNaN(this.opt.windowWidth)?Math.max(this.prop.src.clientWidth,this.prop.src.scrollWidth,this.prop.src.offsetWidth):this.opt.windowWidth)+"px",left:0,right:0,top:0,margin:"auto",backgroundColor:this.opt.backgroundColor},t=function A(t,e){for(var r=3===t.nodeType?document.createTextNode(t.nodeValue):t.cloneNode(!1),n=t.firstChild;n;n=n.nextSibling)!0!==e&&1===n.nodeType&&"SCRIPT"===n.nodeName||r.appendChild(A(n,e));return 1===t.nodeType&&("CANVAS"===t.nodeName?(r.width=t.width,r.height=t.height,r.getContext("2d").drawImage(t,0,0)):"TEXTAREA"!==t.nodeName&&"SELECT"!==t.nodeName||(r.value=t.value),r.addEventListener("load",(function(){r.scrollTop=t.scrollTop,r.scrollLeft=t.scrollLeft}),!0)),r}(this.prop.src,this.opt.html2canvas.javascriptEnabled);"BODY"===t.tagName&&(A.height=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)+"px"),this.prop.overlay=n("div",{className:"html2pdf__overlay",style:{position:"fixed",overflow:"hidden",zIndex:1e3,left:"-100000px",right:0,bottom:0,top:0}}),this.prop.container=n("div",{className:"html2pdf__container",style:A}),this.prop.container.appendChild(t),this.prop.container.firstChild.appendChild(n("div",{style:{clear:"both",border:"0 none transparent",margin:0,padding:0,height:0}})),this.prop.container.style.float="none",this.prop.overlay.appendChild(this.prop.container),document.body.appendChild(this.prop.overlay),this.prop.container.firstChild.style.position="relative",this.prop.container.height=Math.max(this.prop.container.firstChild.clientHeight,this.prop.container.firstChild.scrollHeight,this.prop.container.firstChild.offsetHeight)+"px"}))},i.prototype.toCanvas=function(){var A=[function(){return document.body.contains(this.prop.container)||this.toContainer()}];return this.thenList(A).then(t).then((function(A){var t=Object.assign({},this.opt.html2canvas);return delete t.onrendered,A(this.prop.container,t)})).then((function(A){(this.opt.html2canvas.onrendered||function(){})(A),this.prop.canvas=A,document.body.removeChild(this.prop.overlay)}))},i.prototype.toContext2d=function(){var A=[function(){return document.body.contains(this.prop.container)||this.toContainer()}];return this.thenList(A).then(t).then((function(A){var t=this.opt.jsPDF,e=this.opt.fontFaces,r="number"!=typeof this.opt.width||isNaN(this.opt.width)||"number"!=typeof this.opt.windowWidth||isNaN(this.opt.windowWidth)?1:this.opt.width/this.opt.windowWidth,n=Object.assign({async:!0,allowTaint:!0,scale:r,scrollX:this.opt.scrollX||0,scrollY:this.opt.scrollY||0,backgroundColor:"#ffffff",imageTimeout:15e3,logging:!0,proxy:null,removeContainer:!0,foreignObjectRendering:!1,useCORS:!1},this.opt.html2canvas);if(delete n.onrendered,t.context2d.autoPaging=void 0===this.opt.autoPaging||this.opt.autoPaging,t.context2d.posX=this.opt.x,t.context2d.posY=this.opt.y,t.context2d.margin=this.opt.margin,t.context2d.fontFaces=e,e)for(var i=0;i<e.length;++i){var o=e[i],s=o.src.find((function(A){return"truetype"===A.format}));s&&t.addFont(s.url,o.ref.name,o.ref.style)}return n.windowHeight=n.windowHeight||0,n.windowHeight=0==n.windowHeight?Math.max(this.prop.container.clientHeight,this.prop.container.scrollHeight,this.prop.container.offsetHeight):n.windowHeight,t.context2d.save(!0),A(this.prop.container,n)})).then((function(A){this.opt.jsPDF.context2d.restore(!0),(this.opt.html2canvas.onrendered||function(){})(A),this.prop.canvas=A,document.body.removeChild(this.prop.overlay)}))},i.prototype.toImg=function(){return this.thenList([function(){return this.prop.canvas||this.toCanvas()}]).then((function(){var A=this.prop.canvas.toDataURL("image/"+this.opt.image.type,this.opt.image.quality);this.prop.img=document.createElement("img"),this.prop.img.src=A}))},i.prototype.toPdf=function(){return this.thenList([function(){return this.toContext2d()}]).then((function(){this.prop.pdf=this.prop.pdf||this.opt.jsPDF}))},i.prototype.output=function(A,t,e){return"img"===(e=e||"pdf").toLowerCase()||"image"===e.toLowerCase()?this.outputImg(A,t):this.outputPdf(A,t)},i.prototype.outputPdf=function(A,t){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then((function(){return this.prop.pdf.output(A,t)}))},i.prototype.outputImg=function(A){return this.thenList([function(){return this.prop.img||this.toImg()}]).then((function(){switch(A){case void 0:case"img":return this.prop.img;case"datauristring":case"dataurlstring":return this.prop.img.src;case"datauri":case"dataurl":return document.location.href=this.prop.img.src;default:throw'Image output type "'+A+'" is not supported.'}}))},i.prototype.save=function(A){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).set(A?{filename:A}:null).then((function(){this.prop.pdf.save(this.opt.filename)}))},i.prototype.doCallback=function(){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then((function(){this.prop.callback(this.prop.pdf)}))},i.prototype.set=function(A){if("object"!==r(A))return this;var t=Object.keys(A||{}).map((function(t){if(t in i.template.prop)return function(){this.prop[t]=A[t]};switch(t){case"margin":return this.setMargin.bind(this,A.margin);case"jsPDF":return function(){return this.opt.jsPDF=A.jsPDF,this.setPageSize()};case"pageSize":return this.setPageSize.bind(this,A.pageSize);default:return function(){this.opt[t]=A[t]}}}),this);return this.then((function(){return this.thenList(t)}))},i.prototype.get=function(A,t){return this.then((function(){var e=A in i.template.prop?this.prop[A]:this.opt[A];return t?t(e):e}))},i.prototype.setMargin=function(A){return this.then((function(){switch(r(A)){case"number":A=[A,A,A,A];case"array":if(2===A.length&&(A=[A[0],A[1],A[0],A[1]]),4===A.length)break;default:return this.error("Invalid margin array.")}this.opt.margin=A})).then(this.setPageSize)},i.prototype.setPageSize=function(A){function t(A,t){return Math.floor(A*t/72*96)}return this.then((function(){(A=A||SA.getPageSize(this.opt.jsPDF)).hasOwnProperty("inner")||(A.inner={width:A.width-this.opt.margin[1]-this.opt.margin[3],height:A.height-this.opt.margin[0]-this.opt.margin[2]},A.inner.px={width:t(A.inner.width,A.k),height:t(A.inner.height,A.k)},A.inner.ratio=A.inner.height/A.inner.width),this.prop.pageSize=A}))},i.prototype.setProgress=function(A,t,e,r){return null!=A&&(this.progress.val=A),null!=t&&(this.progress.state=t),null!=e&&(this.progress.n=e),null!=r&&(this.progress.stack=r),this.progress.ratio=this.progress.val/this.progress.state,this},i.prototype.updateProgress=function(A,t,e,r){return this.setProgress(A?this.progress.val+A:null,t||null,e?this.progress.n+e:null,r?this.progress.stack.concat(r):null)},i.prototype.then=function(A,t){var e=this;return this.thenCore(A,t,(function(A,t){return e.updateProgress(null,null,1,[A]),Promise.prototype.then.call(this,(function(t){return e.updateProgress(null,A),t})).then(A,t).then((function(A){return e.updateProgress(1),A}))}))},i.prototype.thenCore=function(A,t,e){e=e||Promise.prototype.then,A&&(A=A.bind(this)),t&&(t=t.bind(this));var r=-1!==Promise.toString().indexOf("[native code]")&&"Promise"===Promise.name?this:i.convert(Object.assign({},this),Promise.prototype),n=e.call(r,A,t);return i.convert(n,this.__proto__)},i.prototype.thenExternal=function(A,t){return Promise.prototype.then.call(this,A,t)},i.prototype.thenList=function(A){var t=this;return A.forEach((function(A){t=t.thenCore(A)})),t},i.prototype.catch=function(A){A&&(A=A.bind(this));var t=Promise.prototype.catch.call(this,A);return i.convert(t,this)},i.prototype.catchExternal=function(A){return Promise.prototype.catch.call(this,A)},i.prototype.error=function(A){return this.then((function(){throw new Error(A)}))},i.prototype.using=i.prototype.set,i.prototype.saveAs=i.prototype.save,i.prototype.export=i.prototype.output,i.prototype.run=i.prototype.then,SA.getPageSize=function(A,t,e){if("object"===s(A)){var r=A;A=r.orientation,t=r.unit||t,e=r.format||e}t=t||"mm",e=e||"a4",A=(""+(A||"P")).toLowerCase();var n,i=(""+e).toLowerCase(),o={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};switch(t){case"pt":n=1;break;case"mm":n=72/25.4;break;case"cm":n=72/2.54;break;case"in":n=72;break;case"px":n=.75;break;case"pc":case"em":n=12;break;case"ex":n=6;break;default:throw"Invalid unit: "+t}var a,c=0,u=0;if(o.hasOwnProperty(i))c=o[i][1]/n,u=o[i][0]/n;else try{c=e[1],u=e[0]}catch(A){throw new Error("Invalid format: "+e)}if("p"===A||"portrait"===A)A="p",u>c&&(a=u,u=c,c=a);else{if("l"!==A&&"landscape"!==A)throw"Invalid orientation: "+A;A="l",c>u&&(a=u,u=c,c=a)}return{width:u,height:c,unit:t,k:n,orientation:A}},A.html=function(A,t){(t=t||{}).callback=t.callback||function(){},t.html2canvas=t.html2canvas||{},t.html2canvas.canvas=t.html2canvas.canvas||this.canvas,t.jsPDF=t.jsPDF||this,t.fontFaces=t.fontFaces?t.fontFaces.map(Et):null;var e=new i(t);return t.worker?e:e.from(A).doCallback()}}(SA.API),SA.API.addJS=function(A){return Ot=A,this.internal.events.subscribe("postPutResources",(function(){_t=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/Names [(EmbeddedJS) "+(_t+1)+" 0 R]"),this.internal.out(">>"),this.internal.out("endobj"),Mt=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/S /JavaScript"),this.internal.out("/JS ("+Ot+")"),this.internal.out(">>"),this.internal.out("endobj")})),this.internal.events.subscribe("putCatalog",(function(){void 0!==_t&&void 0!==Mt&&this.internal.out("/Names <</JavaScript "+_t+" 0 R>>")})),this
|
|
127
127
|
/**
|
|
128
128
|
* @license
|
|
129
129
|
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
|
|
@@ -284,7 +284,7 @@ function(A){var t=function(A){for(var t=A.length,e=new Uint8Array(t),r=0;r<t;r++
|
|
|
284
284
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
285
285
|
* ====================================================================
|
|
286
286
|
*/
|
|
287
|
-
function(){function A(){return(AA.canvg?Promise.resolve(AA.canvg):import("./index.es-
|
|
287
|
+
function(){function A(){return(AA.canvg?Promise.resolve(AA.canvg):import("./index.es-D_fMtNlx.js")).catch((function(A){return Promise.reject(new Error("Could not load canvg: "+A))})).then((function(A){return A.default?A.default:A}))}SA.API.addSvgAsImage=function(t,e,r,n,i,o,s,a){if(isNaN(e)||isNaN(r))throw eA.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(n)||isNaN(i))throw eA.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var c=document.createElement("canvas");c.width=n,c.height=i;var u=c.getContext("2d");u.fillStyle="#fff",u.fillRect(0,0,c.width,c.height);var l={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},h=this;return A().then((function(A){return A.fromString(u,t,l)}),(function(){return Promise.reject(new Error("Could not load canvg."))})).then((function(A){return A.render(l)})).then((function(){h.addImage(c.toDataURL("image/jpeg",1),e,r,n,i,s,a)}))}}(),SA.API.putTotalPages=function(A){var t,e=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(t=new RegExp(A,"g"),e=this.internal.getNumberOfPages()):(t=new RegExp(this.pdfEscape16(A,this.internal.getFont()),"g"),e=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var r=1;r<=this.internal.getNumberOfPages();r++)for(var n=0;n<this.internal.pages[r].length;n++)this.internal.pages[r][n]=this.internal.pages[r][n].replace(t,e);return this},SA.API.viewerPreferences=function(A,t){var e;A=A||{},t=t||!1;var r,n,i,o={HideToolbar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:"UseNone",value:"UseNone",type:"name",explicitSet:!1,valueSet:["UseNone","UseOutlines","UseThumbs","UseOC"],pdfVersion:1.3},Direction:{defaultValue:"L2R",value:"L2R",type:"name",explicitSet:!1,valueSet:["L2R","R2L"],pdfVersion:1.3},ViewArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},ViewClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintScaling:{defaultValue:"AppDefault",value:"AppDefault",type:"name",explicitSet:!1,valueSet:["AppDefault","None"],pdfVersion:1.6},Duplex:{defaultValue:"",value:"none",type:"name",explicitSet:!1,valueSet:["Simplex","DuplexFlipShortEdge","DuplexFlipLongEdge","none"],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:"",value:"",type:"array",explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:"integer",explicitSet:!1,valueSet:null,pdfVersion:1.7}},a=Object.keys(o),c=[],u=0,l=0,h=0;function f(A,t){var e,r=!1;for(e=0;e<A.length;e+=1)A[e]===t&&(r=!0);return r}if(void 0===this.internal.viewerpreferences&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(o)),this.internal.viewerpreferences.isSubscribed=!1),e=this.internal.viewerpreferences.configuration,"reset"===A||!0===t){var B=a.length;for(h=0;h<B;h+=1)e[a[h]].value=e[a[h]].defaultValue,e[a[h]].explicitSet=!1}if("object"===s(A))for(n in A)if(i=A[n],f(a,n)&&void 0!==i){if("boolean"===e[n].type&&"boolean"==typeof i)e[n].value=i;else if("name"===e[n].type&&f(e[n].valueSet,i))e[n].value=i;else if("integer"===e[n].type&&Number.isInteger(i))e[n].value=i;else if("array"===e[n].type){for(u=0;u<i.length;u+=1)if(r=!0,1===i[u].length&&"number"==typeof i[u][0])c.push(String(i[u]-1));else if(i[u].length>1){for(l=0;l<i[u].length;l+=1)"number"!=typeof i[u][l]&&(r=!1);!0===r&&c.push([i[u][0]-1,i[u][1]-1].join(" "))}e[n].value="["+c.join(" ")+"]"}else e[n].value=e[n].defaultValue;e[n].explicitSet=!0}return!1===this.internal.viewerpreferences.isSubscribed&&(this.internal.events.subscribe("putCatalog",(function(){var A,t=[];for(A in e)!0===e[A].explicitSet&&("name"===e[A].type?t.push("/"+A+" /"+e[A].value):t.push("/"+A+" "+e[A].value));0!==t.length&&this.internal.write("/ViewerPreferences\n<<\n"+t.join("\n")+"\n>>")})),this.internal.viewerpreferences.isSubscribed=!0),this.internal.viewerpreferences.configuration=e,this
|
|
288
288
|
/** ====================================================================
|
|
289
289
|
* @license
|
|
290
290
|
* jsPDF XMP metadata plugin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,B as t,u as r,x as n,i as o,y as i,p as s}from"./main.js";import{r as a,a as c,c as u,b as l,d as f}from"./elliptic-D7vAoLbk-DQmYEk-8.js";var p,h,d,y,b,w,g,m,v,k=r(n),_=r(i),P={exports:{}};function E(){return p||(p=1,function(e,t){var r=c,n=r.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function i(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=i),i.prototype=Object.create(n.prototype),o(n,i),i.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},i.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=n(e);return void 0!==t?"string"==typeof r?o.fill(t,r):o.fill(t):o.fill(0),o},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}}(P,P.exports)),P.exports}function S(){if(d)return h;d=1;class e extends Error{constructor(e){super(e||"This operation is not supported for this key type")}}return h=e}function K(){if(b)return y;b=1;class e extends Error{constructor(){super("This has not been implemented yet")}}return y=e}function A(){if(v)return m;v=1;const e=K();return m=class{constructor(e){this.params=e}fromPrivatePKCS1(t){throw new e}fromPrivatePKCS8(t){throw new e}fromPublicPKCS1(t){throw new e}fromPublicPKCS8(t){throw new e}fromPrivateBlk(t){throw new e}fromPublicBlk(t){throw new e}fromJwk(t){throw new e}toPrivatePKCS1(t){throw new e}toPrivatePKCS8(t){throw new e}toPublicPKCS1(t){throw new e}toPublicPKCS8(t){throw new e}toPrivateBlk(t){throw new e}toPublicBlk(t){throw new e}toPrivateJwk(t){throw new e}toPublicJwk(t){throw new e}static formatPem(e,t){return`-----BEGIN ${t} KEY-----\n`+e.match(/.{1,64}/g).join("\n")+`\n-----END ${t} KEY-----`}}}var x,C,B={},j={},U={};function I(){if(C)return x;C=1;var e,t=c,r=t.Buffer,n={};for(e in t)t.hasOwnProperty(e)&&"SlowBuffer"!==e&&"Buffer"!==e&&(n[e]=t[e]);var o=n.Buffer={};for(e in r)r.hasOwnProperty(e)&&"allocUnsafe"!==e&&"allocUnsafeSlow"!==e&&(o[e]=r[e]);if(n.Buffer.prototype=r.prototype,o.from&&o.from!==Uint8Array.from||(o.from=function(e,t,n){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return r(e,t,n)}),o.alloc||(o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var o=r(e);return t&&0!==t.length?"string"==typeof n?o.fill(t,n):o.fill(t):o.fill(0),o}),!n.kStringMaxLength)try{n.kStringMaxLength=s.binding("buffer").kStringMaxLength}catch(e){}return n.constants||(n.constants={MAX_LENGTH:n.kMaxLength},n.kStringMaxLength&&(n.constants.MAX_STRING_LENGTH=n.kStringMaxLength)),x=n}var T,q={};function N(){if(T)return q;T=1;const e=l();function t(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function r(e,t){this.path=e,this.rethrow(t)}return q.Reporter=t,t.prototype.isError=function(e){return e instanceof r},t.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},t.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},t.prototype.enterKey=function(e){return this._reporterState.path.push(e)},t.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},t.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},t.prototype.path=function(){return this._reporterState.path.join("/")},t.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},t.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},t.prototype.error=function(e){let t;const n=this._reporterState,o=e instanceof r;if(t=o?e:new r(n.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!n.options.partial)throw t;return o||n.errors.push(t),t},t.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},e(r,Error),r.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,r),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this},q}var z,O,R,D={};function V(){if(z)return D;z=1;const e=l(),t=N().Reporter,r=I().Buffer;function n(e,n){t.call(this,n),r.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function o(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return o.isEncoderBuffer(e)||(e=new o(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=r.byteLength(e);else{if(!r.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}return e(n,t),D.DecoderBuffer=n,n.isDecoderBuffer=function(e){if(e instanceof n)return!0;return"object"==typeof e&&r.isBuffer(e.base)&&"DecoderBuffer"===e.constructor.name&&"number"==typeof e.offset&&"number"==typeof e.length&&"function"==typeof e.save&&"function"==typeof e.restore&&"function"==typeof e.isEmpty&&"function"==typeof e.readUInt8&&"function"==typeof e.skip&&"function"==typeof e.raw},n.prototype.save=function(){return{offset:this.offset,reporter:t.prototype.save.call(this)}},n.prototype.restore=function(e){const r=new n(this.base);return r.offset=e.offset,r.length=this.offset,this.offset=e.offset,t.prototype.restore.call(this,e.reporter),r},n.prototype.isEmpty=function(){return this.offset===this.length},n.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},n.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");const r=new n(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},n.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},D.EncoderBuffer=o,o.isEncoderBuffer=function(e){if(e instanceof o)return!0;return"object"==typeof e&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},o.prototype.join=function(e,t){return e||(e=r.alloc(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(e,t),t+=r.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):r.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e},D}function L(){if(R)return O;R=1;const e=N().Reporter,t=V().EncoderBuffer,r=V().DecoderBuffer,n=f(),o=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],i=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(o);function s(e,t,r){const n={};this._baseState=n,n.name=r,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}O=s;const a=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];return s.prototype.clone=function(){const e=this._baseState,t={};a.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},s.prototype._wrap=function(){const e=this._baseState;i.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},s.prototype._init=function(e){const t=this._baseState;n(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),n.equal(t.children.length,1,"Root node can have only one child")},s.prototype._useArgs=function(e){const t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(n(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(n(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);const n=e[r];t[n]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){s.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),o.forEach((function(e){s.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return n(null===t.tag),t.tag=e,this._useArgs(r),this}})),s.prototype.use=function(e){n(e);const t=this._baseState;return n(null===t.use),t.use=e,this},s.prototype.optional=function(){return this._baseState.optional=!0,this},s.prototype.def=function(e){const t=this._baseState;return n(null===t.default),t.default=e,t.optional=!0,this},s.prototype.explicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.explicit=e,this},s.prototype.implicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.implicit=e,this},s.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},s.prototype.key=function(e){const t=this._baseState;return n(null===t.key),t.key=e,this},s.prototype.any=function(){return this._baseState.any=!0,this},s.prototype.choice=function(e){const t=this._baseState;return n(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},s.prototype.contains=function(e){const t=this._baseState;return n(null===t.use),t.contains=e,this},s.prototype._decode=function(e,t){const n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));let o,i=n.default,s=!0,a=null;if(null!==n.key&&(a=e.enterKey(n.key)),n.optional){let r=null;if(null!==n.explicit?r=n.explicit:null!==n.implicit?r=n.implicit:null!==n.tag&&(r=n.tag),null!==r||n.any){if(s=this._peekTag(e,r,n.any),e.isError(s))return s}else{const r=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),s=!0}catch(e){s=!1}e.restore(r)}}if(n.obj&&s&&(o=e.enterObject()),s){if(null!==n.explicit){const t=this._decodeTag(e,n.explicit);if(e.isError(t))return t;e=t}const o=e.offset;if(null===n.use&&null===n.choice){let t;n.any&&(t=e.save());const r=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(r))return r;n.any?i=e.raw(t):e=r}if(t&&t.track&&null!==n.tag&&t.track(e.path(),o,e.length,"tagged"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,"content"),n.any||(i=null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(n.any||null!==n.choice||null===n.children||n.children.forEach((function(r){r._decode(e,t)})),n.contains&&("octstr"===n.tag||"bitstr"===n.tag)){const o=new r(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(o,t)}}return n.obj&&s&&(i=e.leaveObject(o)),null===n.key||null===i&&!0!==s?null!==a&&e.exitKey(a):e.leaveKey(a,n.key,i),i},s.prototype._decodeGeneric=function(e,t,r){const n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},s.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),n(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},s.prototype._decodeChoice=function(e,t){const r=this._baseState;let n=null,o=!1;return Object.keys(r.choice).some((function(i){const s=e.save(),a=r.choice[i];try{const r=a._decode(e,t);if(e.isError(r))return!1;n={type:i,value:r},o=!0}catch(t){return e.restore(s),!1}return!0}),this),o?n:e.error("Choice not matched")},s.prototype._createEncoderBuffer=function(e){return new t(e,this.reporter)},s.prototype._encode=function(e,t,r){const n=this._baseState;if(null!==n.default&&n.default===e)return;const o=this._encodeValue(e,t,r);return void 0===o||this._skipDefault(o,t,r)?void 0:o},s.prototype._encodeValue=function(t,r,n){const o=this._baseState;if(null===o.parent)return o.children[0]._encode(t,r||new e);let i=null;if(this.reporter=r,o.optional&&void 0===t){if(null===o.default)return;t=o.default}let s=null,a=!1;if(o.any)i=this._createEncoderBuffer(t);else if(o.choice)i=this._encodeChoice(t,r);else if(o.contains)s=this._getUse(o.contains,n)._encode(t,r),a=!0;else if(o.children)s=o.children.map((function(e){if("null_"===e._baseState.tag)return e._encode(null,r,t);if(null===e._baseState.key)return r.error("Child should have a key");const n=r.enterKey(e._baseState.key);if("object"!=typeof t)return r.error("Child expected, but input is not object");const o=e._encode(t[e._baseState.key],r,t);return r.leaveKey(n),o}),this).filter((function(e){return e})),s=this._createEncoderBuffer(s);else if("seqof"===o.tag||"setof"===o.tag){if(!o.args||1!==o.args.length)return r.error("Too many args for : "+o.tag);if(!Array.isArray(t))return r.error("seqof/setof, but data is not Array");const e=this.clone();e._baseState.implicit=null,s=this._createEncoderBuffer(t.map((function(e){const n=this._baseState;return this._getUse(n.args[0],t)._encode(e,r)}),e))}else null!==o.use?i=this._getUse(o.use,n)._encode(t,r):(s=this._encodePrimitive(o.tag,t),a=!0);if(!o.any&&null===o.choice){const e=null!==o.implicit?o.implicit:o.tag,t=null===o.implicit?"universal":"context";null===e?null===o.use&&r.error("Tag could be omitted only for .use()"):null===o.use&&(i=this._encodeComposite(e,a,t,s))}return null!==o.explicit&&(i=this._encodeComposite(o.explicit,!1,"context",i)),i},s.prototype._encodeChoice=function(e,t){const r=this._baseState,o=r.choice[e.type];return o||n(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),o._encode(e.value,t)},s.prototype._encodePrimitive=function(e,t){const r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},s.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},s.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)},O}var M,J,$,F,Z,G,Y={};function H(){return M||(M=1,function(e){function t(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t}e.tagClass={0:"universal",1:"application",2:"context",3:"private"},e.tagClassByName=t(e.tagClass),e.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},e.tagByName=t(e.tag)}(Y)),Y}function X(){if($)return J;$=1;const e=l(),t=I().Buffer,r=L(),n=H();function o(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new i,this.tree._init(e.body)}function i(e){r.call(this,"der",e)}function s(e){return e<10?"0"+e:e}return J=o,o.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},e(i,r),i.prototype._encodeComposite=function(e,r,o,i){const s=function(e,t,r,o){let i;"seqof"===e?e="seq":"setof"===e&&(e="set");if(n.tagByName.hasOwnProperty(e))i=n.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return o.error("Unknown tag: "+e);i=e}if(i>=31)return o.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=n.tagClassByName[r||"universal"]<<6,i}(e,r,o,this.reporter);if(i.length<128){const e=t.alloc(2);return e[0]=s,e[1]=i.length,this._createEncoderBuffer([e,i])}let a=1;for(let e=i.length;e>=256;e>>=8)a++;const c=t.alloc(2+a);c[0]=s,c[1]=128|a;for(let e=1+a,t=i.length;t>0;e--,t>>=8)c[e]=255&t;return this._createEncoderBuffer([c,i])},i.prototype._encodeStr=function(e,r){if("bitstr"===r)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===r){const r=t.alloc(2*e.length);for(let t=0;t<e.length;t++)r.writeUInt16BE(e.charCodeAt(t),2*t);return this._createEncoderBuffer(r)}return"numstr"===r?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===r?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(r)||"objDesc"===r?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+r+" unsupported")},i.prototype._encodeObjid=function(e,r,n){if("string"==typeof e){if(!r)return this.reporter.error("string objid given, but no values map found");if(!r.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=r[e].split(/[\s.]+/g);for(let t=0;t<e.length;t++)e[t]|=0}else if(Array.isArray(e)){e=e.slice();for(let t=0;t<e.length;t++)e[t]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!n){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let o=0;for(let t=0;t<e.length;t++){let r=e[t];for(o++;r>=128;r>>=7)o++}const i=t.alloc(o);let s=i.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(i[s--]=127&r;(r>>=7)>0;)i[s--]=128|127&r}return this._createEncoderBuffer(i)},i.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[s(n.getUTCFullYear()),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[s(n.getUTCFullYear()%100),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},i.prototype._encodeNull=function(){return this._createEncoderBuffer("")},i.prototype._encodeInt=function(e,r){if("string"==typeof e){if(!r)return this.reporter.error("String int or enum given, but no values map");if(!r.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=r[e]}if("number"!=typeof e&&!t.isBuffer(e)){const r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=t.from(r)}if(t.isBuffer(e)){let r=e.length;0===e.length&&r++;const n=t.alloc(r);return e.copy(n),0===e.length&&(n[0]=0),this._createEncoderBuffer(n)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let n=1;for(let t=e;t>=256;t>>=8)n++;const o=new Array(n);for(let t=o.length-1;t>=0;t--)o[t]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(t.from(o))},i.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},i.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},i.prototype._skipDefault=function(e,t,r){const n=this._baseState;let o;if(null===n.default)return!1;const i=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),i.length!==n.defaultBuffer.length)return!1;for(o=0;o<i.length;o++)if(i[o]!==n.defaultBuffer[o])return!1;return!0},J}function W(){return G||(G=1,function(e){const t=e;t.der=X(),t.pem=function(){if(Z)return F;Z=1;const e=l(),t=X();function r(e){t.call(this,e),this.enc="pem"}return e(r,t),F=r,r.prototype.encode=function(e,r){const n=t.prototype.encode.call(this,e).toString("base64"),o=["-----BEGIN "+r.label+"-----"];for(let e=0;e<n.length;e+=64)o.push(n.slice(e,e+64));return o.push("-----END "+r.label+"-----"),o.join("\n")},F}()}(U)),U}var Q,ee,te,re,ne,oe,ie={};function se(){if(ee)return Q;ee=1;const e=l(),t=u(),r=V().DecoderBuffer,n=L(),o=H();function i(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new s,this.tree._init(e.body)}function s(e){n.call(this,"der",e)}function a(e,t){let r=e.readUInt8(t);if(e.isError(r))return r;const n=o.tagClass[r>>6],i=!(32&r);if(31&~r)r&=31;else{let n=r;for(r=0;!(128&~n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}return{cls:n,primitive:i,tag:r,tagStr:o.tag[r]}}function c(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(!(128&n))return n;const o=127&n;if(o>4)return e.error("length octect is too long");n=0;for(let t=0;t<o;t++){n<<=8;const t=e.readUInt8(r);if(e.isError(t))return t;n|=t}return n}return Q=i,i.prototype.decode=function(e,t){return r.isDecoderBuffer(e)||(e=new r(e,t)),this.tree._decode(e,t)},e(s,n),s.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;const n=e.save(),o=a(e,'Failed to peek tag: "'+t+'"');return e.isError(o)?o:(e.restore(n),o.tag===t||o.tagStr===t||o.tagStr+"of"===t||r)},s.prototype._decodeTag=function(e,t,r){const n=a(e,'Failed to decode tag of "'+t+'"');if(e.isError(n))return n;let o=c(e,n.primitive,'Failed to get length of "'+t+'"');if(e.isError(o))return o;if(!r&&n.tag!==t&&n.tagStr!==t&&n.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(n.primitive||null!==o)return e.skip(o,'Failed to match body of: "'+t+'"');const i=e.save(),s=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(s)?s:(o=e.offset-i.offset,e.restore(i),e.skip(o,'Failed to match body of: "'+t+'"'))},s.prototype._skipUntilEnd=function(e,t){for(;;){const r=a(e,t);if(e.isError(r))return r;const n=c(e,r.primitive,t);if(e.isError(n))return n;let o;if(o=r.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(o))return o;if("end"===r.tagStr)break}},s.prototype._decodeList=function(e,t,r,n){const o=[];for(;!e.isEmpty();){const t=this._peekTag(e,"end");if(e.isError(t))return t;const i=r.decode(e,"der",n);if(e.isError(i)&&t)break;o.push(i)}return o},s.prototype._decodeStr=function(e,t){if("bitstr"===t){const t=e.readUInt8();return e.isError(t)?t:{unused:t,data:e.raw()}}if("bmpstr"===t){const t=e.raw();if(t.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");let r="";for(let e=0;e<t.length/2;e++)r+=String.fromCharCode(t.readUInt16BE(2*e));return r}if("numstr"===t){const t=e.raw().toString("ascii");return this._isNumstr(t)?t:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){const t=e.raw().toString("ascii");return this._isPrintstr(t)?t:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},s.prototype._decodeObjid=function(e,t,r){let n;const o=[];let i=0,s=0;for(;!e.isEmpty();)s=e.readUInt8(),i<<=7,i|=127&s,128&s||(o.push(i),i=0);128&s&&o.push(i);const a=o[0]/40|0,c=o[0]%40;if(n=r?o:[a,c].concat(o.slice(1)),t){let e=t[n.join(" ")];void 0===e&&(e=t[n.join(".")]),void 0!==e&&(n=e)}return n},s.prototype._decodeTime=function(e,t){const r=e.raw().toString();let n,o,i,s,a,c;if("gentime"===t)n=0|r.slice(0,4),o=0|r.slice(4,6),i=0|r.slice(6,8),s=0|r.slice(8,10),a=0|r.slice(10,12),c=0|r.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");n=0|r.slice(0,2),o=0|r.slice(2,4),i=0|r.slice(4,6),s=0|r.slice(6,8),a=0|r.slice(8,10),c=0|r.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,o-1,i,s,a,c,0)},s.prototype._decodeNull=function(){return null},s.prototype._decodeBool=function(e){const t=e.readUInt8();return e.isError(t)?t:0!==t},s.prototype._decodeInt=function(e,r){const n=e.raw();let o=new t(n);return r&&(o=r[o.toString(10)]||o),o},s.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree},Q}function ae(){return ne||(ne=1,function(e){const t=e;t.der=se(),t.pem=function(){if(re)return te;re=1;const e=l(),t=I().Buffer,r=se();function n(e){r.call(this,e),this.enc="pem"}return e(n,r),te=n,n.prototype.decode=function(e,n){const o=e.toString().split(/[\r\n]+/g),i=n.label.toUpperCase(),s=/^-----(BEGIN|END) ([^-]+)-----$/;let a=-1,c=-1;for(let e=0;e<o.length;e++){const t=o[e].match(s);if(null!==t&&t[2]===i){if(-1!==a){if("END"!==t[1])break;c=e;break}if("BEGIN"!==t[1])break;a=e}}if(-1===a||-1===c)throw new Error("PEM section not found for: "+i);const u=o.slice(a+1,c).join("");u.replace(/[^a-z0-9+/=]+/gi,"");const l=t.from(u,"base64");return r.prototype.decode.call(this,l,n)},te}()}(ie)),ie}var ce,ue={};var le,fe,pe={};function he(){return fe||(fe=1,function(){const e=B;e.bignum=u(),e.define=(oe||(oe=1,function(e){const t=W(),r=ae(),n=l();function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}e.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(e){const t=this.name;function r(e){this._initNamed(e,t)}return n(r,e),r.prototype._initNamed=function(t,r){e.call(this,t,r)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(r[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(t[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}}(j)),j).define,e.base=(ce||(ce=1,function(e){const t=e;t.Reporter=N().Reporter,t.DecoderBuffer=V().DecoderBuffer,t.EncoderBuffer=V().EncoderBuffer,t.Node=L()}(ue)),ue),e.constants=(le||(le=1,function(e){const t=e;t._reverse=function(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t},t.der=H()}(pe)),pe),e.decoders=ae(),e.encoders=W()}()),B}var de,ye,be,we,ge,me,ve,ke,_e,Pe,Ee,Se,Ke,Ae,xe,Ce,Be,je,Ue,Ie,Te,qe,Ne,ze,Oe,Re,De,Ve,Le,Me,Je,$e,Fe,Ze,Ge,Ye={exports:{}},He={},Xe={};function We(){if(ye)return He;ye=1,Object.defineProperty(He,"__esModule",{value:!0});var e=(de||(de=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.default=function(e){var r=e.length,n=r%4;if(!n)return e;var o=r,i=4-n,s=r+i,a=t.alloc(s);for(a.write(e);i--;)a.write("=",o++);return a.toString()}),Xe);function r(e,r){return void 0===r&&(r="utf8"),o(e)?i(e.toString("base64")):i(t.from(e,r).toString("base64"))}function n(t){return t=t.toString(),e.default(t).replace(/\-/g,"+").replace(/_/g,"/")}function i(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var s=r;return s.encode=r,s.decode=function(e,r){return void 0===r&&(r="utf8"),t.from(n(e),"base64").toString(r)},s.toBase64=n,s.fromBase64=i,s.toBuffer=function(e){return t.from(n(e),"base64")},He.default=s,He}function Qe(){return be||(be=1,(e=Ye).exports=We().default,e.exports.default=e.exports),Ye.exports;var e}function et(){if(ge)return we;ge=1;const e=he(),r=Qe();return we=class{static convert(n,o,i){if(!n)return;if(o===i)return n;let s;if("raw"===o||n instanceof t)s=n;else if("uint8_array"===o||Array.isArray(n))s=t.from(n);else if("hex"===o)s=t.from(n,"hex");else if("base64"===o)s=t.from(n,"base64");else if("base64url"===o)s=r.toBuffer(n);else{if("bn"!==o&&"bignum"!==o)throw new Error("Invalid fromType");s=t.from(this.pad(n.toString(16)),"hex")}if("raw"===i)return s;if("uint8_array"===i)return Array.from(s);if("hex"===i)return s.toString("hex");if("base64"===i)return s.toString("base64");if("base64url"===i)return r.fromBase64(s.toString("base64"));if("bn"===i||"bignum"===i)return new e.bignum(s);throw new Error("Invalid toType")}static pad(e){return e.length%2==1?`0${e}`:e}},we}function tt(){if(Oe)return ze;Oe=1;const e=new(function(){if(ve)return me;ve=1;const e=he();return me=class{constructor(){Object.defineProperty(this,"_registry",{value:{}})}get registry(){return this._registry}define(t,r){this._registry[t]=e.define(t,r(this))}normalize(e){return this.registry[e]}}}());return e.define("Version",_e?ke:(_e=1,ke=e=>function(){this.int({0:"two-prime",1:"multi"})})),e.define("OtherPrimeInfos",Ee?Pe:(Ee=1,Pe=e=>function(){this.seq().obj(this.key("ri").int(),this.key("di").int(),this.key("ti").int())})),e.define("AlgorithmIdentifier",Ke?Se:(Ke=1,Se=e=>function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())})),e.define("PrivateKeyInfo",(xe||(xe=1,Ae=e=>{let t=e.normalize("Version"),r=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("version").use(t),this.key("algorithm").use(r),this.key("privateKey").octstr())}}),Ae)),e.define("PublicKeyInfo",(Be||(Be=1,Ce=e=>{let t=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("algorithm").use(t),this.key("publicKey").bitstr())}}),Ce)),e.define("RSAPrivateKey",(Ue||(Ue=1,je=e=>{let t=e.normalize("Version"),r=e.normalize("OtherPrimeInfos");return function(){this.seq().obj(this.key("version").use(t),this.key("n").int(),this.key("e").int(),this.key("d").int(),this.key("p").int(),this.key("q").int(),this.key("dp").int(),this.key("dq").int(),this.key("qi").int(),this.key("other").optional().use(r))}}),je)),e.define("RSAPublicKey",Te?Ie:(Te=1,Ie=e=>function(){this.seq().obj(this.key("n").int(),this.key("e").int())})),e.define("ECPrivateKey",Ne?qe:(Ne=1,qe=e=>function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).optional().choice({namedCurve:this.objid()}),this.key("publicKey").explicit(1).optional().bitstr())})),ze=e}function rt(){if(Fe)return $e;Fe=1;const e=g?w:(g=1,w=class{constructor(){this.registry=[],this.classes={}}find(e){return this.registry.find(e)}define(e,t){e.forEach((e=>{let{kty:r}=e;if(!r)throw new Error("Invalid type definition");this.classes[r]||(this.classes[r]=t),this.registry.push(e)}))}normalize(e,t,r){let n=this.classes[e],o=this.find((e=>e[t]===r));if(!n||!o)throw new Error("Invalid type");return new n(o)}}),r=function(){if(De)return Re;De=1;const e=A();S();const r=et(),n=tt();class o extends e{fromPrivatePKCS1(e){let t=n.normalize("RSAPrivateKey"),{n:o,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw"),d:r.convert(s,"bn","raw"),p:r.convert(a,"bn","raw"),q:r.convert(c,"bn","raw"),dp:r.convert(u,"bn","raw"),dq:r.convert(l,"bn","raw"),qi:r.convert(f,"bn","raw")}}fromPrivatePKCS8(e){let t=n.normalize("PrivateKeyInfo"),o=n.normalize("RSAPrivateKey"),i=t.decode(e,"der"),{n:s,e:a,d:c,p:u,q:l,dp:f,dq:p,qi:h}=o.decode(i.privateKey,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw"),d:r.convert(c,"bn","raw"),p:r.convert(u,"bn","raw"),q:r.convert(l,"bn","raw"),dp:r.convert(f,"bn","raw"),dq:r.convert(p,"bn","raw"),qi:r.convert(h,"bn","raw")}}fromPublicPKCS1(e){let t=n.normalize("RSAPublicKey"),{n:o,e:i}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw")}}fromPublicPKCS8(e){let t=n.normalize("PublicKeyInfo"),o=n.normalize("RSAPublicKey"),i=t.decode(e,"der"),{n:s,e:a}=o.decode(i.publicKey.data,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw")}}fromJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u,alg:l}=e;return{n:r.convert(t,"base64url","raw"),e:r.convert(n,"base64url","raw"),d:r.convert(o,"base64url","raw"),p:r.convert(i,"base64url","raw"),q:r.convert(s,"base64url","raw"),dp:r.convert(a,"base64url","raw"),dq:r.convert(c,"base64url","raw"),qi:r.convert(u,"base64url","raw")}}toPrivatePKCS1(e){let{n:t,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=e,{version:p}=this.params,h=n.normalize("RSAPrivateKey").encode({version:p,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn"),d:r.convert(s,"raw","bn"),p:r.convert(a,"raw","bn"),q:r.convert(c,"raw","bn"),dp:r.convert(u,"raw","bn"),dq:r.convert(l,"raw","bn"),qi:r.convert(f,"raw","bn")},"der").toString("base64");return o.formatPem(h,"RSA PRIVATE")}toPrivatePKCS8(e){let{n:i,e:s,d:a,p:c,q:u,dp:l,dq:f,qi:p}=e,{oid:h,algParameters:d,version:y}=this.params,b=n.normalize("PrivateKeyInfo"),w=n.normalize("RSAPrivateKey").encode({version:y,n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn"),d:r.convert(a,"raw","bn"),p:r.convert(c,"raw","bn"),q:r.convert(u,"raw","bn"),dp:r.convert(l,"raw","bn"),dq:r.convert(f,"raw","bn"),qi:r.convert(p,"raw","bn")},"der"),g=b.encode({version:y,algorithm:{algorithm:h.split("."),parameters:t.from(d,"hex")},privateKey:w},"der").toString("base64");return o.formatPem(g,"PRIVATE")}toPublicPKCS1(e){let{n:t,e:i}=e,{version:s}=this.params,a=n.normalize("RSAPublicKey").encode({version:s,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn")},"der").toString("base64");return o.formatPem(a,"RSA PUBLIC")}toPublicPKCS8(e){let{n:i,e:s}=e,{oid:a,algParameters:c}=this.params,u=n.normalize("PublicKeyInfo"),l=n.normalize("RSAPublicKey").encode({n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn")},"der"),f=u.encode({algorithm:{algorithm:a.split("."),parameters:t.from(c,"hex")},publicKey:{unused:0,data:l}},"der").toString("base64");return o.formatPem(f,"PUBLIC")}toPrivateJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u}=e,{kty:l}=this.params;return{kty:l,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url"),d:r.convert(o,"raw","base64url"),p:r.convert(i,"raw","base64url"),q:r.convert(s,"raw","base64url"),dp:r.convert(a,"raw","base64url"),dq:r.convert(c,"raw","base64url"),qi:r.convert(u,"raw","base64url")}}toPublicJwk(e){let{n:t,e:n}=e,{kty:o}=this.params;return{kty:o,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url")}}}return Re=o}(),n=function(){if(Le)return Ve;Le=1,he().bignum;const e=new(0,a().ec)("secp256k1"),r=A();S();const n=et(),o=tt();class i extends r{fromPrivatePKCS1(e){let t=o.normalize("ECPrivateKey").decode(e,"der"),{privateKey:r,publicKey:{data:s}}=t,a=n.convert(s,"raw","hex"),{x:c,y:u}=i.getPoint(a);return{d:r,x:c,y:u}}fromPrivatePKCS8(e){let t=o.normalize("PrivateKeyInfo"),r=o.normalize("ECPrivateKey"),s=t.decode(e,"der"),a=r.decode(s.privateKey,"der"),{privateKey:c,publicKey:{data:u}}=a,l=n.convert(u,"raw","hex"),{x:f,y:p}=i.getPoint(l);return{d:c,x:f,y:p}}fromPublicPKCS8(e){let t=o.normalize("PublicKeyInfo").decode(e,"der"),r=n.convert(t.publicKey.data,"raw","hex");return i.getPoint(r)}fromPrivateBlk(t){let r=e.keyFromPrivate(t,"hex"),o=r.getPublic();return{d:n.convert(r.priv,"bn","raw"),x:n.convert(o.getX(),"bn","raw"),y:n.convert(o.getY(),"bn","raw")}}fromPublicBlk(e){return i.getPoint(e)}fromJwk(e){let{d:t,x:r,y:o}=e;return{d:n.convert(t,"base64url","raw"),x:n.convert(r,"base64url","raw"),y:n.convert(o,"base64url","raw")}}toPrivatePKCS1(e){let{namedCurve:t,keyVersion:r}=this.params,{d:n,x:s,y:a}=e,c=o.normalize("ECPrivateKey"),u=i.makePoint(s,a),l=c.encode({version:r,privateKey:n,parameters:{type:"namedCurve",value:t.split(".")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"EC PRIVATE")}toPrivatePKCS8(e){let{oid:r,algParameters:n,keyVersion:s,infoVersion:a}=this.params,{d:c,x:u,y:l}=e,f=o.normalize("PrivateKeyInfo"),p=o.normalize("ECPrivateKey"),h=i.makePoint(u,l),d=p.encode({version:s,privateKey:c,publicKey:{unused:0,data:h}},"der"),y=f.encode({version:a,algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},privateKey:d},"der").toString("base64");return i.formatPem(y,"PRIVATE")}toPublicPKCS8(e){let{oid:r,algParameters:n}=this.params,{x:s,y:a}=e,c=o.normalize("PublicKeyInfo"),u=i.makePoint(s,a),l=c.encode({algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"PUBLIC")}toPrivateBlk(e){return e.d.toString("hex")}toPublicBlk(e){return n.convert(i.makePoint(e.x,e.y),"raw","hex")}toPrivateJwk(e){let{crv:t,kty:r}=this.params,{d:o,x:i,y:s}=e;return{kty:r,crv:t,d:n.convert(o,"raw","base64url"),x:n.convert(i,"raw","base64url"),y:n.convert(s,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:r}=this.params,{x:o,y:i}=e;return{kty:r,crv:t,x:n.convert(o,"raw","base64url"),y:n.convert(i,"raw","base64url")}}static getPoint(e){let t=e.slice(2,(e.length-2)/2+2),r=e.slice((e.length-2)/2+2);return{x:n.convert(t,"hex","raw"),y:n.convert(r,"hex","raw")}}static makePoint(e,r){let n=t.from("04","hex");return t.concat([n,e,r],n.length+e.length+r.length)}}return Ve=i}(),o=function(){if(Je)return Me;Je=1;const e=A(),r=et(),n=tt();class o extends e{fromPrivatePKCS8(e){const t=n.normalize("PrivateKeyInfo").decode(e,"der").privateKey.slice(2);return{d:t,x:this.publicKeyFromPrivate(t)}}fromPublicPKCS8(e){const t=n.normalize("PublicKeyInfo").decode(e,"der");return{x:r.convert(t.publicKey.data,"hex","raw")}}fromJwk(e){let{d:t,x:n}=e;return{d:r.convert(t,"base64url","raw"),x:r.convert(n,"base64url","raw")}}toPrivatePKCS8(e){let{oid:t,infoVersion:r}=this.params,{d:i}=e;const s=n.normalize("PrivateKeyInfo"),a=this.privateKeyPadding(i);let c=s.encode({version:r,algorithm:{algorithm:t.split(".")},privateKey:a},"der").toString("base64");return o.formatPem(c,"PRIVATE")}toPublicPKCS8(e){let{oid:t}=this.params,{x:i}=e,s=n.normalize("PublicKeyInfo").encode({algorithm:{algorithm:t.split(".")},publicKey:{unused:0,data:r.convert(i,"hex","raw")}},"der").toString("base64");return o.formatPem(s,"PUBLIC")}toPrivateJwk(e){let{crv:t,kty:n}=this.params,{d:o,x:i}=e;return{kty:n,crv:t,d:r.convert(o,"raw","base64url"),x:r.convert(i,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:n}=this.params,{x:o}=e;return{kty:n,crv:t,x:r.convert(o,"raw","base64url")}}privateKeyPadding(e){let r;if("Ed25519"!==this.params.crv)throw new Error(`${this.params.crv} is an invalid curve for EdDSA`);return r=t.from("0420","hex"),t.concat([r,e],r.length+e.length)}publicKeyFromPrivate(e){if("Ed25519"===this.params.crv){const r=new(0,a().eddsa)("ed25519");return t.from(r.keyFromSecret(e).getPublic())}throw new Error(`${this.params.crv} is an invalid curve for EdDSA`)}}return Me=o}(),i=new e;return i.define([{kty:"RSA",oid:"1.2.840.113549.1.1.1",algParameters:"0500",version:"two-prime"}],r),i.define([{kty:"EC",crv:"K-256",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.10",algParameters:"06052b8104000a",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-256",oid:"1.2.840.10045.2.1",namedCurve:"1.2.840.10045.3.1.7",algParameters:"06082a8648ce3d030107",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-384",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.34",algParameters:"06052b81040022",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-521",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.35",algParameters:"06052b81040023",keyVersion:1,infoVersion:"two-prime"}],n),i.define([{kty:"OKP",crv:"Ed25519",oid:"1.3.101.112",infoVersion:"two-prime"}],o),$e=i}var nt,ot,it,st,at,ct,ut=function(){if(Ge)return Ze;Ge=1;const e=S(),r=K(),n=rt(),o=tt(),i=RegExp("\r?\n","g");class s{constructor(t,r){if(!t)throw new e("key is required");if(!r)throw new e("options are required");let{kty:n,format:o,selector:i,crv:s,oid:a}=r;if(!r.kty)throw new e("options.kty is required");if(!r.format)throw new e("options.format is required");if(!r.selector)throw new e("options.selector is required");if(!r.crv&&!r.oid)throw new e("options.crv or options.oid is required");this.kty=n,this.format=o,this.selector=i,this.crv=s,this.oid=a,this.key=this.parseKey(t)}static from(r,a){if(!r)throw new e("key is required");if(!a)throw new e("format is required");if("jwk"===a){let t;if("string"==typeof r)try{t=JSON.parse(r)}catch(t){throw new e("key is not a valid JWK")}else"object"==typeof r&&(t=r);let o,{kty:i,crv:c}=t;if(!i)throw new e("kty is required for JWK");if("EC"===i&&!c)throw new e("crv is required for EC JWK");"RSA"===i&&(o=n.find((e=>e.kty===i)).oid);let u=t.d?"private":"public";return new s(t,{kty:i,crv:c,oid:o,format:a,selector:u})}if("pem"===a){if("string"!=typeof r)throw new e("key is not a valid PEM string");let c=r.split(i),u=c.splice(0,1);c.splice(c.length-1,1);let l,f,p=c.join(""),h=/^-----BEGIN ((RSA|EC) )?(PUBLIC|PRIVATE) KEY-----$/.exec(u),d=h?h[2]:void 0,y=h?h[3]:void 0,b=t.from(p,"base64");if(!y)throw new e("key is not a valid PEM string");if(d){if("RSA"===d)y="PRIVATE"===y?"private_pkcs1":"public_pkcs1",l=n.find((e=>e.kty===d)).oid;else if("EC"===d){let e;if("PRIVATE"===y){y="private_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}else if("PUBLIC"===y){y="public_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}let{parameters:{value:t}}=e;f=n.find((e=>e.namedCurve===t.join("."))).crv}}else{let t,r=o.normalize("PrivateKeyInfo"),i=o.normalize("PublicKeyInfo");"PRIVATE"===y?(y="private_pkcs8",t=r.decode(b,"der")):"PUBLIC"===y&&(y="public_pkcs8",t=i.decode(b,"der"));let{algorithm:{algorithm:s,parameters:a}}=t;s=s.join("."),a=a?a.toString("hex"):void 0;const c=n.find((e=>e.oid===s));if(d=c?c.kty:void 0,!d)throw new e(`${s} is not supported`);"RSA"===d||"OKP"===d?l=s:"EC"===d&&(f=n.find((e=>e.algParameters===a)).crv)}return new s(b,{kty:d,oid:l,crv:f,format:a,selector:y})}if("blk"===a)return new s(r,{kty:"EC",crv:"K-256",format:a,selector:r.length>64?"public":"private"});throw new e(`Invalid format ${a}`)}get alg(){let{kty:e,crv:t,oid:r}=this;if(!this.algorithm){if(t)Object.defineProperty(this,"algorithm",{value:n.normalize(e,"crv",t)});else{if(!r)throw new Error("Both crv and oid are undefined");Object.defineProperty(this,"algorithm",{value:n.normalize(e,"oid",r)})}if(!this.algorithm)throw new Error(`${this.crv||this.oid} is not implemented yet`)}return this.algorithm}parseKey(e){let{alg:t,format:r,selector:n}=this;if("pem"===r)switch(n){case"public_pkcs1":return t.fromPublicPKCS1(e);case"public_pkcs8":return t.fromPublicPKCS8(e);case"private_pkcs1":return t.fromPrivatePKCS1(e);case"private_pkcs8":return t.fromPrivatePKCS8(e);default:throw new Error("Invalid selector value")}if("jwk"===r)return t.fromJwk(e,n);if("blk"===r)switch(n){case"public":return t.fromPublicBlk(e);case"private":return t.fromPrivateBlk(e)}}toJwk(t){let{key:r,alg:n,selector:o}=this;switch(t){case"public":return n.toPublicJwk(r);case"private":if(o.includes("public"))throw new e("Cannot export a private key from a public key");return n.toPrivateJwk(r);default:throw new Error("Invalid key selector")}}toString(t="pem",n="public_pkcs8"){let{key:o,alg:i,selector:s}=this;if("pem"===t)switch(n){case"public_pkcs1":return i.toPublicPKCS1(o);case"public_pkcs8":return i.toPublicPKCS8(o);case"private_pkcs1":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS1(o);case"private_pkcs8":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS8(o);default:throw new Error("Invalid key selector")}else if("jwk"===t)switch(n){case"public":return JSON.stringify(i.toPublicJwk(o));case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return JSON.stringify(i.toPrivateJwk(o));default:throw new Error("Invalid key selector")}else if("blk"===t)switch(n){case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivateBlk(o);case"public":return i.toPublicBlk(o);default:throw new Error("Invalid key selector")}throw new r}}return Ze=s}(),lt=e(ut),ft=e(Qe());function pt(){if(st)return it;st=1;const e=new(0,a().ec)("secp256k1"),t=e.curve,r=t.n.constructor;function n(n){const o=n[0];switch(o){case 2:case 3:return 33!==n.length?null:function(n,o){let i=new r(o);if(i.cmp(t.p)>=0)return null;i=i.toRed(t.red);let s=i.redSqr().redIMul(i).redIAdd(t.b).redSqrt();return 3===n!==s.isOdd()&&(s=s.redNeg()),e.keyPair({pub:{x:i,y:s}})}(o,n.subarray(1,33));case 4:case 6:case 7:return 65!==n.length?null:function(n,o,i){let s=new r(o),a=new r(i);if(s.cmp(t.p)>=0||a.cmp(t.p)>=0)return null;if(s=s.toRed(t.red),a=a.toRed(t.red),(6===n||7===n)&&a.isOdd()!==(7===n))return null;const c=s.redSqr().redIMul(s);return a.redSqr().redISub(c.redIAdd(t.b)).isZero()?e.keyPair({pub:{x:s,y:a}}):null}(o,n.subarray(1,33),n.subarray(33,65));default:return null}}function o(e,t){const r=t.encode(null,33===e.length);for(let t=0;t<e.length;++t)e[t]=r[t]}return it={contextRandomize:()=>0,privateKeyVerify(e){const n=new r(e);return n.cmp(t.n)<0&&!n.isZero()?0:1},privateKeyNegate(e){const n=new r(e),o=t.n.sub(n).umod(t.n).toArrayLike(Uint8Array,"be",32);return e.set(o),0},privateKeyTweakAdd(e,n){const o=new r(n);if(o.cmp(t.n)>=0)return 1;if(o.iadd(new r(e)),o.cmp(t.n)>=0&&o.isub(t.n),o.isZero())return 1;const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},privateKeyTweakMul(e,n){let o=new r(n);if(o.cmp(t.n)>=0||o.isZero())return 1;o.imul(new r(e)),o.cmp(t.n)>=0&&(o=o.umod(t.n));const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},publicKeyVerify:e=>null===n(e)?1:0,publicKeyCreate(n,i){const s=new r(i);if(s.cmp(t.n)>=0||s.isZero())return 1;return o(n,e.keyFromPrivate(i).getPublic()),0},publicKeyConvert(e,t){const r=n(t);if(null===r)return 1;return o(e,r.getPublic()),0},publicKeyNegate(e,t){const r=n(t);if(null===r)return 1;const i=r.getPublic();return i.y=i.y.redNeg(),o(e,i),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e<t.length;++e)if(r[e]=n(t[e]),null===r[e])return 1;let i=r[0].getPublic();for(let e=1;e<r.length;++e)i=i.add(r[e].pub);return i.isInfinity()?2:(o(e,i),0)},publicKeyTweakAdd(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0)return 2;const c=a.getPublic().add(t.g.mul(s));return c.isInfinity()?2:(o(e,c),0)},publicKeyTweakMul(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0||s.isZero())return 2;return o(e,a.getPublic().mul(s)),0},signatureNormalize(n){const o=new r(n.subarray(0,32)),i=new r(n.subarray(32,64));return o.cmp(t.n)>=0||i.cmp(t.n)>=0?1:(1===i.cmp(e.nh)&&n.set(t.n.sub(i).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,n){const o=n.subarray(0,32),i=n.subarray(32,64);if(new r(o).cmp(t.n)>=0)return 1;if(new r(i).cmp(t.n)>=0)return 1;const{output:s}=e;let a=s.subarray(4,37);a[0]=0,a.set(o,1);let c=33,u=0;for(;c>1&&0===a[u]&&!(128&a[u+1]);--c,++u);if(a=a.subarray(u),128&a[0])return 1;if(c>1&&0===a[0]&&!(128&a[1]))return 1;let l=s.subarray(39,72);l[0]=0,l.set(i,1);let f=33,p=0;for(;f>1&&0===l[p]&&!(128&l[p+1]);--f,++p);return l=l.subarray(p),128&l[0]||f>1&&0===l[0]&&!(128&l[1])?1:(e.outputlen=6+c+f,s[0]=48,s[1]=e.outputlen-2,s[2]=2,s[3]=a.length,s.set(a,4),s[4+c]=2,s[5+c]=l.length,s.set(l,6+c),0)},signatureImport(e,n){if(n.length<8)return 1;if(n.length>72)return 1;if(48!==n[0])return 1;if(n[1]!==n.length-2)return 1;if(2!==n[2])return 1;const o=n[3];if(0===o)return 1;if(5+o>=n.length)return 1;if(2!==n[4+o])return 1;const i=n[5+o];if(0===i)return 1;if(6+o+i!==n.length)return 1;if(128&n[4])return 1;if(o>1&&0===n[4]&&!(128&n[5]))return 1;if(128&n[o+6])return 1;if(i>1&&0===n[o+6]&&!(128&n[o+7]))return 1;let s=n.subarray(4,4+o);if(33===s.length&&0===s[0]&&(s=s.subarray(1)),s.length>32)return 1;let a=n.subarray(6+o);if(33===a.length&&0===a[0]&&(a=a.slice(1)),a.length>32)throw new Error("S length is too long");let c=new r(s);c.cmp(t.n)>=0&&(c=new r(0));let u=new r(n.subarray(6+o));return u.cmp(t.n)>=0&&(u=new r(0)),e.set(c.toArrayLike(Uint8Array,"be",32),0),e.set(u.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(n,o,i,s,a){if(a){const e=a;a=t=>{const n=e(o,i,null,s,t);if(!(n instanceof Uint8Array&&32===n.length))throw new Error("This is the way");return new r(n)}}const c=new r(i);if(c.cmp(t.n)>=0||c.isZero())return 1;let u;try{u=e.sign(o,i,{canonical:!0,k:a,pers:s})}catch(e){return 1}return n.signature.set(u.r.toArrayLike(Uint8Array,"be",32),0),n.signature.set(u.s.toArrayLike(Uint8Array,"be",32),32),n.recid=u.recoveryParam,0},ecdsaVerify(o,i,s){const a={r:o.subarray(0,32),s:o.subarray(32,64)},c=new r(a.r),u=new r(a.s);if(c.cmp(t.n)>=0||u.cmp(t.n)>=0)return 1;if(1===u.cmp(e.nh)||c.isZero()||u.isZero())return 3;const l=n(s);if(null===l)return 2;const f=l.getPublic();return e.verify(i,a,f)?0:3},ecdsaRecover(n,i,s,a){const c={r:i.slice(0,32),s:i.slice(32,64)},u=new r(c.r),l=new r(c.s);if(u.cmp(t.n)>=0||l.cmp(t.n)>=0)return 1;if(u.isZero()||l.isZero())return 2;let f;try{f=e.recoverPubKey(a,c,s)}catch(e){return 2}return o(n,f),0},ecdh(o,i,s,a,c,u,l){const f=n(i);if(null===f)return 1;const p=new r(s);if(p.cmp(t.n)>=0||p.isZero())return 2;const h=f.getPublic().mul(p);if(void 0===c){const t=h.encode(null,!0),r=e.hash().update(t).digest();for(let e=0;e<32;++e)o[e]=r[e]}else{u||(u=new Uint8Array(32));const e=h.getX().toArray("be",32);for(let t=0;t<32;++t)u[t]=e[t];l||(l=new Uint8Array(32));const t=h.getY().toArray("be",32);for(let e=0;e<32;++e)l[e]=t[e];const r=c(u,l,a);if(!(r instanceof Uint8Array&&r.length===o.length))return 2;o.set(r)}return 0}}}var ht,dt,yt,bt,wt=(ct||(ct=1,at=function(){if(ot)return nt;ot=1;const e="Impossible case. Please create issue.",t="The tweak was out of range or the resulted private key is invalid",r="The tweak was out of range or equal to zero",n="Unknow error on context randomization",o="Private Key is invalid",i="Public Key could not be parsed",s="Public Key serialization error",a="The sum of the public keys is not valid",c="Signature could not be parsed",u="The nonce generation function failed, or the private key was invalid",l="Public key could not be recover",f="Scalar was invalid (zero or overflow)";function p(e,t){if(!e)throw new Error(t)}function h(e,t,r){if(p(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const n=`Expected ${e} to be an Uint8Array with length [${r.join(", ")}]`;p(r.includes(t.length),n)}else{const n=`Expected ${e} to be an Uint8Array with length ${r}`;p(t.length===r,n)}}function d(e){p("Boolean"===b(e),"Expected compressed to be a Boolean")}function y(e=e=>new Uint8Array(e),t){return"function"==typeof e&&(e=e(t)),h("output",e,t),e}function b(e){return Object.prototype.toString.call(e).slice(8,-1)}return nt=w=>({contextRandomize(e){if(p(null===e||e instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==e&&h("seed",e,32),1===w.contextRandomize(e))throw new Error(n)},privateKeyVerify:e=>(h("private key",e,32),0===w.privateKeyVerify(e)),privateKeyNegate(t){switch(h("private key",t,32),w.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(e)}},privateKeyTweakAdd(e,r){switch(h("private key",e,32),h("tweak",r,32),w.privateKeyTweakAdd(e,r)){case 0:return e;case 1:throw new Error(t)}},privateKeyTweakMul(e,t){switch(h("private key",e,32),h("tweak",t,32),w.privateKeyTweakMul(e,t)){case 0:return e;case 1:throw new Error(r)}},publicKeyVerify:e=>(h("public key",e,[33,65]),0===w.publicKeyVerify(e)),publicKeyCreate(e,t=!0,r){switch(h("private key",e,32),d(t),r=y(r,t?33:65),w.publicKeyCreate(r,e)){case 0:return r;case 1:throw new Error(o);case 2:throw new Error(s)}},publicKeyConvert(e,t=!0,r){switch(h("public key",e,[33,65]),d(t),r=y(r,t?33:65),w.publicKeyConvert(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(s)}},publicKeyNegate(t,r=!0,n){switch(h("public key",t,[33,65]),d(r),n=y(n,r?33:65),w.publicKeyNegate(n,t)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(e);case 3:throw new Error(s)}},publicKeyCombine(e,t=!0,r){p(Array.isArray(e),"Expected public keys to be an Array"),p(e.length>0,"Expected public keys array will have more than zero items");for(const t of e)h("public key",t,[33,65]);switch(d(t),r=y(r,t?33:65),w.publicKeyCombine(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(a);case 3:throw new Error(s)}},publicKeyTweakAdd(e,r,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",r,32),d(n),o=y(o,n?33:65),w.publicKeyTweakAdd(o,e,r)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(t)}},publicKeyTweakMul(e,t,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",t,32),d(n),o=y(o,n?33:65),w.publicKeyTweakMul(o,e,t)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(r)}},signatureNormalize(e){switch(h("signature",e,64),w.signatureNormalize(e)){case 0:return e;case 1:throw new Error(c)}},signatureExport(t,r){h("signature",t,64);const n={output:r=y(r,72),outputlen:72};switch(w.signatureExport(n,t)){case 0:return r.slice(0,n.outputlen);case 1:throw new Error(c);case 2:throw new Error(e)}},signatureImport(t,r){switch(h("signature",t),r=y(r,64),w.signatureImport(r,t)){case 0:return r;case 1:throw new Error(c);case 2:throw new Error(e)}},ecdsaSign(t,r,n={},o){h("message",t,32),h("private key",r,32),p("Object"===b(n),"Expected options to be an Object"),void 0!==n.data&&h("options.data",n.data),void 0!==n.noncefn&&p("Function"===b(n.noncefn),"Expected options.noncefn to be a Function");const i={signature:o=y(o,64),recid:null};switch(w.ecdsaSign(i,t,r,n.data,n.noncefn)){case 0:return i;case 1:throw new Error(u);case 2:throw new Error(e)}},ecdsaVerify(e,t,r){switch(h("signature",e,64),h("message",t,32),h("public key",r,[33,65]),w.ecdsaVerify(e,t,r)){case 0:return!0;case 3:return!1;case 1:throw new Error(c);case 2:throw new Error(i)}},ecdsaRecover(t,r,n,o=!0,i){switch(h("signature",t,64),p("Number"===b(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),h("message",n,32),d(o),i=y(i,o?33:65),w.ecdsaRecover(i,t,r,n)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(l);case 3:throw new Error(e)}},ecdh(e,t,r={},n){switch(h("public key",e,[33,65]),h("private key",t,32),p("Object"===b(r),"Expected options to be an Object"),void 0!==r.data&&h("options.data",r.data),void 0!==r.hashfn?(p("Function"===b(r.hashfn),"Expected options.hashfn to be a Function"),void 0!==r.xbuf&&h("options.xbuf",r.xbuf,32),void 0!==r.ybuf&&h("options.ybuf",r.ybuf,32),h("output",n)):n=y(n,32),w.ecdh(n,e,t,r.data,r.hashfn,r.xbuf,r.ybuf)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(f)}}}),nt}()(pt())),at),gt=e(wt);function mt(){if(bt)return yt;bt=1;const e=(dt||(dt=1,ht=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var o=e.charAt(n),i=o.charCodeAt(0);if(255!==t[i])throw new TypeError(o+" is ambiguous");t[i]=n}var s=e.length,a=e.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,n=0,o=0;e[r]===a;)n++,r++;for(var i=(e.length-r)*c+1>>>0,u=new Uint8Array(i);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var f=0,p=i-1;(0!==l||f<o)&&-1!==p;p--,f++)l+=s*u[p]>>>0,u[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=f,r++}for(var h=i-o;h!==i&&0===u[h];)h++;for(var d=new Uint8Array(n+(i-h)),y=n;h!==i;)d[y++]=u[h++];return d}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var c=(i-o)*u+1>>>0,l=new Uint8Array(c);o!==i;){for(var f=t[o],p=0,h=c-1;(0!==f||p<n)&&-1!==h;h--,p++)f+=256*l[h]>>>0,l[h]=f%s>>>0,f=f/s>>>0;if(0!==f)throw new Error("Non-zero carry");n=p,o++}for(var d=c-n;d!==c&&0===l[d];)d++;for(var y=a.repeat(r);d<c;++d)y+=e.charAt(l[d]);return y},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}),ht);return yt=e("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}export{mt as a,_ as b,k as c,ft as d,wt as e,lt as k,E as r,gt as s};
|
|
1
|
+
import{g as e,B as t,u as r,x as n,i as o,y as i,p as s}from"./main.js";import{r as a,a as c,c as u,b as l,d as f}from"./elliptic-e2d4_kYF-DQmYEk-8.js";var p,h,d,y,b,w,g,m,v,k=r(n),_=r(i),P={exports:{}};function E(){return p||(p=1,function(e,t){var r=c,n=r.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function i(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=i),i.prototype=Object.create(n.prototype),o(n,i),i.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},i.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=n(e);return void 0!==t?"string"==typeof r?o.fill(t,r):o.fill(t):o.fill(0),o},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}}(P,P.exports)),P.exports}function S(){if(d)return h;d=1;class e extends Error{constructor(e){super(e||"This operation is not supported for this key type")}}return h=e}function K(){if(b)return y;b=1;class e extends Error{constructor(){super("This has not been implemented yet")}}return y=e}function A(){if(v)return m;v=1;const e=K();return m=class{constructor(e){this.params=e}fromPrivatePKCS1(t){throw new e}fromPrivatePKCS8(t){throw new e}fromPublicPKCS1(t){throw new e}fromPublicPKCS8(t){throw new e}fromPrivateBlk(t){throw new e}fromPublicBlk(t){throw new e}fromJwk(t){throw new e}toPrivatePKCS1(t){throw new e}toPrivatePKCS8(t){throw new e}toPublicPKCS1(t){throw new e}toPublicPKCS8(t){throw new e}toPrivateBlk(t){throw new e}toPublicBlk(t){throw new e}toPrivateJwk(t){throw new e}toPublicJwk(t){throw new e}static formatPem(e,t){return`-----BEGIN ${t} KEY-----\n`+e.match(/.{1,64}/g).join("\n")+`\n-----END ${t} KEY-----`}}}var x,C,B={},j={},U={};function I(){if(C)return x;C=1;var e,t=c,r=t.Buffer,n={};for(e in t)t.hasOwnProperty(e)&&"SlowBuffer"!==e&&"Buffer"!==e&&(n[e]=t[e]);var o=n.Buffer={};for(e in r)r.hasOwnProperty(e)&&"allocUnsafe"!==e&&"allocUnsafeSlow"!==e&&(o[e]=r[e]);if(n.Buffer.prototype=r.prototype,o.from&&o.from!==Uint8Array.from||(o.from=function(e,t,n){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return r(e,t,n)}),o.alloc||(o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var o=r(e);return t&&0!==t.length?"string"==typeof n?o.fill(t,n):o.fill(t):o.fill(0),o}),!n.kStringMaxLength)try{n.kStringMaxLength=s.binding("buffer").kStringMaxLength}catch(e){}return n.constants||(n.constants={MAX_LENGTH:n.kMaxLength},n.kStringMaxLength&&(n.constants.MAX_STRING_LENGTH=n.kStringMaxLength)),x=n}var T,q={};function N(){if(T)return q;T=1;const e=l();function t(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function r(e,t){this.path=e,this.rethrow(t)}return q.Reporter=t,t.prototype.isError=function(e){return e instanceof r},t.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},t.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},t.prototype.enterKey=function(e){return this._reporterState.path.push(e)},t.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},t.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},t.prototype.path=function(){return this._reporterState.path.join("/")},t.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},t.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},t.prototype.error=function(e){let t;const n=this._reporterState,o=e instanceof r;if(t=o?e:new r(n.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!n.options.partial)throw t;return o||n.errors.push(t),t},t.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},e(r,Error),r.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,r),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this},q}var z,O,R,D={};function V(){if(z)return D;z=1;const e=l(),t=N().Reporter,r=I().Buffer;function n(e,n){t.call(this,n),r.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function o(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return o.isEncoderBuffer(e)||(e=new o(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=r.byteLength(e);else{if(!r.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}return e(n,t),D.DecoderBuffer=n,n.isDecoderBuffer=function(e){if(e instanceof n)return!0;return"object"==typeof e&&r.isBuffer(e.base)&&"DecoderBuffer"===e.constructor.name&&"number"==typeof e.offset&&"number"==typeof e.length&&"function"==typeof e.save&&"function"==typeof e.restore&&"function"==typeof e.isEmpty&&"function"==typeof e.readUInt8&&"function"==typeof e.skip&&"function"==typeof e.raw},n.prototype.save=function(){return{offset:this.offset,reporter:t.prototype.save.call(this)}},n.prototype.restore=function(e){const r=new n(this.base);return r.offset=e.offset,r.length=this.offset,this.offset=e.offset,t.prototype.restore.call(this,e.reporter),r},n.prototype.isEmpty=function(){return this.offset===this.length},n.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},n.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");const r=new n(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},n.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},D.EncoderBuffer=o,o.isEncoderBuffer=function(e){if(e instanceof o)return!0;return"object"==typeof e&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},o.prototype.join=function(e,t){return e||(e=r.alloc(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(e,t),t+=r.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):r.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e},D}function L(){if(R)return O;R=1;const e=N().Reporter,t=V().EncoderBuffer,r=V().DecoderBuffer,n=f(),o=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],i=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(o);function s(e,t,r){const n={};this._baseState=n,n.name=r,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}O=s;const a=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];return s.prototype.clone=function(){const e=this._baseState,t={};a.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},s.prototype._wrap=function(){const e=this._baseState;i.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},s.prototype._init=function(e){const t=this._baseState;n(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),n.equal(t.children.length,1,"Root node can have only one child")},s.prototype._useArgs=function(e){const t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(n(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(n(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);const n=e[r];t[n]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){s.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),o.forEach((function(e){s.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return n(null===t.tag),t.tag=e,this._useArgs(r),this}})),s.prototype.use=function(e){n(e);const t=this._baseState;return n(null===t.use),t.use=e,this},s.prototype.optional=function(){return this._baseState.optional=!0,this},s.prototype.def=function(e){const t=this._baseState;return n(null===t.default),t.default=e,t.optional=!0,this},s.prototype.explicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.explicit=e,this},s.prototype.implicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.implicit=e,this},s.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},s.prototype.key=function(e){const t=this._baseState;return n(null===t.key),t.key=e,this},s.prototype.any=function(){return this._baseState.any=!0,this},s.prototype.choice=function(e){const t=this._baseState;return n(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},s.prototype.contains=function(e){const t=this._baseState;return n(null===t.use),t.contains=e,this},s.prototype._decode=function(e,t){const n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));let o,i=n.default,s=!0,a=null;if(null!==n.key&&(a=e.enterKey(n.key)),n.optional){let r=null;if(null!==n.explicit?r=n.explicit:null!==n.implicit?r=n.implicit:null!==n.tag&&(r=n.tag),null!==r||n.any){if(s=this._peekTag(e,r,n.any),e.isError(s))return s}else{const r=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),s=!0}catch(e){s=!1}e.restore(r)}}if(n.obj&&s&&(o=e.enterObject()),s){if(null!==n.explicit){const t=this._decodeTag(e,n.explicit);if(e.isError(t))return t;e=t}const o=e.offset;if(null===n.use&&null===n.choice){let t;n.any&&(t=e.save());const r=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(r))return r;n.any?i=e.raw(t):e=r}if(t&&t.track&&null!==n.tag&&t.track(e.path(),o,e.length,"tagged"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,"content"),n.any||(i=null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(n.any||null!==n.choice||null===n.children||n.children.forEach((function(r){r._decode(e,t)})),n.contains&&("octstr"===n.tag||"bitstr"===n.tag)){const o=new r(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(o,t)}}return n.obj&&s&&(i=e.leaveObject(o)),null===n.key||null===i&&!0!==s?null!==a&&e.exitKey(a):e.leaveKey(a,n.key,i),i},s.prototype._decodeGeneric=function(e,t,r){const n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},s.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),n(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},s.prototype._decodeChoice=function(e,t){const r=this._baseState;let n=null,o=!1;return Object.keys(r.choice).some((function(i){const s=e.save(),a=r.choice[i];try{const r=a._decode(e,t);if(e.isError(r))return!1;n={type:i,value:r},o=!0}catch(t){return e.restore(s),!1}return!0}),this),o?n:e.error("Choice not matched")},s.prototype._createEncoderBuffer=function(e){return new t(e,this.reporter)},s.prototype._encode=function(e,t,r){const n=this._baseState;if(null!==n.default&&n.default===e)return;const o=this._encodeValue(e,t,r);return void 0===o||this._skipDefault(o,t,r)?void 0:o},s.prototype._encodeValue=function(t,r,n){const o=this._baseState;if(null===o.parent)return o.children[0]._encode(t,r||new e);let i=null;if(this.reporter=r,o.optional&&void 0===t){if(null===o.default)return;t=o.default}let s=null,a=!1;if(o.any)i=this._createEncoderBuffer(t);else if(o.choice)i=this._encodeChoice(t,r);else if(o.contains)s=this._getUse(o.contains,n)._encode(t,r),a=!0;else if(o.children)s=o.children.map((function(e){if("null_"===e._baseState.tag)return e._encode(null,r,t);if(null===e._baseState.key)return r.error("Child should have a key");const n=r.enterKey(e._baseState.key);if("object"!=typeof t)return r.error("Child expected, but input is not object");const o=e._encode(t[e._baseState.key],r,t);return r.leaveKey(n),o}),this).filter((function(e){return e})),s=this._createEncoderBuffer(s);else if("seqof"===o.tag||"setof"===o.tag){if(!o.args||1!==o.args.length)return r.error("Too many args for : "+o.tag);if(!Array.isArray(t))return r.error("seqof/setof, but data is not Array");const e=this.clone();e._baseState.implicit=null,s=this._createEncoderBuffer(t.map((function(e){const n=this._baseState;return this._getUse(n.args[0],t)._encode(e,r)}),e))}else null!==o.use?i=this._getUse(o.use,n)._encode(t,r):(s=this._encodePrimitive(o.tag,t),a=!0);if(!o.any&&null===o.choice){const e=null!==o.implicit?o.implicit:o.tag,t=null===o.implicit?"universal":"context";null===e?null===o.use&&r.error("Tag could be omitted only for .use()"):null===o.use&&(i=this._encodeComposite(e,a,t,s))}return null!==o.explicit&&(i=this._encodeComposite(o.explicit,!1,"context",i)),i},s.prototype._encodeChoice=function(e,t){const r=this._baseState,o=r.choice[e.type];return o||n(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),o._encode(e.value,t)},s.prototype._encodePrimitive=function(e,t){const r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},s.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},s.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)},O}var M,J,$,F,Z,G,Y={};function H(){return M||(M=1,function(e){function t(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t}e.tagClass={0:"universal",1:"application",2:"context",3:"private"},e.tagClassByName=t(e.tagClass),e.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},e.tagByName=t(e.tag)}(Y)),Y}function X(){if($)return J;$=1;const e=l(),t=I().Buffer,r=L(),n=H();function o(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new i,this.tree._init(e.body)}function i(e){r.call(this,"der",e)}function s(e){return e<10?"0"+e:e}return J=o,o.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},e(i,r),i.prototype._encodeComposite=function(e,r,o,i){const s=function(e,t,r,o){let i;"seqof"===e?e="seq":"setof"===e&&(e="set");if(n.tagByName.hasOwnProperty(e))i=n.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return o.error("Unknown tag: "+e);i=e}if(i>=31)return o.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=n.tagClassByName[r||"universal"]<<6,i}(e,r,o,this.reporter);if(i.length<128){const e=t.alloc(2);return e[0]=s,e[1]=i.length,this._createEncoderBuffer([e,i])}let a=1;for(let e=i.length;e>=256;e>>=8)a++;const c=t.alloc(2+a);c[0]=s,c[1]=128|a;for(let e=1+a,t=i.length;t>0;e--,t>>=8)c[e]=255&t;return this._createEncoderBuffer([c,i])},i.prototype._encodeStr=function(e,r){if("bitstr"===r)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===r){const r=t.alloc(2*e.length);for(let t=0;t<e.length;t++)r.writeUInt16BE(e.charCodeAt(t),2*t);return this._createEncoderBuffer(r)}return"numstr"===r?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===r?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(r)||"objDesc"===r?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+r+" unsupported")},i.prototype._encodeObjid=function(e,r,n){if("string"==typeof e){if(!r)return this.reporter.error("string objid given, but no values map found");if(!r.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=r[e].split(/[\s.]+/g);for(let t=0;t<e.length;t++)e[t]|=0}else if(Array.isArray(e)){e=e.slice();for(let t=0;t<e.length;t++)e[t]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!n){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let o=0;for(let t=0;t<e.length;t++){let r=e[t];for(o++;r>=128;r>>=7)o++}const i=t.alloc(o);let s=i.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(i[s--]=127&r;(r>>=7)>0;)i[s--]=128|127&r}return this._createEncoderBuffer(i)},i.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[s(n.getUTCFullYear()),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[s(n.getUTCFullYear()%100),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},i.prototype._encodeNull=function(){return this._createEncoderBuffer("")},i.prototype._encodeInt=function(e,r){if("string"==typeof e){if(!r)return this.reporter.error("String int or enum given, but no values map");if(!r.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=r[e]}if("number"!=typeof e&&!t.isBuffer(e)){const r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=t.from(r)}if(t.isBuffer(e)){let r=e.length;0===e.length&&r++;const n=t.alloc(r);return e.copy(n),0===e.length&&(n[0]=0),this._createEncoderBuffer(n)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let n=1;for(let t=e;t>=256;t>>=8)n++;const o=new Array(n);for(let t=o.length-1;t>=0;t--)o[t]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(t.from(o))},i.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},i.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},i.prototype._skipDefault=function(e,t,r){const n=this._baseState;let o;if(null===n.default)return!1;const i=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),i.length!==n.defaultBuffer.length)return!1;for(o=0;o<i.length;o++)if(i[o]!==n.defaultBuffer[o])return!1;return!0},J}function W(){return G||(G=1,function(e){const t=e;t.der=X(),t.pem=function(){if(Z)return F;Z=1;const e=l(),t=X();function r(e){t.call(this,e),this.enc="pem"}return e(r,t),F=r,r.prototype.encode=function(e,r){const n=t.prototype.encode.call(this,e).toString("base64"),o=["-----BEGIN "+r.label+"-----"];for(let e=0;e<n.length;e+=64)o.push(n.slice(e,e+64));return o.push("-----END "+r.label+"-----"),o.join("\n")},F}()}(U)),U}var Q,ee,te,re,ne,oe,ie={};function se(){if(ee)return Q;ee=1;const e=l(),t=u(),r=V().DecoderBuffer,n=L(),o=H();function i(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new s,this.tree._init(e.body)}function s(e){n.call(this,"der",e)}function a(e,t){let r=e.readUInt8(t);if(e.isError(r))return r;const n=o.tagClass[r>>6],i=!(32&r);if(31&~r)r&=31;else{let n=r;for(r=0;!(128&~n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}return{cls:n,primitive:i,tag:r,tagStr:o.tag[r]}}function c(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(!(128&n))return n;const o=127&n;if(o>4)return e.error("length octect is too long");n=0;for(let t=0;t<o;t++){n<<=8;const t=e.readUInt8(r);if(e.isError(t))return t;n|=t}return n}return Q=i,i.prototype.decode=function(e,t){return r.isDecoderBuffer(e)||(e=new r(e,t)),this.tree._decode(e,t)},e(s,n),s.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;const n=e.save(),o=a(e,'Failed to peek tag: "'+t+'"');return e.isError(o)?o:(e.restore(n),o.tag===t||o.tagStr===t||o.tagStr+"of"===t||r)},s.prototype._decodeTag=function(e,t,r){const n=a(e,'Failed to decode tag of "'+t+'"');if(e.isError(n))return n;let o=c(e,n.primitive,'Failed to get length of "'+t+'"');if(e.isError(o))return o;if(!r&&n.tag!==t&&n.tagStr!==t&&n.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(n.primitive||null!==o)return e.skip(o,'Failed to match body of: "'+t+'"');const i=e.save(),s=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(s)?s:(o=e.offset-i.offset,e.restore(i),e.skip(o,'Failed to match body of: "'+t+'"'))},s.prototype._skipUntilEnd=function(e,t){for(;;){const r=a(e,t);if(e.isError(r))return r;const n=c(e,r.primitive,t);if(e.isError(n))return n;let o;if(o=r.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(o))return o;if("end"===r.tagStr)break}},s.prototype._decodeList=function(e,t,r,n){const o=[];for(;!e.isEmpty();){const t=this._peekTag(e,"end");if(e.isError(t))return t;const i=r.decode(e,"der",n);if(e.isError(i)&&t)break;o.push(i)}return o},s.prototype._decodeStr=function(e,t){if("bitstr"===t){const t=e.readUInt8();return e.isError(t)?t:{unused:t,data:e.raw()}}if("bmpstr"===t){const t=e.raw();if(t.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");let r="";for(let e=0;e<t.length/2;e++)r+=String.fromCharCode(t.readUInt16BE(2*e));return r}if("numstr"===t){const t=e.raw().toString("ascii");return this._isNumstr(t)?t:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){const t=e.raw().toString("ascii");return this._isPrintstr(t)?t:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},s.prototype._decodeObjid=function(e,t,r){let n;const o=[];let i=0,s=0;for(;!e.isEmpty();)s=e.readUInt8(),i<<=7,i|=127&s,128&s||(o.push(i),i=0);128&s&&o.push(i);const a=o[0]/40|0,c=o[0]%40;if(n=r?o:[a,c].concat(o.slice(1)),t){let e=t[n.join(" ")];void 0===e&&(e=t[n.join(".")]),void 0!==e&&(n=e)}return n},s.prototype._decodeTime=function(e,t){const r=e.raw().toString();let n,o,i,s,a,c;if("gentime"===t)n=0|r.slice(0,4),o=0|r.slice(4,6),i=0|r.slice(6,8),s=0|r.slice(8,10),a=0|r.slice(10,12),c=0|r.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");n=0|r.slice(0,2),o=0|r.slice(2,4),i=0|r.slice(4,6),s=0|r.slice(6,8),a=0|r.slice(8,10),c=0|r.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,o-1,i,s,a,c,0)},s.prototype._decodeNull=function(){return null},s.prototype._decodeBool=function(e){const t=e.readUInt8();return e.isError(t)?t:0!==t},s.prototype._decodeInt=function(e,r){const n=e.raw();let o=new t(n);return r&&(o=r[o.toString(10)]||o),o},s.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree},Q}function ae(){return ne||(ne=1,function(e){const t=e;t.der=se(),t.pem=function(){if(re)return te;re=1;const e=l(),t=I().Buffer,r=se();function n(e){r.call(this,e),this.enc="pem"}return e(n,r),te=n,n.prototype.decode=function(e,n){const o=e.toString().split(/[\r\n]+/g),i=n.label.toUpperCase(),s=/^-----(BEGIN|END) ([^-]+)-----$/;let a=-1,c=-1;for(let e=0;e<o.length;e++){const t=o[e].match(s);if(null!==t&&t[2]===i){if(-1!==a){if("END"!==t[1])break;c=e;break}if("BEGIN"!==t[1])break;a=e}}if(-1===a||-1===c)throw new Error("PEM section not found for: "+i);const u=o.slice(a+1,c).join("");u.replace(/[^a-z0-9+/=]+/gi,"");const l=t.from(u,"base64");return r.prototype.decode.call(this,l,n)},te}()}(ie)),ie}var ce,ue={};var le,fe,pe={};function he(){return fe||(fe=1,function(){const e=B;e.bignum=u(),e.define=(oe||(oe=1,function(e){const t=W(),r=ae(),n=l();function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}e.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(e){const t=this.name;function r(e){this._initNamed(e,t)}return n(r,e),r.prototype._initNamed=function(t,r){e.call(this,t,r)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(r[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(t[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}}(j)),j).define,e.base=(ce||(ce=1,function(e){const t=e;t.Reporter=N().Reporter,t.DecoderBuffer=V().DecoderBuffer,t.EncoderBuffer=V().EncoderBuffer,t.Node=L()}(ue)),ue),e.constants=(le||(le=1,function(e){const t=e;t._reverse=function(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t},t.der=H()}(pe)),pe),e.decoders=ae(),e.encoders=W()}()),B}var de,ye,be,we,ge,me,ve,ke,_e,Pe,Ee,Se,Ke,Ae,xe,Ce,Be,je,Ue,Ie,Te,qe,Ne,ze,Oe,Re,De,Ve,Le,Me,Je,$e,Fe,Ze,Ge,Ye={exports:{}},He={},Xe={};function We(){if(ye)return He;ye=1,Object.defineProperty(He,"__esModule",{value:!0});var e=(de||(de=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.default=function(e){var r=e.length,n=r%4;if(!n)return e;var o=r,i=4-n,s=r+i,a=t.alloc(s);for(a.write(e);i--;)a.write("=",o++);return a.toString()}),Xe);function r(e,r){return void 0===r&&(r="utf8"),o(e)?i(e.toString("base64")):i(t.from(e,r).toString("base64"))}function n(t){return t=t.toString(),e.default(t).replace(/\-/g,"+").replace(/_/g,"/")}function i(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var s=r;return s.encode=r,s.decode=function(e,r){return void 0===r&&(r="utf8"),t.from(n(e),"base64").toString(r)},s.toBase64=n,s.fromBase64=i,s.toBuffer=function(e){return t.from(n(e),"base64")},He.default=s,He}function Qe(){return be||(be=1,(e=Ye).exports=We().default,e.exports.default=e.exports),Ye.exports;var e}function et(){if(ge)return we;ge=1;const e=he(),r=Qe();return we=class{static convert(n,o,i){if(!n)return;if(o===i)return n;let s;if("raw"===o||n instanceof t)s=n;else if("uint8_array"===o||Array.isArray(n))s=t.from(n);else if("hex"===o)s=t.from(n,"hex");else if("base64"===o)s=t.from(n,"base64");else if("base64url"===o)s=r.toBuffer(n);else{if("bn"!==o&&"bignum"!==o)throw new Error("Invalid fromType");s=t.from(this.pad(n.toString(16)),"hex")}if("raw"===i)return s;if("uint8_array"===i)return Array.from(s);if("hex"===i)return s.toString("hex");if("base64"===i)return s.toString("base64");if("base64url"===i)return r.fromBase64(s.toString("base64"));if("bn"===i||"bignum"===i)return new e.bignum(s);throw new Error("Invalid toType")}static pad(e){return e.length%2==1?`0${e}`:e}},we}function tt(){if(Oe)return ze;Oe=1;const e=new(function(){if(ve)return me;ve=1;const e=he();return me=class{constructor(){Object.defineProperty(this,"_registry",{value:{}})}get registry(){return this._registry}define(t,r){this._registry[t]=e.define(t,r(this))}normalize(e){return this.registry[e]}}}());return e.define("Version",_e?ke:(_e=1,ke=e=>function(){this.int({0:"two-prime",1:"multi"})})),e.define("OtherPrimeInfos",Ee?Pe:(Ee=1,Pe=e=>function(){this.seq().obj(this.key("ri").int(),this.key("di").int(),this.key("ti").int())})),e.define("AlgorithmIdentifier",Ke?Se:(Ke=1,Se=e=>function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())})),e.define("PrivateKeyInfo",(xe||(xe=1,Ae=e=>{let t=e.normalize("Version"),r=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("version").use(t),this.key("algorithm").use(r),this.key("privateKey").octstr())}}),Ae)),e.define("PublicKeyInfo",(Be||(Be=1,Ce=e=>{let t=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("algorithm").use(t),this.key("publicKey").bitstr())}}),Ce)),e.define("RSAPrivateKey",(Ue||(Ue=1,je=e=>{let t=e.normalize("Version"),r=e.normalize("OtherPrimeInfos");return function(){this.seq().obj(this.key("version").use(t),this.key("n").int(),this.key("e").int(),this.key("d").int(),this.key("p").int(),this.key("q").int(),this.key("dp").int(),this.key("dq").int(),this.key("qi").int(),this.key("other").optional().use(r))}}),je)),e.define("RSAPublicKey",Te?Ie:(Te=1,Ie=e=>function(){this.seq().obj(this.key("n").int(),this.key("e").int())})),e.define("ECPrivateKey",Ne?qe:(Ne=1,qe=e=>function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).optional().choice({namedCurve:this.objid()}),this.key("publicKey").explicit(1).optional().bitstr())})),ze=e}function rt(){if(Fe)return $e;Fe=1;const e=g?w:(g=1,w=class{constructor(){this.registry=[],this.classes={}}find(e){return this.registry.find(e)}define(e,t){e.forEach((e=>{let{kty:r}=e;if(!r)throw new Error("Invalid type definition");this.classes[r]||(this.classes[r]=t),this.registry.push(e)}))}normalize(e,t,r){let n=this.classes[e],o=this.find((e=>e[t]===r));if(!n||!o)throw new Error("Invalid type");return new n(o)}}),r=function(){if(De)return Re;De=1;const e=A();S();const r=et(),n=tt();class o extends e{fromPrivatePKCS1(e){let t=n.normalize("RSAPrivateKey"),{n:o,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw"),d:r.convert(s,"bn","raw"),p:r.convert(a,"bn","raw"),q:r.convert(c,"bn","raw"),dp:r.convert(u,"bn","raw"),dq:r.convert(l,"bn","raw"),qi:r.convert(f,"bn","raw")}}fromPrivatePKCS8(e){let t=n.normalize("PrivateKeyInfo"),o=n.normalize("RSAPrivateKey"),i=t.decode(e,"der"),{n:s,e:a,d:c,p:u,q:l,dp:f,dq:p,qi:h}=o.decode(i.privateKey,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw"),d:r.convert(c,"bn","raw"),p:r.convert(u,"bn","raw"),q:r.convert(l,"bn","raw"),dp:r.convert(f,"bn","raw"),dq:r.convert(p,"bn","raw"),qi:r.convert(h,"bn","raw")}}fromPublicPKCS1(e){let t=n.normalize("RSAPublicKey"),{n:o,e:i}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw")}}fromPublicPKCS8(e){let t=n.normalize("PublicKeyInfo"),o=n.normalize("RSAPublicKey"),i=t.decode(e,"der"),{n:s,e:a}=o.decode(i.publicKey.data,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw")}}fromJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u,alg:l}=e;return{n:r.convert(t,"base64url","raw"),e:r.convert(n,"base64url","raw"),d:r.convert(o,"base64url","raw"),p:r.convert(i,"base64url","raw"),q:r.convert(s,"base64url","raw"),dp:r.convert(a,"base64url","raw"),dq:r.convert(c,"base64url","raw"),qi:r.convert(u,"base64url","raw")}}toPrivatePKCS1(e){let{n:t,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=e,{version:p}=this.params,h=n.normalize("RSAPrivateKey").encode({version:p,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn"),d:r.convert(s,"raw","bn"),p:r.convert(a,"raw","bn"),q:r.convert(c,"raw","bn"),dp:r.convert(u,"raw","bn"),dq:r.convert(l,"raw","bn"),qi:r.convert(f,"raw","bn")},"der").toString("base64");return o.formatPem(h,"RSA PRIVATE")}toPrivatePKCS8(e){let{n:i,e:s,d:a,p:c,q:u,dp:l,dq:f,qi:p}=e,{oid:h,algParameters:d,version:y}=this.params,b=n.normalize("PrivateKeyInfo"),w=n.normalize("RSAPrivateKey").encode({version:y,n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn"),d:r.convert(a,"raw","bn"),p:r.convert(c,"raw","bn"),q:r.convert(u,"raw","bn"),dp:r.convert(l,"raw","bn"),dq:r.convert(f,"raw","bn"),qi:r.convert(p,"raw","bn")},"der"),g=b.encode({version:y,algorithm:{algorithm:h.split("."),parameters:t.from(d,"hex")},privateKey:w},"der").toString("base64");return o.formatPem(g,"PRIVATE")}toPublicPKCS1(e){let{n:t,e:i}=e,{version:s}=this.params,a=n.normalize("RSAPublicKey").encode({version:s,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn")},"der").toString("base64");return o.formatPem(a,"RSA PUBLIC")}toPublicPKCS8(e){let{n:i,e:s}=e,{oid:a,algParameters:c}=this.params,u=n.normalize("PublicKeyInfo"),l=n.normalize("RSAPublicKey").encode({n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn")},"der"),f=u.encode({algorithm:{algorithm:a.split("."),parameters:t.from(c,"hex")},publicKey:{unused:0,data:l}},"der").toString("base64");return o.formatPem(f,"PUBLIC")}toPrivateJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u}=e,{kty:l}=this.params;return{kty:l,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url"),d:r.convert(o,"raw","base64url"),p:r.convert(i,"raw","base64url"),q:r.convert(s,"raw","base64url"),dp:r.convert(a,"raw","base64url"),dq:r.convert(c,"raw","base64url"),qi:r.convert(u,"raw","base64url")}}toPublicJwk(e){let{n:t,e:n}=e,{kty:o}=this.params;return{kty:o,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url")}}}return Re=o}(),n=function(){if(Le)return Ve;Le=1,he().bignum;const e=new(0,a().ec)("secp256k1"),r=A();S();const n=et(),o=tt();class i extends r{fromPrivatePKCS1(e){let t=o.normalize("ECPrivateKey").decode(e,"der"),{privateKey:r,publicKey:{data:s}}=t,a=n.convert(s,"raw","hex"),{x:c,y:u}=i.getPoint(a);return{d:r,x:c,y:u}}fromPrivatePKCS8(e){let t=o.normalize("PrivateKeyInfo"),r=o.normalize("ECPrivateKey"),s=t.decode(e,"der"),a=r.decode(s.privateKey,"der"),{privateKey:c,publicKey:{data:u}}=a,l=n.convert(u,"raw","hex"),{x:f,y:p}=i.getPoint(l);return{d:c,x:f,y:p}}fromPublicPKCS8(e){let t=o.normalize("PublicKeyInfo").decode(e,"der"),r=n.convert(t.publicKey.data,"raw","hex");return i.getPoint(r)}fromPrivateBlk(t){let r=e.keyFromPrivate(t,"hex"),o=r.getPublic();return{d:n.convert(r.priv,"bn","raw"),x:n.convert(o.getX(),"bn","raw"),y:n.convert(o.getY(),"bn","raw")}}fromPublicBlk(e){return i.getPoint(e)}fromJwk(e){let{d:t,x:r,y:o}=e;return{d:n.convert(t,"base64url","raw"),x:n.convert(r,"base64url","raw"),y:n.convert(o,"base64url","raw")}}toPrivatePKCS1(e){let{namedCurve:t,keyVersion:r}=this.params,{d:n,x:s,y:a}=e,c=o.normalize("ECPrivateKey"),u=i.makePoint(s,a),l=c.encode({version:r,privateKey:n,parameters:{type:"namedCurve",value:t.split(".")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"EC PRIVATE")}toPrivatePKCS8(e){let{oid:r,algParameters:n,keyVersion:s,infoVersion:a}=this.params,{d:c,x:u,y:l}=e,f=o.normalize("PrivateKeyInfo"),p=o.normalize("ECPrivateKey"),h=i.makePoint(u,l),d=p.encode({version:s,privateKey:c,publicKey:{unused:0,data:h}},"der"),y=f.encode({version:a,algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},privateKey:d},"der").toString("base64");return i.formatPem(y,"PRIVATE")}toPublicPKCS8(e){let{oid:r,algParameters:n}=this.params,{x:s,y:a}=e,c=o.normalize("PublicKeyInfo"),u=i.makePoint(s,a),l=c.encode({algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"PUBLIC")}toPrivateBlk(e){return e.d.toString("hex")}toPublicBlk(e){return n.convert(i.makePoint(e.x,e.y),"raw","hex")}toPrivateJwk(e){let{crv:t,kty:r}=this.params,{d:o,x:i,y:s}=e;return{kty:r,crv:t,d:n.convert(o,"raw","base64url"),x:n.convert(i,"raw","base64url"),y:n.convert(s,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:r}=this.params,{x:o,y:i}=e;return{kty:r,crv:t,x:n.convert(o,"raw","base64url"),y:n.convert(i,"raw","base64url")}}static getPoint(e){let t=e.slice(2,(e.length-2)/2+2),r=e.slice((e.length-2)/2+2);return{x:n.convert(t,"hex","raw"),y:n.convert(r,"hex","raw")}}static makePoint(e,r){let n=t.from("04","hex");return t.concat([n,e,r],n.length+e.length+r.length)}}return Ve=i}(),o=function(){if(Je)return Me;Je=1;const e=A(),r=et(),n=tt();class o extends e{fromPrivatePKCS8(e){const t=n.normalize("PrivateKeyInfo").decode(e,"der").privateKey.slice(2);return{d:t,x:this.publicKeyFromPrivate(t)}}fromPublicPKCS8(e){const t=n.normalize("PublicKeyInfo").decode(e,"der");return{x:r.convert(t.publicKey.data,"hex","raw")}}fromJwk(e){let{d:t,x:n}=e;return{d:r.convert(t,"base64url","raw"),x:r.convert(n,"base64url","raw")}}toPrivatePKCS8(e){let{oid:t,infoVersion:r}=this.params,{d:i}=e;const s=n.normalize("PrivateKeyInfo"),a=this.privateKeyPadding(i);let c=s.encode({version:r,algorithm:{algorithm:t.split(".")},privateKey:a},"der").toString("base64");return o.formatPem(c,"PRIVATE")}toPublicPKCS8(e){let{oid:t}=this.params,{x:i}=e,s=n.normalize("PublicKeyInfo").encode({algorithm:{algorithm:t.split(".")},publicKey:{unused:0,data:r.convert(i,"hex","raw")}},"der").toString("base64");return o.formatPem(s,"PUBLIC")}toPrivateJwk(e){let{crv:t,kty:n}=this.params,{d:o,x:i}=e;return{kty:n,crv:t,d:r.convert(o,"raw","base64url"),x:r.convert(i,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:n}=this.params,{x:o}=e;return{kty:n,crv:t,x:r.convert(o,"raw","base64url")}}privateKeyPadding(e){let r;if("Ed25519"!==this.params.crv)throw new Error(`${this.params.crv} is an invalid curve for EdDSA`);return r=t.from("0420","hex"),t.concat([r,e],r.length+e.length)}publicKeyFromPrivate(e){if("Ed25519"===this.params.crv){const r=new(0,a().eddsa)("ed25519");return t.from(r.keyFromSecret(e).getPublic())}throw new Error(`${this.params.crv} is an invalid curve for EdDSA`)}}return Me=o}(),i=new e;return i.define([{kty:"RSA",oid:"1.2.840.113549.1.1.1",algParameters:"0500",version:"two-prime"}],r),i.define([{kty:"EC",crv:"K-256",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.10",algParameters:"06052b8104000a",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-256",oid:"1.2.840.10045.2.1",namedCurve:"1.2.840.10045.3.1.7",algParameters:"06082a8648ce3d030107",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-384",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.34",algParameters:"06052b81040022",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-521",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.35",algParameters:"06052b81040023",keyVersion:1,infoVersion:"two-prime"}],n),i.define([{kty:"OKP",crv:"Ed25519",oid:"1.3.101.112",infoVersion:"two-prime"}],o),$e=i}var nt,ot,it,st,at,ct,ut=function(){if(Ge)return Ze;Ge=1;const e=S(),r=K(),n=rt(),o=tt(),i=RegExp("\r?\n","g");class s{constructor(t,r){if(!t)throw new e("key is required");if(!r)throw new e("options are required");let{kty:n,format:o,selector:i,crv:s,oid:a}=r;if(!r.kty)throw new e("options.kty is required");if(!r.format)throw new e("options.format is required");if(!r.selector)throw new e("options.selector is required");if(!r.crv&&!r.oid)throw new e("options.crv or options.oid is required");this.kty=n,this.format=o,this.selector=i,this.crv=s,this.oid=a,this.key=this.parseKey(t)}static from(r,a){if(!r)throw new e("key is required");if(!a)throw new e("format is required");if("jwk"===a){let t;if("string"==typeof r)try{t=JSON.parse(r)}catch(t){throw new e("key is not a valid JWK")}else"object"==typeof r&&(t=r);let o,{kty:i,crv:c}=t;if(!i)throw new e("kty is required for JWK");if("EC"===i&&!c)throw new e("crv is required for EC JWK");"RSA"===i&&(o=n.find((e=>e.kty===i)).oid);let u=t.d?"private":"public";return new s(t,{kty:i,crv:c,oid:o,format:a,selector:u})}if("pem"===a){if("string"!=typeof r)throw new e("key is not a valid PEM string");let c=r.split(i),u=c.splice(0,1);c.splice(c.length-1,1);let l,f,p=c.join(""),h=/^-----BEGIN ((RSA|EC) )?(PUBLIC|PRIVATE) KEY-----$/.exec(u),d=h?h[2]:void 0,y=h?h[3]:void 0,b=t.from(p,"base64");if(!y)throw new e("key is not a valid PEM string");if(d){if("RSA"===d)y="PRIVATE"===y?"private_pkcs1":"public_pkcs1",l=n.find((e=>e.kty===d)).oid;else if("EC"===d){let e;if("PRIVATE"===y){y="private_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}else if("PUBLIC"===y){y="public_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}let{parameters:{value:t}}=e;f=n.find((e=>e.namedCurve===t.join("."))).crv}}else{let t,r=o.normalize("PrivateKeyInfo"),i=o.normalize("PublicKeyInfo");"PRIVATE"===y?(y="private_pkcs8",t=r.decode(b,"der")):"PUBLIC"===y&&(y="public_pkcs8",t=i.decode(b,"der"));let{algorithm:{algorithm:s,parameters:a}}=t;s=s.join("."),a=a?a.toString("hex"):void 0;const c=n.find((e=>e.oid===s));if(d=c?c.kty:void 0,!d)throw new e(`${s} is not supported`);"RSA"===d||"OKP"===d?l=s:"EC"===d&&(f=n.find((e=>e.algParameters===a)).crv)}return new s(b,{kty:d,oid:l,crv:f,format:a,selector:y})}if("blk"===a)return new s(r,{kty:"EC",crv:"K-256",format:a,selector:r.length>64?"public":"private"});throw new e(`Invalid format ${a}`)}get alg(){let{kty:e,crv:t,oid:r}=this;if(!this.algorithm){if(t)Object.defineProperty(this,"algorithm",{value:n.normalize(e,"crv",t)});else{if(!r)throw new Error("Both crv and oid are undefined");Object.defineProperty(this,"algorithm",{value:n.normalize(e,"oid",r)})}if(!this.algorithm)throw new Error(`${this.crv||this.oid} is not implemented yet`)}return this.algorithm}parseKey(e){let{alg:t,format:r,selector:n}=this;if("pem"===r)switch(n){case"public_pkcs1":return t.fromPublicPKCS1(e);case"public_pkcs8":return t.fromPublicPKCS8(e);case"private_pkcs1":return t.fromPrivatePKCS1(e);case"private_pkcs8":return t.fromPrivatePKCS8(e);default:throw new Error("Invalid selector value")}if("jwk"===r)return t.fromJwk(e,n);if("blk"===r)switch(n){case"public":return t.fromPublicBlk(e);case"private":return t.fromPrivateBlk(e)}}toJwk(t){let{key:r,alg:n,selector:o}=this;switch(t){case"public":return n.toPublicJwk(r);case"private":if(o.includes("public"))throw new e("Cannot export a private key from a public key");return n.toPrivateJwk(r);default:throw new Error("Invalid key selector")}}toString(t="pem",n="public_pkcs8"){let{key:o,alg:i,selector:s}=this;if("pem"===t)switch(n){case"public_pkcs1":return i.toPublicPKCS1(o);case"public_pkcs8":return i.toPublicPKCS8(o);case"private_pkcs1":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS1(o);case"private_pkcs8":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS8(o);default:throw new Error("Invalid key selector")}else if("jwk"===t)switch(n){case"public":return JSON.stringify(i.toPublicJwk(o));case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return JSON.stringify(i.toPrivateJwk(o));default:throw new Error("Invalid key selector")}else if("blk"===t)switch(n){case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivateBlk(o);case"public":return i.toPublicBlk(o);default:throw new Error("Invalid key selector")}throw new r}}return Ze=s}(),lt=e(ut),ft=e(Qe());function pt(){if(st)return it;st=1;const e=new(0,a().ec)("secp256k1"),t=e.curve,r=t.n.constructor;function n(n){const o=n[0];switch(o){case 2:case 3:return 33!==n.length?null:function(n,o){let i=new r(o);if(i.cmp(t.p)>=0)return null;i=i.toRed(t.red);let s=i.redSqr().redIMul(i).redIAdd(t.b).redSqrt();return 3===n!==s.isOdd()&&(s=s.redNeg()),e.keyPair({pub:{x:i,y:s}})}(o,n.subarray(1,33));case 4:case 6:case 7:return 65!==n.length?null:function(n,o,i){let s=new r(o),a=new r(i);if(s.cmp(t.p)>=0||a.cmp(t.p)>=0)return null;if(s=s.toRed(t.red),a=a.toRed(t.red),(6===n||7===n)&&a.isOdd()!==(7===n))return null;const c=s.redSqr().redIMul(s);return a.redSqr().redISub(c.redIAdd(t.b)).isZero()?e.keyPair({pub:{x:s,y:a}}):null}(o,n.subarray(1,33),n.subarray(33,65));default:return null}}function o(e,t){const r=t.encode(null,33===e.length);for(let t=0;t<e.length;++t)e[t]=r[t]}return it={contextRandomize:()=>0,privateKeyVerify(e){const n=new r(e);return n.cmp(t.n)<0&&!n.isZero()?0:1},privateKeyNegate(e){const n=new r(e),o=t.n.sub(n).umod(t.n).toArrayLike(Uint8Array,"be",32);return e.set(o),0},privateKeyTweakAdd(e,n){const o=new r(n);if(o.cmp(t.n)>=0)return 1;if(o.iadd(new r(e)),o.cmp(t.n)>=0&&o.isub(t.n),o.isZero())return 1;const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},privateKeyTweakMul(e,n){let o=new r(n);if(o.cmp(t.n)>=0||o.isZero())return 1;o.imul(new r(e)),o.cmp(t.n)>=0&&(o=o.umod(t.n));const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},publicKeyVerify:e=>null===n(e)?1:0,publicKeyCreate(n,i){const s=new r(i);if(s.cmp(t.n)>=0||s.isZero())return 1;return o(n,e.keyFromPrivate(i).getPublic()),0},publicKeyConvert(e,t){const r=n(t);if(null===r)return 1;return o(e,r.getPublic()),0},publicKeyNegate(e,t){const r=n(t);if(null===r)return 1;const i=r.getPublic();return i.y=i.y.redNeg(),o(e,i),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e<t.length;++e)if(r[e]=n(t[e]),null===r[e])return 1;let i=r[0].getPublic();for(let e=1;e<r.length;++e)i=i.add(r[e].pub);return i.isInfinity()?2:(o(e,i),0)},publicKeyTweakAdd(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0)return 2;const c=a.getPublic().add(t.g.mul(s));return c.isInfinity()?2:(o(e,c),0)},publicKeyTweakMul(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0||s.isZero())return 2;return o(e,a.getPublic().mul(s)),0},signatureNormalize(n){const o=new r(n.subarray(0,32)),i=new r(n.subarray(32,64));return o.cmp(t.n)>=0||i.cmp(t.n)>=0?1:(1===i.cmp(e.nh)&&n.set(t.n.sub(i).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,n){const o=n.subarray(0,32),i=n.subarray(32,64);if(new r(o).cmp(t.n)>=0)return 1;if(new r(i).cmp(t.n)>=0)return 1;const{output:s}=e;let a=s.subarray(4,37);a[0]=0,a.set(o,1);let c=33,u=0;for(;c>1&&0===a[u]&&!(128&a[u+1]);--c,++u);if(a=a.subarray(u),128&a[0])return 1;if(c>1&&0===a[0]&&!(128&a[1]))return 1;let l=s.subarray(39,72);l[0]=0,l.set(i,1);let f=33,p=0;for(;f>1&&0===l[p]&&!(128&l[p+1]);--f,++p);return l=l.subarray(p),128&l[0]||f>1&&0===l[0]&&!(128&l[1])?1:(e.outputlen=6+c+f,s[0]=48,s[1]=e.outputlen-2,s[2]=2,s[3]=a.length,s.set(a,4),s[4+c]=2,s[5+c]=l.length,s.set(l,6+c),0)},signatureImport(e,n){if(n.length<8)return 1;if(n.length>72)return 1;if(48!==n[0])return 1;if(n[1]!==n.length-2)return 1;if(2!==n[2])return 1;const o=n[3];if(0===o)return 1;if(5+o>=n.length)return 1;if(2!==n[4+o])return 1;const i=n[5+o];if(0===i)return 1;if(6+o+i!==n.length)return 1;if(128&n[4])return 1;if(o>1&&0===n[4]&&!(128&n[5]))return 1;if(128&n[o+6])return 1;if(i>1&&0===n[o+6]&&!(128&n[o+7]))return 1;let s=n.subarray(4,4+o);if(33===s.length&&0===s[0]&&(s=s.subarray(1)),s.length>32)return 1;let a=n.subarray(6+o);if(33===a.length&&0===a[0]&&(a=a.slice(1)),a.length>32)throw new Error("S length is too long");let c=new r(s);c.cmp(t.n)>=0&&(c=new r(0));let u=new r(n.subarray(6+o));return u.cmp(t.n)>=0&&(u=new r(0)),e.set(c.toArrayLike(Uint8Array,"be",32),0),e.set(u.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(n,o,i,s,a){if(a){const e=a;a=t=>{const n=e(o,i,null,s,t);if(!(n instanceof Uint8Array&&32===n.length))throw new Error("This is the way");return new r(n)}}const c=new r(i);if(c.cmp(t.n)>=0||c.isZero())return 1;let u;try{u=e.sign(o,i,{canonical:!0,k:a,pers:s})}catch(e){return 1}return n.signature.set(u.r.toArrayLike(Uint8Array,"be",32),0),n.signature.set(u.s.toArrayLike(Uint8Array,"be",32),32),n.recid=u.recoveryParam,0},ecdsaVerify(o,i,s){const a={r:o.subarray(0,32),s:o.subarray(32,64)},c=new r(a.r),u=new r(a.s);if(c.cmp(t.n)>=0||u.cmp(t.n)>=0)return 1;if(1===u.cmp(e.nh)||c.isZero()||u.isZero())return 3;const l=n(s);if(null===l)return 2;const f=l.getPublic();return e.verify(i,a,f)?0:3},ecdsaRecover(n,i,s,a){const c={r:i.slice(0,32),s:i.slice(32,64)},u=new r(c.r),l=new r(c.s);if(u.cmp(t.n)>=0||l.cmp(t.n)>=0)return 1;if(u.isZero()||l.isZero())return 2;let f;try{f=e.recoverPubKey(a,c,s)}catch(e){return 2}return o(n,f),0},ecdh(o,i,s,a,c,u,l){const f=n(i);if(null===f)return 1;const p=new r(s);if(p.cmp(t.n)>=0||p.isZero())return 2;const h=f.getPublic().mul(p);if(void 0===c){const t=h.encode(null,!0),r=e.hash().update(t).digest();for(let e=0;e<32;++e)o[e]=r[e]}else{u||(u=new Uint8Array(32));const e=h.getX().toArray("be",32);for(let t=0;t<32;++t)u[t]=e[t];l||(l=new Uint8Array(32));const t=h.getY().toArray("be",32);for(let e=0;e<32;++e)l[e]=t[e];const r=c(u,l,a);if(!(r instanceof Uint8Array&&r.length===o.length))return 2;o.set(r)}return 0}}}var ht,dt,yt,bt,wt=(ct||(ct=1,at=function(){if(ot)return nt;ot=1;const e="Impossible case. Please create issue.",t="The tweak was out of range or the resulted private key is invalid",r="The tweak was out of range or equal to zero",n="Unknow error on context randomization",o="Private Key is invalid",i="Public Key could not be parsed",s="Public Key serialization error",a="The sum of the public keys is not valid",c="Signature could not be parsed",u="The nonce generation function failed, or the private key was invalid",l="Public key could not be recover",f="Scalar was invalid (zero or overflow)";function p(e,t){if(!e)throw new Error(t)}function h(e,t,r){if(p(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const n=`Expected ${e} to be an Uint8Array with length [${r.join(", ")}]`;p(r.includes(t.length),n)}else{const n=`Expected ${e} to be an Uint8Array with length ${r}`;p(t.length===r,n)}}function d(e){p("Boolean"===b(e),"Expected compressed to be a Boolean")}function y(e=e=>new Uint8Array(e),t){return"function"==typeof e&&(e=e(t)),h("output",e,t),e}function b(e){return Object.prototype.toString.call(e).slice(8,-1)}return nt=w=>({contextRandomize(e){if(p(null===e||e instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==e&&h("seed",e,32),1===w.contextRandomize(e))throw new Error(n)},privateKeyVerify:e=>(h("private key",e,32),0===w.privateKeyVerify(e)),privateKeyNegate(t){switch(h("private key",t,32),w.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(e)}},privateKeyTweakAdd(e,r){switch(h("private key",e,32),h("tweak",r,32),w.privateKeyTweakAdd(e,r)){case 0:return e;case 1:throw new Error(t)}},privateKeyTweakMul(e,t){switch(h("private key",e,32),h("tweak",t,32),w.privateKeyTweakMul(e,t)){case 0:return e;case 1:throw new Error(r)}},publicKeyVerify:e=>(h("public key",e,[33,65]),0===w.publicKeyVerify(e)),publicKeyCreate(e,t=!0,r){switch(h("private key",e,32),d(t),r=y(r,t?33:65),w.publicKeyCreate(r,e)){case 0:return r;case 1:throw new Error(o);case 2:throw new Error(s)}},publicKeyConvert(e,t=!0,r){switch(h("public key",e,[33,65]),d(t),r=y(r,t?33:65),w.publicKeyConvert(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(s)}},publicKeyNegate(t,r=!0,n){switch(h("public key",t,[33,65]),d(r),n=y(n,r?33:65),w.publicKeyNegate(n,t)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(e);case 3:throw new Error(s)}},publicKeyCombine(e,t=!0,r){p(Array.isArray(e),"Expected public keys to be an Array"),p(e.length>0,"Expected public keys array will have more than zero items");for(const t of e)h("public key",t,[33,65]);switch(d(t),r=y(r,t?33:65),w.publicKeyCombine(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(a);case 3:throw new Error(s)}},publicKeyTweakAdd(e,r,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",r,32),d(n),o=y(o,n?33:65),w.publicKeyTweakAdd(o,e,r)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(t)}},publicKeyTweakMul(e,t,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",t,32),d(n),o=y(o,n?33:65),w.publicKeyTweakMul(o,e,t)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(r)}},signatureNormalize(e){switch(h("signature",e,64),w.signatureNormalize(e)){case 0:return e;case 1:throw new Error(c)}},signatureExport(t,r){h("signature",t,64);const n={output:r=y(r,72),outputlen:72};switch(w.signatureExport(n,t)){case 0:return r.slice(0,n.outputlen);case 1:throw new Error(c);case 2:throw new Error(e)}},signatureImport(t,r){switch(h("signature",t),r=y(r,64),w.signatureImport(r,t)){case 0:return r;case 1:throw new Error(c);case 2:throw new Error(e)}},ecdsaSign(t,r,n={},o){h("message",t,32),h("private key",r,32),p("Object"===b(n),"Expected options to be an Object"),void 0!==n.data&&h("options.data",n.data),void 0!==n.noncefn&&p("Function"===b(n.noncefn),"Expected options.noncefn to be a Function");const i={signature:o=y(o,64),recid:null};switch(w.ecdsaSign(i,t,r,n.data,n.noncefn)){case 0:return i;case 1:throw new Error(u);case 2:throw new Error(e)}},ecdsaVerify(e,t,r){switch(h("signature",e,64),h("message",t,32),h("public key",r,[33,65]),w.ecdsaVerify(e,t,r)){case 0:return!0;case 3:return!1;case 1:throw new Error(c);case 2:throw new Error(i)}},ecdsaRecover(t,r,n,o=!0,i){switch(h("signature",t,64),p("Number"===b(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),h("message",n,32),d(o),i=y(i,o?33:65),w.ecdsaRecover(i,t,r,n)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(l);case 3:throw new Error(e)}},ecdh(e,t,r={},n){switch(h("public key",e,[33,65]),h("private key",t,32),p("Object"===b(r),"Expected options to be an Object"),void 0!==r.data&&h("options.data",r.data),void 0!==r.hashfn?(p("Function"===b(r.hashfn),"Expected options.hashfn to be a Function"),void 0!==r.xbuf&&h("options.xbuf",r.xbuf,32),void 0!==r.ybuf&&h("options.ybuf",r.ybuf,32),h("output",n)):n=y(n,32),w.ecdh(n,e,t,r.data,r.hashfn,r.xbuf,r.ybuf)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(f)}}}),nt}()(pt())),at),gt=e(wt);function mt(){if(bt)return yt;bt=1;const e=(dt||(dt=1,ht=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var o=e.charAt(n),i=o.charCodeAt(0);if(255!==t[i])throw new TypeError(o+" is ambiguous");t[i]=n}var s=e.length,a=e.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,n=0,o=0;e[r]===a;)n++,r++;for(var i=(e.length-r)*c+1>>>0,u=new Uint8Array(i);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var f=0,p=i-1;(0!==l||f<o)&&-1!==p;p--,f++)l+=s*u[p]>>>0,u[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=f,r++}for(var h=i-o;h!==i&&0===u[h];)h++;for(var d=new Uint8Array(n+(i-h)),y=n;h!==i;)d[y++]=u[h++];return d}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var c=(i-o)*u+1>>>0,l=new Uint8Array(c);o!==i;){for(var f=t[o],p=0,h=c-1;(0!==f||p<n)&&-1!==h;h--,p++)f+=256*l[h]>>>0,l[h]=f%s>>>0,f=f/s>>>0;if(0!==f)throw new Error("Non-zero carry");n=p,o++}for(var d=c-n;d!==c&&0===l[d];)d++;for(var y=a.repeat(r);d<c;++d)y+=e.charAt(l[d]);return y},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}),ht);return yt=e("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}export{mt as a,_ as b,k as c,ft as d,wt as e,lt as k,E as r,gt as s};
|