Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2018
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. /*
  2. * This is a demo script to show you how to connect successfully.
  3. * The code will be callback hell because it's easy and just to show you the basics.
  4. *
  5. * Make sure the account has access to Rocket League. (Family sharing untested)
  6. */
  7.  
  8. const RLAppId = 252950; // https://steamdb.info/app/252950/
  9. const RLEndpoint = 'https://psyonix-rl.appspot.com/Services';
  10. const RLKey = 'c338bd36fb8c42b1a431d30add939fc7';
  11.  
  12. const Config = require('./demo_config');
  13. const Utils = require('./lib/utils');
  14. const SteamUser = require('steam-user');
  15. const CryptoJS = require('crypto-js');
  16.  
  17. let request = require('request');
  18. let clientSteam = new SteamUser();
  19.  
  20. // Step 1: Sign into Steam.
  21. clientSteam.logOn({
  22. 'accountName': Config.username,
  23. 'password': Config.password
  24. });
  25.  
  26. clientSteam.on('loggedOn', details => {
  27. console.log('[Steam] Signed into Steam as ' + clientSteam.steamID + '.');
  28.  
  29. // Step 2: Request an appticket (AuthTicket).
  30. clientSteam.getEncryptedAppTicket(RLAppId, null, (err, ticket) => {
  31. if (err) {
  32. return console.log("[Steam] AppTicket error: " + err);
  33. }
  34.  
  35. console.log('[Steam] Received an appticket.');
  36.  
  37. // Step 3: Authenticate at RocketLeague.
  38. let authRequest = JSON.stringify([
  39. {
  40. Service: 'Auth/AuthPlayer',
  41. Version: 1,
  42. ID: 2,
  43. Params: {
  44. Platform: 'Steam',
  45. PlayerName: Config.displayName,
  46. PlayerID: clientSteam.steamID.getSteamID64(),
  47. GameVersion: 25,
  48. Language: 'INT',
  49. AuthTicket: Utils.bufferToHex(ticket).toUpperCase(),
  50. BuildRegion: '',
  51. FeatureSet: 'FeatureUpdate22_1',
  52. bTrial: false,
  53. bSkipAuth: false
  54. }
  55. }
  56. ]);
  57.  
  58. let authSignature = CryptoJS.HmacSHA256('-' + authRequest, RLKey).toString();
  59.  
  60. request.post({
  61. url: RLEndpoint,
  62. headers: {
  63. 'Content-Type': 'application/x-www-form-urlencoded',
  64. 'User-Agent': 'RL Win/180912.59017.208087 gzip',
  65. 'Cache-Control': 'no-cache',
  66. 'PsyBuildID': '-112028592',
  67. 'PsyEnvironment': 'Prod',
  68. 'PsyRequestID': 'PsyNetMessage_X_3',
  69. 'PsySig': Buffer.from(authSignature, 'hex').toString('base64')
  70. },
  71. body: authRequest
  72. }, (error, response, body) => {
  73. if (error) {
  74. return console.log('[RocketLeague] Auth failed: ' + error);
  75. }
  76.  
  77. // Step 4: Consume tokens to send authenticated requests.
  78. let authResponse = JSON.parse(body).Responses[0].Result;
  79. if (authResponse === undefined) {
  80. return console.log('[RocketLeague] Auth failed: ' + body);
  81. }
  82.  
  83. let authSessionId = authResponse.SessionID;
  84. let authPsyToken = authResponse.PsyToken;
  85.  
  86. console.log('[RocketLeague] Auth was successful.');
  87. console.log('[RocketLeague] Fetching inventory of signed in player..');
  88.  
  89. // It's now possible to make authenticated requests.
  90. // Step 5: Make an authenticated request.
  91. let productsRequest = JSON.stringify([
  92. {
  93. Service: 'GameServer/FindPrivateServer',
  94. Version: 1,
  95. Params: {
  96. ServerName: '123',
  97. Password: '123'
  98. }
  99. }
  100. ]);
  101.  
  102. let productsSignature = CryptoJS.HmacSHA256('-' + productsRequest, RLKey).toString();
  103.  
  104. request.post({
  105. url: RLEndpoint,
  106. headers: {
  107. 'Content-Type': 'application/x-www-form-urlencoded',
  108. 'User-Agent': 'RL Win/180912.59017.208087 gzip',
  109. 'Cache-Control': 'no-cache',
  110. 'PsyBuildID': '-112028592',
  111. 'PsyEnvironment': 'Prod',
  112. 'PsyRequestID': 'PsyNetMessage_X_4',
  113. 'PsySig': Buffer.from(productsSignature, 'hex').toString('base64'),
  114. 'PsyToken': authPsyToken,
  115. 'PsySessionID': authSessionId
  116. },
  117. body: productsRequest
  118. }, (error, response, body) => {
  119. if (error) {
  120. return console.log('[RocketLeague] Auth failed: ' + error);
  121. }
  122. let productsResponse = JSON.parse(body);
  123. console.log(productsResponse.Responses.length)
  124.  
  125. });
  126. });
  127. });
  128. });
  129.  
  130. clientSteam.on('error', function(e) {
  131. console.log(e);
  132. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement