steamcommunity 3.47.0 → 3.48.0
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/classes/CConfirmation.js +37 -37
- package/classes/CEconItem.js +120 -120
- package/classes/CSteamSharedFile.js +221 -221
- package/classes/CSteamUser.js +225 -225
- package/components/confirmations.js +428 -428
- package/components/groups.js +798 -798
- package/components/help.js +64 -64
- package/components/helpers.js +128 -128
- 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/sharedfiles.js +158 -158
- package/components/twofactor.js +152 -152
- package/components/users.js +831 -831
- package/components/webapi.js +128 -25
- package/examples/disable_twofactor.js +22 -59
- package/examples/enable_twofactor.js +22 -61
- package/index.js +462 -600
- package/package.json +44 -46
- 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
|
@@ -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
|
+
}
|