New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

steemauth

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

steemauth - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

1117

lib/protocol/types/index.js

@@ -17,3 +17,3 @@ // Low-level types that make up operations

var HEX_DUMP = process.env.npm_config__graphene_serializer_hex_dump;
var DB_MAX_INSTANCE_ID = Long.fromNumber(((Math.pow(2,48))-1));
var DB_MAX_INSTANCE_ID = Long.fromNumber(((Math.pow(2, 48)) - 1));

@@ -32,3 +32,3 @@ /**

Types.asset = {
fromByteBuffer: function(b){
fromByteBuffer: function fromByteBuffer(b) {
var amount = b.readInt64();

@@ -41,168 +41,184 @@ var precision = b.readUint8();

var amount_string = fromImpliedDecimal(amount, precision);
return amount_string + " " + symbol
return amount_string + " " + symbol;
},
appendByteBuffer: function(b, object){
appendByteBuffer: function appendByteBuffer(b, object) {
object = object.trim();
if( ! /^[0-9]+\.?[0-9]* [A-Za-z0-9]+$/.test(object))
throw new Error("Expecting amount like '99.000 SYMBOL', instead got '" + object + "'")
if (!/^[0-9]+\.?[0-9]* [A-Za-z0-9]+$/.test(object)) throw new Error("Expecting amount like '99.000 SYMBOL', instead got '" + object + "'");
var amount = object.split(" ")[0]
var symbol = object.split(" ")[1]
if(symbol.length > 6)
throw new Error("Symbols are not longer than 6 characters " + symbol + "-"+ symbol.length)
var amount = object.split(" ")[0];
var symbol = object.split(" ")[1];
if (symbol.length > 6) throw new Error("Symbols are not longer than 6 characters " + symbol + "-" + symbol.length);
b.writeInt64(toLong(amount.replace(".", "")))
var dot = amount.indexOf(".") // 0.000
var precision = dot === -1 ? 0 : amount.length - dot - 1
b.writeUint8(precision)
b.append(symbol.toUpperCase(), 'binary')
for(var i = 0; i < 7 - symbol.length; i++)
b.writeUint8(0)
return
b.writeInt64(toLong(amount.replace(".", "")));
var dot = amount.indexOf("."); // 0.000
var precision = dot === -1 ? 0 : amount.length - dot - 1;
b.writeUint8(precision);
b.append(symbol.toUpperCase(), 'binary');
for (var i = 0; i < 7 - symbol.length; i++) {
b.writeUint8(0);
} return;
},
fromObject: function(object){
return object
fromObject: function fromObject(object) {
return object;
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) { return "0.000 STEEM"; }
return object
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return "0.000 STEEM";
}
return object;
}
}
};
Types.uint8 = {
fromByteBuffer: function(b){
fromByteBuffer: function fromByteBuffer(b) {
return b.readUint8();
},
appendByteBuffer: function(b, object){
appendByteBuffer: function appendByteBuffer(b, object) {
b.writeUint8(object);
return;
},
fromObject: function(object){
fromObject: function fromObject(object) {
return object;
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) { return 0; }
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return 0;
}
return parseInt(object);
}
};
};
Types.uint16 = {
fromByteBuffer: function(b){
fromByteBuffer: function fromByteBuffer(b) {
return b.readUint16();
},
appendByteBuffer: function(b, object){
appendByteBuffer: function appendByteBuffer(b, object) {
b.writeUint16(object);
return;
},
fromObject: function(object){
fromObject: function fromObject(object) {
return object;
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) { return 0; }
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return 0;
}
return parseInt(object);
}
};
};
Types.uint32 = {
fromByteBuffer: function(b){
fromByteBuffer: function fromByteBuffer(b) {
return b.readUint32();
},
appendByteBuffer: function(b, object){
appendByteBuffer: function appendByteBuffer(b, object) {
b.writeUint32(object);
return;
},
fromObject: function(object){
fromObject: function fromObject(object) {
return object;
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) { return 0; }
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return 0;
}
return parseInt(object);
}
};
};
var MIN_SIGNED_32 = -1 * Math.pow(2,31);
var MAX_SIGNED_32 = Math.pow(2,31) - 1;
var MIN_SIGNED_32 = -1 * Math.pow(2, 31);
var MAX_SIGNED_32 = Math.pow(2, 31) - 1;
Types.varint32 = {
fromByteBuffer: function(b){
fromByteBuffer: function fromByteBuffer(b) {
return b.readVarint32();
},
appendByteBuffer: function(b, object){
appendByteBuffer: function appendByteBuffer(b, object) {
b.writeVarint32(object);
return;
},
fromObject: function(object){
fromObject: function fromObject(object) {
return object;
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) { return 0; }
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return 0;
}
return parseInt(object);
}
};
};
Types.int16 = {
fromByteBuffer: function(b){
fromByteBuffer: function fromByteBuffer(b) {
return b.readInt16();
},
appendByteBuffer: function(b, object){
appendByteBuffer: function appendByteBuffer(b, object) {
b.writeInt16(object);
return;
},
fromObject: function(object){
fromObject: function fromObject(object) {
return object;
},
toObject: function(object, debug){
if (debug.use_default && object === undefined) { return 0; }
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return 0;
}
return parseInt(object);
}
};
};
Types.int64 = {
fromByteBuffer: function(b){
fromByteBuffer: function fromByteBuffer(b) {
return b.readInt64();
},
appendByteBuffer: function(b, object){
appendByteBuffer: function appendByteBuffer(b, object) {
b.writeInt64(toLong(object));
return;
},
fromObject: function(object){
fromObject: function fromObject(object) {
return toLong(object);
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) { return "0"; }
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return "0";
}
return toLong(object).toString();
}
};
};
Types.uint64 = {
fromByteBuffer: function(b){
fromByteBuffer: function fromByteBuffer(b) {
return b.readUint64();
},
appendByteBuffer: function(b, object){
appendByteBuffer: function appendByteBuffer(b, object) {
b.writeUint64(toLong(object));
return;
},
fromObject: function(object){
fromObject: function fromObject(object) {
return toLong(object);
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) { return "0"; }
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return "0";
}
return toLong(object).toString();
}
};
};
Types.string = {
fromByteBuffer: function(b){
fromByteBuffer: function fromByteBuffer(b) {
return new Buffer(b.readVString(), 'utf8');
},
appendByteBuffer: function(b, object){
b.writeVString(object.toString())
appendByteBuffer: function appendByteBuffer(b, object) {
b.writeVString(object.toString());
return;
},
fromObject: function(object){
fromObject: function fromObject(object) {
return new Buffer(object, 'utf8');
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) { return ""; }
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return "";
}
return object.toString('utf8');

@@ -213,3 +229,3 @@ }

Types.string_binary = {
fromByteBuffer: function(b){
fromByteBuffer: function fromByteBuffer(b) {
var b_copy;

@@ -220,3 +236,3 @@ var len = b.readVarint32();

},
appendByteBuffer: function(b, object){
appendByteBuffer: function appendByteBuffer(b, object) {
b.writeVarint32(object.length);

@@ -226,7 +242,9 @@ b.append(object.toString('binary'), 'binary');

},
fromObject: function(object){
fromObject: function fromObject(object) {
return new Buffer(object);
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) { return ""; }
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return "";
}
return object.toString();

@@ -236,38 +254,38 @@ }

Types.bytes = function(size){
Types.bytes = function (size) {
return {
fromByteBuffer: function(b){
if (size === undefined) {
var b_copy;
var len = b.readVarint32();
b_copy = b.copy(b.offset, b.offset + len), b.skip(len);
return new Buffer(b_copy.toBinary(), 'binary');
} else {
b_copy = b.copy(b.offset, b.offset + size), b.skip(size);
return new Buffer(b_copy.toBinary(), 'binary');
}
},
appendByteBuffer: function(b, object){
if(typeof object === "string")
object = new Buffer(object, "hex")
fromByteBuffer: function fromByteBuffer(b) {
if (size === undefined) {
var b_copy;
var len = b.readVarint32();
b_copy = b.copy(b.offset, b.offset + len), b.skip(len);
return new Buffer(b_copy.toBinary(), 'binary');
} else {
b_copy = b.copy(b.offset, b.offset + size), b.skip(size);
return new Buffer(b_copy.toBinary(), 'binary');
}
},
appendByteBuffer: function appendByteBuffer(b, object) {
if (typeof object === "string") object = new Buffer(object, "hex");
if (size === undefined) {
b.writeVarint32(object.length);
}
b.append(object.toString('binary'), 'binary');
return;
},
fromObject: function(object){
if( Buffer.isBuffer(object) )
return object
if (size === undefined) {
b.writeVarint32(object.length);
}
b.append(object.toString('binary'), 'binary');
return;
},
fromObject: function fromObject(object) {
if (Buffer.isBuffer(object)) return object;
return new Buffer(object, 'hex');
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) {
var zeros=function(num){ return new Array( num ).join( "00" ); };
return zeros(size);
return new Buffer(object, 'hex');
},
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
var zeros = function zeros(num) {
return new Array(num).join("00");
};
return zeros(size);
}
return object.toString('hex');
}
return object.toString('hex');
}
};

@@ -277,6 +295,6 @@ };

Types.bool = {
fromByteBuffer: function(b){
return b.readUint8() === 1
fromByteBuffer: function fromByteBuffer(b) {
return b.readUint8() === 1;
},
appendByteBuffer: function(b, object){
appendByteBuffer: function appendByteBuffer(b, object) {
// supports boolean or integer

@@ -286,8 +304,10 @@ b.writeUint8(JSON.parse(object) ? 1 : 0);

},
fromObject: function(object){
return JSON.parse(object) ? true : false
fromObject: function fromObject(object) {
return JSON.parse(object) ? true : false;
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) { return false; }
return JSON.parse(object) ? true : false
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return false;
}
return JSON.parse(object) ? true : false;
}

@@ -297,12 +317,12 @@ };

Types.void = {
fromByteBuffer: function(b){
fromByteBuffer: function fromByteBuffer(b) {
throw new Error("(void) undefined type");
},
appendByteBuffer: function(b, object){
appendByteBuffer: function appendByteBuffer(b, object) {
throw new Error("(void) undefined type");
},
fromObject: function(object){
fromObject: function fromObject(object) {
throw new Error("(void) undefined type");
},
toObject: function(object, debug ){
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {

@@ -315,45 +335,45 @@ return undefined;

Types.array = function(st_operation){
Types.array = function (st_operation) {
return {
fromByteBuffer: function(b){
var size = b.readVarint32();
if (HEX_DUMP) {
console.log("varint32 size = " + size.toString(16));
}
var result = [];
for (var i = 0; 0 < size ? i < size : i > size; 0 < size ? i++ : i++) {
result.push(st_operation.fromByteBuffer(b));
}
return sortOperation(result, st_operation);
},
appendByteBuffer: function(b, object){
object = sortOperation(object, st_operation)
b.writeVarint32(object.length);
for (var i = 0, o; i < object.length; i++) {
o = object[i];
st_operation.appendByteBuffer(b, o);
}
},
fromObject: function(object){
object = sortOperation(object, st_operation)
var result = [];
for (var i = 0, o; i < object.length; i++) {
o = object[i];
result.push(st_operation.fromObject(o));
}
return result;
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) {
return [ st_operation.toObject(object, debug) ];
}
object = sortOperation(object, st_operation)
fromByteBuffer: function fromByteBuffer(b) {
var size = b.readVarint32();
if (HEX_DUMP) {
console.log("varint32 size = " + size.toString(16));
}
var result = [];
for (var i = 0; 0 < size ? i < size : i > size; 0 < size ? i++ : i++) {
result.push(st_operation.fromByteBuffer(b));
}
return sortOperation(result, st_operation);
},
appendByteBuffer: function appendByteBuffer(b, object) {
object = sortOperation(object, st_operation);
b.writeVarint32(object.length);
for (var i = 0, o; i < object.length; i++) {
o = object[i];
st_operation.appendByteBuffer(b, o);
}
},
fromObject: function fromObject(object) {
object = sortOperation(object, st_operation);
var result = [];
for (var i = 0, o; i < object.length; i++) {
o = object[i];
result.push(st_operation.fromObject(o));
}
return result;
},
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return [st_operation.toObject(object, debug)];
}
object = sortOperation(object, st_operation);
var result = [];
for (var i = 0, o; i < object.length; i++) {
o = object[i];
result.push(st_operation.toObject(o, debug));
var result = [];
for (var i = 0, o; i < object.length; i++) {
o = object[i];
result.push(st_operation.toObject(o, debug));
}
return result;
}
return result;
}
};

@@ -363,6 +383,7 @@ };

Types.time_point_sec = {
fromByteBuffer: function(b){ return b.readUint32(); },
appendByteBuffer: function(b, object){
if(typeof object !== "number")
object = Types.time_point_sec.fromObject(object)
fromByteBuffer: function fromByteBuffer(b) {
return b.readUint32();
},
appendByteBuffer: function appendByteBuffer(b, object) {
if (typeof object !== "number") object = Types.time_point_sec.fromObject(object);

@@ -372,11 +393,8 @@ b.writeUint32(object);

},
fromObject: function(object){
if(typeof object === "number")
return object
fromObject: function fromObject(object) {
if (typeof object === "number") return object;
if(object.getTime)
return Math.floor( object.getTime() / 1000 );
if (object.getTime) return Math.floor(object.getTime() / 1000);
if(typeof object !== "string")
throw new Error("Unknown date type: " + object)
if (typeof object !== "string") throw new Error("Unknown date type: " + object);

@@ -386,83 +404,86 @@ // if(typeof object === "string" && !/Z$/.test(object))

return Math.floor( new Date(object).getTime() / 1000 );
return Math.floor(new Date(object).getTime() / 1000);
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined)
return (new Date(0)).toISOString().split('.')[0];
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) return new Date(0).toISOString().split('.')[0];
if(typeof object === "string")
return object
if (typeof object === "string") return object;
if(object.getTime)
return object.toISOString().split('.')[0]
if (object.getTime) return object.toISOString().split('.')[0];
var int = parseInt(object);
return (new Date( int * 1000 )).toISOString().split('.')[0];
return new Date(int * 1000).toISOString().split('.')[0];
}
}
};
Types.set = function(st_operation){
Types.set = function (st_operation) {
return {
validate: function(array){
var dup_map = {};
for (var i = 0, o; i < array.length; i++) {
o = array[i];
var ref;
if (ref = typeof o, ['string', 'number'].indexOf(ref) >= 0) {
if (dup_map[o] !== undefined) {
throw new Error("duplicate (set)");
validate: function validate(array) {
var dup_map = {};
for (var i = 0, o; i < array.length; i++) {
o = array[i];
var ref;
if (ref = typeof o === "undefined" ? "undefined" : _typeof(o), ['string', 'number'].indexOf(ref) >= 0) {
if (dup_map[o] !== undefined) {
throw new Error("duplicate (set)");
}
dup_map[o] = true;
}
dup_map[o] = true;
}
}
return sortOperation(array, st_operation);
},
fromByteBuffer: function(b){
var size = b.readVarint32();
if (HEX_DUMP) {
console.log("varint32 size = " + size.toString(16));
}
return this.validate(function() {
var result = [];
for (var i = 0; 0 < size ? i < size : i > size; 0 < size ? i++ : i++) {
result.push(st_operation.fromByteBuffer(b));
return sortOperation(array, st_operation);
},
fromByteBuffer: function fromByteBuffer(b) {
var size = b.readVarint32();
if (HEX_DUMP) {
console.log("varint32 size = " + size.toString(16));
}
return result;
}());
},
appendByteBuffer: function(b, object){
if (!object) { object = []; }
b.writeVarint32(object.length);
var iterable = this.validate(object);
for (var i = 0, o; i < iterable.length; i++) {
o = iterable[i];
st_operation.appendByteBuffer(b, o);
}
return;
},
fromObject: function(object){
if (!object) { object = []; }
return this.validate(function() {
var result = [];
for (var i = 0, o; i < object.length; i++) {
o = object[i];
result.push(st_operation.fromObject(o));
return this.validate(function () {
var result = [];
for (var i = 0; 0 < size ? i < size : i > size; 0 < size ? i++ : i++) {
result.push(st_operation.fromByteBuffer(b));
}
return result;
} ());
},
appendByteBuffer: function appendByteBuffer(b, object) {
if (!object) {
object = [];
}
return result;
}());
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) {
return [ st_operation.toObject(object, debug) ];
b.writeVarint32(object.length);
var iterable = this.validate(object);
for (var i = 0, o; i < iterable.length; i++) {
o = iterable[i];
st_operation.appendByteBuffer(b, o);
}
return;
},
fromObject: function fromObject(object) {
if (!object) {
object = [];
}
return this.validate(function () {
var result = [];
for (var i = 0, o; i < object.length; i++) {
o = object[i];
result.push(st_operation.fromObject(o));
}
return result;
} ());
},
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return [st_operation.toObject(object, debug)];
}
if (!object) {
object = [];
}
return this.validate(function () {
var result = [];
for (var i = 0, o; i < object.length; i++) {
o = object[i];
result.push(st_operation.toObject(o, debug));
}
return result;
} ());
}
if (!object) { object = []; }
return this.validate(function() {
var result = [];
for (var i = 0, o; i < object.length; i++) {
o = object[i];
result.push(st_operation.toObject(o, debug));
}
return result;
}());
}
};

@@ -472,48 +493,48 @@ };

// global_parameters_update_operation current_fees
Types.fixed_array = function(count, st_operation) {
return {
fromByteBuffer: function(b) {
var i, j, ref, results;
results = [];
for (i = j = 0, ref = count; j < ref; i = j += 1) {
results.push(st_operation.fromByteBuffer(b));
}
return sortOperation(results, st_operation);
},
appendByteBuffer: function(b, object) {
var i, j, ref;
if (count !== 0) {
object = sortOperation(object, st_operation)
}
for (i = j = 0, ref = count; j < ref; i = j += 1) {
st_operation.appendByteBuffer(b, object[i]);
}
},
fromObject: function(object) {
var i, j, ref, results;
results = [];
for (i = j = 0, ref = count; j < ref; i = j += 1) {
results.push(st_operation.fromObject(object[i]));
}
return results;
},
toObject: function(object, debug) {
var i, j, k, ref, ref1, results, results1;
if (debug == null) {
debug ;
}
if (debug.use_default && object === void 0) {
results = [];
for (i = j = 0, ref = count; j < ref; i = j += 1) {
results.push(st_operation.toObject(void 0, debug));
Types.fixed_array = function (count, st_operation) {
return {
fromByteBuffer: function fromByteBuffer(b) {
var i, j, ref, results;
results = [];
for (i = j = 0, ref = count; j < ref; i = j += 1) {
results.push(st_operation.fromByteBuffer(b));
}
return sortOperation(results, st_operation);
},
appendByteBuffer: function appendByteBuffer(b, object) {
var i, j, ref;
if (count !== 0) {
object = sortOperation(object, st_operation);
}
for (i = j = 0, ref = count; j < ref; i = j += 1) {
st_operation.appendByteBuffer(b, object[i]);
}
},
fromObject: function fromObject(object) {
var i, j, ref, results;
results = [];
for (i = j = 0, ref = count; j < ref; i = j += 1) {
results.push(st_operation.fromObject(object[i]));
}
return results;
},
toObject: function toObject(object, debug) {
var i, j, k, ref, ref1, results, results1;
if (debug == null) {
debug;
}
if (debug.use_default && object === void 0) {
results = [];
for (i = j = 0, ref = count; j < ref; i = j += 1) {
results.push(st_operation.toObject(void 0, debug));
}
return results;
}
results1 = [];
for (i = k = 0, ref1 = count; k < ref1; i = k += 1) {
results1.push(st_operation.toObject(object[i], debug));
}
return results1;
}
return results;
}
results1 = [];
for (i = k = 0, ref1 = count; k < ref1; i = k += 1) {
results1.push(st_operation.toObject(object[i], debug));
}
return results1;
}
};
};
};

@@ -523,39 +544,45 @@

validation is enforced when an object type is used. */
var id_type = function(reserved_spaces, object_type){
var id_type = function id_type(reserved_spaces, object_type) {
return {
fromByteBuffer: function(b){
return b.readVarint32();
},
appendByteBuffer: function(b, object){
if (object.resolve !== undefined) { object = object.resolve; }
// convert 1.2.n into just n
if (/^[0-9]+\.[0-9]+\.[0-9]+$/.test(object)) {
object = parseInt(object.split('.')[2],10);
fromByteBuffer: function fromByteBuffer(b) {
return b.readVarint32();
},
appendByteBuffer: function appendByteBuffer(b, object) {
if (object.resolve !== undefined) {
object = object.resolve;
}
// convert 1.2.n into just n
if (/^[0-9]+\.[0-9]+\.[0-9]+$/.test(object)) {
object = parseInt(object.split('.')[2], 10);
}
b.writeVarint32(parseInt(object), 10);
return;
},
fromObject: function fromObject(object) {
if (object.resolve !== undefined) {
object = object.resolve;
}
if (typeof object === "numeric" || /^[0-9]+$/.test(object)) {
return parseInt(object, 10);
}
return parseInt(object.split('.')[2], 10);
},
toObject: function toObject(object, debug) {
var object_type_id = chain_types.object_type[object_type];
if (debug.use_default && object === undefined) {
return '' + reserved_spaces + '.' + object_type_id + '.0';
}
if (object.resolve !== undefined) {
object = object.resolve;
}
if (/^[0-9]+\.[0-9]+\.[0-9]+$/.test(object)) {
object = parseInt(object.split('.')[2], 10);
}
return '' + reserved_spaces + '.' + object_type_id + '.' + object;
}
b.writeVarint32(parseInt(object),10);
return;
},
fromObject : function(object){
if (object.resolve !== undefined) { object = object.resolve; }
if (typeof object === "numeric" || /^[0-9]+$/.test(object)) {
return parseInt(object,10);
}
return parseInt(object.split('.')[2],10);
},
toObject: function(object, debug ){
var object_type_id = chain_types.object_type[object_type];
if (debug.use_default && object === undefined) {
return ''+reserved_spaces+'.'+object_type_id+'.0';
}
if (object.resolve !== undefined) { object = object.resolve; }
if (/^[0-9]+\.[0-9]+\.[0-9]+$/.test(object)) {
object = parseInt(object.split('.')[2],10);
}
return ''+reserved_spaces+'.'+object_type_id+'.'+object;
},
};
};
Types.protocol_id_type = function(name){
Types.protocol_id_type = function (name) {
return id_type(chain_types.reserved_spaces.protocol_ids, name);

@@ -565,7 +592,9 @@ };

Types.object_id_type = {
fromByteBuffer: function(b){
fromByteBuffer: function fromByteBuffer(b) {
return ObjectId.fromByteBuffer(b);
},
appendByteBuffer: function(b, object){
if (object.resolve !== undefined) { object = object.resolve; }
appendByteBuffer: function appendByteBuffer(b, object) {
if (object.resolve !== undefined) {
object = object.resolve;
}
object = ObjectId.fromString(object);

@@ -575,7 +604,9 @@ object.appendByteBuffer(b);

},
fromObject: function(object){
if (object.resolve !== undefined) { object = object.resolve; }
fromObject: function fromObject(object) {
if (object.resolve !== undefined) {
object = object.resolve;
}
return ObjectId.fromString(object);
},
toObject: function(object, debug ){
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {

@@ -590,8 +621,8 @@ return "0.0.0";

}
};
};
Types.vote_id =
{TYPE: 0x000000FF,
ID: 0xFFFFFF00,
fromByteBuffer: function(b){
Types.vote_id = {
TYPE: 0x000000FF,
ID: 0xFFFFFF00,
fromByteBuffer: function fromByteBuffer(b) {
var value = b.readUint32();

@@ -603,29 +634,28 @@ return {

},
appendByteBuffer: function(b, object){
if(object === "string")
object = Types.vote_id.fromObject(object)
appendByteBuffer: function appendByteBuffer(b, object) {
if (object === "string") object = Types.vote_id.fromObject(object);
var value = object.id << 8 | object.type
var value = object.id << 8 | object.type;
b.writeUint32(value);
return;
},
fromObject: function(object){
if(typeof object === "object") {
return object
fromObject: function fromObject(object) {
if ((typeof object === "undefined" ? "undefined" : _typeof(object)) === "object") {
return object;
}
var type, id = object.split(':');
return { type, id };
var type,
id = object.split(':');
return { type: type, id: id };
},
toObject: function(object, debug ){
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return "0:0";
}
if(typeof object === "string")
object = Types.vote_id.fromObject(object)
if (typeof object === "string") object = Types.vote_id.fromObject(object);
return object.type + ":" + object.id;
},
compare: function(a, b) {
if(typeof a !== "object") a = Types.vote_id.fromObject(a)
if(typeof b !== "object") b = Types.vote_id.fromObject(b)
compare: function compare(a, b) {
if ((typeof a === "undefined" ? "undefined" : _typeof(a)) !== "object") a = Types.vote_id.fromObject(a);
if ((typeof b === "undefined" ? "undefined" : _typeof(b)) !== "object") b = Types.vote_id.fromObject(b);
return parseInt(a.id) - parseInt(b.id);

@@ -635,183 +665,174 @@ }

Types.optional = function(st_operation){
Types.optional = function (st_operation) {
return {
fromByteBuffer: function(b){
if (!(b.readUint8() === 1)) {
return undefined;
}
return st_operation.fromByteBuffer(b);
},
appendByteBuffer: function(b, object){
if (object !== null && object !== undefined) {
b.writeUint8(1);
st_operation.appendByteBuffer(b, object);
} else {
b.writeUint8(0);
}
return;
},
fromObject: function(object){
if (object === undefined) { return undefined; }
return st_operation.fromObject(object);
},
toObject: function(object, debug ){
// toObject is only null save if use_default is true
var result_object = (function() {
if (!debug.use_default && object === undefined) {
fromByteBuffer: function fromByteBuffer(b) {
if (!(b.readUint8() === 1)) {
return undefined;
}
return st_operation.fromByteBuffer(b);
},
appendByteBuffer: function appendByteBuffer(b, object) {
if (object !== null && object !== undefined) {
b.writeUint8(1);
st_operation.appendByteBuffer(b, object);
} else {
return st_operation.toObject(object, debug);
b.writeUint8(0);
}
})();
return;
},
fromObject: function fromObject(object) {
if (object === undefined) {
return undefined;
}
return st_operation.fromObject(object);
},
toObject: function toObject(object, debug) {
// toObject is only null save if use_default is true
var result_object = function () {
if (!debug.use_default && object === undefined) {
return undefined;
} else {
return st_operation.toObject(object, debug);
}
} ();
if (debug.annotate) {
if (typeof result_object === "object") {
result_object.__optional = "parent is optional";
} else {
result_object = {__optional: result_object};
if (debug.annotate) {
if ((typeof result_object === "undefined" ? "undefined" : _typeof(result_object)) === "object") {
result_object.__optional = "parent is optional";
} else {
result_object = { __optional: result_object };
}
}
return result_object;
}
return result_object;
}
};
};
Types.static_variant = function(_st_operations){
Types.static_variant = function (_st_operations) {
return {
nosort: true,
st_operations: _st_operations,
opTypeId : function(value) {
var pos = 0, type_id
if(typeof value === "number")
type_id = value
else {
for(var op of this.st_operations) {
if(op.operation_name === value) {
type_id = pos
break
opTypeId: function opTypeId(value) {
var pos = 0,
type_id;
if (typeof value === "number") type_id = value; else {
for (var _iterator = this.st_operations, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator](); ;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var op = _ref;
if (op.operation_name === value) {
type_id = pos;
break;
}
pos++;
}
pos++
}
return type_id;
},
fromByteBuffer: function fromByteBuffer(b) {
var type_id = b.readVarint32();
var st_operation = this.st_operations[type_id];
if (HEX_DUMP) {
console.error('static_variant id 0x' + type_id.toString(16) + ' (' + type_id + ')');
}
return [type_id, st_operation.fromByteBuffer(b)];
},
appendByteBuffer: function appendByteBuffer(b, object) {
var type_id = this.opTypeId(object[0]);
var st_operation = this.st_operations[type_id];
b.writeVarint32(type_id);
st_operation.appendByteBuffer(b, object[1]);
return;
},
fromObject: function fromObject(object) {
var type_id = this.opTypeId(object[0]);
var st_operation = this.st_operations[type_id];
return [type_id, st_operation.fromObject(object[1])];
},
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return [this.st_operations[0].operation_name, this.st_operations[0].toObject(undefined, debug)];
}
var type_id = this.opTypeId(object[0]);
var st_operation = this.st_operations[type_id];
return [st_operation.operation_name, st_operation.toObject(object[1], debug)];
},
compare: function compare(a, b) {
return strCmp(this.opTypeId(a[0]), this.opTypeId(b[0]));
}
return type_id
},
fromByteBuffer: function(b){
var type_id = b.readVarint32();
var st_operation = this.st_operations[type_id];
if (HEX_DUMP) {
console.error('static_variant id 0x'+type_id.toString(16)+' ('+type_id+')');
}
return [
type_id,
st_operation.fromByteBuffer(b)
];
},
appendByteBuffer: function(b, object){
var type_id = this.opTypeId(object[0]);
var st_operation = this.st_operations[type_id];
b.writeVarint32(type_id);
st_operation.appendByteBuffer(b, object[1]);
return;
},
fromObject: function(object){
var type_id = this.opTypeId(object[0]);
var st_operation = this.st_operations[type_id];
return [
type_id,
st_operation.fromObject(object[1])
];
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) {
return [this.st_operations[0].operation_name, this.st_operations[0].toObject(undefined, debug)];
}
var type_id = this.opTypeId(object[0]);
var st_operation = this.st_operations[type_id];
return [
st_operation.operation_name,
st_operation.toObject(object[1], debug)
];
},
compare: function(a, b) {
return strCmp(this.opTypeId(a[0]), this.opTypeId(b[0]))
}
};
};
Types.map = function(key_st_operation, value_st_operation){
Types.map = function (key_st_operation, value_st_operation) {
return {
validate: function(array){
if (!Array.isArray(array)) {
throw new Error("expecting array");
}
var dup_map = {};
for (var i = 0, o; i < array.length; i++) {
o = array[i];
var ref;
if (!(o.length === 2)) {
throw new Error("expecting two elements");
validate: function validate(array) {
if (!Array.isArray(array)) {
throw new Error("expecting array");
}
if (ref = typeof o[0], ['number', 'string'].indexOf(ref) >= 0) {
if (dup_map[o[0]] !== undefined) {
throw new Error("duplicate (map)");
var dup_map = {};
for (var i = 0, o; i < array.length; i++) {
o = array[i];
var ref;
if (!(o.length === 2)) {
throw new Error("expecting two elements");
}
dup_map[o[0]] = true;
if (ref = _typeof(o[0]), ['number', 'string'].indexOf(ref) >= 0) {
if (dup_map[o[0]] !== undefined) {
throw new Error("duplicate (map)");
}
dup_map[o[0]] = true;
}
}
}
return sortOperation(array, key_st_operation);
},
return sortOperation(array, key_st_operation);
},
fromByteBuffer: function(b){
var result = [];
var end = b.readVarint32();
for (var i = 0; 0 < end ? i < end : i > end; 0 < end ? i++ : i++) {
result.push([
key_st_operation.fromByteBuffer(b),
value_st_operation.fromByteBuffer(b)
]);
}
return this.validate(result);
},
fromByteBuffer: function fromByteBuffer(b) {
var result = [];
var end = b.readVarint32();
for (var i = 0; 0 < end ? i < end : i > end; 0 < end ? i++ : i++) {
result.push([key_st_operation.fromByteBuffer(b), value_st_operation.fromByteBuffer(b)]);
}
return this.validate(result);
},
appendByteBuffer: function(b, object){
this.validate(object);
b.writeVarint32(object.length);
for (var i = 0, o; i < object.length; i++) {
o = object[i];
key_st_operation.appendByteBuffer(b, o[0]);
value_st_operation.appendByteBuffer(b, o[1]);
appendByteBuffer: function appendByteBuffer(b, object) {
this.validate(object);
b.writeVarint32(object.length);
for (var i = 0, o; i < object.length; i++) {
o = object[i];
key_st_operation.appendByteBuffer(b, o[0]);
value_st_operation.appendByteBuffer(b, o[1]);
}
return;
},
fromObject: function fromObject(object) {
var result = [];
for (var i = 0, o; i < object.length; i++) {
o = object[i];
result.push([key_st_operation.fromObject(o[0]), value_st_operation.fromObject(o[1])]);
}
return this.validate(result);
},
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return [[key_st_operation.toObject(undefined, debug), value_st_operation.toObject(undefined, debug)]];
}
object = this.validate(object);
var result = [];
for (var i = 0, o; i < object.length; i++) {
o = object[i];
result.push([key_st_operation.toObject(o[0], debug), value_st_operation.toObject(o[1], debug)]);
}
return result;
}
return;
},
fromObject: function(object){
var result = [];
for (var i = 0, o; i < object.length; i++) {
o = object[i];
result.push([
key_st_operation.fromObject(o[0]),
value_st_operation.fromObject(o[1])
]);
}
return this.validate(result)
},
toObject: function(object, debug ){
if (debug.use_default && object === undefined) {
return [
[
key_st_operation.toObject(undefined, debug),
value_st_operation.toObject(undefined, debug)
]
];
}
object = this.validate(object);
var result = []
for (var i = 0, o; i < object.length; i++) {
o = object[i];
result.push([
key_st_operation.toObject(o[0], debug),
value_st_operation.toObject(o[1], debug)
]);
}
return result
}
};

@@ -821,46 +842,51 @@ };

Types.public_key = {
toPublic : function(object){
if (object.resolve !== undefined) { object = object.resolve; }
return object == null ? object :
object.Q ? object : PublicKey.fromStringOrThrow(object)
toPublic: function toPublic(object) {
if (object.resolve !== undefined) {
object = object.resolve;
}
return object == null ? object : object.Q ? object : PublicKey.fromStringOrThrow(object);
},
fromByteBuffer : function(b){
fromByteBuffer: function fromByteBuffer(b) {
return fp.public_key(b);
},
appendByteBuffer : function(b, object){
appendByteBuffer: function appendByteBuffer(b, object) {
fp.public_key(b, Types.public_key.toPublic(object));
return;
},
fromObject: function(object){
if (object.Q) { return object; }
fromObject: function fromObject(object) {
if (object.Q) {
return object;
}
return Types.public_key.toPublic(object);
},
toObject: function(object, debug ){
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {
return config.address_prefix + "859gxfnXyUriMgUeThh1fWv3oqcpLFyHa3TfFYC4PK2HqhToVM";
}
return object.toString()
return object.toString();
},
compare:function(a, b) {
compare: function compare(a, b) {
// sort decending
return -1 * strCmp(a.toString(), b.toString())
return -1 * strCmp(a.toString(), b.toString());
}
};
Types.address =
{_to_address: function(object){
if (object.addy) { return object; }
Types.address = {
_to_address: function _to_address(object) {
if (object.addy) {
return object;
}
return Address.fromString(object);
},
fromByteBuffer: function(b){
fromByteBuffer: function fromByteBuffer(b) {
return new Address(fp.ripemd160(b));
},
appendByteBuffer: function(b, object){
appendByteBuffer: function appendByteBuffer(b, object) {
fp.ripemd160(b, Types.address._to_address(object).toBuffer());
return;
},
fromObject: function(object){
fromObject: function fromObject(object) {
return Types.address._to_address(object);
},
toObject: function(object, debug ){
toObject: function toObject(object, debug) {
if (debug.use_default && object === undefined) {

@@ -871,7 +897,8 @@ return config.address_prefix + "664KmHxSuQyDsfwo4WEJvWpzg1QKdg67S";

},
compare: function(a, b) {
compare: function compare(a, b) {
// sort decending
return -1 * strCmp(a.toString(), b.toString())
return -1 * strCmp(a.toString(), b.toString());
}
};
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

@@ -888,11 +915,11 @@ var strCmp = function strCmp(a, b) {

}) : // custom compare operation
array.sort(function (a, b) {
return typeof firstEl(a) === "number" && typeof firstEl(b) === "number" ? firstEl(a) - firstEl(b) :
// A binary string compare does not work. Performanance is very good so HEX is used.. localeCompare is another option.
Buffer.isBuffer(firstEl(a)) && Buffer.isBuffer(firstEl(b)) ? strCmp(firstEl(a).toString("hex"), firstEl(b).toString("hex")) : strCmp(firstEl(a).toString(), firstEl(b).toString());
});
array.sort(function (a, b) {
return typeof firstEl(a) === "number" && typeof firstEl(b) === "number" ? firstEl(a) - firstEl(b) :
// A binary string compare does not work. Performanance is very good so HEX is used.. localeCompare is another option.
Buffer.isBuffer(firstEl(a)) && Buffer.isBuffer(firstEl(b)) ? strCmp(firstEl(a).toString("hex"), firstEl(b).toString("hex")) : strCmp(firstEl(a).toString(), firstEl(b).toString());
});
};
var toLong = function toLong(value) {
return Long.isLong(value)?value:Long.fromString(value)
}
return Long.isLong(value) ? value : Long.fromString(value);
};

@@ -940,3 +967,3 @@ var ObjectId = function () {

return ObjectId;
}();
} ();

@@ -997,20 +1024,16 @@ var Address = function () {

var fromImpliedDecimal = function(number, precision) {
if(typeof number === "number") {
assert(number <= 9007199254740991, "overflow")
number = ""+number;
} else
if( number.toString )
number = number.toString()
while(number.length < precision + 1)// 0.123
number = "0" + number
// 44000 => 44.000
var dec_string = number.substring(number.length - precision)
return number.substring(0, number.length - precision) +
(dec_string ? "." + dec_string : "")
}
var fromImpliedDecimal = function fromImpliedDecimal(number, precision) {
if (typeof number === "number") {
assert(number <= 9007199254740991, "overflow");
number = "" + number;
} else if (number.toString) number = number.toString();
module.exports = Types;
while (number.length < precision + 1) {
// 0.123
number = "0" + number;
} // 44000 => 44.000
var dec_string = number.substring(number.length - precision);
return number.substring(0, number.length - precision) + (dec_string ? "." + dec_string : "");
};
module.exports = Types;
{
"name": "steemauth",
"version": "0.0.15",
"version": "0.0.16",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc