@botpoison/browser 0.1.33 → 0.2.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/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ declare global {
11
11
  interface Window {
12
12
  __BOTPOISON_VERSION__: string | undefined;
13
13
  __BOTPOISON_SUBMIT_LISTENER__: boolean | undefined;
14
+ __BOTPOISON_SESSION_OPENED__: boolean | undefined;
14
15
  }
15
16
  }
16
17
  type BotpoisonOptions = {
@@ -25,7 +26,6 @@ declare class Botpoison {
25
26
  private readonly baseUrl?;
26
27
  constructor({ publicKey, baseUrl }: BotpoisonOptions);
27
28
  static init(): void;
28
- prepare(): Promise<void>;
29
29
  challenge(options?: ChallengeOptions): Promise<{
30
30
  solution: string;
31
31
  }>;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var __botpoison=(()=>{var ZF=Object.create;var dF=Object.defineProperty;var QF=Object.getOwnPropertyDescriptor;var F0=Object.getOwnPropertyNames;var t0=Object.getPrototypeOf,h0=Object.prototype.hasOwnProperty;var x0=(s,n)=>()=>(n||s((n={exports:{}}).exports,n),n.exports),e0=(s,n)=>{for(var c in n)dF(s,c,{get:n[c],enumerable:!0})},MF=(s,n,c,A)=>{if(n&&typeof n=="object"||typeof n=="function")for(let S of F0(n))!h0.call(s,S)&&S!==c&&dF(s,S,{get:()=>n[S],enumerable:!(A=QF(n,S))||A.enumerable});return s};var i0=(s,n,c)=>(c=s!=null?ZF(t0(s)):{},MF(n||!s||!s.__esModule?dF(c,"default",{value:s,enumerable:!0}):c,s)),s0=s=>MF(dF({},"__esModule",{value:!0}),s);var HF=x0((p0,yF)=>{"use strict";(function(){"use strict";var s="input is invalid type",n="finalize already called",c=typeof window=="object",A=c?window:{};A.JS_SHA512_NO_WINDOW&&(c=!1);var S=!c&&typeof self=="object",b=!A.JS_SHA512_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;b?A=global:S&&(A=self);var k=!A.JS_SHA512_NO_COMMON_JS&&typeof yF=="object"&&yF.exports,nF=typeof define=="function"&&define.amd,oF=!A.JS_SHA512_NO_ARRAY_BUFFER&&typeof ArrayBuffer!="undefined",F="0123456789abcdef".split(""),XF=[-2147483648,8388608,32768,128],rF=[24,16,8,0],lF=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],EF=["hex","array","digest","arrayBuffer"],d=[];(A.JS_SHA512_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(t){return Object.prototype.toString.call(t)==="[object Array]"}),oF&&(A.JS_SHA512_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer});var RF=function(t,r){return function(o){return new v(r,!0).update(o)[t]()}},pF=function(t){var r=RF("hex",t);r.create=function(){return new v(t)},r.update=function(B){return r.create().update(B)};for(var o=0;o<EF.length;++o){var E=EF[o];r[E]=RF(E,t)}return r},LF=function(t,r){return function(o,E){return new aF(o,r,!0).update(E)[t]()}},AF=function(t){var r=LF("hex",t);r.create=function(B){return new aF(B,t)},r.update=function(B,l){return r.create(B).update(l)};for(var o=0;o<EF.length;++o){var E=EF[o];r[E]=LF(E,t)}return r};function v(t,r){r?(d[0]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=d[16]=d[17]=d[18]=d[19]=d[20]=d[21]=d[22]=d[23]=d[24]=d[25]=d[26]=d[27]=d[28]=d[29]=d[30]=d[31]=d[32]=0,this.blocks=d):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t==384?(this.h0h=3418070365,this.h0l=3238371032,this.h1h=1654270250,this.h1l=914150663,this.h2h=2438529370,this.h2l=812702999,this.h3h=355462360,this.h3l=4144912697,this.h4h=1731405415,this.h4l=4290775857,this.h5h=2394180231,this.h5l=1750603025,this.h6h=3675008525,this.h6l=1694076839,this.h7h=1203062813,this.h7l=3204075428):t==256?(this.h0h=573645204,this.h0l=4230739756,this.h1h=2673172387,this.h1l=3360449730,this.h2h=596883563,this.h2l=1867755857,this.h3h=2520282905,this.h3l=1497426621,this.h4h=2519219938,this.h4l=2827943907,this.h5h=3193839141,this.h5l=1401305490,this.h6h=721525244,this.h6l=746961066,this.h7h=246885852,this.h7l=2177182882):t==224?(this.h0h=2352822216,this.h0l=424955298,this.h1h=1944164710,this.h1l=2312950998,this.h2h=502970286,this.h2l=855612546,this.h3h=1738396948,this.h3l=1479516111,this.h4h=258812777,this.h4l=2077511080,this.h5h=2011393907,this.h5l=79989058,this.h6h=1067287976,this.h6l=1780299464,this.h7h=286451373,this.h7l=2446758561):(this.h0h=1779033703,this.h0l=4089235720,this.h1h=3144134277,this.h1l=2227873595,this.h2h=1013904242,this.h2l=4271175723,this.h3h=2773480762,this.h3l=1595750129,this.h4h=1359893119,this.h4l=2917565137,this.h5h=2600822924,this.h5l=725511199,this.h6h=528734635,this.h6l=4215389547,this.h7h=1541459225,this.h7l=327033209),this.bits=t,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1}v.prototype.update=function(t){if(this.finalized)throw new Error(n);var r,o=typeof t;if(o!=="string"){if(o==="object"){if(t===null)throw new Error(s);if(oF&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!oF||!ArrayBuffer.isView(t)))throw new Error(s)}else throw new Error(s);r=!0}for(var E,B=0,l,_=t.length,i=this.blocks;B<_;){if(this.hashed&&(this.hashed=!1,i[0]=this.block,i[1]=i[2]=i[3]=i[4]=i[5]=i[6]=i[7]=i[8]=i[9]=i[10]=i[11]=i[12]=i[13]=i[14]=i[15]=i[16]=i[17]=i[18]=i[19]=i[20]=i[21]=i[22]=i[23]=i[24]=i[25]=i[26]=i[27]=i[28]=i[29]=i[30]=i[31]=i[32]=0),r)for(l=this.start;B<_&&l<128;++B)i[l>>2]|=t[B]<<rF[l++&3];else for(l=this.start;B<_&&l<128;++B)E=t.charCodeAt(B),E<128?i[l>>2]|=E<<rF[l++&3]:E<2048?(i[l>>2]|=(192|E>>6)<<rF[l++&3],i[l>>2]|=(128|E&63)<<rF[l++&3]):E<55296||E>=57344?(i[l>>2]|=(224|E>>12)<<rF[l++&3],i[l>>2]|=(128|E>>6&63)<<rF[l++&3],i[l>>2]|=(128|E&63)<<rF[l++&3]):(E=65536+((E&1023)<<10|t.charCodeAt(++B)&1023),i[l>>2]|=(240|E>>18)<<rF[l++&3],i[l>>2]|=(128|E>>12&63)<<rF[l++&3],i[l>>2]|=(128|E>>6&63)<<rF[l++&3],i[l>>2]|=(128|E&63)<<rF[l++&3]);this.lastByteIndex=l,this.bytes+=l-this.start,l>=128?(this.block=i[32],this.start=l-128,this.hash(),this.hashed=!0):this.start=l}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this},v.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[32]=this.block,t[r>>2]|=XF[r&3],this.block=t[32],r>=112&&(this.hashed||this.hash(),t[0]=this.block,t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=t[16]=t[17]=t[18]=t[19]=t[20]=t[21]=t[22]=t[23]=t[24]=t[25]=t[26]=t[27]=t[28]=t[29]=t[30]=t[31]=t[32]=0),t[30]=this.hBytes<<3|this.bytes>>>29,t[31]=this.bytes<<3,this.hash()}},v.prototype.hash=function(){var t=this.h0h,r=this.h0l,o=this.h1h,E=this.h1l,B=this.h2h,l=this.h2l,_=this.h3h,i=this.h3l,C=this.h4h,D=this.h4l,O=this.h5h,w=this.h5l,T=this.h6h,I=this.h6l,N=this.h7h,U=this.h7l,g=this.blocks,p,K,j,V,z,h,x,e,a,bF,vF,OF,wF,TF,IF,BF,CF,xF,eF,f,u,y,m,iF,sF;for(p=32;p<160;p+=2)f=g[p-30],u=g[p-29],K=(f>>>1|u<<31)^(f>>>8|u<<24)^f>>>7,j=(u>>>1|f<<31)^(u>>>8|f<<24)^(u>>>7|f<<25),f=g[p-4],u=g[p-3],V=(f>>>19|u<<13)^(u>>>29|f<<3)^f>>>6,z=(u>>>19|f<<13)^(f>>>29|u<<3)^(u>>>6|f<<26),f=g[p-32],u=g[p-31],y=g[p-14],m=g[p-13],h=(m&65535)+(u&65535)+(j&65535)+(z&65535),x=(m>>>16)+(u>>>16)+(j>>>16)+(z>>>16)+(h>>>16),e=(y&65535)+(f&65535)+(K&65535)+(V&65535)+(x>>>16),a=(y>>>16)+(f>>>16)+(K>>>16)+(V>>>16)+(e>>>16),g[p]=a<<16|e&65535,g[p+1]=x<<16|h&65535;var J=t,$=r,P=o,R=E,L=B,M=l,W=_,G=i,q=C,Y=D,X=O,Z=w,Q=T,FF=I,tF=N,hF=U;for(BF=P&L,CF=R&M,p=0;p<160;p+=8)K=(J>>>28|$<<4)^($>>>2|J<<30)^($>>>7|J<<25),j=($>>>28|J<<4)^(J>>>2|$<<30)^(J>>>7|$<<25),V=(q>>>14|Y<<18)^(q>>>18|Y<<14)^(Y>>>9|q<<23),z=(Y>>>14|q<<18)^(Y>>>18|q<<14)^(q>>>9|Y<<23),bF=J&P,vF=$&R,xF=bF^J&L^BF,eF=vF^$&M^CF,iF=q&X^~q&Q,sF=Y&Z^~Y&FF,f=g[p],u=g[p+1],y=lF[p],m=lF[p+1],h=(m&65535)+(u&65535)+(sF&65535)+(z&65535)+(hF&65535),x=(m>>>16)+(u>>>16)+(sF>>>16)+(z>>>16)+(hF>>>16)+(h>>>16),e=(y&65535)+(f&65535)+(iF&65535)+(V&65535)+(tF&65535)+(x>>>16),a=(y>>>16)+(f>>>16)+(iF>>>16)+(V>>>16)+(tF>>>16)+(e>>>16),f=a<<16|e&65535,u=x<<16|h&65535,h=(eF&65535)+(j&65535),x=(eF>>>16)+(j>>>16)+(h>>>16),e=(xF&65535)+(K&65535)+(x>>>16),a=(xF>>>16)+(K>>>16)+(e>>>16),y=a<<16|e&65535,m=x<<16|h&65535,h=(G&65535)+(u&65535),x=(G>>>16)+(u>>>16)+(h>>>16),e=(W&65535)+(f&65535)+(x>>>16),a=(W>>>16)+(f>>>16)+(e>>>16),tF=a<<16|e&65535,hF=x<<16|h&65535,h=(m&65535)+(u&65535),x=(m>>>16)+(u>>>16)+(h>>>16),e=(y&65535)+(f&65535)+(x>>>16),a=(y>>>16)+(f>>>16)+(e>>>16),W=a<<16|e&65535,G=x<<16|h&65535,K=(W>>>28|G<<4)^(G>>>2|W<<30)^(G>>>7|W<<25),j=(G>>>28|W<<4)^(W>>>2|G<<30)^(W>>>7|G<<25),V=(tF>>>14|hF<<18)^(tF>>>18|hF<<14)^(hF>>>9|tF<<23),z=(hF>>>14|tF<<18)^(hF>>>18|tF<<14)^(tF>>>9|hF<<23),OF=W&J,wF=G&$,xF=OF^W&P^bF,eF=wF^G&R^vF,iF=tF&q^~tF&X,sF=hF&Y^~hF&Z,f=g[p+2],u=g[p+3],y=lF[p+2],m=lF[p+3],h=(m&65535)+(u&65535)+(sF&65535)+(z&65535)+(FF&65535),x=(m>>>16)+(u>>>16)+(sF>>>16)+(z>>>16)+(FF>>>16)+(h>>>16),e=(y&65535)+(f&65535)+(iF&65535)+(V&65535)+(Q&65535)+(x>>>16),a=(y>>>16)+(f>>>16)+(iF>>>16)+(V>>>16)+(Q>>>16)+(e>>>16),f=a<<16|e&65535,u=x<<16|h&65535,h=(eF&65535)+(j&65535),x=(eF>>>16)+(j>>>16)+(h>>>16),e=(xF&65535)+(K&65535)+(x>>>16),a=(xF>>>16)+(K>>>16)+(e>>>16),y=a<<16|e&65535,m=x<<16|h&65535,h=(M&65535)+(u&65535),x=(M>>>16)+(u>>>16)+(h>>>16),e=(L&65535)+(f&65535)+(x>>>16),a=(L>>>16)+(f>>>16)+(e>>>16),Q=a<<16|e&65535,FF=x<<16|h&65535,h=(m&65535)+(u&65535),x=(m>>>16)+(u>>>16)+(h>>>16),e=(y&65535)+(f&65535)+(x>>>16),a=(y>>>16)+(f>>>16)+(e>>>16),L=a<<16|e&65535,M=x<<16|h&65535,K=(L>>>28|M<<4)^(M>>>2|L<<30)^(M>>>7|L<<25),j=(M>>>28|L<<4)^(L>>>2|M<<30)^(L>>>7|M<<25),V=(Q>>>14|FF<<18)^(Q>>>18|FF<<14)^(FF>>>9|Q<<23),z=(FF>>>14|Q<<18)^(FF>>>18|Q<<14)^(Q>>>9|FF<<23),TF=L&W,IF=M&G,xF=TF^L&J^OF,eF=IF^M&$^wF,iF=Q&tF^~Q&q,sF=FF&hF^~FF&Y,f=g[p+4],u=g[p+5],y=lF[p+4],m=lF[p+5],h=(m&65535)+(u&65535)+(sF&65535)+(z&65535)+(Z&65535),x=(m>>>16)+(u>>>16)+(sF>>>16)+(z>>>16)+(Z>>>16)+(h>>>16),e=(y&65535)+(f&65535)+(iF&65535)+(V&65535)+(X&65535)+(x>>>16),a=(y>>>16)+(f>>>16)+(iF>>>16)+(V>>>16)+(X>>>16)+(e>>>16),f=a<<16|e&65535,u=x<<16|h&65535,h=(eF&65535)+(j&65535),x=(eF>>>16)+(j>>>16)+(h>>>16),e=(xF&65535)+(K&65535)+(x>>>16),a=(xF>>>16)+(K>>>16)+(e>>>16),y=a<<16|e&65535,m=x<<16|h&65535,h=(R&65535)+(u&65535),x=(R>>>16)+(u>>>16)+(h>>>16),e=(P&65535)+(f&65535)+(x>>>16),a=(P>>>16)+(f>>>16)+(e>>>16),X=a<<16|e&65535,Z=x<<16|h&65535,h=(m&65535)+(u&65535),x=(m>>>16)+(u>>>16)+(h>>>16),e=(y&65535)+(f&65535)+(x>>>16),a=(y>>>16)+(f>>>16)+(e>>>16),P=a<<16|e&65535,R=x<<16|h&65535,K=(P>>>28|R<<4)^(R>>>2|P<<30)^(R>>>7|P<<25),j=(R>>>28|P<<4)^(P>>>2|R<<30)^(P>>>7|R<<25),V=(X>>>14|Z<<18)^(X>>>18|Z<<14)^(Z>>>9|X<<23),z=(Z>>>14|X<<18)^(Z>>>18|X<<14)^(X>>>9|Z<<23),BF=P&L,CF=R&M,xF=BF^P&W^TF,eF=CF^R&G^IF,iF=X&Q^~X&tF,sF=Z&FF^~Z&hF,f=g[p+6],u=g[p+7],y=lF[p+6],m=lF[p+7],h=(m&65535)+(u&65535)+(sF&65535)+(z&65535)+(Y&65535),x=(m>>>16)+(u>>>16)+(sF>>>16)+(z>>>16)+(Y>>>16)+(h>>>16),e=(y&65535)+(f&65535)+(iF&65535)+(V&65535)+(q&65535)+(x>>>16),a=(y>>>16)+(f>>>16)+(iF>>>16)+(V>>>16)+(q>>>16)+(e>>>16),f=a<<16|e&65535,u=x<<16|h&65535,h=(eF&65535)+(j&65535),x=(eF>>>16)+(j>>>16)+(h>>>16),e=(xF&65535)+(K&65535)+(x>>>16),a=(xF>>>16)+(K>>>16)+(e>>>16),y=a<<16|e&65535,m=x<<16|h&65535,h=($&65535)+(u&65535),x=($>>>16)+(u>>>16)+(h>>>16),e=(J&65535)+(f&65535)+(x>>>16),a=(J>>>16)+(f>>>16)+(e>>>16),q=a<<16|e&65535,Y=x<<16|h&65535,h=(m&65535)+(u&65535),x=(m>>>16)+(u>>>16)+(h>>>16),e=(y&65535)+(f&65535)+(x>>>16),a=(y>>>16)+(f>>>16)+(e>>>16),J=a<<16|e&65535,$=x<<16|h&65535;h=(r&65535)+($&65535),x=(r>>>16)+($>>>16)+(h>>>16),e=(t&65535)+(J&65535)+(x>>>16),a=(t>>>16)+(J>>>16)+(e>>>16),this.h0h=a<<16|e&65535,this.h0l=x<<16|h&65535,h=(E&65535)+(R&65535),x=(E>>>16)+(R>>>16)+(h>>>16),e=(o&65535)+(P&65535)+(x>>>16),a=(o>>>16)+(P>>>16)+(e>>>16),this.h1h=a<<16|e&65535,this.h1l=x<<16|h&65535,h=(l&65535)+(M&65535),x=(l>>>16)+(M>>>16)+(h>>>16),e=(B&65535)+(L&65535)+(x>>>16),a=(B>>>16)+(L>>>16)+(e>>>16),this.h2h=a<<16|e&65535,this.h2l=x<<16|h&65535,h=(i&65535)+(G&65535),x=(i>>>16)+(G>>>16)+(h>>>16),e=(_&65535)+(W&65535)+(x>>>16),a=(_>>>16)+(W>>>16)+(e>>>16),this.h3h=a<<16|e&65535,this.h3l=x<<16|h&65535,h=(D&65535)+(Y&65535),x=(D>>>16)+(Y>>>16)+(h>>>16),e=(C&65535)+(q&65535)+(x>>>16),a=(C>>>16)+(q>>>16)+(e>>>16),this.h4h=a<<16|e&65535,this.h4l=x<<16|h&65535,h=(w&65535)+(Z&65535),x=(w>>>16)+(Z>>>16)+(h>>>16),e=(O&65535)+(X&65535)+(x>>>16),a=(O>>>16)+(X>>>16)+(e>>>16),this.h5h=a<<16|e&65535,this.h5l=x<<16|h&65535,h=(I&65535)+(FF&65535),x=(I>>>16)+(FF>>>16)+(h>>>16),e=(T&65535)+(Q&65535)+(x>>>16),a=(T>>>16)+(Q>>>16)+(e>>>16),this.h6h=a<<16|e&65535,this.h6l=x<<16|h&65535,h=(U&65535)+(hF&65535),x=(U>>>16)+(hF>>>16)+(h>>>16),e=(N&65535)+(tF&65535)+(x>>>16),a=(N>>>16)+(tF>>>16)+(e>>>16),this.h7h=a<<16|e&65535,this.h7l=x<<16|h&65535},v.prototype.hex=function(){this.finalize();var t=this.h0h,r=this.h0l,o=this.h1h,E=this.h1l,B=this.h2h,l=this.h2l,_=this.h3h,i=this.h3l,C=this.h4h,D=this.h4l,O=this.h5h,w=this.h5l,T=this.h6h,I=this.h6l,N=this.h7h,U=this.h7l,g=this.bits,p=F[t>>28&15]+F[t>>24&15]+F[t>>20&15]+F[t>>16&15]+F[t>>12&15]+F[t>>8&15]+F[t>>4&15]+F[t&15]+F[r>>28&15]+F[r>>24&15]+F[r>>20&15]+F[r>>16&15]+F[r>>12&15]+F[r>>8&15]+F[r>>4&15]+F[r&15]+F[o>>28&15]+F[o>>24&15]+F[o>>20&15]+F[o>>16&15]+F[o>>12&15]+F[o>>8&15]+F[o>>4&15]+F[o&15]+F[E>>28&15]+F[E>>24&15]+F[E>>20&15]+F[E>>16&15]+F[E>>12&15]+F[E>>8&15]+F[E>>4&15]+F[E&15]+F[B>>28&15]+F[B>>24&15]+F[B>>20&15]+F[B>>16&15]+F[B>>12&15]+F[B>>8&15]+F[B>>4&15]+F[B&15]+F[l>>28&15]+F[l>>24&15]+F[l>>20&15]+F[l>>16&15]+F[l>>12&15]+F[l>>8&15]+F[l>>4&15]+F[l&15]+F[_>>28&15]+F[_>>24&15]+F[_>>20&15]+F[_>>16&15]+F[_>>12&15]+F[_>>8&15]+F[_>>4&15]+F[_&15];return g>=256&&(p+=F[i>>28&15]+F[i>>24&15]+F[i>>20&15]+F[i>>16&15]+F[i>>12&15]+F[i>>8&15]+F[i>>4&15]+F[i&15]),g>=384&&(p+=F[C>>28&15]+F[C>>24&15]+F[C>>20&15]+F[C>>16&15]+F[C>>12&15]+F[C>>8&15]+F[C>>4&15]+F[C&15]+F[D>>28&15]+F[D>>24&15]+F[D>>20&15]+F[D>>16&15]+F[D>>12&15]+F[D>>8&15]+F[D>>4&15]+F[D&15]+F[O>>28&15]+F[O>>24&15]+F[O>>20&15]+F[O>>16&15]+F[O>>12&15]+F[O>>8&15]+F[O>>4&15]+F[O&15]+F[w>>28&15]+F[w>>24&15]+F[w>>20&15]+F[w>>16&15]+F[w>>12&15]+F[w>>8&15]+F[w>>4&15]+F[w&15]),g==512&&(p+=F[T>>28&15]+F[T>>24&15]+F[T>>20&15]+F[T>>16&15]+F[T>>12&15]+F[T>>8&15]+F[T>>4&15]+F[T&15]+F[I>>28&15]+F[I>>24&15]+F[I>>20&15]+F[I>>16&15]+F[I>>12&15]+F[I>>8&15]+F[I>>4&15]+F[I&15]+F[N>>28&15]+F[N>>24&15]+F[N>>20&15]+F[N>>16&15]+F[N>>12&15]+F[N>>8&15]+F[N>>4&15]+F[N&15]+F[U>>28&15]+F[U>>24&15]+F[U>>20&15]+F[U>>16&15]+F[U>>12&15]+F[U>>8&15]+F[U>>4&15]+F[U&15]),p},v.prototype.toString=v.prototype.hex,v.prototype.digest=function(){this.finalize();var t=this.h0h,r=this.h0l,o=this.h1h,E=this.h1l,B=this.h2h,l=this.h2l,_=this.h3h,i=this.h3l,C=this.h4h,D=this.h4l,O=this.h5h,w=this.h5l,T=this.h6h,I=this.h6l,N=this.h7h,U=this.h7l,g=this.bits,p=[t>>24&255,t>>16&255,t>>8&255,t&255,r>>24&255,r>>16&255,r>>8&255,r&255,o>>24&255,o>>16&255,o>>8&255,o&255,E>>24&255,E>>16&255,E>>8&255,E&255,B>>24&255,B>>16&255,B>>8&255,B&255,l>>24&255,l>>16&255,l>>8&255,l&255,_>>24&255,_>>16&255,_>>8&255,_&255];return g>=256&&p.push(i>>24&255,i>>16&255,i>>8&255,i&255),g>=384&&p.push(C>>24&255,C>>16&255,C>>8&255,C&255,D>>24&255,D>>16&255,D>>8&255,D&255,O>>24&255,O>>16&255,O>>8&255,O&255,w>>24&255,w>>16&255,w>>8&255,w&255),g==512&&p.push(T>>24&255,T>>16&255,T>>8&255,T&255,I>>24&255,I>>16&255,I>>8&255,I&255,N>>24&255,N>>16&255,N>>8&255,N&255,U>>24&255,U>>16&255,U>>8&255,U&255),p},v.prototype.array=v.prototype.digest,v.prototype.arrayBuffer=function(){this.finalize();var t=this.bits,r=new ArrayBuffer(t/8),o=new DataView(r);return o.setUint32(0,this.h0h),o.setUint32(4,this.h0l),o.setUint32(8,this.h1h),o.setUint32(12,this.h1l),o.setUint32(16,this.h2h),o.setUint32(20,this.h2l),o.setUint32(24,this.h3h),t>=256&&o.setUint32(28,this.h3l),t>=384&&(o.setUint32(32,this.h4h),o.setUint32(36,this.h4l),o.setUint32(40,this.h5h),o.setUint32(44,this.h5l)),t==512&&(o.setUint32(48,this.h6h),o.setUint32(52,this.h6l),o.setUint32(56,this.h7h),o.setUint32(60,this.h7l)),r},v.prototype.clone=function(){var t=new v(this.bits,!1);return this.copyTo(t),t},v.prototype.copyTo=function(t){var r=0,o=["h0h","h0l","h1h","h1l","h2h","h2l","h3h","h3l","h4h","h4l","h5h","h5l","h6h","h6l","h7h","h7l","start","bytes","hBytes","finalized","hashed","lastByteIndex"];for(r=0;r<o.length;++r)t[o[r]]=this[o[r]];for(r=0;r<this.blocks.length;++r)t.blocks[r]=this.blocks[r]};function aF(t,r,o){var E,B=typeof t;if(B!=="string"){if(B==="object"){if(t===null)throw new Error(s);if(oF&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!oF||!ArrayBuffer.isView(t)))throw new Error(s)}else throw new Error(s);E=!0}var l=t.length;if(!E){for(var _=[],l=t.length,i=0,C,D=0;D<l;++D)C=t.charCodeAt(D),C<128?_[i++]=C:C<2048?(_[i++]=192|C>>6,_[i++]=128|C&63):C<55296||C>=57344?(_[i++]=224|C>>12,_[i++]=128|C>>6&63,_[i++]=128|C&63):(C=65536+((C&1023)<<10|t.charCodeAt(++D)&1023),_[i++]=240|C>>18,_[i++]=128|C>>12&63,_[i++]=128|C>>6&63,_[i++]=128|C&63);t=_}t.length>128&&(t=new v(r,!0).update(t).array());for(var O=[],w=[],D=0;D<128;++D){var T=t[D]||0;O[D]=92^T,w[D]=54^T}v.call(this,r,o),this.update(w),this.oKeyPad=O,this.inner=!0,this.sharedMemory=o}aF.prototype=new v,aF.prototype.finalize=function(){if(v.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();v.call(this,this.bits,this.sharedMemory),this.update(this.oKeyPad),this.update(t),v.prototype.finalize.call(this)}},aF.prototype.clone=function(){var t=new aF([],this.bits,!1);this.copyTo(t),t.inner=this.inner;for(var r=0;r<this.oKeyPad.length;++r)t.oKeyPad[r]=this.oKeyPad[r];return t};var H=pF(512);H.sha512=H,H.sha384=pF(384),H.sha512_256=pF(256),H.sha512_224=pF(224),H.sha512.hmac=AF(512),H.sha384.hmac=AF(384),H.sha512_256.hmac=AF(256),H.sha512_224.hmac=AF(224),k?yF.exports=H:(A.sha512=H.sha512,A.sha384=H.sha384,A.sha512_256=H.sha512_256,A.sha512_224=H.sha512_224,nF&&define(function(){return H}))})()});var a0={};e0(a0,{default:()=>SF});var _F="https://api.botpoison.com",fF="_botpoison";var kF=({formElement:s,value:n})=>{let c=s.querySelector(`input[name="${fF}"]`);if(!c){let A=s.ownerDocument;c=A.createElement("input"),c.setAttribute("type","hidden"),c.setAttribute("name",fF),A.getElementById(fF)||c.setAttribute("id",fF),s.appendChild(c)}return c.setAttribute("value",n),c},DF=({formElement:s,name:n})=>{s.dispatchEvent(new CustomEvent(`botpoison-challenge-${n}`))};var KF=i0(HF()),r0=async({input:s,expected:n})=>{let c=0;for(;;){let A=(0,KF.sha512)(`${s}:${c}`);if(c%4e4===0&&await jF(0),A.substring(0,n.length)===n)return c.toString();c++}},jF=s=>new Promise(n=>setTimeout(n,s)),n0=async({challenge:s,onProgress:n})=>{let{nonce:c,difficulty:A,hardness:S}=s.payload,b=[];n==null||n(0);for(let k=0;k<S;k++){let nF=await r0({input:`${c}:${k}`,expected:"0".repeat(A)});b.push(nF),n==null||n(b.length/S),await jF(0)}return b},VF=n0;var zF="_botpoison.v1.session.",cF,NF=new Map,JF=()=>{if(cF!==void 0)return cF;try{let s=window.sessionStorage,n=`${zF}probe`;s.setItem(n,"1"),s.removeItem(n),cF=s}catch(s){cF=null}return cF},uF=s=>`${zF}${s}`,UF=s=>{var c;let n=JF();if(!n)return NF.get(uF(s));try{return(c=n.getItem(uF(s)))!=null?c:void 0}catch(A){return NF.get(uF(s))}},$F=(s,n)=>{let c=JF();if(c)try{c.setItem(uF(s),n);return}catch(A){cF=null}NF.set(uF(s),n)};var PF=new Map,WF=s=>UF(s),mF=({publicKey:s,baseUrl:n=_F})=>{if(UF(s))return Promise.resolve();let c=PF.get(s);if(c)return c;let A=fetch(`${n}/session`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({publicKey:s,hostname:location.hostname,version:"0.1.33"})}).then(async S=>{if(!S.ok)return;let b=await S.json();b&&typeof b.token=="string"&&$F(s,b.token)}).catch(()=>{}).finally(()=>{PF.delete(s)});return PF.set(s,A),A};var gF=async({publicKey:s,baseUrl:n=_F,onProgress:c})=>{let S=await(await fetch(`${n}/challenge`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({publicKey:s,hostname:location.hostname,version:"0.1.33",token:WF(s)})})).json(),b=await VF({challenge:S,onProgress:c});return{solution:btoa(JSON.stringify({challenge:S,solutions:b}))}};var GF=s=>{if(!s||!s.tagName)return;let n=s;if(n.tagName!=="FORM")return;let c=n,A=c.dataset.botpoisonPublicKey;return A?{formElement:c,publicKey:A}:void 0},qF=({documentRef:s,baseUrl:n})=>{let c=S=>{try{let b=GF(S.target);if(!b)return;let{formElement:k,publicKey:nF}=b;S.preventDefault(),DF({formElement:k,name:"start"}),gF({publicKey:nF,baseUrl:n}).then(({solution:oF})=>{DF({formElement:k,name:"success"}),kF({formElement:k,value:oF}),HTMLFormElement.prototype.submit.call(k)}).catch(oF=>{console.error(oF),DF({formElement:k,name:"error"})})}catch(b){console.error(b)}},A=S=>{var b,k;try{let nF=GF((k=(b=S.target)==null?void 0:b.closest)==null?void 0:k.call(b,"form"));nF&&mF({publicKey:nF.publicKey,baseUrl:n})}catch(nF){console.error(nF)}};return s.addEventListener("submit",c),s.addEventListener("focusin",A),s.addEventListener("input",A),{dispose:()=>{s.removeEventListener("submit",c),s.removeEventListener("focusin",A),s.removeEventListener("input",A)}}};var YF=()=>{o0(),l0()},SF=class{constructor({publicKey:n,baseUrl:c}){this.publicKey=n,this.baseUrl=c}static init(){YF()}async prepare(){return mF({publicKey:this.publicKey,baseUrl:this.baseUrl})}async challenge(n){let{onProgress:c}=n||{};return gF({publicKey:this.publicKey,baseUrl:this.baseUrl,onProgress:c})}},o0=()=>{typeof document!="undefined"&&(window.__BOTPOISON_VERSION__="0.1.33")},l0=()=>{typeof document!="undefined"&&(window.__BOTPOISON_SUBMIT_LISTENER__||(window.__BOTPOISON_SUBMIT_LISTENER__=!0,qF({documentRef:document})))};YF();return s0(a0);})();
