@botpoison/browser 0.3.1 → 1.0.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 +3 -3
- package/dist/index.js +1 -13
- package/dist/index.mjs +70 -105
- package/package.json +1 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
type ProgressCallback = (progress: number) => void;
|
|
2
2
|
type SignedChallenge = {
|
|
3
3
|
payload: {
|
|
4
|
+
algo?: string;
|
|
4
5
|
nonce: string;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
modulus: string;
|
|
7
|
+
squarings: number;
|
|
7
8
|
};
|
|
8
9
|
};
|
|
9
10
|
|
|
@@ -12,7 +13,6 @@ declare global {
|
|
|
12
13
|
__BOTPOISON_VERSION__: string | undefined;
|
|
13
14
|
__BOTPOISON_SUBMIT_LISTENER__: boolean | undefined;
|
|
14
15
|
__BOTPOISON_SESSION_OPENED__: boolean | undefined;
|
|
15
|
-
__BOTPOISON_HONEYPOT_INSTALLED__: boolean | undefined;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
type BotpoisonOptions = {
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
"use strict";var __botpoison=(()=>{var t0=Object.create;var yF=Object.defineProperty;var e0=Object.getOwnPropertyDescriptor;var h0=Object.getOwnPropertyNames;var i0=Object.getPrototypeOf,x0=Object.prototype.hasOwnProperty;var s0=(e,s)=>()=>(s||e((s={exports:{}}).exports,s),s.exports),n0=(e,s)=>{for(var r in s)yF(e,r,{get:s[r],enumerable:!0})},MF=(e,s,r,p)=>{if(s&&typeof s=="object"||typeof s=="function")for(let m of h0(s))!x0.call(e,m)&&m!==r&&yF(e,m,{get:()=>s[m],enumerable:!(p=e0(s,m))||p.enumerable});return e};var r0=(e,s,r)=>(r=e!=null?t0(i0(e)):{},MF(s||!e||!e.__esModule?yF(r,"default",{value:e,enumerable:!0}):r,e)),o0=e=>MF(yF({},"__esModule",{value:!0}),e);var jF=s0((S0,OF)=>{"use strict";(function(){"use strict";var e="input is invalid type",s="finalize already called",r=typeof window=="object",p=r?window:{};p.JS_SHA512_NO_WINDOW&&(r=!1);var m=!r&&typeof self=="object",b=!p.JS_SHA512_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;b?p=global:m&&(p=self);var nF=!p.JS_SHA512_NO_COMMON_JS&&typeof OF=="object"&&OF.exports,lF=typeof define=="function"&&define.amd,EF=!p.JS_SHA512_NO_ARRAY_BUFFER&&typeof ArrayBuffer!="undefined",F="0123456789abcdef".split(""),F0=[-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],BF=["hex","array","digest","arrayBuffer"],C=[];(p.JS_SHA512_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(t){return Object.prototype.toString.call(t)==="[object Array]"}),EF&&(p.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,o){return function(l){return new g(o,!0).update(l)[t]()}},CF=function(t){var o=UF("hex",t);o.create=function(){return new g(t)},o.update=function(A){return o.create().update(A)};for(var l=0;l<BF.length;++l){var E=BF[l];o[E]=UF(E,t)}return o},HF=function(t,o){return function(l,E){return new fF(l,o,!0).update(E)[t]()}},_F=function(t){var o=HF("hex",t);o.create=function(A){return new fF(A,t)},o.update=function(A,a){return o.create(A).update(a)};for(var l=0;l<BF.length;++l){var E=BF[l];o[E]=HF(E,t)}return o};function g(t,o){o?(C[0]=C[1]=C[2]=C[3]=C[4]=C[5]=C[6]=C[7]=C[8]=C[9]=C[10]=C[11]=C[12]=C[13]=C[14]=C[15]=C[16]=C[17]=C[18]=C[19]=C[20]=C[21]=C[22]=C[23]=C[24]=C[25]=C[26]=C[27]=C[28]=C[29]=C[30]=C[31]=C[32]=0,this.blocks=C):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(s);var o,l=typeof t;if(l!=="string"){if(l==="object"){if(t===null)throw new Error(e);if(EF&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!EF||!ArrayBuffer.isView(t)))throw new Error(e)}else throw new Error(e);o=!0}for(var E,A=0,a,_=t.length,n=this.blocks;A<_;){if(this.hashed&&(this.hashed=!1,n[0]=this.block,n[1]=n[2]=n[3]=n[4]=n[5]=n[6]=n[7]=n[8]=n[9]=n[10]=n[11]=n[12]=n[13]=n[14]=n[15]=n[16]=n[17]=n[18]=n[19]=n[20]=n[21]=n[22]=n[23]=n[24]=n[25]=n[26]=n[27]=n[28]=n[29]=n[30]=n[31]=n[32]=0),o)for(a=this.start;A<_&&a<128;++A)n[a>>2]|=t[A]<<sF[a++&3];else for(a=this.start;A<_&&a<128;++A)E=t.charCodeAt(A),E<128?n[a>>2]|=E<<sF[a++&3]:E<2048?(n[a>>2]|=(192|E>>6)<<sF[a++&3],n[a>>2]|=(128|E&63)<<sF[a++&3]):E<55296||E>=57344?(n[a>>2]|=(224|E>>12)<<sF[a++&3],n[a>>2]|=(128|E>>6&63)<<sF[a++&3],n[a>>2]|=(128|E&63)<<sF[a++&3]):(E=65536+((E&1023)<<10|t.charCodeAt(++A)&1023),n[a>>2]|=(240|E>>18)<<sF[a++&3],n[a>>2]|=(128|E>>12&63)<<sF[a++&3],n[a>>2]|=(128|E>>6&63)<<sF[a++&3],n[a>>2]|=(128|E&63)<<sF[a++&3]);this.lastByteIndex=a,this.bytes+=a-this.start,a>=128?(this.block=n[32],this.start=a-128,this.hash(),this.hashed=!0):this.start=a}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,o=this.lastByteIndex;t[32]=this.block,t[o>>2]|=F0[o&3],this.block=t[32],o>=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,o=this.h0l,l=this.h1h,E=this.h1l,A=this.h2h,a=this.h2l,_=this.h3h,n=this.h3l,B=this.h4h,D=this.h4l,v=this.h5h,w=this.h5l,T=this.h6h,I=this.h6l,N=this.h7h,P=this.h7l,O=this.blocks,d,M,K,j,z,h,i,x,f,TF,IF,NF,PF,RF,kF,mF,DF,eF,hF,c,u,y,S,iF,xF;for(d=32;d<160;d+=2)c=O[d-30],u=O[d-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=O[d-4],u=O[d-3],j=(c>>>19|u<<13)^(u>>>29|c<<3)^c>>>6,z=(u>>>19|c<<13)^(c>>>29|u<<3)^(u>>>6|c<<26),c=O[d-32],u=O[d-31],y=O[d-14],S=O[d-13],h=(S&65535)+(u&65535)+(K&65535)+(z&65535),i=(S>>>16)+(u>>>16)+(K>>>16)+(z>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(M&65535)+(j&65535)+(i>>>16),f=(y>>>16)+(c>>>16)+(M>>>16)+(j>>>16)+(x>>>16),O[d]=f<<16|x&65535,O[d+1]=i<<16|h&65535;var J=t,V=o,R=l,k=E,L=A,U=a,$=_,W=n,Y=B,q=D,G=v,Q=w,X=T,Z=I,FF=N,tF=P;for(mF=R&L,DF=k&U,d=0;d<160;d+=8)M=(J>>>28|V<<4)^(V>>>2|J<<30)^(V>>>7|J<<25),K=(V>>>28|J<<4)^(J>>>2|V<<30)^(J>>>7|V<<25),j=(Y>>>14|q<<18)^(Y>>>18|q<<14)^(q>>>9|Y<<23),z=(q>>>14|Y<<18)^(q>>>18|Y<<14)^(Y>>>9|q<<23),TF=J&R,IF=V&k,eF=TF^J&L^mF,hF=IF^V&U^DF,iF=Y&G^~Y&X,xF=q&Q^~q&Z,c=O[d],u=O[d+1],y=rF[d],S=rF[d+1],h=(S&65535)+(u&65535)+(xF&65535)+(z&65535)+(tF&65535),i=(S>>>16)+(u>>>16)+(xF>>>16)+(z>>>16)+(tF>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(iF&65535)+(j&65535)+(FF&65535)+(i>>>16),f=(y>>>16)+(c>>>16)+(iF>>>16)+(j>>>16)+(FF>>>16)+(x>>>16),c=f<<16|x&65535,u=i<<16|h&65535,h=(hF&65535)+(K&65535),i=(hF>>>16)+(K>>>16)+(h>>>16),x=(eF&65535)+(M&65535)+(i>>>16),f=(eF>>>16)+(M>>>16)+(x>>>16),y=f<<16|x&65535,S=i<<16|h&65535,h=(W&65535)+(u&65535),i=(W>>>16)+(u>>>16)+(h>>>16),x=($&65535)+(c&65535)+(i>>>16),f=($>>>16)+(c>>>16)+(x>>>16),FF=f<<16|x&65535,tF=i<<16|h&65535,h=(S&65535)+(u&65535),i=(S>>>16)+(u>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(i>>>16),f=(y>>>16)+(c>>>16)+(x>>>16),$=f<<16|x&65535,W=i<<16|h&65535,M=($>>>28|W<<4)^(W>>>2|$<<30)^(W>>>7|$<<25),K=(W>>>28|$<<4)^($>>>2|W<<30)^($>>>7|W<<25),j=(FF>>>14|tF<<18)^(FF>>>18|tF<<14)^(tF>>>9|FF<<23),z=(tF>>>14|FF<<18)^(tF>>>18|FF<<14)^(FF>>>9|tF<<23),NF=$&J,PF=W&V,eF=NF^$&R^TF,hF=PF^W&k^IF,iF=FF&Y^~FF&G,xF=tF&q^~tF&Q,c=O[d+2],u=O[d+3],y=rF[d+2],S=rF[d+3],h=(S&65535)+(u&65535)+(xF&65535)+(z&65535)+(Z&65535),i=(S>>>16)+(u>>>16)+(xF>>>16)+(z>>>16)+(Z>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(iF&65535)+(j&65535)+(X&65535)+(i>>>16),f=(y>>>16)+(c>>>16)+(iF>>>16)+(j>>>16)+(X>>>16)+(x>>>16),c=f<<16|x&65535,u=i<<16|h&65535,h=(hF&65535)+(K&65535),i=(hF>>>16)+(K>>>16)+(h>>>16),x=(eF&65535)+(M&65535)+(i>>>16),f=(eF>>>16)+(M>>>16)+(x>>>16),y=f<<16|x&65535,S=i<<16|h&65535,h=(U&65535)+(u&65535),i=(U>>>16)+(u>>>16)+(h>>>16),x=(L&65535)+(c&65535)+(i>>>16),f=(L>>>16)+(c>>>16)+(x>>>16),X=f<<16|x&65535,Z=i<<16|h&65535,h=(S&65535)+(u&65535),i=(S>>>16)+(u>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(i>>>16),f=(y>>>16)+(c>>>16)+(x>>>16),L=f<<16|x&65535,U=i<<16|h&65535,M=(L>>>28|U<<4)^(U>>>2|L<<30)^(U>>>7|L<<25),K=(U>>>28|L<<4)^(L>>>2|U<<30)^(L>>>7|U<<25),j=(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),RF=L&$,kF=U&W,eF=RF^L&J^NF,hF=kF^U&V^PF,iF=X&FF^~X&Y,xF=Z&tF^~Z&q,c=O[d+4],u=O[d+5],y=rF[d+4],S=rF[d+5],h=(S&65535)+(u&65535)+(xF&65535)+(z&65535)+(Q&65535),i=(S>>>16)+(u>>>16)+(xF>>>16)+(z>>>16)+(Q>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(iF&65535)+(j&65535)+(G&65535)+(i>>>16),f=(y>>>16)+(c>>>16)+(iF>>>16)+(j>>>16)+(G>>>16)+(x>>>16),c=f<<16|x&65535,u=i<<16|h&65535,h=(hF&65535)+(K&65535),i=(hF>>>16)+(K>>>16)+(h>>>16),x=(eF&65535)+(M&65535)+(i>>>16),f=(eF>>>16)+(M>>>16)+(x>>>16),y=f<<16|x&65535,S=i<<16|h&65535,h=(k&65535)+(u&65535),i=(k>>>16)+(u>>>16)+(h>>>16),x=(R&65535)+(c&65535)+(i>>>16),f=(R>>>16)+(c>>>16)+(x>>>16),G=f<<16|x&65535,Q=i<<16|h&65535,h=(S&65535)+(u&65535),i=(S>>>16)+(u>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(i>>>16),f=(y>>>16)+(c>>>16)+(x>>>16),R=f<<16|x&65535,k=i<<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=(G>>>14|Q<<18)^(G>>>18|Q<<14)^(Q>>>9|G<<23),z=(Q>>>14|G<<18)^(Q>>>18|G<<14)^(G>>>9|Q<<23),mF=R&L,DF=k&U,eF=mF^R&$^RF,hF=DF^k&W^kF,iF=G&X^~G&FF,xF=Q&Z^~Q&tF,c=O[d+6],u=O[d+7],y=rF[d+6],S=rF[d+7],h=(S&65535)+(u&65535)+(xF&65535)+(z&65535)+(q&65535),i=(S>>>16)+(u>>>16)+(xF>>>16)+(z>>>16)+(q>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(iF&65535)+(j&65535)+(Y&65535)+(i>>>16),f=(y>>>16)+(c>>>16)+(iF>>>16)+(j>>>16)+(Y>>>16)+(x>>>16),c=f<<16|x&65535,u=i<<16|h&65535,h=(hF&65535)+(K&65535),i=(hF>>>16)+(K>>>16)+(h>>>16),x=(eF&65535)+(M&65535)+(i>>>16),f=(eF>>>16)+(M>>>16)+(x>>>16),y=f<<16|x&65535,S=i<<16|h&65535,h=(V&65535)+(u&65535),i=(V>>>16)+(u>>>16)+(h>>>16),x=(J&65535)+(c&65535)+(i>>>16),f=(J>>>16)+(c>>>16)+(x>>>16),Y=f<<16|x&65535,q=i<<16|h&65535,h=(S&65535)+(u&65535),i=(S>>>16)+(u>>>16)+(h>>>16),x=(y&65535)+(c&65535)+(i>>>16),f=(y>>>16)+(c>>>16)+(x>>>16),J=f<<16|x&65535,V=i<<16|h&65535;h=(o&65535)+(V&65535),i=(o>>>16)+(V>>>16)+(h>>>16),x=(t&65535)+(J&65535)+(i>>>16),f=(t>>>16)+(J>>>16)+(x>>>16),this.h0h=f<<16|x&65535,this.h0l=i<<16|h&65535,h=(E&65535)+(k&65535),i=(E>>>16)+(k>>>16)+(h>>>16),x=(l&65535)+(R&65535)+(i>>>16),f=(l>>>16)+(R>>>16)+(x>>>16),this.h1h=f<<16|x&65535,this.h1l=i<<16|h&65535,h=(a&65535)+(U&65535),i=(a>>>16)+(U>>>16)+(h>>>16),x=(A&65535)+(L&65535)+(i>>>16),f=(A>>>16)+(L>>>16)+(x>>>16),this.h2h=f<<16|x&65535,this.h2l=i<<16|h&65535,h=(n&65535)+(W&65535),i=(n>>>16)+(W>>>16)+(h>>>16),x=(_&65535)+($&65535)+(i>>>16),f=(_>>>16)+($>>>16)+(x>>>16),this.h3h=f<<16|x&65535,this.h3l=i<<16|h&65535,h=(D&65535)+(q&65535),i=(D>>>16)+(q>>>16)+(h>>>16),x=(B&65535)+(Y&65535)+(i>>>16),f=(B>>>16)+(Y>>>16)+(x>>>16),this.h4h=f<<16|x&65535,this.h4l=i<<16|h&65535,h=(w&65535)+(Q&65535),i=(w>>>16)+(Q>>>16)+(h>>>16),x=(v&65535)+(G&65535)+(i>>>16),f=(v>>>16)+(G>>>16)+(x>>>16),this.h5h=f<<16|x&65535,this.h5l=i<<16|h&65535,h=(I&65535)+(Z&65535),i=(I>>>16)+(Z>>>16)+(h>>>16),x=(T&65535)+(X&65535)+(i>>>16),f=(T>>>16)+(X>>>16)+(x>>>16),this.h6h=f<<16|x&65535,this.h6l=i<<16|h&65535,h=(P&65535)+(tF&65535),i=(P>>>16)+(tF>>>16)+(h>>>16),x=(N&65535)+(FF&65535)+(i>>>16),f=(N>>>16)+(FF>>>16)+(x>>>16),this.h7h=f<<16|x&65535,this.h7l=i<<16|h&65535},g.prototype.hex=function(){this.finalize();var t=this.h0h,o=this.h0l,l=this.h1h,E=this.h1l,A=this.h2h,a=this.h2l,_=this.h3h,n=this.h3l,B=this.h4h,D=this.h4l,v=this.h5h,w=this.h5l,T=this.h6h,I=this.h6l,N=this.h7h,P=this.h7l,O=this.bits,d=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[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[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[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[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[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[_>>28&15]+F[_>>24&15]+F[_>>20&15]+F[_>>16&15]+F[_>>12&15]+F[_>>8&15]+F[_>>4&15]+F[_&15];return O>=256&&(d+=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]),O>=384&&(d+=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[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]+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]),O==512&&(d+=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[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]),d},g.prototype.toString=g.prototype.hex,g.prototype.digest=function(){this.finalize();var t=this.h0h,o=this.h0l,l=this.h1h,E=this.h1l,A=this.h2h,a=this.h2l,_=this.h3h,n=this.h3l,B=this.h4h,D=this.h4l,v=this.h5h,w=this.h5l,T=this.h6h,I=this.h6l,N=this.h7h,P=this.h7l,O=this.bits,d=[t>>24&255,t>>16&255,t>>8&255,t&255,o>>24&255,o>>16&255,o>>8&255,o&255,l>>24&255,l>>16&255,l>>8&255,l&255,E>>24&255,E>>16&255,E>>8&255,E&255,A>>24&255,A>>16&255,A>>8&255,A&255,a>>24&255,a>>16&255,a>>8&255,a&255,_>>24&255,_>>16&255,_>>8&255,_&255];return O>=256&&d.push(n>>24&255,n>>16&255,n>>8&255,n&255),O>=384&&d.push(B>>24&255,B>>16&255,B>>8&255,B&255,D>>24&255,D>>16&255,D>>8&255,D&255,v>>24&255,v>>16&255,v>>8&255,v&255,w>>24&255,w>>16&255,w>>8&255,w&255),O==512&&d.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,P>>24&255,P>>16&255,P>>8&255,P&255),d},g.prototype.array=g.prototype.digest,g.prototype.arrayBuffer=function(){this.finalize();var t=this.bits,o=new ArrayBuffer(t/8),l=new DataView(o);return l.setUint32(0,this.h0h),l.setUint32(4,this.h0l),l.setUint32(8,this.h1h),l.setUint32(12,this.h1l),l.setUint32(16,this.h2h),l.setUint32(20,this.h2l),l.setUint32(24,this.h3h),t>=256&&l.setUint32(28,this.h3l),t>=384&&(l.setUint32(32,this.h4h),l.setUint32(36,this.h4l),l.setUint32(40,this.h5h),l.setUint32(44,this.h5l)),t==512&&(l.setUint32(48,this.h6h),l.setUint32(52,this.h6l),l.setUint32(56,this.h7h),l.setUint32(60,this.h7l)),o},g.prototype.clone=function(){var t=new g(this.bits,!1);return this.copyTo(t),t},g.prototype.copyTo=function(t){var o=0,l=["h0h","h0l","h1h","h1l","h2h","h2l","h3h","h3l","h4h","h4l","h5h","h5l","h6h","h6l","h7h","h7l","start","bytes","hBytes","finalized","hashed","lastByteIndex"];for(o=0;o<l.length;++o)t[l[o]]=this[l[o]];for(o=0;o<this.blocks.length;++o)t.blocks[o]=this.blocks[o]};function fF(t,o,l){var E,A=typeof t;if(A!=="string"){if(A==="object"){if(t===null)throw new Error(e);if(EF&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!EF||!ArrayBuffer.isView(t)))throw new Error(e)}else throw new Error(e);E=!0}var a=t.length;if(!E){for(var _=[],a=t.length,n=0,B,D=0;D<a;++D)B=t.charCodeAt(D),B<128?_[n++]=B:B<2048?(_[n++]=192|B>>6,_[n++]=128|B&63):B<55296||B>=57344?(_[n++]=224|B>>12,_[n++]=128|B>>6&63,_[n++]=128|B&63):(B=65536+((B&1023)<<10|t.charCodeAt(++D)&1023),_[n++]=240|B>>18,_[n++]=128|B>>12&63,_[n++]=128|B>>6&63,_[n++]=128|B&63);t=_}t.length>128&&(t=new g(o,!0).update(t).array());for(var v=[],w=[],D=0;D<128;++D){var T=t[D]||0;v[D]=92^T,w[D]=54^T}g.call(this,o,l),this.update(w),this.oKeyPad=v,this.inner=!0,this.sharedMemory=l}fF.prototype=new g,fF.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)}},fF.prototype.clone=function(){var t=new fF([],this.bits,!1);this.copyTo(t),t.inner=this.inner;for(var o=0;o<this.oKeyPad.length;++o)t.oKeyPad[o]=this.oKeyPad[o];return t};var H=CF(512);H.sha512=H,H.sha384=CF(384),H.sha512_256=CF(256),H.sha512_224=CF(224),H.sha512.hmac=_F(512),H.sha384.hmac=_F(384),H.sha512_256.hmac=_F(256),H.sha512_224.hmac=_F(224),nF?OF.exports=H:(p.sha512=H.sha512,p.sha384=H.sha384,p.sha512_256=H.sha512_256,p.sha512_224=H.sha512_224,lF&&define(function(){return H}))})()});var C0={};n0(C0,{default:()=>wF});var oF="https://api.botpoison.com",pF="_botpoison",aF={"Content-Type":"text/plain",Accept:"application/json"};var KF=({formElement:e,value:s})=>{let r=e.querySelector(`input[name="${pF}"]`);if(!r){let p=e.ownerDocument;r=p.createElement("input"),r.setAttribute("type","hidden"),r.setAttribute("name",pF),p.getElementById(pF)||r.setAttribute("id",pF),e.appendChild(r)}return r.setAttribute("value",s),r},SF=({formElement:e,name:s})=>{e.dispatchEvent(new CustomEvent(`botpoison-challenge-${s}`))};var zF=r0(jF()),l0=async({input:e,expected:s})=>{let r=0;for(;;){let p=(0,zF.sha512)(`${e}:${r}`);if(r%4e4===0&&await JF(0),p.substring(0,s.length)===s)return r.toString();r++}},JF=e=>new Promise(s=>setTimeout(s,e)),a0=async({challenge:e,onProgress:s})=>{let{nonce:r,difficulty:p,hardness:m}=e.payload,b=[];s==null||s(0);for(let nF=0;nF<m;nF++){let lF=await l0({input:`${r}:${nF}`,expected:"0".repeat(p)});b.push(lF),s==null||s(b.length/m),await JF(0)}return b},VF=a0;var $F="_botpoison.v2.session.",cF,LF=new Map,WF=()=>{if(cF!==void 0)return cF;try{let e=window.sessionStorage,s=`${$F}probe`;e.setItem(s,"1"),e.removeItem(s),cF=e}catch(e){cF=null}return cF},dF=e=>`${$F}${e}`,gF=e=>{var r;let s=WF();if(!s)return LF.get(dF(e));try{return(r=s.getItem(dF(e)))!=null?r:void 0}catch(p){return LF.get(dF(e))}},YF=(e,s)=>{let r=WF();if(r)try{r.setItem(dF(e),s);return}catch(p){cF=null}LF.set(dF(e),s)};var AF,uF=(e=oF)=>gF(e),qF=(e,s)=>{let r=s==null?void 0:s.token;typeof r=="string"&&YF(e,r)},bF=({baseUrl:e=oF}={})=>gF(e)?Promise.resolve():AF||(AF=fetch(`${e}/session`,{method:"POST",headers:aF,body:"{}"}).then(async s=>{s.ok&&qF(e,await s.json())}).catch(()=>{}).finally(()=>{AF=void 0}),AF),GF=({challenge:e,solutions:s,baseUrl:r=oF})=>fetch(`${r}/session`,{method:"POST",headers:aF,keepalive:!0,body:JSON.stringify({challenge:e,solutions:s,token:gF(r)})}).then(async p=>{p.ok&&qF(r,await p.json())}).catch(()=>{});var f0=()=>typeof location=="undefined"?void 0:location.hostname,vF=async({publicKey:e,baseUrl:s=oF,onProgress:r})=>{let m=await(await fetch(`${s}/challenge`,{method:"POST",headers:aF,body:JSON.stringify({publicKey:e,hostname:f0(),version:"0.3.1",token:uF(s)})})).json(),b=await VF({challenge:m,onProgress:r});return GF({challenge:m,solutions:b,baseUrl:s}),{solution:btoa(JSON.stringify({challenge:m,solutions:b}))}};var c0=e=>{if(!e||!e.tagName)return;let s=e;if(s.tagName!=="FORM")return;let r=s,p=r.dataset.botpoisonPublicKey;return p?{formElement:r,publicKey:p}:void 0},QF=({documentRef:e,baseUrl:s})=>{let r=p=>{try{let m=c0(p.target);if(!m)return;let{formElement:b,publicKey:nF}=m;p.preventDefault(),SF({formElement:b,name:"start"}),vF({publicKey:nF,baseUrl:s}).then(({solution:lF})=>{SF({formElement:b,name:"success"}),KF({formElement:b,value:lF}),HTMLFormElement.prototype.submit.call(b)}).catch(lF=>{console.error(lF),SF({formElement:b,name:"error"})})}catch(m){console.error(m)}};return e.addEventListener("submit",r),{dispose:()=>{e.removeEventListener("submit",r)}}};var u0=({documentRef:e,baseUrl:s})=>{var b;let r=e.createElement("form");r.setAttribute("method","post"),r.setAttribute("aria-hidden","true"),r.setAttribute("style","position:absolute;left:-9999px;top:-9999px;width:1px;height:1px;visibility:hidden;"),Object.defineProperty(r,"action",{get:()=>`${s}/honeypot`,enumerable:!1,configurable:!0});let p=e.createElement("input");p.setAttribute("type","email"),p.setAttribute("name","newsletter"),p.setAttribute("tabindex","-1"),p.setAttribute("autocomplete","off"),r.appendChild(p);let m=e.createElement("input");return m.setAttribute("type","hidden"),m.setAttribute("name","token"),m.setAttribute("value",(b=uF(s))!=null?b:""),r.appendChild(m),r.addEventListener("submit",nF=>{nF.preventDefault(),fetch(`${s}/honeypot`,{method:"POST",headers:aF,body:JSON.stringify({token:uF(s)})}).catch(()=>{})}),e.body.appendChild(r),m},E0=()=>typeof navigator!="undefined"&&navigator.webdriver===!0||typeof window!="undefined"&&"Cypress"in window,XF=({documentRef:e,baseUrl:s=oF})=>{if(typeof e.createElement!="function"||E0())return;let r=()=>{let p=u0({documentRef:e,baseUrl:s}),m=()=>{bF({baseUrl:s}).then(()=>{var b;p.setAttribute("value",(b=uF(s))!=null?b:"")})};typeof requestIdleCallback=="function"?requestIdleCallback(m,{timeout:2e3}):setTimeout(m,0)};e.readyState==="loading"?e.addEventListener("DOMContentLoaded",r):r()};var ZF=()=>{p0(),d0(),B0(),A0()},wF=class{constructor({publicKey:s,baseUrl:r}){this.publicKey=s,this.baseUrl=r}static init(){ZF()}async challenge(s){let{onProgress:r}=s||{};return vF({publicKey:this.publicKey,baseUrl:this.baseUrl,onProgress:r})}},p0=()=>{typeof document!="undefined"&&(window.__BOTPOISON_VERSION__="0.3.1")},d0=()=>{typeof document!="undefined"&&(window.__BOTPOISON_SUBMIT_LISTENER__||(window.__BOTPOISON_SUBMIT_LISTENER__=!0,QF({documentRef:document})))},A0=()=>{typeof document=="undefined"||window.__BOTPOISON_HONEYPOT_INSTALLED__||(window.__BOTPOISON_HONEYPOT_INSTALLED__=!0,XF({documentRef:document}))},B0=()=>{if(typeof document=="undefined"||window.__BOTPOISON_SESSION_OPENED__)return;window.__BOTPOISON_SESSION_OPENED__=!0;let e=()=>{bF()};typeof requestIdleCallback=="function"?requestIdleCallback(e,{timeout:2e3}):setTimeout(e,0)};ZF();return o0(C0);})();
|
|
2
|
-
/*! Bundled license information:
|
|
3
|
-
|
|
4
|
-
js-sha512/src/sha512.js:
|
|
5
|
-
(*
|
|
6
|
-
* [js-sha512]{@link https://github.com/emn178/js-sha512}
|
|
7
|
-
*
|
|
8
|
-
* @version 0.8.0
|
|
9
|
-
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
10
|
-
* @copyright Chen, Yi-Cyuan 2014-2018
|
|
11
|
-
* @license MIT
|
|
12
|
-
*)
|
|
13
|
-
*/
|
|
1
|
+
"use strict";var __botpoison=(()=>{var O=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var M=(t,e)=>{for(var n in e)O(t,n,{get:e[n],enumerable:!0})},F=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of U(e))!D.call(t,r)&&r!==n&&O(t,r,{get:()=>e[r],enumerable:!(o=R(e,r))||o.enumerable});return t};var K=t=>F(O({},"__esModule",{value:!0}),t);var W={};M(W,{default:()=>y});var u="https://api.botpoison.com",m="_botpoison",_={"Content-Type":"text/plain",Accept:"application/json"};var T=({formElement:t,value:e})=>{let n=t.querySelector(`input[name="${m}"]`);if(!n){let o=t.ownerDocument;n=o.createElement("input"),n.setAttribute("type","hidden"),n.setAttribute("name",m),o.getElementById(m)||n.setAttribute("id",m),t.appendChild(n)}return n.setAttribute("value",e),n},f=({formElement:t,name:e})=>{t.dispatchEvent(new CustomEvent(`botpoison-challenge-${e}`))};var $=t=>new Promise(e=>setTimeout(e,t)),I=t=>{let e="";for(let n of t)e+=n.toString(16).padStart(2,"0");return BigInt(`0x${e}`)},H=t=>{let e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return n},V=(t,e)=>{let n=t.toString(16).padStart(e*2,"0"),o="";for(let r=0;r<n.length;r+=2)o+=String.fromCharCode(parseInt(n.substring(r,r+2),16));return btoa(o)},j=async({nonce:t,modulus:e,byteLength:n})=>{let o=new TextEncoder,r=[],s=0;for(let i=0;s<n;i++){let l=new Uint8Array(await crypto.subtle.digest("SHA-256",o.encode(`${t}:${i}`)));r.push(l),s+=l.length}let c=new Uint8Array(s),a=0;for(let i of r)c.set(i,a),a+=i.length;let p=I(c.subarray(0,n))%e;return p*p%e},G="sundial",q=async({challenge:t,onProgress:e})=>{let{algo:n,nonce:o,modulus:r,squarings:s}=t.payload;if(n!==void 0&&n!==G)throw new Error(`Botpoison: this version cannot solve "${n}" challenges. Upgrade @botpoison/browser.`);let c=H(r),a=I(c),p=c.length;e==null||e(0);let i=await j({nonce:o,modulus:a,byteLength:p});for(let l=0;l<s;l++)i=i*i%a,l%2e4===19999&&(e==null||e(l/s),await $(0));return e==null||e(1),[V(i,p)]},N=q;var w="_botpoison.v2.session.",d,b=new Map,A=()=>{if(d!==void 0)return d;try{let t=window.sessionStorage,e=`${w}probe`;t.setItem(e,"1"),t.removeItem(e),d=t}catch(t){d=null}return d},g=t=>`${w}${t}`,E=t=>{var n;let e=A();if(!e)return b.get(g(t));try{return(n=e.getItem(g(t)))!=null?n:void 0}catch(o){return b.get(g(t))}},C=(t,e)=>{let n=A();if(n)try{n.setItem(g(t),e);return}catch(o){d=null}b.set(g(t),e)};var S,L=(t=u)=>E(t),v=(t,e)=>{let n=e==null?void 0:e.token;typeof n=="string"&&C(t,n)},k=({baseUrl:t=u}={})=>E(t)?Promise.resolve():S||(S=fetch(`${t}/session`,{method:"POST",headers:_,body:"{}"}).then(async e=>{e.ok&&v(t,await e.json())}).catch(()=>{}).finally(()=>{S=void 0}),S),P=({challenge:t,solutions:e,baseUrl:n=u})=>fetch(`${n}/session`,{method:"POST",headers:_,keepalive:!0,body:JSON.stringify({challenge:t,solutions:e,token:E(n)})}).then(async o=>{o.ok&&v(n,await o.json())}).catch(()=>{});var J=()=>typeof location=="undefined"?void 0:location.hostname,h=async({publicKey:t,baseUrl:e=u,onProgress:n})=>{let r=await(await fetch(`${e}/challenge`,{method:"POST",headers:_,body:JSON.stringify({publicKey:t,hostname:J(),version:"1.0.0",token:L(e)})})).json(),s=await N({challenge:r,onProgress:n});return P({challenge:r,solutions:s,baseUrl:e}),{solution:btoa(JSON.stringify({challenge:r,solutions:s}))}};var Q=t=>{if(!t||!t.tagName)return;let e=t;if(e.tagName!=="FORM")return;let n=e,o=n.dataset.botpoisonPublicKey;return o?{formElement:n,publicKey:o}:void 0},B=({documentRef:t,baseUrl:e})=>{let n=o=>{try{let r=Q(o.target);if(!r)return;let{formElement:s,publicKey:c}=r;o.preventDefault(),f({formElement:s,name:"start"}),h({publicKey:c,baseUrl:e}).then(({solution:a})=>{f({formElement:s,name:"success"}),T({formElement:s,value:a}),HTMLFormElement.prototype.submit.call(s)}).catch(a=>{console.error(a),f({formElement:s,name:"error"})})}catch(r){console.error(r)}};return t.addEventListener("submit",n),{dispose:()=>{t.removeEventListener("submit",n)}}};var x=()=>{Y(),z(),X()},y=class{constructor({publicKey:e,baseUrl:n}){this.publicKey=e,this.baseUrl=n}static init(){x()}async challenge(e){let{onProgress:n}=e||{};return h({publicKey:this.publicKey,baseUrl:this.baseUrl,onProgress:n})}},Y=()=>{typeof document!="undefined"&&(window.__BOTPOISON_VERSION__="1.0.0")},z=()=>{typeof document!="undefined"&&(window.__BOTPOISON_SUBMIT_LISTENER__||(window.__BOTPOISON_SUBMIT_LISTENER__=!0,B({documentRef:document})))},X=()=>{if(typeof document=="undefined"||window.__BOTPOISON_SESSION_OPENED__)return;window.__BOTPOISON_SESSION_OPENED__=!0;let t=()=>{k()};typeof requestIdleCallback=="function"?requestIdleCallback(t,{timeout:2e3}):setTimeout(t,0)};x();return K(W);})();
|
|
14
2
|
(function (root, factory) {
|
|
15
3
|
if (typeof exports === "object" && typeof module !== "undefined") {
|
|
16
4
|
module.exports = factory();
|
package/dist/index.mjs
CHANGED
|
@@ -35,41 +35,83 @@ var dispatchChallengeEvent = ({
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
// src/computeSolutions.ts
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
var YIELD_INTERVAL = 2e4;
|
|
39
|
+
var sleep = (time) => new Promise((r) => setTimeout(r, time));
|
|
40
|
+
var bytesToBigInt = (bytes) => {
|
|
41
|
+
let hex = "";
|
|
42
|
+
for (const byte of bytes) {
|
|
43
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
44
|
+
}
|
|
45
|
+
return BigInt(`0x${hex}`);
|
|
46
|
+
};
|
|
47
|
+
var base64ToBytes = (value) => {
|
|
48
|
+
const binary = atob(value);
|
|
49
|
+
const bytes = new Uint8Array(binary.length);
|
|
50
|
+
for (let i = 0; i < binary.length; i++) {
|
|
51
|
+
bytes[i] = binary.charCodeAt(i);
|
|
52
|
+
}
|
|
53
|
+
return bytes;
|
|
54
|
+
};
|
|
55
|
+
var bigIntToBase64 = (value, byteLength) => {
|
|
56
|
+
const hex = value.toString(16).padStart(byteLength * 2, "0");
|
|
57
|
+
let binary = "";
|
|
58
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
59
|
+
binary += String.fromCharCode(parseInt(hex.substring(i, i + 2), 16));
|
|
60
|
+
}
|
|
61
|
+
return btoa(binary);
|
|
62
|
+
};
|
|
63
|
+
var deriveX = async ({
|
|
64
|
+
nonce,
|
|
65
|
+
modulus,
|
|
66
|
+
byteLength
|
|
42
67
|
}) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
68
|
+
const encoder = new TextEncoder();
|
|
69
|
+
const parts = [];
|
|
70
|
+
let length = 0;
|
|
71
|
+
for (let counter = 0; length < byteLength; counter++) {
|
|
72
|
+
const digest = new Uint8Array(
|
|
73
|
+
await crypto.subtle.digest(
|
|
74
|
+
"SHA-256",
|
|
75
|
+
encoder.encode(`${nonce}:${counter}`)
|
|
76
|
+
)
|
|
77
|
+
);
|
|
78
|
+
parts.push(digest);
|
|
79
|
+
length += digest.length;
|
|
53
80
|
}
|
|
81
|
+
const joined = new Uint8Array(length);
|
|
82
|
+
let offset = 0;
|
|
83
|
+
for (const part of parts) {
|
|
84
|
+
joined.set(part, offset);
|
|
85
|
+
offset += part.length;
|
|
86
|
+
}
|
|
87
|
+
const x = bytesToBigInt(joined.subarray(0, byteLength)) % modulus;
|
|
88
|
+
return x * x % modulus;
|
|
54
89
|
};
|
|
55
|
-
var
|
|
90
|
+
var ALGO = "sundial";
|
|
56
91
|
var computeSolutions = async ({
|
|
57
92
|
challenge,
|
|
58
93
|
onProgress
|
|
59
94
|
}) => {
|
|
60
|
-
const { nonce,
|
|
61
|
-
|
|
95
|
+
const { algo, nonce, modulus: encodedModulus, squarings } = challenge.payload;
|
|
96
|
+
if (algo !== void 0 && algo !== ALGO) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
`Botpoison: this version cannot solve "${algo}" challenges. Upgrade @botpoison/browser.`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const modulusBytes = base64ToBytes(encodedModulus);
|
|
102
|
+
const modulus = bytesToBigInt(modulusBytes);
|
|
103
|
+
const byteLength = modulusBytes.length;
|
|
62
104
|
onProgress == null ? void 0 : onProgress(0);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
await sleep(0);
|
|
105
|
+
let y = await deriveX({ nonce, modulus, byteLength });
|
|
106
|
+
for (let i = 0; i < squarings; i++) {
|
|
107
|
+
y = y * y % modulus;
|
|
108
|
+
if (i % YIELD_INTERVAL === YIELD_INTERVAL - 1) {
|
|
109
|
+
onProgress == null ? void 0 : onProgress(i / squarings);
|
|
110
|
+
await sleep(0);
|
|
111
|
+
}
|
|
71
112
|
}
|
|
72
|
-
|
|
113
|
+
onProgress == null ? void 0 : onProgress(1);
|
|
114
|
+
return [bigIntToBase64(y, byteLength)];
|
|
73
115
|
};
|
|
74
116
|
var computeSolutions_default = computeSolutions;
|
|
75
117
|
|
|
@@ -183,7 +225,7 @@ var runChallenge = async ({
|
|
|
183
225
|
hostname: hostname(),
|
|
184
226
|
// Copies of this bundle stay embedded in sites for years, so the API
|
|
185
227
|
// has to start collecting this long before it can act on it.
|
|
186
|
-
version: "0.
|
|
228
|
+
version: "1.0.0",
|
|
187
229
|
token: getSessionToken(baseUrl)
|
|
188
230
|
})
|
|
189
231
|
});
|
|
@@ -250,81 +292,11 @@ var createAutoSubmit = ({
|
|
|
250
292
|
};
|
|
251
293
|
};
|
|
252
294
|
|
|
253
|
-
// src/honeypot.ts
|
|
254
|
-
var injectHoneypot = ({
|
|
255
|
-
documentRef,
|
|
256
|
-
baseUrl
|
|
257
|
-
}) => {
|
|
258
|
-
var _a;
|
|
259
|
-
const formElement = documentRef.createElement("form");
|
|
260
|
-
formElement.setAttribute("method", "post");
|
|
261
|
-
formElement.setAttribute("aria-hidden", "true");
|
|
262
|
-
formElement.setAttribute(
|
|
263
|
-
"style",
|
|
264
|
-
"position:absolute;left:-9999px;top:-9999px;width:1px;height:1px;visibility:hidden;"
|
|
265
|
-
);
|
|
266
|
-
Object.defineProperty(formElement, "action", {
|
|
267
|
-
get: () => `${baseUrl}/honeypot`,
|
|
268
|
-
enumerable: false,
|
|
269
|
-
configurable: true
|
|
270
|
-
});
|
|
271
|
-
const emailField = documentRef.createElement("input");
|
|
272
|
-
emailField.setAttribute("type", "email");
|
|
273
|
-
emailField.setAttribute("name", "newsletter");
|
|
274
|
-
emailField.setAttribute("tabindex", "-1");
|
|
275
|
-
emailField.setAttribute("autocomplete", "off");
|
|
276
|
-
formElement.appendChild(emailField);
|
|
277
|
-
const tokenField = documentRef.createElement("input");
|
|
278
|
-
tokenField.setAttribute("type", "hidden");
|
|
279
|
-
tokenField.setAttribute("name", "token");
|
|
280
|
-
tokenField.setAttribute("value", (_a = getSessionToken(baseUrl)) != null ? _a : "");
|
|
281
|
-
formElement.appendChild(tokenField);
|
|
282
|
-
formElement.addEventListener("submit", (event) => {
|
|
283
|
-
event.preventDefault();
|
|
284
|
-
fetch(`${baseUrl}/honeypot`, {
|
|
285
|
-
method: "POST",
|
|
286
|
-
headers: SIMPLE_REQUEST_HEADERS,
|
|
287
|
-
body: JSON.stringify({ token: getSessionToken(baseUrl) })
|
|
288
|
-
}).catch(() => void 0);
|
|
289
|
-
});
|
|
290
|
-
documentRef.body.appendChild(formElement);
|
|
291
|
-
return tokenField;
|
|
292
|
-
};
|
|
293
|
-
var isUnderTestAutomation = () => typeof navigator !== "undefined" && navigator.webdriver === true || typeof window !== "undefined" && "Cypress" in window;
|
|
294
|
-
var installHoneypot = ({
|
|
295
|
-
documentRef,
|
|
296
|
-
baseUrl = DEFAULT_BASE_URL
|
|
297
|
-
}) => {
|
|
298
|
-
if (typeof documentRef.createElement !== "function" || isUnderTestAutomation()) {
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
const inject = () => {
|
|
302
|
-
const tokenField = injectHoneypot({ documentRef, baseUrl });
|
|
303
|
-
const refresh = () => {
|
|
304
|
-
void openSession({ baseUrl }).then(() => {
|
|
305
|
-
var _a;
|
|
306
|
-
tokenField.setAttribute("value", (_a = getSessionToken(baseUrl)) != null ? _a : "");
|
|
307
|
-
});
|
|
308
|
-
};
|
|
309
|
-
if (typeof requestIdleCallback === "function") {
|
|
310
|
-
requestIdleCallback(refresh, { timeout: 2e3 });
|
|
311
|
-
} else {
|
|
312
|
-
setTimeout(refresh, 0);
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
if (documentRef.readyState === "loading") {
|
|
316
|
-
documentRef.addEventListener("DOMContentLoaded", inject);
|
|
317
|
-
} else {
|
|
318
|
-
inject();
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
|
|
322
295
|
// src/index.ts
|
|
323
296
|
var init = () => {
|
|
324
297
|
addVersion();
|
|
325
298
|
addSubmitListener();
|
|
326
299
|
startSession();
|
|
327
|
-
startHoneypot();
|
|
328
300
|
};
|
|
329
301
|
var Botpoison = class {
|
|
330
302
|
constructor({ publicKey, baseUrl }) {
|
|
@@ -345,7 +317,7 @@ var Botpoison = class {
|
|
|
345
317
|
};
|
|
346
318
|
var addVersion = () => {
|
|
347
319
|
if (typeof document !== "undefined") {
|
|
348
|
-
window.__BOTPOISON_VERSION__ = "0.
|
|
320
|
+
window.__BOTPOISON_VERSION__ = "1.0.0";
|
|
349
321
|
}
|
|
350
322
|
};
|
|
351
323
|
var addSubmitListener = () => {
|
|
@@ -356,13 +328,6 @@ var addSubmitListener = () => {
|
|
|
356
328
|
}
|
|
357
329
|
}
|
|
358
330
|
};
|
|
359
|
-
var startHoneypot = () => {
|
|
360
|
-
if (typeof document === "undefined" || window.__BOTPOISON_HONEYPOT_INSTALLED__) {
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
window.__BOTPOISON_HONEYPOT_INSTALLED__ = true;
|
|
364
|
-
installHoneypot({ documentRef: document });
|
|
365
|
-
};
|
|
366
331
|
var startSession = () => {
|
|
367
332
|
if (typeof document === "undefined" || window.__BOTPOISON_SESSION_OPENED__) {
|
|
368
333
|
return;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpoison/browser",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -21,9 +21,6 @@
|
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=18"
|
|
23
23
|
},
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"js-sha512": "^0.8.0"
|
|
26
|
-
},
|
|
27
24
|
"devDependencies": {
|
|
28
25
|
"@types/node": "^22.20.1",
|
|
29
26
|
"happy-dom": "^20.11.1",
|