steamcommunity 3.46.1 → 3.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +22 -22
- package/classes/CConfirmation.js +37 -37
- package/classes/CEconItem.js +120 -120
- package/classes/CMarketItem.js +189 -189
- package/classes/CMarketSearchResult.js +89 -89
- package/classes/CSteamGroup.js +155 -155
- package/classes/CSteamUser.js +225 -217
- package/components/chat.js +283 -283
- package/components/confirmations.js +428 -428
- package/components/groups.js +798 -732
- package/components/help.js +64 -64
- package/components/helpers.js +128 -108
- package/components/http.js +150 -150
- package/components/inventoryhistory.js +173 -173
- package/components/login.js +110 -0
- package/components/market.js +387 -387
- package/components/profile.js +475 -475
- package/components/twofactor.js +152 -152
- package/components/users.js +831 -767
- package/components/webapi.js +118 -118
- package/examples/README.md +35 -35
- package/examples/accept_all_confirmations.js +173 -173
- package/examples/disable_twofactor.js +135 -135
- package/examples/edit-group-announcement.js +118 -118
- package/examples/enable_twofactor.js +182 -182
- package/index.js +13 -151
- package/package.json +11 -6
- package/resources/EChatState.js +14 -14
- package/resources/EConfirmationType.js +12 -12
- package/resources/EFriendRelationship.js +23 -23
- package/resources/EPersonaState.js +23 -23
- package/resources/EPersonaStateFlag.js +32 -32
- package/resources/EResult.js +254 -254
- package/.editorconfig +0 -13
- package/.github/FUNDING.yml +0 -2
- package/.idea/.name +0 -1
- package/.idea/codeStyleSettings.xml +0 -13
- package/.idea/codeStyles/Project.xml +0 -15
- package/.idea/codeStyles/codeStyleConfig.xml +0 -6
- package/.idea/copyright/profiles_settings.xml +0 -3
- package/.idea/encodings.xml +0 -6
- package/.idea/inspectionProfiles/Project_Default.xml +0 -11
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -9
- package/.idea/node-steamcommunity.iml +0 -8
- package/.idea/steamcommunity.iml +0 -10
- package/.idea/vcs.xml +0 -7
- package/.idea/watcherTasks.xml +0 -4
- package/CONTRIBUTING.md +0 -36
|
@@ -1,173 +1,173 @@
|
|
|
1
|
-
var SteamCommunity = require('../index.js');
|
|
2
|
-
var CEconItem = require('../classes/CEconItem.js');
|
|
3
|
-
var Helpers = require('./helpers.js');
|
|
4
|
-
var SteamID = require('steamid');
|
|
5
|
-
var request = require('request');
|
|
6
|
-
var Cheerio = require('cheerio');
|
|
7
|
-
var Async = require('async');
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
* Inventory history in a nutshell.
|
|
11
|
-
*
|
|
12
|
-
* There are no more page numbers. Now you have to request after_time and optionally after_trade.
|
|
13
|
-
* Without "prev" set, you will request 30 trades that were completed FURTHER IN THE PAST than after_time (and optionally after_trade)
|
|
14
|
-
* With "prev" set, you will request 30 trades that were completed MORE RECENTLY than after_time (and optionally after_trade)
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Use GetTradeHistory instead: https://lab.xpaw.me/steam_api_documentation.html#IEconService_GetTradeHistory_v1
|
|
19
|
-
* @param {object} options
|
|
20
|
-
* @param {function} callback
|
|
21
|
-
*/
|
|
22
|
-
SteamCommunity.prototype.getInventoryHistory = function(options, callback) {
|
|
23
|
-
if (typeof options === 'function') {
|
|
24
|
-
callback = options;
|
|
25
|
-
options = {};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
options.direction = options.direction || "past";
|
|
29
|
-
|
|
30
|
-
var qs = "?l=english";
|
|
31
|
-
if (options.startTime) {
|
|
32
|
-
if (options.startTime instanceof Date) {
|
|
33
|
-
options.startTime = Math.floor(options.startTime.getTime() / 1000);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
qs += "&after_time=" + options.startTime;
|
|
37
|
-
|
|
38
|
-
if (options.startTrade) {
|
|
39
|
-
qs += "&after_trade=" + options.startTrade;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (options.direction == "future") {
|
|
44
|
-
qs += "&prev=1";
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
this._myProfile("inventoryhistory" + qs, null, function(err, response, body) {
|
|
48
|
-
if (err) {
|
|
49
|
-
callback(err);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
var output = {};
|
|
54
|
-
var vanityURLs = [];
|
|
55
|
-
|
|
56
|
-
var $ = Cheerio.load(body);
|
|
57
|
-
if (!$('.inventory_history_pagingrow').html()) {
|
|
58
|
-
callback(new Error("Malformed page: no paging row found"));
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Load the inventory item data
|
|
63
|
-
var match2 = body.match(/var g_rgHistoryInventory = (.*);/);
|
|
64
|
-
if (!match2) {
|
|
65
|
-
callback(new Error("Malformed page: no trade found"));
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
var historyInventory = JSON.parse(match2[1]);
|
|
71
|
-
} catch (ex) {
|
|
72
|
-
callback(new Error("Malformed page: no well-formed trade data found"));
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
var i;
|
|
77
|
-
|
|
78
|
-
// See if we've got paging buttons
|
|
79
|
-
var $paging = $('.inventory_history_nextbtn .pagebtn:not(.disabled)');
|
|
80
|
-
var href;
|
|
81
|
-
for (i = 0; i < $paging.length; i++) {
|
|
82
|
-
href = $paging[i].attribs.href;
|
|
83
|
-
if (href.match(/prev=1/)) {
|
|
84
|
-
output.firstTradeTime = new Date(href.match(/after_time=(\d+)/)[1] * 1000);
|
|
85
|
-
output.firstTradeID = href.match(/after_trade=(\d+)/)[1];
|
|
86
|
-
} else {
|
|
87
|
-
output.lastTradeTime = new Date(href.match(/after_time=(\d+)/)[1] * 1000);
|
|
88
|
-
output.lastTradeID = href.match(/after_trade=(\d+)/)[1];
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
output.trades = [];
|
|
93
|
-
var trades = $('.tradehistoryrow');
|
|
94
|
-
|
|
95
|
-
var item, trade, profileLink, items, j, econItem, timeMatch, time;
|
|
96
|
-
for (i = 0; i < trades.length; i++) {
|
|
97
|
-
item = $(trades[i]);
|
|
98
|
-
trade = {};
|
|
99
|
-
|
|
100
|
-
trade.onHold = !!item.find('span:nth-of-type(2)').text().match(/Trade on Hold/i);
|
|
101
|
-
|
|
102
|
-
timeMatch = item.find('.tradehistory_timestamp').html().match(/(\d+):(\d+)(am|pm)/);
|
|
103
|
-
if (timeMatch[1] == 12 && timeMatch[3] == 'am') {
|
|
104
|
-
timeMatch[1] = 0;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (timeMatch[1] < 12 && timeMatch[3] == 'pm') {
|
|
108
|
-
timeMatch[1] = parseInt(timeMatch[1], 10) + 12;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
time = (timeMatch[1] < 10 ? '0' : '') + timeMatch[1] + ':' + timeMatch[2] + ':00';
|
|
112
|
-
|
|
113
|
-
trade.date = new Date(item.find('.tradehistory_date').html() + ' ' + time + ' UTC');
|
|
114
|
-
trade.partnerName = item.find('.tradehistory_event_description a').html();
|
|
115
|
-
trade.partnerSteamID = null;
|
|
116
|
-
trade.partnerVanityURL = null;
|
|
117
|
-
trade.itemsReceived = [];
|
|
118
|
-
trade.itemsGiven = [];
|
|
119
|
-
|
|
120
|
-
profileLink = item.find('.tradehistory_event_description a').attr('href');
|
|
121
|
-
if (profileLink.indexOf('/profiles/') != -1) {
|
|
122
|
-
trade.partnerSteamID = new SteamID(profileLink.match(/(\d+)$/)[1]);
|
|
123
|
-
} else {
|
|
124
|
-
trade.partnerVanityURL = profileLink.match(/\/([^\/]+)$/)[1];
|
|
125
|
-
if (options.resolveVanityURLs && vanityURLs.indexOf(trade.partnerVanityURL) == -1) {
|
|
126
|
-
vanityURLs.push(trade.partnerVanityURL);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
items = item.find('.history_item');
|
|
131
|
-
for (j = 0; j < items.length; j++) {
|
|
132
|
-
match = body.match(new RegExp("HistoryPageCreateItemHover\\( '" + $(items[j]).attr('id') + "', (\\d+), '(\\d+)', '(\\d+|class_\\d+_instance_\\d+|class_\\d+)', '(\\d+)' \\);"));
|
|
133
|
-
econItem = historyInventory[match[1]][match[2]][match[3]];
|
|
134
|
-
|
|
135
|
-
if ($(items[j]).attr('id').indexOf('received') != -1) {
|
|
136
|
-
trade.itemsReceived.push(new CEconItem(econItem));
|
|
137
|
-
} else {
|
|
138
|
-
trade.itemsGiven.push(new CEconItem(econItem));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
output.trades.push(trade);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (options.resolveVanityURLs) {
|
|
146
|
-
Async.map(vanityURLs, Helpers.resolveVanityURL, function(err, results) {
|
|
147
|
-
if (err) {
|
|
148
|
-
callback(err);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
for (i = 0; i < output.trades.length; i++) {
|
|
153
|
-
if (output.trades[i].partnerSteamID || !output.trades[i].partnerVanityURL) {
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Find the vanity URL
|
|
158
|
-
for (j = 0; j < results.length; j++) {
|
|
159
|
-
if (results[j].vanityURL == output.trades[i].partnerVanityURL) {
|
|
160
|
-
output.trades[i].partnerSteamID = new SteamID(results[j].steamID);
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
callback(null, output);
|
|
167
|
-
});
|
|
168
|
-
} else {
|
|
169
|
-
callback(null, output);
|
|
170
|
-
}
|
|
171
|
-
}, "steamcommunity");
|
|
172
|
-
};
|
|
173
|
-
|
|
1
|
+
var SteamCommunity = require('../index.js');
|
|
2
|
+
var CEconItem = require('../classes/CEconItem.js');
|
|
3
|
+
var Helpers = require('./helpers.js');
|
|
4
|
+
var SteamID = require('steamid');
|
|
5
|
+
var request = require('request');
|
|
6
|
+
var Cheerio = require('cheerio');
|
|
7
|
+
var Async = require('async');
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Inventory history in a nutshell.
|
|
11
|
+
*
|
|
12
|
+
* There are no more page numbers. Now you have to request after_time and optionally after_trade.
|
|
13
|
+
* Without "prev" set, you will request 30 trades that were completed FURTHER IN THE PAST than after_time (and optionally after_trade)
|
|
14
|
+
* With "prev" set, you will request 30 trades that were completed MORE RECENTLY than after_time (and optionally after_trade)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use GetTradeHistory instead: https://lab.xpaw.me/steam_api_documentation.html#IEconService_GetTradeHistory_v1
|
|
19
|
+
* @param {object} options
|
|
20
|
+
* @param {function} callback
|
|
21
|
+
*/
|
|
22
|
+
SteamCommunity.prototype.getInventoryHistory = function(options, callback) {
|
|
23
|
+
if (typeof options === 'function') {
|
|
24
|
+
callback = options;
|
|
25
|
+
options = {};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
options.direction = options.direction || "past";
|
|
29
|
+
|
|
30
|
+
var qs = "?l=english";
|
|
31
|
+
if (options.startTime) {
|
|
32
|
+
if (options.startTime instanceof Date) {
|
|
33
|
+
options.startTime = Math.floor(options.startTime.getTime() / 1000);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
qs += "&after_time=" + options.startTime;
|
|
37
|
+
|
|
38
|
+
if (options.startTrade) {
|
|
39
|
+
qs += "&after_trade=" + options.startTrade;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (options.direction == "future") {
|
|
44
|
+
qs += "&prev=1";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
this._myProfile("inventoryhistory" + qs, null, function(err, response, body) {
|
|
48
|
+
if (err) {
|
|
49
|
+
callback(err);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var output = {};
|
|
54
|
+
var vanityURLs = [];
|
|
55
|
+
|
|
56
|
+
var $ = Cheerio.load(body);
|
|
57
|
+
if (!$('.inventory_history_pagingrow').html()) {
|
|
58
|
+
callback(new Error("Malformed page: no paging row found"));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Load the inventory item data
|
|
63
|
+
var match2 = body.match(/var g_rgHistoryInventory = (.*);/);
|
|
64
|
+
if (!match2) {
|
|
65
|
+
callback(new Error("Malformed page: no trade found"));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
var historyInventory = JSON.parse(match2[1]);
|
|
71
|
+
} catch (ex) {
|
|
72
|
+
callback(new Error("Malformed page: no well-formed trade data found"));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var i;
|
|
77
|
+
|
|
78
|
+
// See if we've got paging buttons
|
|
79
|
+
var $paging = $('.inventory_history_nextbtn .pagebtn:not(.disabled)');
|
|
80
|
+
var href;
|
|
81
|
+
for (i = 0; i < $paging.length; i++) {
|
|
82
|
+
href = $paging[i].attribs.href;
|
|
83
|
+
if (href.match(/prev=1/)) {
|
|
84
|
+
output.firstTradeTime = new Date(href.match(/after_time=(\d+)/)[1] * 1000);
|
|
85
|
+
output.firstTradeID = href.match(/after_trade=(\d+)/)[1];
|
|
86
|
+
} else {
|
|
87
|
+
output.lastTradeTime = new Date(href.match(/after_time=(\d+)/)[1] * 1000);
|
|
88
|
+
output.lastTradeID = href.match(/after_trade=(\d+)/)[1];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
output.trades = [];
|
|
93
|
+
var trades = $('.tradehistoryrow');
|
|
94
|
+
|
|
95
|
+
var item, trade, profileLink, items, j, econItem, timeMatch, time;
|
|
96
|
+
for (i = 0; i < trades.length; i++) {
|
|
97
|
+
item = $(trades[i]);
|
|
98
|
+
trade = {};
|
|
99
|
+
|
|
100
|
+
trade.onHold = !!item.find('span:nth-of-type(2)').text().match(/Trade on Hold/i);
|
|
101
|
+
|
|
102
|
+
timeMatch = item.find('.tradehistory_timestamp').html().match(/(\d+):(\d+)(am|pm)/);
|
|
103
|
+
if (timeMatch[1] == 12 && timeMatch[3] == 'am') {
|
|
104
|
+
timeMatch[1] = 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (timeMatch[1] < 12 && timeMatch[3] == 'pm') {
|
|
108
|
+
timeMatch[1] = parseInt(timeMatch[1], 10) + 12;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
time = (timeMatch[1] < 10 ? '0' : '') + timeMatch[1] + ':' + timeMatch[2] + ':00';
|
|
112
|
+
|
|
113
|
+
trade.date = new Date(item.find('.tradehistory_date').html() + ' ' + time + ' UTC');
|
|
114
|
+
trade.partnerName = item.find('.tradehistory_event_description a').html();
|
|
115
|
+
trade.partnerSteamID = null;
|
|
116
|
+
trade.partnerVanityURL = null;
|
|
117
|
+
trade.itemsReceived = [];
|
|
118
|
+
trade.itemsGiven = [];
|
|
119
|
+
|
|
120
|
+
profileLink = item.find('.tradehistory_event_description a').attr('href');
|
|
121
|
+
if (profileLink.indexOf('/profiles/') != -1) {
|
|
122
|
+
trade.partnerSteamID = new SteamID(profileLink.match(/(\d+)$/)[1]);
|
|
123
|
+
} else {
|
|
124
|
+
trade.partnerVanityURL = profileLink.match(/\/([^\/]+)$/)[1];
|
|
125
|
+
if (options.resolveVanityURLs && vanityURLs.indexOf(trade.partnerVanityURL) == -1) {
|
|
126
|
+
vanityURLs.push(trade.partnerVanityURL);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
items = item.find('.history_item');
|
|
131
|
+
for (j = 0; j < items.length; j++) {
|
|
132
|
+
match = body.match(new RegExp("HistoryPageCreateItemHover\\( '" + $(items[j]).attr('id') + "', (\\d+), '(\\d+)', '(\\d+|class_\\d+_instance_\\d+|class_\\d+)', '(\\d+)' \\);"));
|
|
133
|
+
econItem = historyInventory[match[1]][match[2]][match[3]];
|
|
134
|
+
|
|
135
|
+
if ($(items[j]).attr('id').indexOf('received') != -1) {
|
|
136
|
+
trade.itemsReceived.push(new CEconItem(econItem));
|
|
137
|
+
} else {
|
|
138
|
+
trade.itemsGiven.push(new CEconItem(econItem));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
output.trades.push(trade);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (options.resolveVanityURLs) {
|
|
146
|
+
Async.map(vanityURLs, Helpers.resolveVanityURL, function(err, results) {
|
|
147
|
+
if (err) {
|
|
148
|
+
callback(err);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
for (i = 0; i < output.trades.length; i++) {
|
|
153
|
+
if (output.trades[i].partnerSteamID || !output.trades[i].partnerVanityURL) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Find the vanity URL
|
|
158
|
+
for (j = 0; j < results.length; j++) {
|
|
159
|
+
if (results[j].vanityURL == output.trades[i].partnerVanityURL) {
|
|
160
|
+
output.trades[i].partnerSteamID = new SteamID(results[j].steamID);
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
callback(null, output);
|
|
167
|
+
});
|
|
168
|
+
} else {
|
|
169
|
+
callback(null, output);
|
|
170
|
+
}
|
|
171
|
+
}, "steamcommunity");
|
|
172
|
+
};
|
|
173
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const {chrome} = require('@doctormckay/user-agents');
|
|
2
|
+
|
|
3
|
+
const SteamCommunity = require('../index.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef LogOnDetails
|
|
7
|
+
* @property {string} accountName
|
|
8
|
+
* @property {string} password
|
|
9
|
+
* @property {string} [steamguard]
|
|
10
|
+
* @property {string} [authCode]
|
|
11
|
+
* @property {string} [twoFactorCode]
|
|
12
|
+
* @property {boolean} disableMobile
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef LogOnResponse
|
|
17
|
+
* @property {string} sessionID
|
|
18
|
+
* @property {string[]} cookies
|
|
19
|
+
* @property {string} steamguard
|
|
20
|
+
* @property {string} [mobileAccessToken]
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param {LogOnDetails} logOnDetails
|
|
26
|
+
* @returns {Promise<LogOnResponse>}
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
SteamCommunity.prototype._modernLogin = function(logOnDetails) {
|
|
30
|
+
return new Promise(async (resolve, reject) => {
|
|
31
|
+
if (!isNodeVersionNewEnough()) {
|
|
32
|
+
return reject(new Error(`Node.js version is too old! Need >=12.22.0 or later, got ${process.versions.node}.`));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (this._options.request) {
|
|
36
|
+
return reject(new Error('SteamCommunity.login() is incompatible with node-steamcommunity v3\'s usage of \'request\'. If you need to specify a custom \'request\' instance (e.g. when using a proxy), use https://www.npmjs.com/package/steam-session directly to log onto Steam.'));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Import this here so we don't cause problems on old Node versions if this code path isn't taken.
|
|
40
|
+
const {LoginSession, EAuthTokenPlatformType, EAuthSessionGuardType} = require('steam-session');
|
|
41
|
+
|
|
42
|
+
let session = new LoginSession(
|
|
43
|
+
logOnDetails.disableMobile
|
|
44
|
+
? EAuthTokenPlatformType.WebBrowser
|
|
45
|
+
: EAuthTokenPlatformType.MobileApp,
|
|
46
|
+
{
|
|
47
|
+
localAddress: this._options.localAddress,
|
|
48
|
+
userAgent: this._options.userAgent || chrome()
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
session.on('authenticated', async () => {
|
|
53
|
+
try {
|
|
54
|
+
let webCookies = await session.getWebCookies();
|
|
55
|
+
let sessionIdCookie = webCookies.find(c => c.startsWith('sessionid='));
|
|
56
|
+
resolve({
|
|
57
|
+
sessionID: sessionIdCookie.split('=')[1],
|
|
58
|
+
cookies: webCookies,
|
|
59
|
+
steamguard: session.steamGuardMachineToken,
|
|
60
|
+
mobileAccessToken: logOnDetails.disableMobile ? null : session.accessToken
|
|
61
|
+
});
|
|
62
|
+
} catch (ex) {
|
|
63
|
+
reject(ex);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
session.on('error', (err) => {
|
|
68
|
+
reject(err);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
let startResult = await session.startWithCredentials({
|
|
73
|
+
accountName: logOnDetails.accountName,
|
|
74
|
+
password: logOnDetails.password,
|
|
75
|
+
steamGuardMachineToken: logOnDetails.steamguard,
|
|
76
|
+
steamGuardCode: logOnDetails.authCode || logOnDetails.twoFactorCode
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (startResult.actionRequired) {
|
|
80
|
+
// Cannot continue with login, need something from the user
|
|
81
|
+
session.cancelLoginAttempt();
|
|
82
|
+
|
|
83
|
+
let emailMfaAction = startResult.validActions.find(action => action.type == EAuthSessionGuardType.EmailCode);
|
|
84
|
+
if (emailMfaAction) {
|
|
85
|
+
let err = new Error('SteamGuard');
|
|
86
|
+
err.emaildomain = emailMfaAction.detail;
|
|
87
|
+
return reject(err);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return reject(new Error('SteamGuardMobile'));
|
|
91
|
+
}
|
|
92
|
+
} catch (ex) {
|
|
93
|
+
return reject(ex);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
function isNodeVersionNewEnough() {
|
|
99
|
+
let [major, minor] = process.versions.node.split('.');
|
|
100
|
+
|
|
101
|
+
if (major < 12) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (major == 12 && minor < 22) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return true;
|
|
110
|
+
}
|