newgrounds-boom
Version:
Newgrounds.io plugin for Kaboom
3 lines (2 loc) • 16.2 kB
JavaScript
var ne=Object.defineProperty;var k=(i,n)=>ne(i,"name",{value:n,configurable:!0}),T=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+i+'" is not supported')});var oe=Object.defineProperty,D=k((i,n)=>oe(i,"name",{value:n,configurable:!0}),"S"),te=(i=>typeof T<"u"?T:typeof Proxy<"u"?new Proxy(i,{get:(n,o)=>(typeof T<"u"?T:n)[o]}):i)(function(i){if(typeof T<"u")return T.apply(this,arguments);throw new Error('Dynamic require of "'+i+'" is not supported')}),R=k((i,n)=>()=>(i&&(n=i(i=0)),n),"A"),se=k((i,n)=>()=>(n||i((n={exports:{}}).exports,n),n.exports),"ue");function re(i){(function(n,o){typeof exports=="object"?module.exports=exports=o():typeof define=="function"&&define.amd?define([],o):i.CryptoJS=o()})(0,function(){var n=n||function(o,h){var c;if(typeof window<"u"&&window.crypto&&(c=window.crypto),!c&&typeof window<"u"&&window.msCrypto&&(c=window.msCrypto),!c&&typeof global<"u"&&global.crypto&&(c=global.crypto),!c&&typeof te=="function")try{c=te("crypto")}catch{}var p=D(function(){if(c){if(typeof c.getRandomValues=="function")try{return c.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof c.randomBytes=="function")try{return c.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},"i"),v=Object.create||function(){function s(){}return k(s,"n"),D(s,"t"),function(y){var g;return s.prototype=y,g=new s,s.prototype=null,g}}(),w={},x=w.lib={},m=x.Base={extend:function(s){var y=v(this);return s&&y.mixIn(s),y.hasOwnProperty("init")&&this.init!==y.init||(y.init=function(){y.$super.init.apply(this,arguments)}),y.init.prototype=y,y.$super=this,y},create:function(){var s=this.extend();return s.init.apply(s,arguments),s},init:function(){},mixIn:function(s){for(var y in s)s.hasOwnProperty(y)&&(this[y]=s[y]);s.hasOwnProperty("toString")&&(this.toString=s.toString)},clone:function(){return this.init.prototype.extend(this)}},b=x.WordArray=m.extend({init:function(s,y){s=this.words=s||[],this.sigBytes=y??4*s.length},toString:function(s){return(s||Hex).stringify(this)},concat:function(s){var y=this.words,g=s.words,d=this.sigBytes,f=s.sigBytes;if(this.clamp(),d%4)for(var l=0;l<f;l++){var S=g[l>>>2]>>>24-l%4*8&255;y[d+l>>>2]|=S<<24-(d+l)%4*8}else for(l=0;l<f;l+=4)y[d+l>>>2]=g[l>>>2];return this.sigBytes+=f,this},clamp:function(){var s=this.words,y=this.sigBytes;s[y>>>2]&=4294967295<<32-y%4*8,s.length=o.ceil(y/4)},clone:function(){var s=m.clone.call(this);return s.words=this.words.slice(0),s},random:function(s){for(var y=[],g=0;g<s;g+=4)y.push(p());return new b.init(y,s)}}),B=w.enc={},M=B.Latin1={stringify:function(s){for(var y=s.words,g=s.sigBytes,d=[],f=0;f<g;f++){var l=y[f>>>2]>>>24-f%4*8&255;d.push(String.fromCharCode(l))}return d.join("")},parse:function(s){for(var y=s.length,g=[],d=0;d<y;d++)g[d>>>2]|=(255&s.charCodeAt(d))<<24-d%4*8;return new b.init(g,y)}},A=B.Utf8={stringify:function(s){try{return decodeURIComponent(escape(M.stringify(s)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(s){return M.parse(unescape(encodeURIComponent(s)))}};return x.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new b.init,this._nDataBytes=0},_append:function(s){typeof s=="string"&&(s=A.parse(s)),this._data.concat(s),this._nDataBytes+=s.sigBytes},_process:function(s){var y,g=this._data,d=g.words,f=g.sigBytes,l=this.blockSize,S=f/(4*l),e=(S=s?o.ceil(S):o.max((0|S)-this._minBufferSize,0))*l,r=o.min(4*e,f);if(e){for(var u=0;u<e;u+=l)this._doProcessBlock(d,u);y=d.splice(0,e),g.sigBytes-=r}return new b.init(y,r)},clone:function(){var s=m.clone.call(this);return s._data=this._data.clone(),s},_minBufferSize:0}),w.algo={},w}(Math);return function(){var o=n,h=o.lib.WordArray;o.enc.Base64={stringify:function(c){var p=c.words,v=c.sigBytes,w=this._map;c.clamp();for(var x=[],m=0;m<v;m+=3)for(var b=(p[m>>>2]>>>24-m%4*8&255)<<16|(p[m+1>>>2]>>>24-(m+1)%4*8&255)<<8|p[m+2>>>2]>>>24-(m+2)%4*8&255,B=0;B<4&&m+.75*B<v;B++)x.push(w.charAt(b>>>6*(3-B)&63));var M=w.charAt(64);if(M)for(;x.length%4;)x.push(M);return x.join("")},parse:function(c){var p=c.length,v=this._map,w=this._reverseMap;if(!w){w=this._reverseMap=[];for(var x=0;x<v.length;x++)w[v.charCodeAt(x)]=x}var m=v.charAt(64);if(m){var b=c.indexOf(m);b!==-1&&(p=b)}return function(B,M,A){for(var s=[],y=0,g=0;g<M;g++)if(g%4){var d=A[B.charCodeAt(g-1)]<<g%4*2,f=A[B.charCodeAt(g)]>>>6-g%4*2,l=d|f;s[y>>>2]|=l<<24-y%4*8,y++}return h.create(s,y)}(c,p,w)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),n.lib.Cipher||function(o){var h=n,c=h.lib,p=c.Base,v=c.WordArray,w=c.BufferedBlockAlgorithm,x=h.enc,m=(x.Utf8,x.Base64),b=h.algo.EvpKDF,B=c.Cipher=w.extend({cfg:p.extend(),createEncryptor:function(e,r){return this.create(this._ENC_XFORM_MODE,e,r)},createDecryptor:function(e,r){return this.create(this._DEC_XFORM_MODE,e,r)},init:function(e,r,u){this.cfg=this.cfg.extend(u),this._xformMode=e,this._key=r,this.reset()},reset:function(){w.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(r){return typeof r=="string"?S:f}return k(e,"e"),D(e,"t"),function(r){return{encrypt:function(u,t,a){return e(t).encrypt(r,u,t,a)},decrypt:function(u,t,a){return e(t).decrypt(r,u,t,a)}}}}()}),M=(c.StreamCipher=B.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),h.mode={}),A=c.BlockCipherMode=p.extend({createEncryptor:function(e,r){return this.Encryptor.create(e,r)},createDecryptor:function(e,r){return this.Decryptor.create(e,r)},init:function(e,r){this._cipher=e,this._iv=r}}),s=M.CBC=function(){var e=A.extend();function r(u,t,a){var _,C=this._iv;C?(_=C,this._iv=o):_=this._prevBlock;for(var E=0;E<a;E++)u[t+E]^=_[E]}return k(r,"r"),D(r,"r"),e.Encryptor=e.extend({processBlock:function(u,t){var a=this._cipher,_=a.blockSize;r.call(this,u,t,_),a.encryptBlock(u,t),this._prevBlock=u.slice(t,t+_)}}),e.Decryptor=e.extend({processBlock:function(u,t){var a=this._cipher,_=a.blockSize,C=u.slice(t,t+_);a.decryptBlock(u,t),r.call(this,u,t,_),this._prevBlock=C}}),e}(),y=(h.pad={}).Pkcs7={pad:function(e,r){for(var u=4*r,t=u-e.sigBytes%u,a=t<<24|t<<16|t<<8|t,_=[],C=0;C<t;C+=4)_.push(a);var E=v.create(_,t);e.concat(E)},unpad:function(e){var r=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=r}},g=(c.BlockCipher=B.extend({cfg:B.cfg.extend({mode:s,padding:y}),reset:function(){var e;B.reset.call(this);var r=this.cfg,u=r.iv,t=r.mode;this._xformMode==this._ENC_XFORM_MODE?e=t.createEncryptor:(e=t.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,u&&u.words):(this._mode=e.call(t,this,u&&u.words),this._mode.__creator=e)},_doProcessBlock:function(e,r){this._mode.processBlock(e,r)},_doFinalize:function(){var e,r=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(r.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),r.unpad(e)),e},blockSize:4}),c.CipherParams=p.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}})),d=(h.format={}).OpenSSL={stringify:function(e){var r=e.ciphertext,u=e.salt;return(u?v.create([1398893684,1701076831]).concat(u).concat(r):r).toString(m)},parse:function(e){var r,u=m.parse(e),t=u.words;return t[0]==1398893684&&t[1]==1701076831&&(r=v.create(t.slice(2,4)),t.splice(0,4),u.sigBytes-=16),g.create({ciphertext:u,salt:r})}},f=c.SerializableCipher=p.extend({cfg:p.extend({format:d}),encrypt:function(e,r,u,t){t=this.cfg.extend(t);var a=e.createEncryptor(u,t),_=a.finalize(r),C=a.cfg;return g.create({ciphertext:_,key:u,iv:C.iv,algorithm:e,mode:C.mode,padding:C.padding,blockSize:e.blockSize,formatter:t.format})},decrypt:function(e,r,u,t){return t=this.cfg.extend(t),r=this._parse(r,t.format),e.createDecryptor(u,t).finalize(r.ciphertext)},_parse:function(e,r){return typeof e=="string"?r.parse(e,this):e}}),l=(h.kdf={}).OpenSSL={execute:function(e,r,u,t){t||(t=v.random(8));var a=b.create({keySize:r+u}).compute(e,t),_=v.create(a.words.slice(r),4*u);return a.sigBytes=4*r,g.create({key:a,iv:_,salt:t})}},S=c.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:l}),encrypt:function(e,r,u,t){var a=(t=this.cfg.extend(t)).kdf.execute(u,e.keySize,e.ivSize);t.iv=a.iv;var _=f.encrypt.call(this,e,r,a.key,t);return _.mixIn(a),_},decrypt:function(e,r,u,t){t=this.cfg.extend(t),r=this._parse(r,t.format);var a=t.kdf.execute(u,e.keySize,e.ivSize,r.salt);return t.iv=a.iv,f.decrypt.call(this,e,r,a.key,t)}})}(),function(){var o=n,h=o.lib.BlockCipher,c=o.algo,p=[],v=[],w=[],x=[],m=[],b=[],B=[],M=[],A=[],s=[];(function(){for(var d=[],f=0;f<256;f++)d[f]=f<128?f<<1:f<<1^283;var l=0,S=0;for(f=0;f<256;f++){var e=S^S<<1^S<<2^S<<3^S<<4;e=e>>>8^255&e^99,p[l]=e,v[e]=l;var r=d[l],u=d[r],t=d[u],a=257*d[e]^16843008*e;w[l]=a<<24|a>>>8,x[l]=a<<16|a>>>16,m[l]=a<<8|a>>>24,b[l]=a,a=16843009*t^65537*u^257*r^16843008*l,B[e]=a<<24|a>>>8,M[e]=a<<16|a>>>16,A[e]=a<<8|a>>>24,s[e]=a,l?(l=r^d[d[d[t^r]]],S^=d[d[S]]):l=S=1}})();var y=[0,1,2,4,8,16,32,64,128,27,54],g=c.AES=h.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var d=this._keyPriorReset=this._key,f=d.words,l=d.sigBytes/4,S=4*((this._nRounds=l+6)+1),e=this._keySchedule=[],r=0;r<S;r++)r<l?e[r]=f[r]:(a=e[r-1],r%l?l>6&&r%l==4&&(a=p[a>>>24]<<24|p[a>>>16&255]<<16|p[a>>>8&255]<<8|p[255&a]):(a=p[(a=a<<8|a>>>24)>>>24]<<24|p[a>>>16&255]<<16|p[a>>>8&255]<<8|p[255&a],a^=y[r/l|0]<<24),e[r]=e[r-l]^a);for(var u=this._invKeySchedule=[],t=0;t<S;t++){if(r=S-t,t%4)var a=e[r];else a=e[r-4];u[t]=t<4||r<=4?a:B[p[a>>>24]]^M[p[a>>>16&255]]^A[p[a>>>8&255]]^s[p[255&a]]}}},encryptBlock:function(d,f){this._doCryptBlock(d,f,this._keySchedule,w,x,m,b,p)},decryptBlock:function(d,f){var l=d[f+1];d[f+1]=d[f+3],d[f+3]=l,this._doCryptBlock(d,f,this._invKeySchedule,B,M,A,s,v),l=d[f+1],d[f+1]=d[f+3],d[f+3]=l},_doCryptBlock:function(d,f,l,S,e,r,u,t){for(var a=this._nRounds,_=d[f]^l[0],C=d[f+1]^l[1],E=d[f+2]^l[2],z=d[f+3]^l[3],P=4,ee=1;ee<a;ee++){var U=S[_>>>24]^e[C>>>16&255]^r[E>>>8&255]^u[255&z]^l[P++],F=S[C>>>24]^e[E>>>16&255]^r[z>>>8&255]^u[255&_]^l[P++],I=S[E>>>24]^e[z>>>16&255]^r[_>>>8&255]^u[255&C]^l[P++],N=S[z>>>24]^e[_>>>16&255]^r[C>>>8&255]^u[255&E]^l[P++];_=U,C=F,E=I,z=N}U=(t[_>>>24]<<24|t[C>>>16&255]<<16|t[E>>>8&255]<<8|t[255&z])^l[P++],F=(t[C>>>24]<<24|t[E>>>16&255]<<16|t[z>>>8&255]<<8|t[255&_])^l[P++],I=(t[E>>>24]<<24|t[z>>>16&255]<<16|t[_>>>8&255]<<8|t[255&C])^l[P++],N=(t[z>>>24]<<24|t[_>>>16&255]<<16|t[C>>>8&255]<<8|t[255&E])^l[P++],d[f]=U,d[f+1]=F,d[f+2]=I,d[f+3]=N},keySize:8});o.AES=h._createHelper(g)}(),n})}k(re,"Z");var ae=R(()=>{D(re,"setCrypto")});function q(i,n=0,o={}){var h,c,p,v,w,x,m;this.appID=i,this.cipher=n,re(this),this.medalDisplayTime=o.medalDisplayTime||5,this.showPopups=o.showPopups||!0,this.showDescriptions=o.showDescriptions||!0,this.debug=o.debug||!1,this.points=[5,10,25,50,100],this.displayMedalQueue=[];let b=new URL(window.location.href);this.sessionID=(h=b.searchParams.get("ngio_session_id"))!=null?h:0;let B=this.call("ScoreBoard.getBoards",0,0);this.scoreboards=(v=(p=(c=B?.result)==null?void 0:c.data)==null?void 0:p.scoreboards)!=null?v:[];let M=this.call("Medal.getList",0,0);this.medals=(m=(x=(w=M?.result)==null?void 0:w.data)==null?void 0:x.medals)!=null?m:[];for(let A of this.medals)A.image=new Image,A.image.src=A.icon,this.debug&&(A.unlocked=0)}k(q,"U");var ce=R(()=>{ae(),D(q,"connect")});function J(i){if(!this.medals||!this.medals.find(o=>o.id==i))return;let n=this.medals.find(o=>o.id==i);n.unlocked||(n.unlocked=!0,this.call("Medal.unlock",{id:n.id}))}k(J,"j");function L(i){return unescape(i.name+" ("+this.points[i.difficulty-1]+")"+(this.showDescriptions?" - "+i.description:""))}k(L,"J");var le=R(()=>{D(J,"unlockMedal"),D(L,"getMedalText")});function V(i,n=0,o="A",h=0,c=0,p=10){var v,w;if(!this.scoreboards||!this.scoreboards.find(m=>m.id==i))return;let x=this.scoreboards.find(m=>m.id==i);return(w=(v=this.call("ScoreBoard.getScores",{id:x.id,user:n,period:o,social:h,skip:c,limit:p},0).result)==null?void 0:v.data)==null?void 0:w.scores}k(V,"L");function X(i,n){if(!this.scoreboards||!this.scoreboards.find(h=>h.id==i))return;let o=this.scoreboards.find(h=>h.id==i);this.call("ScoreBoard.postScore",{id:o.id,value:n})}k(X,"N");var ue=R(()=>{D(V,"getScores"),D(X,"postScore")});function ie(i,n,o,h,c,p=.5){if(!this.medals||!this.medals.find(m=>m.id==n))return;i.save(),i.fillStyle="#fff",i.strokeStyle="#000",i.shadowColor="#000",i.textBaseline="middle",i.textAlign="left",i.font=c/2+"px impact",i.lineWidth=c/35,i.shadowBlur=c/5,i.globalAlpha=p;let v=this.medals.find(m=>m.id==n);i.drawImage(v.image,o,h,c,c),i.strokeRect(o,h,c,c);let w=this.points[v.difficulty-1],x=this.getMedalText(v);i.lineWidth=Math.max(1,c/26),i.strokeText(x,o+c*1.2,h+c/2),i.fillText(x,o+c*1.2,h+c/2),i.restore()}k(ie,"pe");function G(i){var n;if((n=this.displayMedalQueue)!=null&&n.length){let o=this.displayMedalQueue[0];o.time+=i,o.time>this.medalDisplayTime&&this.displayMedalQueue.shift()}}k(G,"X");function Q(i,n=50){var o;if((o=this.displayMedalQueue)!=null&&o.length){let h=this.displayMedalQueue[0],c=h.time<1?1-h.time:0,p=h.time>this.medalDisplayTime-1?this.medalDisplayTime-h.time:1,v=i.canvas.height+c*n*1.5;ie(i,h.index,0,v-n,n,p)}}k(Q,"G");var de=R(()=>{D(ie,"renderMedal"),D(G,"update"),D(Q,"render")});function W(){var i,n,o,h;let c=this.call("App.checkSession");return(h=(o=(n=(i=c?.result)==null?void 0:i.data)==null?void 0:n.session)==null?void 0:o.user)==null?void 0:h.name}k(W,"H");function j(){var i,n;let o=this.call("App.getCurrentVersion");return(n=(i=o?.result)==null?void 0:i.data)==null?void 0:n.current_version}k(j,"Q");function H(){var i,n,o,h;let c=this.call("App.checkSession");return(h=(o=(n=(i=c?.result)==null?void 0:i.data)==null?void 0:n.session)==null?void 0:o.user)==null?void 0:h.supporter}k(H,"V");var fe=R(()=>{D(W,"getUsername"),D(j,"getVersion"),D(H,"isSupporter")});function K(i){if(!this.cipher)return i;let n=this.CryptoJS.enc.Base64.parse(this.cipher),o=this.CryptoJS.lib.WordArray.random(16),h=this.CryptoJS.AES.encrypt(JSON.stringify(i),n,{iv:o}),c=this.CryptoJS.enc.Base64.stringify(o.concat(h.ciphertext));return i.secure=c,i.parameters=null,i}k(K,"W");function $(i,n=!1,o=!0){let h=this.encryptCall({component:i,parameters:n}),c={app_id:this.appID,session_id:this.sessionID,call:h},p=new FormData;p.append("input",JSON.stringify(c));let v=new XMLHttpRequest,w="https://newgrounds.io/gateway_v3.php";if(v.open("POST",w,this.debug?!1:o),v.send(p),v.responseText)return this.debug&&console.log(v.responseText),this.responseText=v.responseText,JSON.parse(v.responseText)}k($,"q");var he=R(()=>{D(K,"encryptCall"),D($,"call")});function Z(i){var n,o,h;let c=this.call("CloudSave.loadSlot",{id:i},!1),p=new XMLHttpRequest;return p.open("GET",(h=(o=(n=c?.result)==null?void 0:n.data)==null?void 0:o.slot)==null?void 0:h.url,!1),p.send(),p.status==200?p.responseText:"nope."}k(Z,"K");function Y(i,n){return this.call("CloudSave.setData",{id:i,data:n})}k(Y,"$");var pe=R(()=>{D(Z,"getCloudData"),D(Y,"setCloudData")}),ye=se((i,n)=>{ce(),le(),ue(),de(),fe(),he(),pe();var o={connect:q,unlockMedal:J,getMedalText:L,getScores:V,postScore:X,update:G,render:Q,getUsername:W,getVersion:j,isSupporter:H,call:$,encryptCall:K,getCloudData:Z,setCloudData:Y};window.Connect=q,window.UnlockMedal=J,window.GetMedalText=L,window.GetScores=V,window.PostScore=X,window.update=G,window.render=Q,window.GetUsername=W,window.GetVersion=j,window.IsSupporter=H,window.GetCloudData=Z,window.SetCloudData=Y,window.call=$,window.encryptCall=K,n.exports=o}),O=ye();function ve(i){return{ngConnect(n,o,h){O.connect(n,o,{debug:h})},ngUnlockMedal(n){O.unlockMedal(n)},ngPostScore(n,o){O.postScore(n,o)},ngUsername(){return O.getUsername()},ngVersion(){return O.getVersion()},ngIsSupporter(){return Boolean(O.isSupporter())}}}k(ve,"newgroundsPlugin");var xe=ve;export{xe as default,ve as newgroundsPlugin};
//# sourceMappingURL=newgrounds.mjs.map