@botpoison/browser 0.4.0 → 1.1.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 +86 -128
- package/package.json +13 -14
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
|
|
|
@@ -11,7 +12,6 @@ declare global {
|
|
|
11
12
|
interface Window {
|
|
12
13
|
__BOTPOISON_VERSION__: string | undefined;
|
|
13
14
|
__BOTPOISON_SUBMIT_LISTENER__: boolean | undefined;
|
|
14
|
-
__BOTPOISON_SESSION_OPENED__: boolean | undefined;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
type BotpoisonOptions = {
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
"use strict";var __botpoison=(()=>{var F0=Object.create;var SF=Object.defineProperty;var t0=Object.getOwnPropertyDescriptor;var h0=Object.getOwnPropertyNames;var e0=Object.getPrototypeOf,x0=Object.prototype.hasOwnProperty;var i0=(s,n)=>()=>(n||s((n={exports:{}}).exports,n),n.exports),s0=(s,n)=>{for(var a in n)SF(s,a,{get:n[a],enumerable:!0})},LF=(s,n,a,C)=>{if(n&&typeof n=="object"||typeof n=="function")for(let w of h0(n))!x0.call(s,w)&&w!==a&&SF(s,w,{get:()=>n[w],enumerable:!(C=t0(n,w))||C.enumerable});return s};var n0=(s,n,a)=>(a=s!=null?F0(e0(s)):{},LF(n||!s||!s.__esModule?SF(a,"default",{value:s,enumerable:!0}):a,s)),r0=s=>LF(SF({},"__esModule",{value:!0}),s);var HF=i0((_0,yF)=>{"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 yF=="object"&&yF.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],BF=["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]()}},CF=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<BF.length;++o){var E=BF[o];r[E]=UF(E,t)}return r},kF=function(t,r){return function(o,E){return new lF(o,r,!0).update(E)[t]()}},dF=function(t){var r=kF("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<BF.length;++o){var E=BF[o];r[E]=kF(E,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 E,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)E=t.charCodeAt(A),E<128?i[l>>2]|=E<<sF[l++&3]:E<2048?(i[l>>2]|=(192|E>>6)<<sF[l++&3],i[l>>2]|=(128|E&63)<<sF[l++&3]):E<55296||E>=57344?(i[l>>2]|=(224|E>>12)<<sF[l++&3],i[l>>2]|=(128|E>>6&63)<<sF[l++&3],i[l>>2]|=(128|E&63)<<sF[l++&3]):(E=65536+((E&1023)<<10|t.charCodeAt(++A)&1023),i[l>>2]|=(240|E>>18)<<sF[l++&3],i[l>>2]|=(128|E>>12&63)<<sF[l++&3],i[l>>2]|=(128|E>>6&63)<<sF[l++&3],i[l>>2]|=(128|E&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,E=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,I=this.h7h,N=this.h7l,y=this.blocks,p,M,H,K,z,h,e,x,f,bF,wF,TF,IF,NF,PF,_F,DF,hF,eF,c,u,S,m,xF,iF;for(p=32;p<160;p+=2)c=y[p-30],u=y[p-29],M=(c>>>1|u<<31)^(c>>>8|u<<24)^c>>>7,H=(u>>>1|c<<31)^(u>>>8|c<<24)^(u>>>7|c<<25),c=y[p-4],u=y[p-3],K=(c>>>19|u<<13)^(u>>>29|c<<3)^c>>>6,z=(u>>>19|c<<13)^(c>>>29|u<<3)^(u>>>6|c<<26),c=y[p-32],u=y[p-31],S=y[p-14],m=y[p-13],h=(m&65535)+(u&65535)+(H&65535)+(z&65535),e=(m>>>16)+(u>>>16)+(H>>>16)+(z>>>16)+(h>>>16),x=(S&65535)+(c&65535)+(M&65535)+(K&65535)+(e>>>16),f=(S>>>16)+(c>>>16)+(M>>>16)+(K>>>16)+(x>>>16),y[p]=f<<16|x&65535,y[p+1]=e<<16|h&65535;var j=t,J=r,P=o,R=E,U=A,k=l,V=_,$=i,W=B,G=D,Y=O,q=v,Q=b,X=T,Z=I,FF=N;for(_F=P&U,DF=R&k,p=0;p<160;p+=8)M=(j>>>28|J<<4)^(J>>>2|j<<30)^(J>>>7|j<<25),H=(J>>>28|j<<4)^(j>>>2|J<<30)^(j>>>7|J<<25),K=(W>>>14|G<<18)^(W>>>18|G<<14)^(G>>>9|W<<23),z=(G>>>14|W<<18)^(G>>>18|W<<14)^(W>>>9|G<<23),bF=j&P,wF=J&R,hF=bF^j&U^_F,eF=wF^J&k^DF,xF=W&Y^~W&Q,iF=G&q^~G&X,c=y[p],u=y[p+1],S=rF[p],m=rF[p+1],h=(m&65535)+(u&65535)+(iF&65535)+(z&65535)+(FF&65535),e=(m>>>16)+(u>>>16)+(iF>>>16)+(z>>>16)+(FF>>>16)+(h>>>16),x=(S&65535)+(c&65535)+(xF&65535)+(K&65535)+(Z&65535)+(e>>>16),f=(S>>>16)+(c>>>16)+(xF>>>16)+(K>>>16)+(Z>>>16)+(x>>>16),c=f<<16|x&65535,u=e<<16|h&65535,h=(eF&65535)+(H&65535),e=(eF>>>16)+(H>>>16)+(h>>>16),x=(hF&65535)+(M&65535)+(e>>>16),f=(hF>>>16)+(M>>>16)+(x>>>16),S=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),Z=f<<16|x&65535,FF=e<<16|h&65535,h=(m&65535)+(u&65535),e=(m>>>16)+(u>>>16)+(h>>>16),x=(S&65535)+(c&65535)+(e>>>16),f=(S>>>16)+(c>>>16)+(x>>>16),V=f<<16|x&65535,$=e<<16|h&65535,M=(V>>>28|$<<4)^($>>>2|V<<30)^($>>>7|V<<25),H=($>>>28|V<<4)^(V>>>2|$<<30)^(V>>>7|$<<25),K=(Z>>>14|FF<<18)^(Z>>>18|FF<<14)^(FF>>>9|Z<<23),z=(FF>>>14|Z<<18)^(FF>>>18|Z<<14)^(Z>>>9|FF<<23),TF=V&j,IF=$&J,hF=TF^V&P^bF,eF=IF^$&R^wF,xF=Z&W^~Z&Y,iF=FF&G^~FF&q,c=y[p+2],u=y[p+3],S=rF[p+2],m=rF[p+3],h=(m&65535)+(u&65535)+(iF&65535)+(z&65535)+(X&65535),e=(m>>>16)+(u>>>16)+(iF>>>16)+(z>>>16)+(X>>>16)+(h>>>16),x=(S&65535)+(c&65535)+(xF&65535)+(K&65535)+(Q&65535)+(e>>>16),f=(S>>>16)+(c>>>16)+(xF>>>16)+(K>>>16)+(Q>>>16)+(x>>>16),c=f<<16|x&65535,u=e<<16|h&65535,h=(eF&65535)+(H&65535),e=(eF>>>16)+(H>>>16)+(h>>>16),x=(hF&65535)+(M&65535)+(e>>>16),f=(hF>>>16)+(M>>>16)+(x>>>16),S=f<<16|x&65535,m=e<<16|h&65535,h=(k&65535)+(u&65535),e=(k>>>16)+(u>>>16)+(h>>>16),x=(U&65535)+(c&65535)+(e>>>16),f=(U>>>16)+(c>>>16)+(x>>>16),Q=f<<16|x&65535,X=e<<16|h&65535,h=(m&65535)+(u&65535),e=(m>>>16)+(u>>>16)+(h>>>16),x=(S&65535)+(c&65535)+(e>>>16),f=(S>>>16)+(c>>>16)+(x>>>16),U=f<<16|x&65535,k=e<<16|h&65535,M=(U>>>28|k<<4)^(k>>>2|U<<30)^(k>>>7|U<<25),H=(k>>>28|U<<4)^(U>>>2|k<<30)^(U>>>7|k<<25),K=(Q>>>14|X<<18)^(Q>>>18|X<<14)^(X>>>9|Q<<23),z=(X>>>14|Q<<18)^(X>>>18|Q<<14)^(Q>>>9|X<<23),NF=U&V,PF=k&$,hF=NF^U&j^TF,eF=PF^k&J^IF,xF=Q&Z^~Q&W,iF=X&FF^~X&G,c=y[p+4],u=y[p+5],S=rF[p+4],m=rF[p+5],h=(m&65535)+(u&65535)+(iF&65535)+(z&65535)+(q&65535),e=(m>>>16)+(u>>>16)+(iF>>>16)+(z>>>16)+(q>>>16)+(h>>>16),x=(S&65535)+(c&65535)+(xF&65535)+(K&65535)+(Y&65535)+(e>>>16),f=(S>>>16)+(c>>>16)+(xF>>>16)+(K>>>16)+(Y>>>16)+(x>>>16),c=f<<16|x&65535,u=e<<16|h&65535,h=(eF&65535)+(H&65535),e=(eF>>>16)+(H>>>16)+(h>>>16),x=(hF&65535)+(M&65535)+(e>>>16),f=(hF>>>16)+(M>>>16)+(x>>>16),S=f<<16|x&65535,m=e<<16|h&65535,h=(R&65535)+(u&65535),e=(R>>>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=(S&65535)+(c&65535)+(e>>>16),f=(S>>>16)+(c>>>16)+(x>>>16),P=f<<16|x&65535,R=e<<16|h&65535,M=(P>>>28|R<<4)^(R>>>2|P<<30)^(R>>>7|P<<25),H=(R>>>28|P<<4)^(P>>>2|R<<30)^(P>>>7|R<<25),K=(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),_F=P&U,DF=R&k,hF=_F^P&V^NF,eF=DF^R&$^PF,xF=Y&Q^~Y&Z,iF=q&X^~q&FF,c=y[p+6],u=y[p+7],S=rF[p+6],m=rF[p+7],h=(m&65535)+(u&65535)+(iF&65535)+(z&65535)+(G&65535),e=(m>>>16)+(u>>>16)+(iF>>>16)+(z>>>16)+(G>>>16)+(h>>>16),x=(S&65535)+(c&65535)+(xF&65535)+(K&65535)+(W&65535)+(e>>>16),f=(S>>>16)+(c>>>16)+(xF>>>16)+(K>>>16)+(W>>>16)+(x>>>16),c=f<<16|x&65535,u=e<<16|h&65535,h=(eF&65535)+(H&65535),e=(eF>>>16)+(H>>>16)+(h>>>16),x=(hF&65535)+(M&65535)+(e>>>16),f=(hF>>>16)+(M>>>16)+(x>>>16),S=f<<16|x&65535,m=e<<16|h&65535,h=(J&65535)+(u&65535),e=(J>>>16)+(u>>>16)+(h>>>16),x=(j&65535)+(c&65535)+(e>>>16),f=(j>>>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=(S&65535)+(c&65535)+(e>>>16),f=(S>>>16)+(c>>>16)+(x>>>16),j=f<<16|x&65535,J=e<<16|h&65535;h=(r&65535)+(J&65535),e=(r>>>16)+(J>>>16)+(h>>>16),x=(t&65535)+(j&65535)+(e>>>16),f=(t>>>16)+(j>>>16)+(x>>>16),this.h0h=f<<16|x&65535,this.h0l=e<<16|h&65535,h=(E&65535)+(R&65535),e=(E>>>16)+(R>>>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)+(U&65535)+(e>>>16),f=(A>>>16)+(U>>>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)+(X&65535),e=(T>>>16)+(X>>>16)+(h>>>16),x=(b&65535)+(Q&65535)+(e>>>16),f=(b>>>16)+(Q>>>16)+(x>>>16),this.h6h=f<<16|x&65535,this.h6l=e<<16|h&65535,h=(N&65535)+(FF&65535),e=(N>>>16)+(FF>>>16)+(h>>>16),x=(I&65535)+(Z&65535)+(e>>>16),f=(I>>>16)+(Z>>>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,E=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,I=this.h7h,N=this.h7l,y=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[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 y>=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]),y>=384&&(p+=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]),y==512&&(p+=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[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]),p},g.prototype.toString=g.prototype.hex,g.prototype.digest=function(){this.finalize();var t=this.h0h,r=this.h0l,o=this.h1h,E=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,I=this.h7h,N=this.h7l,y=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,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 y>=256&&p.push(i>>24&255,i>>16&255,i>>8&255,i&255),y>=384&&p.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),y==512&&p.push(b>>24&255,b>>16&255,b>>8&255,b&255,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},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 E,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);E=!0}var l=t.length;if(!E){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=CF(512);L.sha512=L,L.sha384=CF(384),L.sha512_256=CF(256),L.sha512_224=CF(224),L.sha512.hmac=dF(512),L.sha384.hmac=dF(384),L.sha512_256.hmac=dF(256),L.sha512_224.hmac=dF(224),nF?yF.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={};s0(p0,{default:()=>vF});var aF="https://api.botpoison.com",uF="_botpoison",EF={"Content-Type":"text/plain",Accept:"application/json"};var MF=({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},mF=({formElement:s,name:n})=>{s.dispatchEvent(new CustomEvent(`botpoison-challenge-${n}`))};var KF=n0(HF()),o0=async({input:s,expected:n})=>{let a=0;for(;;){let C=(0,KF.sha512)(`${s}:${a}`);if(a%4e4===0&&await zF(0),C.substring(0,n.length)===n)return a.toString();a++}},zF=s=>new Promise(n=>setTimeout(n,s)),l0=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 o0({input:`${a}:${nF}`,expected:"0".repeat(C)});tF.push(oF),n==null||n(tF.length/w),await zF(0)}return tF},jF=l0;var JF="_botpoison.v2.session.",fF,RF=new Map,VF=()=>{if(fF!==void 0)return fF;try{let s=window.sessionStorage,n=`${JF}probe`;s.setItem(n,"1"),s.removeItem(n),fF=s}catch(s){fF=null}return fF},pF=s=>`${JF}${s}`,gF=s=>{var a;let n=VF();if(!n)return RF.get(pF(s));try{return(a=n.getItem(pF(s)))!=null?a:void 0}catch(C){return RF.get(pF(s))}},$F=(s,n)=>{let a=VF();if(a)try{a.setItem(pF(s),n);return}catch(C){fF=null}RF.set(pF(s),n)};var AF,WF=(s=aF)=>gF(s),GF=(s,n)=>{let a=n==null?void 0:n.token;typeof a=="string"&&$F(s,a)},YF=({baseUrl:s=aF}={})=>gF(s)?Promise.resolve():AF||(AF=fetch(`${s}/session`,{method:"POST",headers:EF,body:"{}"}).then(async n=>{n.ok&&GF(s,await n.json())}).catch(()=>{}).finally(()=>{AF=void 0}),AF),qF=({challenge:s,solutions:n,baseUrl:a=aF})=>fetch(`${a}/session`,{method:"POST",headers:EF,keepalive:!0,body:JSON.stringify({challenge:s,solutions:n,token:gF(a)})}).then(async C=>{C.ok&&GF(a,await C.json())}).catch(()=>{});var a0=()=>typeof location=="undefined"?void 0:location.hostname,OF=async({publicKey:s,baseUrl:n=aF,onProgress:a})=>{let w=await(await fetch(`${n}/challenge`,{method:"POST",headers:EF,body:JSON.stringify({publicKey:s,hostname:a0(),version:"0.4.0",token:WF(n)})})).json(),tF=await jF({challenge:w,onProgress:a});return qF({challenge:w,solutions:tF,baseUrl:n}),{solution:btoa(JSON.stringify({challenge:w,solutions:tF}))}};var f0=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=f0(C.target);if(!w)return;let{formElement:tF,publicKey:nF}=w;C.preventDefault(),mF({formElement:tF,name:"start"}),OF({publicKey:nF,baseUrl:n}).then(({solution:oF})=>{mF({formElement:tF,name:"success"}),MF({formElement:tF,value:oF}),HTMLFormElement.prototype.submit.call(tF)}).catch(oF=>{console.error(oF),mF({formElement:tF,name:"error"})})}catch(w){console.error(w)}};return s.addEventListener("submit",a),{dispose:()=>{s.removeEventListener("submit",a)}}};var XF=()=>{c0(),u0(),E0()},vF=class{constructor({publicKey:n,baseUrl:a}){this.publicKey=n,this.baseUrl=a}static init(){XF()}async challenge(n){let{onProgress:a}=n||{};return OF({publicKey:this.publicKey,baseUrl:this.baseUrl,onProgress:a})}},c0=()=>{typeof document!="undefined"&&(window.__BOTPOISON_VERSION__="0.4.0")},u0=()=>{typeof document!="undefined"&&(window.__BOTPOISON_SUBMIT_LISTENER__||(window.__BOTPOISON_SUBMIT_LISTENER__=!0,QF({documentRef:document})))},E0=()=>{if(typeof document=="undefined"||window.__BOTPOISON_SESSION_OPENED__)return;window.__BOTPOISON_SESSION_OPENED__=!0;let s=()=>{YF()};typeof requestIdleCallback=="function"?requestIdleCallback(s,{timeout:2e3}):setTimeout(s,0)};XF();return r0(p0);})();
|
|
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 b=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var L=(n,e)=>{for(var t in e)b(n,t,{get:e[t],enumerable:!0})},N=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of A(e))!C.call(n,o)&&o!==t&&b(n,o,{get:()=>e[o],enumerable:!(r=I(e,o))||r.enumerable});return n};var w=n=>N(b({},"__esModule",{value:!0}),n);var H={};L(H,{default:()=>E});var d="https://api.botpoison.com",u="_botpoison",m={"Content-Type":"text/plain",Accept:"application/json"};var f=({formElement:n,value:e})=>{let t=n.querySelector(`input[name="${u}"]`);if(!t){let r=n.ownerDocument;t=r.createElement("input"),t.setAttribute("type","hidden"),t.setAttribute("name",u),r.getElementById(u)||t.setAttribute("id",u),n.appendChild(t)}return t.setAttribute("value",e),t},g=({formElement:n,name:e})=>{n.dispatchEvent(new CustomEvent(`botpoison-challenge-${e}`))};var U=n=>new Promise(e=>setTimeout(e,n)),h=n=>{let e="";for(let t of n)e+=t.toString(16).padStart(2,"0");return BigInt(`0x${e}`)},v=n=>{let e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t},B=(n,e)=>{let t=n.toString(16).padStart(e*2,"0"),r="";for(let o=0;o<t.length;o+=2)r+=String.fromCharCode(parseInt(t.substring(o,o+2),16));return btoa(r)},R=async({nonce:n,modulus:e,byteLength:t})=>{let r=new TextEncoder,o=[],s=0;for(let l=0;s<t;l++){let p=new Uint8Array(await crypto.subtle.digest("SHA-256",r.encode(`${n}:${l}`)));o.push(p),s+=p.length}let a=new Uint8Array(s),i=0;for(let l of o)a.set(l,i),i+=l.length;let c=h(a.subarray(0,t))%e;return c*c%e},x=async({x:n,modulus:e,squarings:t,onProgress:r})=>{let o=n;for(let s=0;s<t;s++)o=o*o%e,s%2e4===19999&&(r==null||r(s/t),await U(0));return o},P="sundial",M=async({challenge:n,onProgress:e})=>{let{algo:t,nonce:r,modulus:o,squarings:s}=n.payload;if(t!==void 0&&t!==P)throw new Error(`Botpoison: this version cannot solve "${t}" challenges. Upgrade @botpoison/browser.`);let a=v(o),i=h(a),c=a.length;e==null||e(0);let l=await R({nonce:r,modulus:i,byteLength:c}),p=await x({x:l,modulus:i,squarings:s,onProgress:e});return e==null||e(1),[B(p,c)]},S=M;var y=({challenge:n,solutions:e,baseUrl:t=d})=>fetch(`${t}/session`,{method:"POST",headers:m,keepalive:!0,body:JSON.stringify({challenge:n,solutions:e})}).then(()=>{},()=>{});var D=()=>typeof location=="undefined"?void 0:location.hostname,_=async({publicKey:n,baseUrl:e=d,onProgress:t})=>{let o=await(await fetch(`${e}/challenge`,{method:"POST",headers:m,body:JSON.stringify({publicKey:n,hostname:D(),version:"1.1.0"})})).json(),s=await S({challenge:o,onProgress:t});return y({challenge:o,solutions:s,baseUrl:e}),{solution:btoa(JSON.stringify({challenge:o,solutions:s}))}};var k=n=>{if(!n||!n.tagName)return;let e=n;if(e.tagName!=="FORM")return;let t=e,r=t.dataset.botpoisonPublicKey;return r?{formElement:t,publicKey:r}:void 0},O=({documentRef:n,baseUrl:e})=>{let t=r=>{try{let o=k(r.target);if(!o)return;let{formElement:s,publicKey:a}=o;r.preventDefault(),g({formElement:s,name:"start"}),_({publicKey:a,baseUrl:e}).then(({solution:i})=>{g({formElement:s,name:"success"}),f({formElement:s,value:i}),HTMLFormElement.prototype.submit.call(s)}).catch(i=>{console.error(i),g({formElement:s,name:"error"})})}catch(o){console.error(o)}};return n.addEventListener("submit",t),{dispose:()=>{n.removeEventListener("submit",t)}}};var T=()=>{K(),F()},E=class{constructor({publicKey:e,baseUrl:t}){this.publicKey=e,this.baseUrl=t}static init(){T()}async challenge(e){let{onProgress:t}=e||{};return _({publicKey:this.publicKey,baseUrl:this.baseUrl,onProgress:t})}},K=()=>{typeof document!="undefined"&&(window.__BOTPOISON_VERSION__="1.1.0")},F=()=>{typeof document!="undefined"&&(window.__BOTPOISON_SUBMIT_LISTENER__||(window.__BOTPOISON_SUBMIT_LISTENER__=!0,O({documentRef:document})))};T();return w(H);})();
|
|
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,121 +35,98 @@ var dispatchChallengeEvent = ({
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
// src/computeSolutions.ts
|
|
38
|
-
|
|
39
|
-
var computeCollisionInteger = async ({
|
|
40
|
-
input,
|
|
41
|
-
expected
|
|
42
|
-
}) => {
|
|
43
|
-
let attempt = 0;
|
|
44
|
-
while (true) {
|
|
45
|
-
const hash = sha512(`${input}:${attempt}`);
|
|
46
|
-
if (attempt % 4e4 === 0) {
|
|
47
|
-
await sleep(0);
|
|
48
|
-
}
|
|
49
|
-
if (hash.substring(0, expected.length) === expected) {
|
|
50
|
-
return attempt.toString();
|
|
51
|
-
}
|
|
52
|
-
attempt++;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
38
|
+
var YIELD_INTERVAL = 2e4;
|
|
55
39
|
var sleep = (time) => new Promise((r) => setTimeout(r, time));
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const { nonce, difficulty, hardness } = challenge.payload;
|
|
61
|
-
const solutions = [];
|
|
62
|
-
onProgress == null ? void 0 : onProgress(0);
|
|
63
|
-
for (let h = 0; h < hardness; h++) {
|
|
64
|
-
const solution = await computeCollisionInteger({
|
|
65
|
-
input: `${nonce}:${h}`,
|
|
66
|
-
expected: "0".repeat(difficulty)
|
|
67
|
-
});
|
|
68
|
-
solutions.push(solution);
|
|
69
|
-
onProgress == null ? void 0 : onProgress(solutions.length / hardness);
|
|
70
|
-
await sleep(0);
|
|
40
|
+
var bytesToBigInt = (bytes) => {
|
|
41
|
+
let hex = "";
|
|
42
|
+
for (const byte of bytes) {
|
|
43
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
71
44
|
}
|
|
72
|
-
return
|
|
45
|
+
return BigInt(`0x${hex}`);
|
|
73
46
|
};
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var memory = /* @__PURE__ */ new Map();
|
|
80
|
-
var getBacking = () => {
|
|
81
|
-
if (backing !== void 0) {
|
|
82
|
-
return backing;
|
|
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);
|
|
83
52
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
backing = null;
|
|
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));
|
|
92
60
|
}
|
|
93
|
-
return
|
|
61
|
+
return btoa(binary);
|
|
94
62
|
};
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
63
|
+
var deriveX = async ({
|
|
64
|
+
nonce,
|
|
65
|
+
modulus,
|
|
66
|
+
byteLength
|
|
67
|
+
}) => {
|
|
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;
|
|
101
80
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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;
|
|
106
86
|
}
|
|
87
|
+
const x = bytesToBigInt(joined.subarray(0, byteLength)) % modulus;
|
|
88
|
+
return x * x % modulus;
|
|
107
89
|
};
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
90
|
+
var runChain = async ({
|
|
91
|
+
x,
|
|
92
|
+
modulus,
|
|
93
|
+
squarings,
|
|
94
|
+
onProgress
|
|
95
|
+
}) => {
|
|
96
|
+
let y = x;
|
|
97
|
+
for (let i = 0; i < squarings; i++) {
|
|
98
|
+
y = y * y % modulus;
|
|
99
|
+
if (i % YIELD_INTERVAL === YIELD_INTERVAL - 1) {
|
|
100
|
+
onProgress == null ? void 0 : onProgress(i / squarings);
|
|
101
|
+
await sleep(0);
|
|
116
102
|
}
|
|
117
103
|
}
|
|
118
|
-
|
|
104
|
+
return y;
|
|
119
105
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
var openSession = ({
|
|
131
|
-
baseUrl = DEFAULT_BASE_URL
|
|
132
|
-
} = {}) => {
|
|
133
|
-
if (readSessionToken(baseUrl)) {
|
|
134
|
-
return Promise.resolve();
|
|
135
|
-
}
|
|
136
|
-
if (inFlight) {
|
|
137
|
-
return inFlight;
|
|
106
|
+
var ALGO = "sundial";
|
|
107
|
+
var computeSolutions = async ({
|
|
108
|
+
challenge,
|
|
109
|
+
onProgress
|
|
110
|
+
}) => {
|
|
111
|
+
const { algo, nonce, modulus: encodedModulus, squarings } = challenge.payload;
|
|
112
|
+
if (algo !== void 0 && algo !== ALGO) {
|
|
113
|
+
throw new Error(
|
|
114
|
+
`Botpoison: this version cannot solve "${algo}" challenges. Upgrade @botpoison/browser.`
|
|
115
|
+
);
|
|
138
116
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}).catch(() => void 0).finally(() => {
|
|
148
|
-
inFlight = void 0;
|
|
149
|
-
});
|
|
150
|
-
return inFlight;
|
|
117
|
+
const modulusBytes = base64ToBytes(encodedModulus);
|
|
118
|
+
const modulus = bytesToBigInt(modulusBytes);
|
|
119
|
+
const byteLength = modulusBytes.length;
|
|
120
|
+
onProgress == null ? void 0 : onProgress(0);
|
|
121
|
+
const x = await deriveX({ nonce, modulus, byteLength });
|
|
122
|
+
const y = await runChain({ x, modulus, squarings, onProgress });
|
|
123
|
+
onProgress == null ? void 0 : onProgress(1);
|
|
124
|
+
return [bigIntToBase64(y, byteLength)];
|
|
151
125
|
};
|
|
152
|
-
var
|
|
126
|
+
var computeSolutions_default = computeSolutions;
|
|
127
|
+
|
|
128
|
+
// src/reportWork.ts
|
|
129
|
+
var reportWork = ({
|
|
153
130
|
challenge,
|
|
154
131
|
solutions,
|
|
155
132
|
baseUrl = DEFAULT_BASE_URL
|
|
@@ -157,16 +134,11 @@ var exchangeSolved = ({
|
|
|
157
134
|
method: "POST",
|
|
158
135
|
headers: SIMPLE_REQUEST_HEADERS,
|
|
159
136
|
keepalive: true,
|
|
160
|
-
body: JSON.stringify({
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}).then(async (response) => {
|
|
166
|
-
if (response.ok) {
|
|
167
|
-
store(baseUrl, await response.json());
|
|
168
|
-
}
|
|
169
|
-
}).catch(() => void 0);
|
|
137
|
+
body: JSON.stringify({ challenge, solutions })
|
|
138
|
+
}).then(
|
|
139
|
+
() => void 0,
|
|
140
|
+
() => void 0
|
|
141
|
+
);
|
|
170
142
|
|
|
171
143
|
// src/runChallenge.ts
|
|
172
144
|
var hostname = () => typeof location === "undefined" ? void 0 : location.hostname;
|
|
@@ -183,8 +155,7 @@ var runChallenge = async ({
|
|
|
183
155
|
hostname: hostname(),
|
|
184
156
|
// Copies of this bundle stay embedded in sites for years, so the API
|
|
185
157
|
// has to start collecting this long before it can act on it.
|
|
186
|
-
version: "
|
|
187
|
-
token: getSessionToken(baseUrl)
|
|
158
|
+
version: "1.1.0"
|
|
188
159
|
})
|
|
189
160
|
});
|
|
190
161
|
const challenge = await response.json();
|
|
@@ -192,7 +163,7 @@ var runChallenge = async ({
|
|
|
192
163
|
challenge,
|
|
193
164
|
onProgress
|
|
194
165
|
});
|
|
195
|
-
void
|
|
166
|
+
void reportWork({ challenge, solutions, baseUrl });
|
|
196
167
|
const serialized = btoa(
|
|
197
168
|
JSON.stringify({
|
|
198
169
|
challenge,
|
|
@@ -254,7 +225,6 @@ var createAutoSubmit = ({
|
|
|
254
225
|
var init = () => {
|
|
255
226
|
addVersion();
|
|
256
227
|
addSubmitListener();
|
|
257
|
-
startSession();
|
|
258
228
|
};
|
|
259
229
|
var Botpoison = class {
|
|
260
230
|
constructor({ publicKey, baseUrl }) {
|
|
@@ -275,7 +245,7 @@ var Botpoison = class {
|
|
|
275
245
|
};
|
|
276
246
|
var addVersion = () => {
|
|
277
247
|
if (typeof document !== "undefined") {
|
|
278
|
-
window.__BOTPOISON_VERSION__ = "
|
|
248
|
+
window.__BOTPOISON_VERSION__ = "1.1.0";
|
|
279
249
|
}
|
|
280
250
|
};
|
|
281
251
|
var addSubmitListener = () => {
|
|
@@ -286,18 +256,6 @@ var addSubmitListener = () => {
|
|
|
286
256
|
}
|
|
287
257
|
}
|
|
288
258
|
};
|
|
289
|
-
var startSession = () => {
|
|
290
|
-
if (typeof document === "undefined" || window.__BOTPOISON_SESSION_OPENED__) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
window.__BOTPOISON_SESSION_OPENED__ = true;
|
|
294
|
-
const open = () => void openSession();
|
|
295
|
-
if (typeof requestIdleCallback === "function") {
|
|
296
|
-
requestIdleCallback(open, { timeout: 2e3 });
|
|
297
|
-
} else {
|
|
298
|
-
setTimeout(open, 0);
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
259
|
init();
|
|
302
260
|
export {
|
|
303
261
|
Botpoison as default
|
package/package.json
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpoison/browser",
|
|
3
|
+
"version": "1.1.0",
|
|
3
4
|
"private": false,
|
|
4
|
-
"version": "0.4.0",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"module": "./dist/index.mjs",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"unpkg": "./dist/index.js",
|
|
9
|
-
"jsdelivr": "./dist/index.js",
|
|
10
5
|
"exports": {
|
|
11
6
|
".": {
|
|
12
7
|
"types": "./dist/index.d.ts",
|
|
@@ -15,26 +10,30 @@
|
|
|
15
10
|
},
|
|
16
11
|
"./package.json": "./package.json"
|
|
17
12
|
},
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"jsdelivr": "./dist/index.js",
|
|
15
|
+
"unpkg": "./dist/index.js",
|
|
16
|
+
"module": "./dist/index.mjs",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
18
|
"files": [
|
|
19
19
|
"dist"
|
|
20
20
|
],
|
|
21
|
-
"engines": {
|
|
22
|
-
"node": ">=18"
|
|
23
|
-
},
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"js-sha512": "^0.8.0"
|
|
26
|
-
},
|
|
27
21
|
"devDependencies": {
|
|
28
22
|
"@types/node": "^22.20.1",
|
|
29
|
-
"
|
|
23
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
24
|
+
"happy-dom": "^20.14.0",
|
|
30
25
|
"tsup": "^8.5.1",
|
|
31
26
|
"typescript": "^6.0.3",
|
|
32
27
|
"vite": "^6.4.3",
|
|
33
|
-
"vitest": "^4.1.
|
|
28
|
+
"vitest": "^4.1.11"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18"
|
|
34
32
|
},
|
|
35
33
|
"scripts": {
|
|
36
34
|
"build": "bash scripts/build.sh",
|
|
37
35
|
"test": "bash scripts/test.sh",
|
|
36
|
+
"test:coverage": "bash scripts/test.sh --coverage",
|
|
38
37
|
"typecheck": "bash scripts/typecheck.sh"
|
|
39
38
|
}
|
|
40
39
|
}
|