1
+ "use strict";var __botpoison=(()=>{var QF=Object.create;var DF=Object.defineProperty;var F0=Object.getOwnPropertyDescriptor;var t0=Object.getOwnPropertyNames;var h0=Object.getPrototypeOf,e0=Object.prototype.hasOwnProperty;var x0=(s,n)=>()=>(n||s((n={exports:{}}).exports,n),n.exports),i0=(s,n)=>{for(var a in n)DF(s,a,{get:n[a],enumerable:!0})},kF=(s,n,a,C)=>{if(n&&typeof n=="object"||typeof n=="function")for(let w of t0(n))!e0.call(s,w)&&w!==a&&DF(s,w,{get:()=>n[w],enumerable:!(C=F0(n,w))||C.enumerable});return s};var s0=(s,n,a)=>(a=s!=null?QF(h0(s)):{},kF(n||!s||!s.__esModule?DF(a,"default",{value:s,enumerable:!0}):a,s)),n0=s=>kF(DF({},"__esModule",{value:!0}),s);var MF=x0((d0,mF)=>{"use strict";(function(){"use strict";var s="input is invalid type",n="finalize already called",a=typeof window=="object",C=a?window:{};C.JS_SHA512_NO_WINDOW&&(a=!1);var w=!a&&typeof self=="object",tF=!C.JS_SHA512_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;tF?C=global:w&&(C=self);var nF=!C.JS_SHA512_NO_COMMON_JS&&typeof mF=="object"&&mF.exports,oF=typeof define=="function"&&define.amd,cF=!C.JS_SHA512_NO_ARRAY_BUFFER&&typeof ArrayBuffer!="undefined",F="0123456789abcdef".split(""),ZF=[-2147483648,8388608,32768,128],sF=[24,16,8,0],rF=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],AF=["hex","array","digest","arrayBuffer"],d=[];(C.JS_SHA512_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(t){return Object.prototype.toString.call(t)==="[object Array]"}),cF&&(C.JS_SHA512_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer});var UF=function(t,r){return function(o){return new g(r,!0).update(o)[t]()}},BF=function(t){var r=UF("hex",t);r.create=function(){return new g(t)},r.update=function(A){return r.create().update(A)};for(var o=0;o<AF.length;++o){var p=AF[o];r[p]=UF(p,t)}return r},RF=function(t,r){return function(o,p){return new lF(o,r,!0).update(p)[t]()}},CF=function(t){var r=RF("hex",t);r.create=function(A){return new lF(A,t)},r.update=function(A,l){return r.create(A).update(l)};for(var o=0;o<AF.length;++o){var p=AF[o];r[p]=RF(p,t)}return r};function g(t,r){r?(d[0]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=d[16]=d[17]=d[18]=d[19]=d[20]=d[21]=d[22]=d[23]=d[24]=d[25]=d[26]=d[27]=d[28]=d[29]=d[30]=d[31]=d[32]=0,this.blocks=d):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t==384?(this.h0h=3418070365,this.h0l=3238371032,this.h1h=1654270250,this.h1l=914150663,this.h2h=2438529370,this.h2l=812702999,this.h3h=355462360,this.h3l=4144912697,this.h4h=1731405415,this.h4l=4290775857,this.h5h=2394180231,this.h5l=1750603025,this.h6h=3675008525,this.h6l=1694076839,this.h7h=1203062813,this.h7l=3204075428):t==256?(this.h0h=573645204,this.h0l=4230739756,this.h1h=2673172387,this.h1l=3360449730,this.h2h=596883563,this.h2l=1867755857,this.h3h=2520282905,this.h3l=1497426621,this.h4h=2519219938,this.h4l=2827943907,this.h5h=3193839141,this.h5l=1401305490,this.h6h=721525244,this.h6l=746961066,this.h7h=246885852,this.h7l=2177182882):t==224?(this.h0h=2352822216,this.h0l=424955298,this.h1h=1944164710,this.h1l=2312950998,this.h2h=502970286,this.h2l=855612546,this.h3h=1738396948,this.h3l=1479516111,this.h4h=258812777,this.h4l=2077511080,this.h5h=2011393907,this.h5l=79989058,this.h6h=1067287976,this.h6l=1780299464,this.h7h=286451373,this.h7l=2446758561):(this.h0h=1779033703,this.h0l=4089235720,this.h1h=3144134277,this.h1l=2227873595,this.h2h=1013904242,this.h2l=4271175723,this.h3h=2773480762,this.h3l=1595750129,this.h4h=1359893119,this.h4l=2917565137,this.h5h=2600822924,this.h5l=725511199,this.h6h=528734635,this.h6l=4215389547,this.h7h=1541459225,this.h7l=327033209),this.bits=t,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1}g.prototype.update=function(t){if(this.finalized)throw new Error(n);var r,o=typeof t;if(o!=="string"){if(o==="object"){if(t===null)throw new Error(s);if(cF&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!cF||!ArrayBuffer.isView(t)))throw new Error(s)}else throw new Error(s);r=!0}for(var p,A=0,l,_=t.length,i=this.blocks;A<_;){if(this.hashed&&(this.hashed=!1,i[0]=this.block,i[1]=i[2]=i[3]=i[4]=i[5]=i[6]=i[7]=i[8]=i[9]=i[10]=i[11]=i[12]=i[13]=i[14]=i[15]=i[16]=i[17]=i[18]=i[19]=i[20]=i[21]=i[22]=i[23]=i[24]=i[25]=i[26]=i[27]=i[28]=i[29]=i[30]=i[31]=i[32]=0),r)for(l=this.start;A<_&&l<128;++A)i[l>>2]|=t[A]<<sF[l++&3];else for(l=this.start;A<_&&l<128;++A)p=t.charCodeAt(A),p<128?i[l>>2]|=p<<sF[l++&3]:p<2048?(i[l>>2]|=(192|p>>6)<<sF[l++&3],i[l>>2]|=(128|p&63)<<sF[l++&3]):p<55296||p>=57344?(i[l>>2]|=(224|p>>12)<<sF[l++&3],i[l>>2]|=(128|p>>6&63)<<sF[l++&3],i[l>>2]|=(128|p&63)<<sF[l++&3]):(p=65536+((p&1023)<<10|t.charCodeAt(++A)&1023),i[l>>2]|=(240|p>>18)<<sF[l++&3],i[l>>2]|=(128|p>>12&63)<<sF[l++&3],i[l>>2]|=(128|p>>6&63)<<sF[l++&3],i[l>>2]|=(128|p&63)<<sF[l++&3]);this.lastByteIndex=l,this.bytes+=l-this.start,l>=128?(this.block=i[32],this.start=l-128,this.hash(),this.hashed=!0):this.start=l}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this},g.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[32]=this.block,t[r>>2]|=ZF[r&3],this.block=t[32],r>=112&&(this.hashed||this.hash(),t[0]=this.block,t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=t[16]=t[17]=t[18]=t[19]=t[20]=t[21]=t[22]=t[23]=t[24]=t[25]=t[26]=t[27]=t[28]=t[29]=t[30]=t[31]=t[32]=0),t[30]=this.hBytes<<3|this.bytes>>>29,t[31]=this.bytes<<3,this.hash()}},g.prototype.hash=function(){var t=this.h0h,r=this.h0l,o=this.h1h,p=this.h1l,A=this.h2h,l=this.h2l,_=this.h3h,i=this.h3l,B=this.h4h,D=this.h4l,O=this.h5h,v=this.h5l,b=this.h6h,T=this.h6l,N=this.h7h,I=this.h7l,S=this.blocks,E,M,K,j,H,h,e,x,f,vF,bF,wF,TF,NF,IF,dF,_F,hF,eF,c,u,y,m,xF,iF;for(E=32;E<160;E+=2)c=S[E-30],u=S[E-29],M=(c>>>1|u<<31)^(c>>>8|u<<24)^c>>>7,K=(u>>>1|c<<31)^(u>>>8|c<<24)^(u>>>7|c<<25),c=S[E-4],u=S[E-3],j=(c>>>19|u<<13)^(u>>>29|c<<3)^c>>>6,H=(u>>>19|c<<13)^(c>>>29|u<<3)^(u>>>6|c<<26),c=S[E-32],u=S[E-31],y=S[E-14],m=S[E-13],h=(m&65535)+(u&65535)+(K&65535)+(H&65535),e=(m>>>16)+(u>>>16)+(K>>>16)+(H>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(M&65535)+(j&65535)+(e>>>16),f=(y>>>16)+(c>>>16)+(M>>>16)+(j>>>16)+(x>>>16),S[E]=f<<16|x&65535,S[E+1]=e<<16|h&65535;var z=t,J=r,P=o,U=p,R=A,k=l,V=_,$=i,W=B,G=D,Y=O,q=v,X=b,Z=T,Q=N,FF=I;for(dF=P&R,_F=U&k,E=0;E<160;E+=8)M=(z>>>28|J<<4)^(J>>>2|z<<30)^(J>>>7|z<<25),K=(J>>>28|z<<4)^(z>>>2|J<<30)^(z>>>7|J<<25),j=(W>>>14|G<<18)^(W>>>18|G<<14)^(G>>>9|W<<23),H=(G>>>14|W<<18)^(G>>>18|W<<14)^(W>>>9|G<<23),vF=z&P,bF=J&U,hF=vF^z&R^dF,eF=bF^J&k^_F,xF=W&Y^~W&X,iF=G&q^~G&Z,c=S[E],u=S[E+1],y=rF[E],m=rF[E+1],h=(m&65535)+(u&65535)+(iF&65535)+(H&65535)+(FF&65535),e=(m>>>16)+(u>>>16)+(iF>>>16)+(H>>>16)+(FF>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(xF&65535)+(j&65535)+(Q&65535)+(e>>>16),f=(y>>>16)+(c>>>16)+(xF>>>16)+(j>>>16)+(Q>>>16)+(x>>>16),c=f<<16|x&65535,u=e<<16|h&65535,h=(eF&65535)+(K&65535),e=(eF>>>16)+(K>>>16)+(h>>>16),x=(hF&65535)+(M&65535)+(e>>>16),f=(hF>>>16)+(M>>>16)+(x>>>16),y=f<<16|x&65535,m=e<<16|h&65535,h=($&65535)+(u&65535),e=($>>>16)+(u>>>16)+(h>>>16),x=(V&65535)+(c&65535)+(e>>>16),f=(V>>>16)+(c>>>16)+(x>>>16),Q=f<<16|x&65535,FF=e<<16|h&65535,h=(m&65535)+(u&65535),e=(m>>>16)+(u>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(e>>>16),f=(y>>>16)+(c>>>16)+(x>>>16),V=f<<16|x&65535,$=e<<16|h&65535,M=(V>>>28|$<<4)^($>>>2|V<<30)^($>>>7|V<<25),K=($>>>28|V<<4)^(V>>>2|$<<30)^(V>>>7|$<<25),j=(Q>>>14|FF<<18)^(Q>>>18|FF<<14)^(FF>>>9|Q<<23),H=(FF>>>14|Q<<18)^(FF>>>18|Q<<14)^(Q>>>9|FF<<23),wF=V&z,TF=$&J,hF=wF^V&P^vF,eF=TF^$&U^bF,xF=Q&W^~Q&Y,iF=FF&G^~FF&q,c=S[E+2],u=S[E+3],y=rF[E+2],m=rF[E+3],h=(m&65535)+(u&65535)+(iF&65535)+(H&65535)+(Z&65535),e=(m>>>16)+(u>>>16)+(iF>>>16)+(H>>>16)+(Z>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(xF&65535)+(j&65535)+(X&65535)+(e>>>16),f=(y>>>16)+(c>>>16)+(xF>>>16)+(j>>>16)+(X>>>16)+(x>>>16),c=f<<16|x&65535,u=e<<16|h&65535,h=(eF&65535)+(K&65535),e=(eF>>>16)+(K>>>16)+(h>>>16),x=(hF&65535)+(M&65535)+(e>>>16),f=(hF>>>16)+(M>>>16)+(x>>>16),y=f<<16|x&65535,m=e<<16|h&65535,h=(k&65535)+(u&65535),e=(k>>>16)+(u>>>16)+(h>>>16),x=(R&65535)+(c&65535)+(e>>>16),f=(R>>>16)+(c>>>16)+(x>>>16),X=f<<16|x&65535,Z=e<<16|h&65535,h=(m&65535)+(u&65535),e=(m>>>16)+(u>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(e>>>16),f=(y>>>16)+(c>>>16)+(x>>>16),R=f<<16|x&65535,k=e<<16|h&65535,M=(R>>>28|k<<4)^(k>>>2|R<<30)^(k>>>7|R<<25),K=(k>>>28|R<<4)^(R>>>2|k<<30)^(R>>>7|k<<25),j=(X>>>14|Z<<18)^(X>>>18|Z<<14)^(Z>>>9|X<<23),H=(Z>>>14|X<<18)^(Z>>>18|X<<14)^(X>>>9|Z<<23),NF=R&V,IF=k&$,hF=NF^R&z^wF,eF=IF^k&J^TF,xF=X&Q^~X&W,iF=Z&FF^~Z&G,c=S[E+4],u=S[E+5],y=rF[E+4],m=rF[E+5],h=(m&65535)+(u&65535)+(iF&65535)+(H&65535)+(q&65535),e=(m>>>16)+(u>>>16)+(iF>>>16)+(H>>>16)+(q>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(xF&65535)+(j&65535)+(Y&65535)+(e>>>16),f=(y>>>16)+(c>>>16)+(xF>>>16)+(j>>>16)+(Y>>>16)+(x>>>16),c=f<<16|x&65535,u=e<<16|h&65535,h=(eF&65535)+(K&65535),e=(eF>>>16)+(K>>>16)+(h>>>16),x=(hF&65535)+(M&65535)+(e>>>16),f=(hF>>>16)+(M>>>16)+(x>>>16),y=f<<16|x&65535,m=e<<16|h&65535,h=(U&65535)+(u&65535),e=(U>>>16)+(u>>>16)+(h>>>16),x=(P&65535)+(c&65535)+(e>>>16),f=(P>>>16)+(c>>>16)+(x>>>16),Y=f<<16|x&65535,q=e<<16|h&65535,h=(m&65535)+(u&65535),e=(m>>>16)+(u>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(e>>>16),f=(y>>>16)+(c>>>16)+(x>>>16),P=f<<16|x&65535,U=e<<16|h&65535,M=(P>>>28|U<<4)^(U>>>2|P<<30)^(U>>>7|P<<25),K=(U>>>28|P<<4)^(P>>>2|U<<30)^(P>>>7|U<<25),j=(Y>>>14|q<<18)^(Y>>>18|q<<14)^(q>>>9|Y<<23),H=(q>>>14|Y<<18)^(q>>>18|Y<<14)^(Y>>>9|q<<23),dF=P&R,_F=U&k,hF=dF^P&V^NF,eF=_F^U&$^IF,xF=Y&X^~Y&Q,iF=q&Z^~q&FF,c=S[E+6],u=S[E+7],y=rF[E+6],m=rF[E+7],h=(m&65535)+(u&65535)+(iF&65535)+(H&65535)+(G&65535),e=(m>>>16)+(u>>>16)+(iF>>>16)+(H>>>16)+(G>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(xF&65535)+(j&65535)+(W&65535)+(e>>>16),f=(y>>>16)+(c>>>16)+(xF>>>16)+(j>>>16)+(W>>>16)+(x>>>16),c=f<<16|x&65535,u=e<<16|h&65535,h=(eF&65535)+(K&65535),e=(eF>>>16)+(K>>>16)+(h>>>16),x=(hF&65535)+(M&65535)+(e>>>16),f=(hF>>>16)+(M>>>16)+(x>>>16),y=f<<16|x&65535,m=e<<16|h&65535,h=(J&65535)+(u&65535),e=(J>>>16)+(u>>>16)+(h>>>16),x=(z&65535)+(c&65535)+(e>>>16),f=(z>>>16)+(c>>>16)+(x>>>16),W=f<<16|x&65535,G=e<<16|h&65535,h=(m&65535)+(u&65535),e=(m>>>16)+(u>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(e>>>16),f=(y>>>16)+(c>>>16)+(x>>>16),z=f<<16|x&65535,J=e<<16|h&65535;h=(r&65535)+(J&65535),e=(r>>>16)+(J>>>16)+(h>>>16),x=(t&65535)+(z&65535)+(e>>>16),f=(t>>>16)+(z>>>16)+(x>>>16),this.h0h=f<<16|x&65535,this.h0l=e<<16|h&65535,h=(p&65535)+(U&65535),e=(p>>>16)+(U>>>16)+(h>>>16),x=(o&65535)+(P&65535)+(e>>>16),f=(o>>>16)+(P>>>16)+(x>>>16),this.h1h=f<<16|x&65535,this.h1l=e<<16|h&65535,h=(l&65535)+(k&65535),e=(l>>>16)+(k>>>16)+(h>>>16),x=(A&65535)+(R&65535)+(e>>>16),f=(A>>>16)+(R>>>16)+(x>>>16),this.h2h=f<<16|x&65535,this.h2l=e<<16|h&65535,h=(i&65535)+($&65535),e=(i>>>16)+($>>>16)+(h>>>16),x=(_&65535)+(V&65535)+(e>>>16),f=(_>>>16)+(V>>>16)+(x>>>16),this.h3h=f<<16|x&65535,this.h3l=e<<16|h&65535,h=(D&65535)+(G&65535),e=(D>>>16)+(G>>>16)+(h>>>16),x=(B&65535)+(W&65535)+(e>>>16),f=(B>>>16)+(W>>>16)+(x>>>16),this.h4h=f<<16|x&65535,this.h4l=e<<16|h&65535,h=(v&65535)+(q&65535),e=(v>>>16)+(q>>>16)+(h>>>16),x=(O&65535)+(Y&65535)+(e>>>16),f=(O>>>16)+(Y>>>16)+(x>>>16),this.h5h=f<<16|x&65535,this.h5l=e<<16|h&65535,h=(T&65535)+(Z&65535),e=(T>>>16)+(Z>>>16)+(h>>>16),x=(b&65535)+(X&65535)+(e>>>16),f=(b>>>16)+(X>>>16)+(x>>>16),this.h6h=f<<16|x&65535,this.h6l=e<<16|h&65535,h=(I&65535)+(FF&65535),e=(I>>>16)+(FF>>>16)+(h>>>16),x=(N&65535)+(Q&65535)+(e>>>16),f=(N>>>16)+(Q>>>16)+(x>>>16),this.h7h=f<<16|x&65535,this.h7l=e<<16|h&65535},g.prototype.hex=function(){this.finalize();var t=this.h0h,r=this.h0l,o=this.h1h,p=this.h1l,A=this.h2h,l=this.h2l,_=this.h3h,i=this.h3l,B=this.h4h,D=this.h4l,O=this.h5h,v=this.h5l,b=this.h6h,T=this.h6l,N=this.h7h,I=this.h7l,S=this.bits,E=F[t>>28&15]+F[t>>24&15]+F[t>>20&15]+F[t>>16&15]+F[t>>12&15]+F[t>>8&15]+F[t>>4&15]+F[t&15]+F[r>>28&15]+F[r>>24&15]+F[r>>20&15]+F[r>>16&15]+F[r>>12&15]+F[r>>8&15]+F[r>>4&15]+F[r&15]+F[o>>28&15]+F[o>>24&15]+F[o>>20&15]+F[o>>16&15]+F[o>>12&15]+F[o>>8&15]+F[o>>4&15]+F[o&15]+F[p>>28&15]+F[p>>24&15]+F[p>>20&15]+F[p>>16&15]+F[p>>12&15]+F[p>>8&15]+F[p>>4&15]+F[p&15]+F[A>>28&15]+F[A>>24&15]+F[A>>20&15]+F[A>>16&15]+F[A>>12&15]+F[A>>8&15]+F[A>>4&15]+F[A&15]+F[l>>28&15]+F[l>>24&15]+F[l>>20&15]+F[l>>16&15]+F[l>>12&15]+F[l>>8&15]+F[l>>4&15]+F[l&15]+F[_>>28&15]+F[_>>24&15]+F[_>>20&15]+F[_>>16&15]+F[_>>12&15]+F[_>>8&15]+F[_>>4&15]+F[_&15];return S>=256&&(E+=F[i>>28&15]+F[i>>24&15]+F[i>>20&15]+F[i>>16&15]+F[i>>12&15]+F[i>>8&15]+F[i>>4&15]+F[i&15]),S>=384&&(E+=F[B>>28&15]+F[B>>24&15]+F[B>>20&15]+F[B>>16&15]+F[B>>12&15]+F[B>>8&15]+F[B>>4&15]+F[B&15]+F[D>>28&15]+F[D>>24&15]+F[D>>20&15]+F[D>>16&15]+F[D>>12&15]+F[D>>8&15]+F[D>>4&15]+F[D&15]+F[O>>28&15]+F[O>>24&15]+F[O>>20&15]+F[O>>16&15]+F[O>>12&15]+F[O>>8&15]+F[O>>4&15]+F[O&15]+F[v>>28&15]+F[v>>24&15]+F[v>>20&15]+F[v>>16&15]+F[v>>12&15]+F[v>>8&15]+F[v>>4&15]+F[v&15]),S==512&&(E+=F[b>>28&15]+F[b>>24&15]+F[b>>20&15]+F[b>>16&15]+F[b>>12&15]+F[b>>8&15]+F[b>>4&15]+F[b&15]+F[T>>28&15]+F[T>>24&15]+F[T>>20&15]+F[T>>16&15]+F[T>>12&15]+F[T>>8&15]+F[T>>4&15]+F[T&15]+F[N>>28&15]+F[N>>24&15]+F[N>>20&15]+F[N>>16&15]+F[N>>12&15]+F[N>>8&15]+F[N>>4&15]+F[N&15]+F[I>>28&15]+F[I>>24&15]+F[I>>20&15]+F[I>>16&15]+F[I>>12&15]+F[I>>8&15]+F[I>>4&15]+F[I&15]),E},g.prototype.toString=g.prototype.hex,g.prototype.digest=function(){this.finalize();var t=this.h0h,r=this.h0l,o=this.h1h,p=this.h1l,A=this.h2h,l=this.h2l,_=this.h3h,i=this.h3l,B=this.h4h,D=this.h4l,O=this.h5h,v=this.h5l,b=this.h6h,T=this.h6l,N=this.h7h,I=this.h7l,S=this.bits,E=[t>>24&255,t>>16&255,t>>8&255,t&255,r>>24&255,r>>16&255,r>>8&255,r&255,o>>24&255,o>>16&255,o>>8&255,o&255,p>>24&255,p>>16&255,p>>8&255,p&255,A>>24&255,A>>16&255,A>>8&255,A&255,l>>24&255,l>>16&255,l>>8&255,l&255,_>>24&255,_>>16&255,_>>8&255,_&255];return S>=256&&E.push(i>>24&255,i>>16&255,i>>8&255,i&255),S>=384&&E.push(B>>24&255,B>>16&255,B>>8&255,B&255,D>>24&255,D>>16&255,D>>8&255,D&255,O>>24&255,O>>16&255,O>>8&255,O&255,v>>24&255,v>>16&255,v>>8&255,v&255),S==512&&E.push(b>>24&255,b>>16&255,b>>8&255,b&255,T>>24&255,T>>16&255,T>>8&255,T&255,N>>24&255,N>>16&255,N>>8&255,N&255,I>>24&255,I>>16&255,I>>8&255,I&255),E},g.prototype.array=g.prototype.digest,g.prototype.arrayBuffer=function(){this.finalize();var t=this.bits,r=new ArrayBuffer(t/8),o=new DataView(r);return o.setUint32(0,this.h0h),o.setUint32(4,this.h0l),o.setUint32(8,this.h1h),o.setUint32(12,this.h1l),o.setUint32(16,this.h2h),o.setUint32(20,this.h2l),o.setUint32(24,this.h3h),t>=256&&o.setUint32(28,this.h3l),t>=384&&(o.setUint32(32,this.h4h),o.setUint32(36,this.h4l),o.setUint32(40,this.h5h),o.setUint32(44,this.h5l)),t==512&&(o.setUint32(48,this.h6h),o.setUint32(52,this.h6l),o.setUint32(56,this.h7h),o.setUint32(60,this.h7l)),r},g.prototype.clone=function(){var t=new g(this.bits,!1);return this.copyTo(t),t},g.prototype.copyTo=function(t){var r=0,o=["h0h","h0l","h1h","h1l","h2h","h2l","h3h","h3l","h4h","h4l","h5h","h5l","h6h","h6l","h7h","h7l","start","bytes","hBytes","finalized","hashed","lastByteIndex"];for(r=0;r<o.length;++r)t[o[r]]=this[o[r]];for(r=0;r<this.blocks.length;++r)t.blocks[r]=this.blocks[r]};function lF(t,r,o){var p,A=typeof t;if(A!=="string"){if(A==="object"){if(t===null)throw new Error(s);if(cF&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!cF||!ArrayBuffer.isView(t)))throw new Error(s)}else throw new Error(s);p=!0}var l=t.length;if(!p){for(var _=[],l=t.length,i=0,B,D=0;D<l;++D)B=t.charCodeAt(D),B<128?_[i++]=B:B<2048?(_[i++]=192|B>>6,_[i++]=128|B&63):B<55296||B>=57344?(_[i++]=224|B>>12,_[i++]=128|B>>6&63,_[i++]=128|B&63):(B=65536+((B&1023)<<10|t.charCodeAt(++D)&1023),_[i++]=240|B>>18,_[i++]=128|B>>12&63,_[i++]=128|B>>6&63,_[i++]=128|B&63);t=_}t.length>128&&(t=new g(r,!0).update(t).array());for(var O=[],v=[],D=0;D<128;++D){var b=t[D]||0;O[D]=92^b,v[D]=54^b}g.call(this,r,o),this.update(v),this.oKeyPad=O,this.inner=!0,this.sharedMemory=o}lF.prototype=new g,lF.prototype.finalize=function(){if(g.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();g.call(this,this.bits,this.sharedMemory),this.update(this.oKeyPad),this.update(t),g.prototype.finalize.call(this)}},lF.prototype.clone=function(){var t=new lF([],this.bits,!1);this.copyTo(t),t.inner=this.inner;for(var r=0;r<this.oKeyPad.length;++r)t.oKeyPad[r]=this.oKeyPad[r];return t};var L=BF(512);L.sha512=L,L.sha384=BF(384),L.sha512_256=BF(256),L.sha512_224=BF(224),L.sha512.hmac=CF(512),L.sha384.hmac=CF(384),L.sha512_256.hmac=CF(256),L.sha512_224.hmac=CF(224),nF?mF.exports=L:(C.sha512=L.sha512,C.sha384=L.sha384,C.sha512_256=L.sha512_256,C.sha512_224=L.sha512_224,oF&&define(function(){return L}))})()});var p0={};i0(p0,{default:()=>OF});var aF="https://api.botpoison.com",uF="_botpoison";var LF=({formElement:s,value:n})=>{let a=s.querySelector(`input[name="${uF}"]`);if(!a){let C=s.ownerDocument;a=C.createElement("input"),a.setAttribute("type","hidden"),a.setAttribute("name",uF),C.getElementById(uF)||a.setAttribute("id",uF),s.appendChild(a)}return a.setAttribute("value",n),a},yF=({formElement:s,name:n})=>{s.dispatchEvent(new CustomEvent(`botpoison-challenge-${n}`))};var KF=s0(MF()),r0=async({input:s,expected:n})=>{let a=0;for(;;){let C=(0,KF.sha512)(`${s}:${a}`);if(a%4e4===0&&await jF(0),C.substring(0,n.length)===n)return a.toString();a++}},jF=s=>new Promise(n=>setTimeout(n,s)),o0=async({challenge:s,onProgress:n})=>{let{nonce:a,difficulty:C,hardness:w}=s.payload,tF=[];n==null||n(0);for(let nF=0;nF<w;nF++){let oF=await r0({input:`${a}:${nF}`,expected:"0".repeat(C)});tF.push(oF),n==null||n(tF.length/w),await jF(0)}return tF},HF=o0;var zF="_botpoison.v2.session.",fF,PF=new Map,JF=()=>{if(fF!==void 0)return fF;try{let s=window.sessionStorage,n=`${zF}probe`;s.setItem(n,"1"),s.removeItem(n),fF=s}catch(s){fF=null}return fF},pF=s=>`${zF}${s}`,SF=s=>{var a;let n=JF();if(!n)return PF.get(pF(s));try{return(a=n.getItem(pF(s)))!=null?a:void 0}catch(C){return PF.get(pF(s))}},VF=(s,n)=>{let a=JF();if(a)try{a.setItem(pF(s),n);return}catch(C){fF=null}PF.set(pF(s),n)};var EF,$F=(s=aF)=>SF(s),WF=(s,n)=>{let a=n==null?void 0:n.token;typeof a=="string"&&VF(s,a)},GF=({baseUrl:s=aF}={})=>SF(s)?Promise.resolve():EF||(EF=fetch(`${s}/session`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:"{}"}).then(async n=>{n.ok&&WF(s,await n.json())}).catch(()=>{}).finally(()=>{EF=void 0}),EF),YF=({challenge:s,solutions:n,baseUrl:a=aF})=>fetch(`${a}/session`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({challenge:s,solutions:n,token:SF(a)})}).then(async C=>{C.ok&&WF(a,await C.json())}).catch(()=>{});var l0=()=>typeof location=="undefined"?void 0:location.hostname,gF=async({publicKey:s,baseUrl:n=aF,onProgress:a})=>{let w=await(await fetch(`${n}/challenge`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({publicKey:s,hostname:l0(),version:"0.2.0",token:$F(n)})})).json(),tF=await HF({challenge:w,onProgress:a});return YF({challenge:w,solutions:tF,baseUrl:n}),{solution:btoa(JSON.stringify({challenge:w,solutions:tF}))}};var a0=s=>{if(!s||!s.tagName)return;let n=s;if(n.tagName!=="FORM")return;let a=n,C=a.dataset.botpoisonPublicKey;return C?{formElement:a,publicKey:C}:void 0},qF=({documentRef:s,baseUrl:n})=>{let a=C=>{try{let w=a0(C.target);if(!w)return;let{formElement:tF,publicKey:nF}=w;C.preventDefault(),yF({formElement:tF,name:"start"}),gF({publicKey:nF,baseUrl:n}).then(({solution:oF})=>{yF({formElement:tF,name:"success"}),LF({formElement:tF,value:oF}),HTMLFormElement.prototype.submit.call(tF)}).catch(oF=>{console.error(oF),yF({formElement:tF,name:"error"})})}catch(w){console.error(w)}};return s.addEventListener("submit",a),{dispose:()=>{s.removeEventListener("submit",a)}}};var XF=()=>{f0(),c0(),u0()},OF=class{constructor({publicKey:n,baseUrl:a}){this.publicKey=n,this.baseUrl=a}static init(){XF()}async challenge(n){let{onProgress:a}=n||{};return gF({publicKey:this.publicKey,baseUrl:this.baseUrl,onProgress:a})}},f0=()=>{typeof document!="undefined"&&(window.__BOTPOISON_VERSION__="0.2.0")},c0=()=>{typeof document!="undefined"&&(window.__BOTPOISON_SUBMIT_LISTENER__||(window.__BOTPOISON_SUBMIT_LISTENER__=!0,qF({documentRef:document})))},u0=()=>{if(typeof document=="undefined"||window.__BOTPOISON_SESSION_OPENED__)return;window.__BOTPOISON_SESSION_OPENED__=!0;let s=()=>{GF()};typeof requestIdleCallback=="function"?requestIdleCallback(s,{timeout:2e3}):setTimeout(s,0)};XF();return n0(p0);})();
2
2
  /*! Bundled license information:
3
3
 
4
4
  js-sha512/src/sha512.js:
package/dist/index.mjs CHANGED
@@ -70,7 +70,7 @@ var computeSolutions = async ({
70
70
  var computeSolutions_default = computeSolutions;
71
71
 
72
72
  // src/storage.ts
73
- var PREFIX = "_botpoison.v1.session.";
73
+ var PREFIX = "_botpoison.v2.session.";
74
74
  var backing;
75
75
  var memory = /* @__PURE__ */ new Map();
