Jump to content
McKay Development

chaot1c

Member
  • Posts

    6
  • Joined

  • Last visited

Community Answers

  1. chaot1c's post in ClientMicroTxnAuthRequest (5504) was marked as the answer   
    Thank you for your help, I did that and it was successful, but on 4 step i needed 32-bit value of 1 (1 = OK, 2 = Fail) so here it is: 
    let fs = require('fs'); let Steam = require('../node_modules/steam/lib/steam_client'); let SteamTotp = require('steam-totp'); let Language = require('./language.js'); let ByteBuffer = require('bytebuffer'); let BinaryKVParser = require('binarykvparser'); let Long = require('long'); if(fs.existsSync('servers')) Steam.servers = JSON.parse(fs.readFileSync('servers')); let steamGameCoordinator, accountDetails; let steamClient = new Steam.SteamClient(); let steamUser = new Steam.SteamUser(steamClient); let steamFriends = new Steam.SteamFriends(steamClient); let Protos = { Steam: Steam.Internal, CSGO: Steam.GC.CSGO.Internal }; if(process.argv[2]) { accountDetails = { toLogOn: { account_name: process.argv[2], password: process.argv[3], two_factor_code: process.argv[4] ? SteamTotp.generateAuthCode(process.argv[4]) : null }, localAddress: process.argv[5] || null, count: parseInt(process.argv[6]) || null }; } else throw new Error('Usage: node <script> "login" "password" "shared_secret" "ip" count'); steamClient.handlers = {}; steamClient.connect({ localAddress: accountDetails.localAddress }); steamClient.on('connected', () => steamUser.logOn(accountDetails.toLogOn)); steamClient.on('logOnResponse', logonResp => { if(logonResp.eresult == Steam.EResult.OK) { if(!process.send) console.log('Logged in!'); steamFriends.setPersonaState(Steam.EPersonaState.Online); steamUser.gamesPlayed({ games_played: [ { game_id: 730 } ] }); steamGameCoordinator = new Steam.SteamGameCoordinator(steamClient, 730); steamGameCoordinator.handlers = {}; steamGameCoordinator.on('message', (header, body, callback) => { let protobuf = !!header.proto; if(steamGameCoordinator.handlers[header.msg]) steamGameCoordinator.handlers[header.msg].call(null, body); else { let msgName = header.msg; for(let i in Language) { if(Language.hasOwnProperty(i) && Language[i] == header.msg) { msgName = i; break; } } steamGameCoordinator.emit('debug', 'Got unhandled steamGameCoordinator message ' + msgName + (protobuf ? ' (protobuf)' : '')); } }); steamGameCoordinator.handlers[Protos.CSGO.EGCBaseClientMsg.k_EMsgGCClientWelcome] = function(body) { clearInterval(hello); let proto = Protos.CSGO.CMsgClientWelcome.decode(body); if(accountDetails.count) { buyItems([ { item_def_id: 1356, quantity: accountDetails.count, cost_in_local_currency: parseInt(accountDetails.count * 249), purchase_type: 0 } ]); } }; steamGameCoordinator.handlers[Protos.CSGO.EGCItemMsg.k_EMsgGCStorePurchaseFinalizeResponse] = function(body) { let proto = Protos.CSGO.CMsgGCStorePurchaseFinalizeResponse.decode(body); if(process.send) process.send(proto); else console.log(proto); }; let hello = setInterval(() => steamGameCoordinator.send({ msg: Protos.CSGO.EGCBaseClientMsg.k_EMsgGCClientHello, proto: {} }, (new Protos.CSGO.CMsgClientHello()).toBuffer()), 5000); } else if(logonResp.eresult == Steam.EResult.TwoFactorCodeMismatch) setTimeout(() => steamUser.logOn(accountDetails.toLogOn), 30000); else if(process.send) process.send(logonResp); else console.log(logonResp); }); steamClient.on('servers', servers => fs.writeFile('servers', JSON.stringify(servers))); steamClient.on('message', (header, body, callback) => { let protobuf = !!header.proto; if(steamClient.handlers[header.msg]) steamClient.handlers[header.msg].call(null, body); else { let msgName = header.msg; for(let i in Steam.EMsg) { if(Steam.EMsg.hasOwnProperty(i) && Steam.EMsg[i] == header.msg) { msgName = i; break; } } steamClient.emit('debug', 'Got unhandled steamClient message ' + msgName + (protobuf ? ' (protobuf)' : '')); } }); steamClient.handlers[Steam.EMsg.ClientMicroTxnAuthRequest] = function(body) { body = BinaryKVParser.parse(body.slice(1)); let data = body.MessageObject; let txn_id = data.orderid; let payload = new ByteBuffer(12, ByteBuffer.LITTLE_ENDIAN); payload.writeInt64(data.transid); payload.writeInt32(1); steamClient.send({ msg: Steam.EMsg.ClientMicroTxnAuthorize, proto: null }, payload.buffer, (header, body) => { if(header.msg == Steam.EMsg.ClientMicroTxnAuthorizeResponse) { body = body.slice(0, 4); let result = body.readInt8(); if(result == Steam.EResult.OK) { steamGameCoordinator.send({ msg: Protos.CSGO.EGCItemMsg.k_EMsgGCStorePurchaseFinalize, proto: {} }, (new Protos.CSGO.CMsgGCStorePurchaseFinalize({ txn_id })).toBuffer()); } } else if(process.send) process.send({ result: false }); else console.log(header, body); }); }; steamClient.handlers[Steam.EMsg.ClientWalletInfoUpdate] = function(body) { let proto = Protos.Steam.CMsgClientWalletInfoUpdate.decode(body); steamClient.walletInfo = proto; }; function buyItems(line_items) { steamGameCoordinator.send({ msg: Protos.CSGO.EGCItemMsg.k_EMsgGCStorePurchaseInit, proto: {} }, (new Protos.CSGO.CMsgGCStorePurchaseInit({ country: '', language: 8, currency: 0, line_items })).toBuffer()); } Where Language is language.js from node-globaloffensive and Steam is node-steam with pull request (https://github.com/seishun/node-steam/pull/397). Would you adapt this to your node-globaloffensive?
×
×
  • Create New...