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