76
76
  var getBacking = () => {
@@ -88,73 +88,83 @@ var getBacking = () => {
88
88
  }
89
89
  return backing;
90
90
  };
91
- var keyFor = (publicKey) => `${PREFIX}${publicKey}`;
92
- var readSessionToken = (publicKey) => {
91
+ var keyFor = (baseUrl) => `${PREFIX}${baseUrl}`;
92
+ var readSessionToken = (baseUrl) => {
93
93
  var _a;
94
- const store = getBacking();
95
- if (!store) {
96
- return memory.get(keyFor(publicKey));
94
+ const store2 = getBacking();
95
+ if (!store2) {
96
+ return memory.get(keyFor(baseUrl));
97
97
  }
98
98
  try {
99
- return (_a = store.getItem(keyFor(publicKey))) != null ? _a : void 0;
99
+ return (_a = store2.getItem(keyFor(baseUrl))) != null ? _a : void 0;
100
100
  } catch (e) {
101
- return memory.get(keyFor(publicKey));
101
+ return memory.get(keyFor(baseUrl));
102
102
  }
103
103
  };
104
- var writeSessionToken = (publicKey, token) => {
105
- const store = getBacking();
106
- if (store) {
104
+ var writeSessionToken = (baseUrl, token) => {
105
+ const store2 = getBacking();
106
+ if (store2) {
107
107
  try {
108
- store.setItem(keyFor(publicKey), token);
108
+ store2.setItem(keyFor(baseUrl), token);
109
109
  return;
110
110
  } catch (e) {
111
111
  backing = null;
112
112
  }
113
113
  }
114
- memory.set(keyFor(publicKey), token);
114
+ memory.set(keyFor(baseUrl), token);
115
115
  };
116
116
 
117
117
  // src/session.ts
118
- var inFlight = /* @__PURE__ */ new Map();
119
- var getSessionToken = (publicKey) => readSessionToken(publicKey);
120
- var requestSession = ({
121
- publicKey,
118
+ var inFlight;
119
+ var getSessionToken = (baseUrl = DEFAULT_BASE_URL) => readSessionToken(baseUrl);
120
+ var store = (baseUrl, body) => {
121
+ const token = body == null ? void 0 : body.token;
122
+ if (typeof token === "string") {
123
+ writeSessionToken(baseUrl, token);
124
+ }
125
+ };
126
+ var openSession = ({
122
127
  baseUrl = DEFAULT_BASE_URL
123
- }) => {
124
- if (readSessionToken(publicKey)) {
128
+ } = {}) => {
129
+ if (readSessionToken(baseUrl)) {
125
130
  return Promise.resolve();
126
131
  }
127
- const existing = inFlight.get(publicKey);
128
- if (existing) {
129
- return existing;
132
+ if (inFlight) {
133
+ return inFlight;
130
134
  }
131
- const request = fetch(`${baseUrl}/session`, {
135
+ inFlight = fetch(`${baseUrl}/session`, {
132
136
  method: "POST",
133
- headers: {
134
- "Content-Type": "application/json",
135
- Accept: "application/json"
136
- },
137
- body: JSON.stringify({
138
- publicKey,
139
- hostname: location.hostname,
140
- version: "0.1.33"
141
- })
137
+ headers: { "Content-Type": "application/json", Accept: "application/json" },
138
+ body: "{}"
142
139
  }).then(async (response) => {
143
- if (!response.ok) {
144
- return;
145
- }
146
- const body = await response.json();
147
- if (body && typeof body.token === "string") {
148
- writeSessionToken(publicKey, body.token);
140
+ if (response.ok) {
141
+ store(baseUrl, await response.json());
149
142
  }
150
143
  }).catch(() => void 0).finally(() => {
151
- inFlight.delete(publicKey);
144
+ inFlight = void 0;
152
145
  });
153
- inFlight.set(publicKey, request);
154
- return request;
146
+ return inFlight;
155
147
  };
148
+ var exchangeSolved = ({
149
+ challenge,
150
+ solutions,
151
+ baseUrl = DEFAULT_BASE_URL
152
+ }) => fetch(`${baseUrl}/session`, {
153
+ method: "POST",
154
+ headers: { "Content-Type": "application/json", Accept: "application/json" },
155
+ body: JSON.stringify({
156
+ challenge,
157
+ solutions,
158
+ token: readSessionToken(baseUrl)
159
+ })
160
+ }).then(async (response) => {
161
+ if (response.ok) {
162
+ store(baseUrl, await response.json());
163
+ }
164
+ }).catch(() => void 0);
156
165
 
157
166
  // src/runChallenge.ts
167
+ var hostname = () => typeof location === "undefined" ? void 0 : location.hostname;
158
168
  var runChallenge = async ({
159
169
  publicKey,
160
170
  baseUrl = DEFAULT_BASE_URL,
@@ -168,11 +178,11 @@ var runChallenge = async ({
168
178
  },
169
179
  body: JSON.stringify({
170
180
  publicKey,
171
- hostname: location.hostname,
181
+ hostname: hostname(),
172
182
  // Copies of this bundle stay embedded in sites for years, so the API
173
183
  // has to start collecting this long before it can act on it.
174
- version: "0.1.33",
175
- token: getSessionToken(publicKey)
184
+ version: "0.2.0",
185
+ token: getSessionToken(baseUrl)
176
186
  })
177
187
  });
178
188
  const challenge = await response.json();
@@ -180,6 +190,7 @@ var runChallenge = async ({
180
190
  challenge,
181
191
  onProgress
182
192
  });
193
+ void exchangeSolved({ challenge, solutions, baseUrl });
183
194
  const serialized = btoa(
184
195
  JSON.stringify({
185
196
  challenge,
@@ -229,27 +240,10 @@ var createAutoSubmit = ({
229
240
  console.error(error);
230
241
  }
231
242
  };
232
- const onInteraction = (event) => {
233
- var _a, _b;
234
- try {
235
- const found = protectedForm(
236
- (_b = (_a = event.target) == null ? void 0 : _a.closest) == null ? void 0 : _b.call(_a, "form")
237
- );
238
- if (found) {
239
- void requestSession({ publicKey: found.publicKey, baseUrl });
240
- }
241
- } catch (error) {
242
- console.error(error);
243
- }
244
- };
245
243
  documentRef.addEventListener("submit", onSubmit);
246
- documentRef.addEventListener("focusin", onInteraction);
247
- documentRef.addEventListener("input", onInteraction);
248
244
  return {
249
245
  dispose: () => {
250
246
  documentRef.removeEventListener("submit", onSubmit);
251
- documentRef.removeEventListener("focusin", onInteraction);
252
- documentRef.removeEventListener("input", onInteraction);
253
247
  }
254
248
  };
255
249
  };
@@ -258,6 +252,7 @@ var createAutoSubmit = ({
258
252
  var init = () => {
259
253
  addVersion();
260
254
  addSubmitListener();
255
+ startSession();
261
256
  };
262
257
  var Botpoison = class {
263
258
  constructor({ publicKey, baseUrl }) {
@@ -267,16 +262,6 @@ var Botpoison = class {
267
262
  static init() {
268
263
  init();
269
264
  }
270
- // For integrations that call challenge() themselves and so have no form for
271
- // the automatic listener to watch. Call it when the form is shown: the API
272
- // starts its clock here, and a challenge requested well after earns less
273
- // work. Never rejects.
274
- async prepare() {
275
- return requestSession({
276
- publicKey: this.publicKey,
277
- baseUrl: this.baseUrl
278
- });
279
- }
280
265
  async challenge(options) {
281
266
  const { onProgress } = options || {};
282
267
  return runChallenge({
@@ -288,7 +273,7 @@ var Botpoison = class {
288
273
  };
289
274
  var addVersion = () => {
290
275
  if (typeof document !== "undefined") {
291
- window.__BOTPOISON_VERSION__ = "0.1.33";
276
+ window.__BOTPOISON_VERSION__ = "0.2.0";
292
277
  }
293
278
  };
294
279
  var addSubmitListener = () => {
@@ -299,6 +284,18 @@ var addSubmitListener = () => {
299
284
  }
300
285
  }
301
286
  };
287
+ var startSession = () => {
288
+ if (typeof document === "undefined" || window.__BOTPOISON_SESSION_OPENED__) {
289
+ return;
290
+ }
291
+ window.__BOTPOISON_SESSION_OPENED__ = true;
292
+ const open = () => void openSession();
293
+ if (typeof requestIdleCallback === "function") {
294
+ requestIdleCallback(open, { timeout: 2e3 });
295
+ } else {
296
+ setTimeout(open, 0);
297
+ }
298
+ };
302
299
  init();
303
300
  export {
304
301
  Botpoison as default
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@botpoison/browser",
3
3
  "private": false,
4
- "version": "0.1.33",
4
+ "version": "0.2.0",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
@@ -27,7 +27,6 @@
27
27
  "devDependencies": {
28
28
  "@types/node": "^22.20.1",
29
29
  "happy-dom": "^20.11.1",
30
- "tslib": "^2.3.1",
31
30
  "tsup": "^8.5.1",
32
31
  "typescript": "^6.0.3",
33
32
  "vite": "^6.4.3",