Skip to content

Commit

Permalink
added cloudsave component
Browse files Browse the repository at this point in the history
  • Loading branch information
PsychoGoldfishNG committed Aug 1, 2022
1 parent ca7462f commit d999baf
Showing 1 changed file with 137 additions and 1 deletion.
138 changes: 137 additions & 1 deletion bin/newgroundsio.js
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,114 @@ Newgrounds.io.model.result.prototype.fromObject = function(object) {


Newgrounds.io.model.result.prototype.constructor = Newgrounds.io.model.result;/**
/**
* Contains information about a CloudSave slot.
* @name Newgrounds.io.model.saveslot
* @constructor
* @memberof Newgrounds.io.model
* @property {string} datetime - A date and time (in ISO 8601 format) representing when this slot was last saved.
* @property {number} id - The slot number.
* @property {number} size - The size of the save data in bytes.
* @property {number} timestamp - A unix timestamp representing when this slot was last saved.
* @property {string} url - The URL containing the actual save data for this slot, or null if this slot has no data.
* @param {Newgrounds.io.core} [ngio] - A Newgrounds.io.core instance associated with the model object.
* @param {object} [from_object] - A literal object used to populate this model's properties.
*/
Newgrounds.io.model.saveslot = function(ngio, from_object) {

/* private vars */
var _datetime, _id, _size, _timestamp, _url;
this.__property_names = ["datetime","id","size","timestamp","url"];
this.__classname = "Newgrounds.io.model.saveslot";
this.__ngio = ngio;

var _datetime;
Object.defineProperty(this, 'datetime', {
get: function() { return typeof(_datetime) == 'undefined' ? null : _datetime; },
set: function(__vv__) {
Newgrounds.io.model.checkStrictValue(this.__classname, 'datetime', __vv__, String, null, null, null);
_datetime = __vv__;
}
});

var _id;
Object.defineProperty(this, 'id', {
get: function() { return typeof(_id) == 'undefined' ? null : _id; },
set: function(__vv__) {
Newgrounds.io.model.checkStrictValue(this.__classname, 'id', __vv__, Number, null, null, null);
_id = __vv__;
}
});

var _size;
Object.defineProperty(this, 'size', {
get: function() { return typeof(_size) == 'undefined' ? null : _size; },
set: function(__vv__) {
Newgrounds.io.model.checkStrictValue(this.__classname, 'size', __vv__, Number, null, null, null);
_size = __vv__;
}
});

var _timestamp;
Object.defineProperty(this, 'timestamp', {
get: function() { return typeof(_timestamp) == 'undefined' ? null : _timestamp; },
set: function(__vv__) {
Newgrounds.io.model.checkStrictValue(this.__classname, 'timestamp', __vv__, Number, null, null, null);
_timestamp = __vv__;
}
});

var _url;
Object.defineProperty(this, 'url', {
get: function() { return typeof(_url) == 'undefined' ? null : _url; },
set: function(__vv__) {
Newgrounds.io.model.checkStrictValue(this.__classname, 'url', __vv__, String, null, null, null);
_url = __vv__;
}
});

if(from_object) this.fromObject(from_object);
};

Newgrounds.io.model.saveslot.prototype._has_ngio_user = function() {
return (this.__ngio && this.__ngio.user);
}

/**
* Converts the model instance to a literal object.
* @instance
* @memberof Newgrounds.io.model.saveslot
* @function toObject
* @return {object}
*/
Newgrounds.io.model.saveslot.prototype.toObject = function() {
var object = {};
for(var i=0; i<this.__property_names.length; i++) {
if (typeof(this[this.__property_names[i]]) != 'undefined') object[this.__property_names[i]] = this[this.__property_names[i]];
}
return object;
};

/**
* Populates the model instance using a literal object.
* @instance
* @memberof Newgrounds.io.model.saveslot
* @function fromObject
* @param {object} object - An object containing property/value pairs
*/
Newgrounds.io.model.saveslot.prototype.fromObject = function(object) {
var property, model;
for(var i=0; i<this.__property_names.length; i++) {
property = object[this.__property_names[i]];
this[this.__property_names[i]] = property;
}
};


Newgrounds.io.model.saveslot.prototype.constructor = Newgrounds.io.model.saveslot;

* Contains information about a score posted to a scoreboard.
* @name Newgrounds.io.model.score
* @constructor
Expand Down Expand Up @@ -2344,6 +2452,34 @@ Newgrounds.io.call_validators.App = {
*/
startSession: {"require_session":false,"secure":false,"redirect":false,"import":false,"params":{"force":{"type":Boolean,"extract_from":null,"required":null,"description":"If true, will create a new session even if the user already has an existing one.\n\nNote: Any previous session ids will no longer be valid if this is used."}},"returns":{"session":{"object":"session","description":null}}}

};
/**
* Contains validation rules for calls within the 'CloudSave' component.
* @memberof Newgrounds.io.call_validators
* @type {object}
*/
Newgrounds.io.call_validators.CloudSave = {

/**
* @property {object} clearSlot - Contains rules for validating calls to 'CloudSave.clearSlot'.
*/
clearSlot: {"require_session":true,"secure":false,"redirect":false,"import":false,"params":{"id":{"type":String,"extract_from":null,"required":true,"description":"The slot number."}},"returns":{"slot":{"object":"saveslot","description":"A #saveslot object."}}},

/**
* @property {object} loadSlot - Contains rules for validating calls to 'CloudSave.loadSlot'.
*/
loadSlot: {"require_session":true,"secure":false,"redirect":false,"import":false,"params":{"id":{"type":Number,"extract_from":null,"required":true,"description":"The slot number."}},"returns":{"slot":{"object":"saveslot","description":"A #saveslot object."}}},

/**
* @property {object} loadSlots - Contains rules for validating calls to 'CloudSave.loadSlots'.
*/
loadSlots: {"require_session":true,"secure":false,"redirect":false,"import":false,"params":{},"returns":{"slots":{"array":{"object":"saveslot"},"description":"An array of #saveslot objects."}}},

/**
* @property {object} setData - Contains rules for validating calls to 'CloudSave.setData'.
*/
setData: {"require_session":true,"secure":false,"redirect":false,"import":false,"params":{"data":{"type":Number,"extract_from":null,"required":true,"description":"The data you want to save."},"id":{"type":Number,"extract_from":null,"required":true,"description":"The slot number."}},"returns":{"slot":{"object":"saveslot","description":null}}}

};
/**
* Contains validation rules for calls within the 'Event' component.
Expand Down Expand Up @@ -2751,4 +2887,4 @@ b.keySize,b.ivSize);l.iv=d.iv;b=a.encrypt.call(this,b,c,d.key,l);b.mixIn(d);retu
(function(){for(var u=CryptoJS,p=u.lib.BlockCipher,d=u.algo,l=[],s=[],t=[],r=[],w=[],v=[],b=[],x=[],q=[],n=[],a=[],c=0;256>c;c++)a[c]=128>c?c<<1:c<<1^283;for(var e=0,j=0,c=0;256>c;c++){var k=j^j<<1^j<<2^j<<3^j<<4,k=k>>>8^k&255^99;l[e]=k;s[k]=e;var z=a[e],F=a[z],G=a[F],y=257*a[k]^16843008*k;t[e]=y<<24|y>>>8;r[e]=y<<16|y>>>16;w[e]=y<<8|y>>>24;v[e]=y;y=16843009*G^65537*F^257*z^16843008*e;b[k]=y<<24|y>>>8;x[k]=y<<16|y>>>16;q[k]=y<<8|y>>>24;n[k]=y;e?(e=z^a[a[a[G^z]]],j^=a[a[j]]):e=j=1}var H=[0,1,2,4,8,
16,32,64,128,27,54],d=d.AES=p.extend({_doReset:function(){for(var a=this._key,c=a.words,d=a.sigBytes/4,a=4*((this._nRounds=d+6)+1),e=this._keySchedule=[],j=0;j<a;j++)if(j<d)e[j]=c[j];else{var k=e[j-1];j%d?6<d&&4==j%d&&(k=l[k>>>24]<<24|l[k>>>16&255]<<16|l[k>>>8&255]<<8|l[k&255]):(k=k<<8|k>>>24,k=l[k>>>24]<<24|l[k>>>16&255]<<16|l[k>>>8&255]<<8|l[k&255],k^=H[j/d|0]<<24);e[j]=e[j-d]^k}c=this._invKeySchedule=[];for(d=0;d<a;d++)j=a-d,k=d%4?e[j]:e[j-4],c[d]=4>d||4>=j?k:b[l[k>>>24]]^x[l[k>>>16&255]]^q[l[k>>>
8&255]]^n[l[k&255]]},encryptBlock:function(a,b){this._doCryptBlock(a,b,this._keySchedule,t,r,w,v,l)},decryptBlock:function(a,c){var d=a[c+1];a[c+1]=a[c+3];a[c+3]=d;this._doCryptBlock(a,c,this._invKeySchedule,b,x,q,n,s);d=a[c+1];a[c+1]=a[c+3];a[c+3]=d},_doCryptBlock:function(a,b,c,d,e,j,l,f){for(var m=this._nRounds,g=a[b]^c[0],h=a[b+1]^c[1],k=a[b+2]^c[2],n=a[b+3]^c[3],p=4,r=1;r<m;r++)var q=d[g>>>24]^e[h>>>16&255]^j[k>>>8&255]^l[n&255]^c[p++],s=d[h>>>24]^e[k>>>16&255]^j[n>>>8&255]^l[g&255]^c[p++],t=
d[k>>>24]^e[n>>>16&255]^j[g>>>8&255]^l[h&255]^c[p++],n=d[n>>>24]^e[g>>>16&255]^j[h>>>8&255]^l[k&255]^c[p++],g=q,h=s,k=t;q=(f[g>>>24]<<24|f[h>>>16&255]<<16|f[k>>>8&255]<<8|f[n&255])^c[p++];s=(f[h>>>24]<<24|f[k>>>16&255]<<16|f[n>>>8&255]<<8|f[g&255])^c[p++];t=(f[k>>>24]<<24|f[n>>>16&255]<<16|f[g>>>8&255]<<8|f[h&255])^c[p++];n=(f[n>>>24]<<24|f[g>>>16&255]<<16|f[h>>>8&255]<<8|f[k&255])^c[p++];a[b]=q;a[b+1]=s;a[b+2]=t;a[b+3]=n},keySize:8});u.AES=p._createHelper(d)})();
d[k>>>24]^e[n>>>16&255]^j[g>>>8&255]^l[h&255]^c[p++],n=d[n>>>24]^e[g>>>16&255]^j[h>>>8&255]^l[k&255]^c[p++],g=q,h=s,k=t;q=(f[g>>>24]<<24|f[h>>>16&255]<<16|f[k>>>8&255]<<8|f[n&255])^c[p++];s=(f[h>>>24]<<24|f[k>>>16&255]<<16|f[n>>>8&255]<<8|f[g&255])^c[p++];t=(f[k>>>24]<<24|f[n>>>16&255]<<16|f[g>>>8&255]<<8|f[h&255])^c[p++];n=(f[n>>>24]<<24|f[g>>>16&255]<<16|f[h>>>8&255]<<8|f[k&255])^c[p++];a[b]=q;a[b+1]=s;a[b+2]=t;a[b+3]=n},keySize:8});u.AES=p._createHelper(d)})();

0 comments on commit d999baf

Please sign in to comment.