paytools-3ds
Version:
3D secure implementation with a single line of code
2 lines • 24.4 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("threeDs",[],t):"object"==typeof exports?exports.threeDs=t():e.threeDs=t()}(self,(()=>(()=>{var e={612(e,t,r){!function(){"use strict";e.exports={inflate:r(967),deflate:r(931)}}()},931(e){!function(){var t,r,n,s,o,i,l,a,c,f,u,d,h,g,m,p,v,w,b,y,S,_,C,P,x,T,M,R,E,D,N,k,F,A,U,q,H,I,O,B,$,J,j,W,X,L,z,G,Q,V,Y,Z,K,ee,te,re,ne=32768,se=258,oe=32768,ie=32767,le=262,ae=32506,ce=15,fe=256,ue=286,de=30,he=parseInt(17/3,10),ge=null;function me(){this.fc=0,this.dl=0}function pe(){this.dyn_tree=null,this.static_tree=null,this.extra_bits=null,this.extra_base=0,this.elems=0,this.max_length=0,this.max_code=0}function ve(e,t,r,n){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n}function we(){this.next=null,this.len=0,this.ptr=[],this.off=0}var be=[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],ye=[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],Se=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],_e=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Ce=[new ve(0,0,0,0),new ve(4,4,8,4),new ve(4,5,16,8),new ve(4,6,32,32),new ve(4,4,16,16),new ve(8,16,32,32),new ve(8,16,128,128),new ve(8,32,128,256),new ve(32,128,258,1024),new ve(32,258,258,4096)];function Pe(e){e.next=t,t=e}function xe(e){return u[ne+e]}function Te(e,t){return u[ne+e]=t}function Me(e){ge[i+o++]=e,i+o===8192&&function(){var e,s;if(0!==o){for(null!==t?(l=t,t=t.next):l=new we,l.next=null,l.len=l.off=0,e=l,null===r?r=n=e:n=n.next=e,e.len=o-i,s=0;s<e.len;s++)e.ptr[s]=ge[i+s];o=i=0}var l}()}function Re(e){e&=65535,i+o<8190?(ge[i+o++]=255&e,ge[i+o++]=e>>>8):(Me(255&e),Me(e>>>8))}function Ee(){m=(m<<he^255&a[S+3-1])&ie,p=xe(m),u[32767&S]=p,Te(m,S)}function De(e,t){Qe(t[e].fc,t[e].dl)}function Ne(e){return 255&(e<256?W[e]:W[256+(e>>7)])}function ke(e,t,r){return e[t].fc<e[r].fc||e[t].fc===e[r].fc&&J[t]<=J[r]}function Fe(e,t,r){var n;for(n=0;n<r&&re<te.length;n++)e[t+n]=255&te[re++];return n}function Ae(e){var t,r,n,s,o=x,i=S,l=y,c=S>ae?S-ae:0,f=S+se,d=a[i+l-1],h=a[i+l];y>=R&&(o>>=2);do{if(a[(t=e)+l]===h&&a[t+l-1]===d&&a[t]===a[i]&&a[++t]===a[i+1]){for(i+=2,t++;i<f;){for(s=!1,n=0;n<8;n+=1)if(t+=1,a[i+=1]!==a[t]){s=!0;break}if(s)break}if(r=se-(f-i),i=f-se,r>l){if(_=e,l=r,r>=E)break;d=a[i+l-1],h=a[i+l]}}}while((e=u[32767&e])>c&&0!=--o);return l}function Ue(){var e,t,r=65536-P-S;if(-1===r)r--;else if(S>=65274){for(e=0;e<ne;e++)a[e]=a[e+ne];for(_-=ne,S-=ne,g-=ne,e=0;e<oe;e++)Te(e,(t=xe(e))>=ne?t-ne:0);for(e=0;e<ne;e++)t=u[e],u[e]=t>=ne?t-ne:0;r+=ne}C||((e=Fe(a,S+P,r))<=0?C=!0:P+=e)}function qe(){C||(d=0,h=0,function(){var e,t,r,n,s;if(0!==F[0].dl)return;for(U.dyn_tree=D,U.static_tree=k,U.extra_bits=be,U.extra_base=257,U.elems=ue,U.max_length=ce,U.max_code=0,q.dyn_tree=N,q.static_tree=F,q.extra_bits=ye,q.extra_base=0,q.elems=de,q.max_length=ce,q.max_code=0,H.dyn_tree=A,H.static_tree=null,H.extra_bits=Se,H.extra_base=0,H.elems=19,H.max_length=7,H.max_code=0,r=0,n=0;n<28;n++)for(X[n]=r,e=0;e<1<<be[n];e++)j[r++]=n;for(j[r-1]=n,s=0,n=0;n<16;n++)for(L[n]=s,e=0;e<1<<ye[n];e++)W[s++]=n;for(s>>=7;n<de;n++)for(L[n]=s<<7,e=0;e<1<<ye[n]-7;e++)W[256+s++]=n;for(t=0;t<=ce;t++)I[t]=0;e=0;for(;e<=143;)k[e++].dl=8,I[8]++;for(;e<=255;)k[e++].dl=9,I[9]++;for(;e<=279;)k[e++].dl=7,I[7]++;for(;e<=287;)k[e++].dl=8,I[8]++;for($e(k,287),e=0;e<de;e++)F[e].dl=5,F[e].fc=Ve(e,5);Oe()}(),function(){var e;for(e=0;e<oe;e++)u[ne+e]=0;if(T=Ce[M].max_lazy,R=Ce[M].good_length,E=Ce[M].nice_length,x=Ce[M].max_chain,S=0,g=0,(P=Fe(a,0,65536))<=0)return C=!0,void(P=0);for(C=!1;P<le&&!C;)Ue();for(m=0,e=0;e<2;e++)m=(m<<he^255&a[e])&ie}(),r=null,o=0,i=0,M<=3?(y=2,b=0):(b=2,w=!1),l=!1)}function He(e,t,n){var o;return s||(qe(),s=!0,0!==P)?(o=Ie(e,t,n))===n?n:l?o:(M<=3?function(){for(;0!==P&&null===r;){var e;if(Ee(),0!==p&&S-p<=ae&&(b=Ae(p))>P&&(b=P),b>=3)if(e=Le(S-_,b-3),P-=b,b<=T){b--;do{S++,Ee()}while(0!=--b);S++}else S+=b,b=0,m=((m=255&a[S])<<he^255&a[S+1])&ie;else e=Le(0,255&a[S]),P--,S++;for(e&&(Xe(0),g=S);P<le&&!C;)Ue()}}():function(){for(;0!==P&&null===r;){if(Ee(),y=b,v=_,b=2,0!==p&&y<T&&S-p<=ae&&((b=Ae(p))>P&&(b=P),3===b&&S-_>4096&&b--),y>=3&&b<=y){var e;e=Le(S-1-v,y-3),P-=y-1,y-=2;do{S++,Ee()}while(0!=--y);w=!1,b=2,S++,e&&(Xe(0),g=S)}else w?(Le(0,255&a[S-1])&&(Xe(0),g=S),S++,P--):(w=!0,S++,P--);for(;P<le&&!C;)Ue()}}(),0===P&&(w&&Le(0,255&a[S-1]),Xe(1),l=!0),o+Ie(e,o+t,n-o)):(l=!0,0)}function Ie(e,t,n){var s,l,a;for(s=0;null!==r&&s<n;){for((l=n-s)>r.len&&(l=r.len),a=0;a<l;a++)e[t+s+a]=r.ptr[r.off+a];var c;if(r.off+=l,r.len-=l,s+=l,0===r.len)c=r,r=r.next,Pe(c)}if(s===n)return s;if(i<o){for((l=n-s)>o-i&&(l=o-i),a=0;a<l;a++)e[t+s+a]=ge[i+a];s+=l,o===(i+=l)&&(o=i=0)}return s}function Oe(){var e;for(e=0;e<ue;e++)D[e].fc=0;for(e=0;e<de;e++)N[e].fc=0;for(e=0;e<19;e++)A[e].fc=0;D[256].fc=1,K=ee=0,G=Q=V=0,Y=0,Z=1}function Be(e,t){for(var r=O[t],n=t<<1;n<=B&&(n<B&&ke(e,O[n+1],O[n])&&n++,!ke(e,r,O[n]));)O[t]=O[n],t=n,n<<=1;O[t]=r}function $e(e,t){var r,n,s=[],o=0;for(r=1;r<=ce;r++)o=o+I[r-1]<<1,s[r]=o;for(n=0;n<=t;n++){var i=e[n].dl;0!==i&&(e[n].fc=Ve(s[i]++,i))}}function Je(e){var t,r,n=e.dyn_tree,s=e.static_tree,o=e.elems,i=-1,l=o;for(B=0,$=573,t=0;t<o;t++)0!==n[t].fc?(O[++B]=i=t,J[t]=0):n[t].dl=0;for(;B<2;){var a=O[++B]=i<2?++i:0;n[a].fc=1,J[a]=0,K--,null!==s&&(ee-=s[a].dl)}for(e.max_code=i,t=B>>1;t>=1;t--)Be(n,t);do{t=O[1],O[1]=O[B--],Be(n,1),r=O[1],O[--$]=t,O[--$]=r,n[l].fc=n[t].fc+n[r].fc,J[t]>J[r]+1?J[l]=J[t]:J[l]=J[r]+1,n[t].dl=n[r].dl=l,O[1]=l++,Be(n,1)}while(B>=2);O[--$]=O[1],function(e){var t,r,n,s,o,i,l=e.dyn_tree,a=e.extra_bits,c=e.extra_base,f=e.max_code,u=e.max_length,d=e.static_tree,h=0;for(s=0;s<=ce;s++)I[s]=0;for(l[O[$]].dl=0,t=$+1;t<573;t++)(s=l[l[r=O[t]].dl].dl+1)>u&&(s=u,h++),l[r].dl=s,r>f||(I[s]++,o=0,r>=c&&(o=a[r-c]),i=l[r].fc,K+=i*(s+o),null!==d&&(ee+=i*(d[r].dl+o)));if(0!==h){do{for(s=u-1;0===I[s];)s--;I[s]--,I[s+1]+=2,I[u]--,h-=2}while(h>0);for(s=u;0!==s;s--)for(r=I[s];0!==r;)(n=O[--t])>f||(l[n].dl!==s&&(K+=(s-l[n].dl)*l[n].fc,l[n].fc=s),r--)}}(e),$e(n,i)}function je(e,t){var r,n,s=-1,o=e[0].dl,i=0,l=7,a=4;for(0===o&&(l=138,a=3),e[t+1].dl=65535,r=0;r<=t;r++)n=o,o=e[r+1].dl,++i<l&&n===o||(i<a?A[n].fc+=i:0!==n?(n!==s&&A[n].fc++,A[16].fc++):i<=10?A[17].fc++:A[18].fc++,i=0,s=n,0===o?(l=138,a=3):n===o?(l=6,a=3):(l=7,a=4))}function We(e,t){var r,n,s=-1,o=e[0].dl,i=0,l=7,a=4;for(0===o&&(l=138,a=3),r=0;r<=t;r++)if(n=o,o=e[r+1].dl,!(++i<l&&n===o)){if(i<a)do{De(n,A)}while(0!=--i);else 0!==n?(n!==s&&(De(n,A),i--),De(16,A),Qe(i-3,2)):i<=10?(De(17,A),Qe(i-3,3)):(De(18,A),Qe(i-11,7));i=0,s=n,0===o?(l=138,a=3):n===o?(l=6,a=3):(l=7,a=4)}}function Xe(e){var t,r,n,s,o;if(s=S-g,z[V]=Y,Je(U),Je(q),n=function(){var e;for(je(D,U.max_code),je(N,q.max_code),Je(H),e=18;e>=3&&0===A[_e[e]].dl;e--);return K+=3*(e+1)+5+5+4,e}(),(r=ee+3+7>>3)<=(t=K+3+7>>3)&&(t=r),s+4<=t&&g>=0)for(Qe(0+e,3),Ye(),Re(s),Re(~s),o=0;o<s;o++)Me(a[g+o]);else r===t?(Qe(2+e,3),ze(k,F)):(Qe(4+e,3),function(e,t,r){var n;for(Qe(e-257,5),Qe(t-1,5),Qe(r-4,4),n=0;n<r;n++)Qe(A[_e[n]].dl,3);We(D,e-1),We(N,t-1)}(U.max_code+1,q.max_code+1,n+1),ze(D,N));Oe(),0!==e&&Ye()}function Le(e,t){if(f[G++]=t,0===e?D[t].fc++:(e--,D[j[t]+fe+1].fc++,N[Ne(e)].fc++,c[Q++]=e,Y|=Z),Z<<=1,7&G||(z[V++]=Y,Y=0,Z=1),M>2&&!(4095&G)){var r,n=8*G,s=S-g;for(r=0;r<de;r++)n+=N[r].fc*(5+ye[r]);if(n>>=3,Q<parseInt(G/2,10)&&n<parseInt(s/2,10))return!0}return 8191===G||8192===Q}function ze(e,t){var r,n,s,o,i=0,l=0,a=0,u=0;if(0!==G)do{7&i||(u=z[a++]),n=255&f[i++],1&u?(De((s=j[n])+fe+1,e),0!==(o=be[s])&&Qe(n-=X[s],o),De(s=Ne(r=c[l++]),t),0!==(o=ye[s])&&Qe(r-=L[s],o)):De(n,e),u>>=1}while(i<G);De(256,e)}var Ge=16;function Qe(e,t){h>Ge-t?(Re(d|=e<<h),d=e>>Ge-h,h+=t-Ge):(d|=e<<h,h+=t)}function Ve(e,t){var r=0;do{r|=1&e,e>>=1,r<<=1}while(--t>0);return r>>1}function Ye(){h>8?Re(d):h>0&&Me(d),d=0,h=0}e.exports=function(e,o){var i,l;te=e,re=0,void 0===o&&(o=6),function(e){var o;if(e?e<1?e=1:e>9&&(e=9):e=6,M=e,s=!1,C=!1,null===ge){for(t=r=n=null,ge=[],a=[],c=[],f=[],u=[],D=[],o=0;o<573;o++)D[o]=new me;for(N=[],o=0;o<61;o++)N[o]=new me;for(k=[],o=0;o<288;o++)k[o]=new me;for(F=[],o=0;o<de;o++)F[o]=new me;for(A=[],o=0;o<39;o++)A[o]=new me;U=new pe,q=new pe,H=new pe,I=[],O=[],J=[],j=[],W=[],X=[],L=[],z=[]}}(o),l=[];do{i=He(l,l.length,1024)}while(i>0);return te=null,l},e.exports.DEFAULT_LEVEL=6}()},967(e){!function(){var t,r,n,s,o,i,l,a,c,f,u,d,h,g,m,p,v,w=null,b=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],y=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],S=[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,99,99],_=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],C=[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],P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function x(){this.next=null,this.list=null}function T(){this.e=0,this.b=0,this.n=0,this.t=null}function M(e,t,r,n,s,o){var i;this.BMAX=16,this.N_MAX=288,this.status=0,this.root=null,this.m=0;var l,a,c,f,u,d,h,g,m,p,v,w,b,y,S,_,C=[],P=[],M=new T,R=[],E=[],D=[];for(_=this.root=null,u=0;u<this.BMAX+1;u++)C[u]=0;for(u=0;u<this.BMAX+1;u++)P[u]=0;for(u=0;u<this.BMAX;u++)R[u]=null;for(u=0;u<this.N_MAX;u++)E[u]=0;for(u=0;u<this.BMAX+1;u++)D[u]=0;l=t>256?e[256]:this.BMAX,g=e,m=0,u=t;do{C[g[m]]++,m++}while(--u>0);if(C[0]===t)return this.root=null,this.m=0,void(this.status=0);for(d=1;d<=this.BMAX&&0===C[d];d++);for(h=d,o<d&&(o=d),u=this.BMAX;0!==u&&0===C[u];u--);for(c=u,o>u&&(o=u),b=1<<d;d<u;d++,b<<=1)if((b-=C[d])<0)return this.status=2,void(this.m=o);if((b-=C[u])<0)return this.status=2,void(this.m=o);for(C[u]+=b,D[1]=d=0,g=C,m=1,w=2;--u>0;)D[w++]=d+=g[m++];g=e,m=0,u=0;do{0!==(d=g[m++])&&(E[D[d]++]=u)}while(++u<t);for(t=D[c],D[0]=u=0,g=E,m=0,f=-1,v=P[0]=0,p=null,y=0;h<=c;h++)for(i=C[h];i-- >0;){for(;h>v+P[1+f];){if(v+=P[1+f],f++,y=(y=c-v)>o?o:y,(a=1<<(d=h-v))>i+1)for(a-=i+1,w=h;++d<y&&!((a<<=1)<=C[++w]);)a-=C[w];for(v+d>l&&v<l&&(d=l-v),y=1<<d,P[1+f]=d,p=[],S=0;S<y;S++)p[S]=new T;(_=_?_.next=new x:this.root=new x).next=null,_.list=p,R[f]=p,f>0&&(D[f]=u,M.b=P[f],M.e=16+d,M.t=p,d=(u&(1<<v)-1)>>v-P[f],R[f-1][d].e=M.e,R[f-1][d].b=M.b,R[f-1][d].n=M.n,R[f-1][d].t=M.t)}for(M.b=h-v,m>=t?M.e=99:g[m]<r?(M.e=g[m]<256?16:15,M.n=g[m++]):(M.e=s[g[m]-r],M.n=n[g[m++]-r]),a=1<<h-v,d=u>>v;d<y;d+=a)p[d].e=M.e,p[d].b=M.b,p[d].n=M.n,p[d].t=M.t;for(d=1<<h-1;u&d;d>>=1)u^=d;for(u^=d;(u&(1<<v)-1)!==D[f];)v-=P[f],f--}this.m=P[1],this.status=0!==b&&1!==c?1:0}function R(e){for(;l<e;)i|=(p.length===v?-1:255&p[v++])<<l,l+=8}function E(e){return i&b[e]}function D(e){i>>=e,l-=e}function N(e,n,s){var o,i,l;if(0===s)return 0;for(l=0;;){for(R(g),o=(i=d.list[E(g)]).e;o>16;){if(99===o)return-1;D(i.b),R(o-=16),o=(i=i.t[E(o)]).e}if(D(i.b),16!==o){if(15===o)break;for(R(o),f=i.n+E(o),D(o),R(m),o=(i=h.list[E(m)]).e;o>16;){if(99===o)return-1;D(i.b),R(o-=16),o=(i=i.t[E(o)]).e}for(D(i.b),R(o),u=r-i.n-E(o),D(o);f>0&&l<s;)f--,u&=32767,r&=32767,e[n+l++]=t[r++]=t[u++];if(l===s)return s}else if(r&=32767,e[n+l++]=t[r++]=i.n,l===s)return s}return a=-1,l}function k(e,n,s){var o;if(D(o=7&l),R(16),o=E(16),D(16),R(16),o!==(65535&~i))return-1;for(D(16),f=o,o=0;f>0&&o<s;)f--,r&=32767,R(8),e[n+o++]=t[r++]=E(8),D(8);return 0===f&&(a=-1),o}function F(e,t,r){if(!w){var i,l,a=[];for(i=0;i<144;i++)a[i]=8;for(;i<256;i++)a[i]=9;for(;i<280;i++)a[i]=7;for(;i<288;i++)a[i]=8;if(0!==(l=new M(a,288,257,y,S,s=7)).status)return console.error("HufBuild error: "+l.status),-1;for(w=l.root,s=l.m,i=0;i<30;i++)a[i]=5;if((l=new M(a,30,0,_,C,o=5)).status>1)return w=null,console.error("HufBuild error: "+l.status),-1;n=l.root,o=l.m}return d=w,h=n,g=s,m=o,N(e,t,r)}function A(e,t,r){var n,s,o,i,l,a,c,f,u,p=[];for(n=0;n<316;n++)p[n]=0;if(R(5),c=257+E(5),D(5),R(5),f=1+E(5),D(5),R(4),a=4+E(4),D(4),c>286||f>30)return-1;for(s=0;s<a;s++)R(3),p[P[s]]=E(3),D(3);for(;s<19;s++)p[P[s]]=0;if(0!==(u=new M(p,19,19,null,null,g=7)).status)return-1;for(d=u.root,g=u.m,i=c+f,n=o=0;n<i;)if(R(g),D(s=(l=d.list[E(g)]).b),(s=l.n)<16)p[n++]=o=s;else if(16===s){if(R(2),s=3+E(2),D(2),n+s>i)return-1;for(;s-- >0;)p[n++]=o}else if(17===s){if(R(3),s=3+E(3),D(3),n+s>i)return-1;for(;s-- >0;)p[n++]=0;o=0}else{if(R(7),s=11+E(7),D(7),n+s>i)return-1;for(;s-- >0;)p[n++]=0;o=0}if(u=new M(p,c,257,y,S,g=9),0===g&&(u.status=1),0!==u.status&&1!==u.status)return-1;for(d=u.root,g=u.m,n=0;n<f;n++)p[n]=p[n+c];return u=new M(p,f,0,_,C,m=6),h=u.root,0===(m=u.m)&&c>257||0!==u.status?-1:N(e,t,r)}function U(e,n,s){var o,i;for(o=0;o<s;){if(c&&-1===a)return o;if(f>0){if(0!==a)for(;f>0&&o<s;)f--,u&=32767,r&=32767,e[n+o++]=t[r++]=t[u++];else{for(;f>0&&o<s;)f--,r&=32767,R(8),e[n+o++]=t[r++]=E(8),D(8);0===f&&(a=-1)}if(o===s)return o}if(-1===a){if(c)break;R(1),0!==E(1)&&(c=!0),D(1),R(2),a=E(2),D(2),d=null,f=0}switch(a){case 0:i=k(e,n+o,s-o);break;case 1:i=d?N(e,n+o,s-o):F(e,n+o,s-o);break;case 2:i=d?N(e,n+o,s-o):A(e,n+o,s-o);break;default:i=-1}if(-1===i)return c?0:-1;o+=i}return o}e.exports=function(e){var n,s=[];t||(t=[]),r=0,i=0,l=0,a=-1,c=!1,f=u=0,d=null,p=e,v=0;do{n=U(s,s.length,1024)}while(n>0);return p=null,s}}()}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";function e(e,t=void 0,r=void 0,n=""){if(e){if(t){let i="";r&&(i=`<input type='hidden' name='${r}' value='${n}'>`);var s="<body onload='document.getElementById(\"frmRedirect\").submit();'><form method='post' id='frmRedirect' action='"+t+"'>"+i+"</form></body>",o=e.contentWindow?.document;o?.open(),o?.write(s),o?.close()}}else{const e="iFrameElement not accessible";console.error(e)}}function t(e){return s(o(e).map((e=>e.charCodeAt(0))))}function s(e){return decodeURIComponent(e.map((function(e){return"%"+("00"+e.toString(16)).slice(-2)})).join(""))}function o(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");return window.atob(t).split("")}r.r(n),r.d(n,{CardData:()=>CardData,ClientAuthenticatedMessage:()=>ClientAuthenticatedMessage,ClientChallengeRequiredMessage:()=>ClientChallengeRequiredMessage,ClientFingerPrintRequiredMessage:()=>ClientFingerPrintRequiredMessage,ClientMessage:()=>ClientMessage,ClientTechnicalProblemDetectedMessage:()=>ClientTechnicalProblemDetectedMessage,Engine:()=>Engine});var i=r(612);function l(e){const r=e.split(".");if(3!==r.length)return;const n=t(r[0]),l=JSON.parse(n);var a=t(r[1]);if("Def"===l?.cmp){var c=JSON.parse(a),f=o(c).map((e=>e.charCodeAt(0)));a=s(i.inflate(f))}return JSON.parse(a)}class CardData{cardType;cardNumber;expirationYear;expirationMonth;cardHolderName;securityCode;issueNumber;ownerId;customerEmail;customerPhone;billingAddress}class ClientMessage{messageType;providerName}class ClientAuthenticatedMessage extends ClientMessage{threeDS}class ClientFingerPrintRequiredMessage extends ClientMessage{fingerPrintUri;fingerPrintData}class ClientChallengeRequiredMessage extends ClientMessage{ascUri}class ClientTechnicalProblemDetectedMessage extends ClientMessage{reason;reference}class Engine{_oldModelStyle=!0;createSessionUrl;getChallengeResultsUrl;getFingerpringResultsUrl;sessionToken;backgroundPollingInterval;timerPollingHandle;stopPollingSemaphore=!1;iFrame;_providerName;_cyberSourceJwt;_options;resolver;_supportedCardBrands;constructor(e="https://api.epaytools.com",t=void 0){this.createSessionUrl=`${e}/threeDsSessions/init`,this.getChallengeResultsUrl=`${e}/threeDsSessions/challengeStatus`,this.getFingerpringResultsUrl=`${e}/threeDsSessions/fingerPrintStatus?isNotified=false`,this._options=t}async perform3ds(e,t,r,n=void 0){if(!t||!e){const e="iFrameElementId or sessionToken are empty; quitting";return console.error(e),Promise.reject(e)}if(!r&&!n){const e="Both cardData and cardToken are empty; quitting";return console.error(e),Promise.reject(e)}if(!this.parseSessionToken(e)){const e="Token could not be parsed; quitting";return console.error(e),Promise.reject(e)}if(r&&(!r.cardType||!this._supportedCardBrands.includes(r.cardType))){console.warn(`Card brand: ${r?.cardType} is not enrolled for 3ds`);const e={messageType:"CardNotEnrolled",providerName:"Unknown"};this.resolver(e)}const s=document.querySelector(t);if(!s){const e=t+" not accessible";return console.error(e),Promise.reject(e)}return this.iFrame=this.forceCast(s),this.sessionToken=e,this.init3DSecAuthSession(r,n),new Promise(((e,t)=>{this.resolver=e}))}onPresentingGui;parseSessionToken(e){const t=l(e);if(!t.pld)return console.log(`Cannot parse token. Ignored: ${e}`),!1;const r=t.pld.url;return r?(this._supportedCardBrands=t.pld.brnd3ds||t.pld.brnd,this._oldModelStyle=!1,this.createSessionUrl=`${r}/start3ds`,this.getChallengeResultsUrl=`${r}/challengeStatus`,this.getFingerpringResultsUrl=`${r}/fingerPrintStatus`,!0):(console.log(`Cannot obtain url from token. Ignored: ${e}`),!1)}init3DSecAuthSession(e,t){let r;if(this._oldModelStyle){if(!e)throw new Error("cardData is empty");const t=this.forceCast(e);t.windowWidth=self.innerWidth,t.windowHeight=self.innerHeight,t.timeZoneOffsetMinutes=(new Date).getTimezoneOffset(),t.colorDepth=screen.colorDepth,t.browserScreenWidth=screen.availWidth,t.browserScreenHeight=screen.availHeight,t.browserJavaEnabled=!1,e?.customerEmail&&(t.customerEmail=e.customerEmail),e?.customerPhone&&(t.customerPhone=e.customerPhone),r=JSON.stringify(t)}else{const n={card:e?{type:e.cardType,number:e.cardNumber,expirationMonth:e.expirationMonth,expirationYear:e.expirationYear,securityCode:e.securityCode,nameOnCard:e.cardHolderName,issueNumber:e.issueNumber,ownerId:e.ownerId}:void 0,cardToken:t,browserProperties:{windowWidth:self.innerWidth,windowHeight:self.innerHeight,timeZoneOffsetMinutes:(new Date).getTimezoneOffset(),colorDepth:screen.colorDepth,browserScreenWidth:screen.availWidth,browserScreenHeight:screen.availHeight,browserJavaEnabled:!1},customerEmail:e?.customerEmail,customerPhone:e?.customerPhone,billingAddress:e?.billingAddress};r=JSON.stringify(n)}const n=new XMLHttpRequest;n.onload=()=>{if(n.status<300){var e=JSON.parse(n.responseText);this.handleInitSessionResponse(e)}else this.handleError("Status:"+n.status+"; "+n.responseText,"init3DSecAuthSession Error")},n.ontimeout=()=>{this.handleError("Http post request timed out","init3DSecAuthSession")},n.open("POST",this.createSessionUrl,!0),n.timeout=2e4,n.setRequestHeader("Content-type","application/json"),n.setRequestHeader("Authorization","Bearer "+this.sessionToken),n.send(r)}handleInitSessionResponse(t){if(0!=t.success)switch(console.log(`init: Recieved ${t.clientMessage.messageType} message from server; ProviderName: ${t.clientMessage.providerName}`),this._providerName=t.clientMessage.providerName,t.clientMessage.messageType){case"TechnicalProblem":case"Rejected":case"Authenticated":case"AttemptWithoutAuthentication":case"CardNotEnrolled":this.resolver(t.clientMessage);break;case"ChallengeRequired":this.sessionToken=t.token;const r=this.forceCast(t.clientMessage);this.performChallenge(r.ascUri);break;case"FingerPrintRequired":this.sessionToken=t.token,console.log("Creating a fingerprint iFrame");const n=document.createElement("iframe");n.style.display="none",n.style.width="10",n.style.height="10","CyberSource"==this._providerName?window.onmessage=e=>{"https://centinelapistag.cardinalcommerce.com"===e.origin&&(console.log(e.data),this.getStatusResult(this.getFingerpringResultsUrl))}:setTimeout((()=>this.startPollResults(this.getFingerpringResultsUrl)),1e3),document.body.appendChild(n);const s=this.forceCast(t.clientMessage);let o,i;if("Shift4"==this._providerName)o="threeDSMethodData",i=s.fingerPrintData;else{if("CyberSource"!=this._providerName){const e="Unknown 3ds Provider: "+this._providerName;throw console.error(e),new Error(e)}s.fingerPrintData.split("|");i=this.getCyberSourceJwt(s),this._cyberSourceJwt=i,o="JWT"}e(n,s.fingerPrintUri,o,i),this.timerPollingHandle=window.setTimeout((()=>{this.stopPollingResults(),n.parentNode?.removeChild(n),this.handleError("Timeout on receiving response after creating a fingerprint iFrame","fingerprintrequired")}),2e4);break;default:const l="Received unknown message - "+t.clientMessage.messageType;throw console.error(l),new Error(l)}else{console.error(`Received an error from api: ${t.message}`);const e={messageType:"TechnicalProblem",reason:t.message,reference:"",providerName:"Unknown"};this.resolver(e)}}startPollResults(e){this.stopPollingSemaphore=!1,this.backgroundPollingInterval=window.setTimeout((e=>this.getStatusResult(e)),2e3,e)}getStatusResult(e){const t=new XMLHttpRequest;t.onload=()=>{if(t.status<300){const r=JSON.parse(t.responseText);if(console.log("Received message: "+r.messageType),"NoResponse"===r.messageType)return void(this.stopPollingSemaphore?(console.log("Response not ready yet; Stop polling was signalled => polling stopped"),this.handleError("Timeout while Polling results","Polling timeout")):(console.log("Response not ready yet; Keep on polling"),this.startPollResults(e)));if(console.log("Response received; Stop polling and handle message"),this.stopPollingResults(),"ChallengeRequired"===r.messageType){const e=this.forceCast(r);this.performChallenge(e.ascUri)}else{const e=this.forceCast(r);this.handleServerResultMessage(e)}}else this.handleError(t.responseText,"Polling error")},t.ontimeout=e=>{this.handleError("Http get request timed out from get Challenge status request","Polling")},t.open("GET",e,!0),t.timeout=2e4,t.setRequestHeader("Authorization","Bearer "+this.sessionToken),t.send()}getCyberSourceJwt(e){const t=e.fingerPrintData?.split("|");return t?.length>1?t[1]:""}performChallenge(t){if(this.onPresentingGui?.(!0),this.timerPollingHandle=window.setTimeout((()=>{this.iFrame.style.display="none",this.handleError("Timeout on receiving response after creating a challenge iFrame","challengerequired")}),6e5),console.log("Creating a challenge iFrame"),this._options&&this._options.postMessageTarget){const e=this._options.postMessageTarget;this.iFrame.onload=()=>{console.log("3DS challenge iframe loaded");parent.postMessage({messageType:"ThreeDsChallengeLoaded"},e),this.iFrame.onload=null}}if(this._options&&this._options.displayChallengeFormWithinPage?this.scrollToElement(this.iFrame):(this.iFrame.style.position="fixed",this.iFrame.style.zIndex="99999",this.iFrame.style.width="100%",this.iFrame.style.height="100%"),this.iFrame.style.display="inline","Shift4"===this._providerName)this.iFrame.setAttribute("src",t),this.startPollResults(this.getChallengeResultsUrl);else{if("CyberSource"!==this._providerName){const e="Unknown 3ds Provider: "+this._providerName;throw console.error(e),new Error(e)}r=this.iFrame,n=e=>{const[t,r]=this.getPathAndQueryStringParamsFromUrl(e);console.log(`Received callback to new src: ${e}; Path is: ${t}; QS: ${r}`),"/results"==t?this.getStatusResult(this.getChallengeResultsUrl+r):console.warn("Path is not '/results'; ignoring")},new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&"src"===e.attributeName&&(console.log("iframe src changed to:",r.src),n(r.src))}))})).observe(r,{attributes:!0,attributeFilter:["src"]}),e(this.iFrame,"https://centinelapistag.cardinalcommerce.com/V2/Cruise/StepUp","JWT",this._cyberSourceJwt)}var r,n}getPathAndQueryStringParamsFromUrl(e){try{const t=new URL(e);return[t.pathname,t.search]}catch(e){return console.error("Invalid URL:",e),[void 0,void 0]}}scrollToElement(e){e?(document.documentElement.style.scrollBehavior="smooth",e.scrollIntoView({behavior:"smooth"})):console.warn("Element not found")}stopPollingResults(){console.log("Signalling a Stop polling and stopping a possible pending poll"),this.onPresentingGui?.(!1),this.stopPollingSemaphore=!0,window.clearTimeout(this.backgroundPollingInterval),window.clearTimeout(this.timerPollingHandle)}handleServerResultMessage(e){console.log("3DS: Received "+e.messageType+" message from server"),this.iFrame.style.display="none",this.resolver(e)}handleError(e,t){console.error(t+": "+e);const r=new ClientTechnicalProblemDetectedMessage;r.messageType="TechnicalProblem",r.reason=e,r.reference=t,this.resolver(r)}forceCast(e){return e}}})(),n})()));
//# sourceMappingURL=index.js.map