Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
g_ProcessPersonaSemaphore.wait(async (release) => {
if (typeof user.last_logoff === 'number') {
user.last_logoff = new Date(user.last_logoff * 1000);
}
if (typeof user.last_logon === 'number') {
user.last_logon = new Date(user.last_logon * 1000);
}
if (typeof user.last_seen_online === 'number') {
user.last_seen_online = new Date(user.last_seen_online * 1000);
}
if (typeof user.avatar_hash === 'object' && (Buffer.isBuffer(user.avatar_hash) || ByteBuffer.isByteBuffer(user.avatar_hash))) {
let hash = user.avatar_hash.toString('hex');
// handle default avatar
if (hash === "0000000000000000000000000000000000000000") {
hash = "fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb";
}
user.avatar_url_icon = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/" + hash.substring(0, 2) + "/" + hash;
user.avatar_url_medium = user.avatar_url_icon + "_medium.jpg";
user.avatar_url_full = user.avatar_url_icon + "_full.jpg";
user.avatar_url_icon += ".jpg";
}
// only delete rich_presence_string if we have confirmation that the user isn't in-game
if ((user.rich_presence && user.rich_presence.length == 0) || user.gameid === '0') {
delete user.rich_presence_string;
CMClient.prototype.send = function(header, body, callback) {
// ignore any target job ID
if (header.proto) {
delete header.proto.jobid_target;
} else {
delete header.targetJobID;
}
if (ByteBuffer.isByteBuffer(body)) {
body = body.toBuffer();
}
this._send(header, body, callback);
};
this.defindex = defindex;
this.value = null;
this.details = details;
if(typeof details.stored_as_integer !== 'undefined') {
// It's a standard type attribute.
if(ByteBuffer.isByteBuffer(value)) {
if(details.stored_as_integer) {
this.value = value.readUint32();
} else {
this.value = value.readFloat32();
}
} else {
this.value = details.stored_as_integer ? parseInt(value, 10) : parseFloat(value);
}
} else if(details.attribute_type && ByteBuffer.isByteBuffer(value)) {
// Parse it from a protobuf
switch(details.attribute_type) {
case 'string':
this.value = Protos.CAttribute_String.decode(value).value;
break;
case 'item_slot_criteria':
this.value = Protos.CAttribute_ItemSlotCriteria.decode(value).tags;
break;
case 'uint64':
this.value = value.readUint64();
break;
case 'dynamic_recipe_component_defined_item':
this.value = Protos.CAttribute_DynamicRecipeComponent.decode(value);
case EUdpPacketType.ChallengeReq:
data = new Buffer(0);
break;
case EUdpPacketType.Connect:
var challenge = data;
data = new Buffer(4);
data.writeUInt32LE((challenge ^ CHALLENGE_MASK) >>> 0, 0);
break;
case EUdpPacketType.Disconnect:
data = new Buffer(0);
break;
case EUdpPacketType.Data:
if(ByteBuffer.isByteBuffer(data)) {
data = data.toBuffer();
}
if(this.sessionKey) {
data = SteamCrypto.symmetricEncrypt(data, this.sessionKey);
}
break;
case EUdpPacketType.Datagram:
data = new Buffer(0);
break;
default:
this.emit('debug', "Tried to send bad packet type " + type);
return;
exports.parse = function(buffer) {
if (!ByteBuffer.isByteBuffer(buffer)) {
buffer = ByteBuffer.wrap(buffer, ByteBuffer.LITTLE_ENDIAN);
}
var manifest = {};
var magic;
var meta;
var length;
while (buffer.remaining() > 0) {
magic = buffer.readUint32();
switch (magic) {
case PROTOBUF_PAYLOAD_MAGIC:
length = buffer.readUint32();
manifest.files = Protos.ContentManifestPayload.decode(buffer.slice(buffer.offset, buffer.offset + length)).mappings;
buffer.skip(length);
break;
Steam.Internal[cnode.name].decode = function(buffer) {
if (!ByteBuffer.isByteBuffer(buffer)) {
buffer = ByteBuffer.wrap(buffer, ByteBuffer.LITTLE_ENDIAN);
}
var object = {};
cnode.childNodes.forEach(function(prop) {
var typestr = exports.emitType(prop.type);
var size = code_generator.getTypeSize(prop);
var defflags = prop.flags;
var symname = prop.name;
if (defflags == 'const') {
return;
}
if (!size) {
function decodeProto(proto, encoded) {
if (ByteBuffer.isByteBuffer(encoded)) {
encoded = encoded.toBuffer();
}
let decoded = proto.decode(encoded);
let objNoDefaults = proto.toObject(decoded, {"longs": String});
let objWithDefaults = proto.toObject(decoded, {"defaults": true, "longs": String});
return replaceDefaults(objNoDefaults, objWithDefaults);
function replaceDefaults(noDefaults, withDefaults) {
if (Array.isArray(withDefaults)) {
return withDefaults.map((val, idx) => replaceDefaults(noDefaults[idx], val));
}
for (let i in withDefaults) {
if (!withDefaults.hasOwnProperty(i)) {
continue;
function decodeProto(proto, encoded) {
if (ByteBuffer.isByteBuffer(encoded)) {
encoded = encoded.toBuffer();
}
let decoded = proto.decode(encoded);
let objNoDefaults = proto.toObject(decoded, {"longs": String});
let objWithDefaults = proto.toObject(decoded, {"defaults": true, "longs": String});
return replaceDefaults(objNoDefaults, objWithDefaults);
function replaceDefaults(noDefaults, withDefaults) {
if (Array.isArray(withDefaults)) {
return withDefaults.map((val, idx) => replaceDefaults(noDefaults[idx], val));
}
for (let i in withDefaults) {
if (!withDefaults.hasOwnProperty(i)) {
continue;
Steam.Internal[cnode.name].decode = function(buffer) {
if (!ByteBuffer.isByteBuffer(buffer)) {
buffer = ByteBuffer.wrap(buffer, ByteBuffer.LITTLE_ENDIAN);
}
var object = {};
cnode.childNodes.forEach(function(prop) {
var typestr = exports.emitType(prop.type);
var size = code_generator.getTypeSize(prop);
var defflags = prop.flags;
var symname = prop.name;
if (defflags == 'const') {
return;
}
if (!size) {