npm i steam-weblogin
import Account from "steam-weblogin";
import SteamCommunity from "steamcommunity";
const community = new SteamCommunity();
community.login(
{
accountName: "login",
password: "password",
disableMobile: true
},
async (error, sessionID, cookies) => {
if (!error) {
const account = new Account(cookies);
const {
body,
headers,
request: { uri },
cookies
} = await account.login("https://www.csgo500.com/steam/preauth");
console.log(uri, body, cookies, headers);
}
}
);
request: RequestAPI<any, any, any>
- requestretry (default) or request-promise instance
/* Example usage */
const response = await account.request.get("https://steamcommunity.com");
account.request = require("request-promise").defaults({
proxy: "http://localhost:8888"
});
// the best way to change the defaults
account.request = account.request.defaults({
proxy: "http://localhost:8888"
});
cookies: Cookies;
- Cookies instance
/* Example usage */
account.cookies.export();
account.cookies = new Cookies(jar);
new Account(cookies: Cookies | CookieArray)
cookies
- logged in Steam cookies (sessionid, steamLoginSecure, ...), can be Cookies or CookieArray
/* Example usage */
import Account from "steam-weblogin";
const Account = require("steam-weblogin").default; // ES5 syntax
const account = new Account([
"steamLoginSecure=value",
"sessionid=value",
"steamCountry=value"
]);
const account = new Account(cookies);
login(url: String, { clone: Boolean = true }): LoginResponse
url
- any url that redirects to steam openid login page https://steamcommunity.com/openid/login?openid.mode=checkid_setup&openid.ns=..., like https://www.csgo500.com/steam/preauth (3d-party site)clone
- iftrue (default)
would useaccount.jar.clone()
, else would useaccount.jar
as a jar
/* Example usage */
const response = await account.login("https://www.csgo500.com/steam/preauth");
rejects with LoginError if passed cookies are bad
interface LoginResponse {
statusCode: Number;
body: String;
headers: Object;
request: {
uri: Url;
method: String;
headers: Object;
};
cookies: Object;
}
import { LoginResponse } from "steam-weblogin";
jar: CookieJar;
- CookieJar instance
/* Example usage */
const str = cookies.jar.getCookieStringSync("https://steamcommunity.com");
cookies.jar = new CookieJar();
readonly jar: request.CookieJar;
- RequestJar instance, changes when jar changes
/* Example usage */
request.get("https://steamcommunity.com", { jar: cookies.requestJar });
new Cookies(cookies: CookieArray);
cookies
- logged in Steam cookies (sessionid, steamLoginSecure, ...), can be Cookies or CookieArray
import { Cookies } from "steam-weblogin";
const cookies = new Cookies([
"steamLoginSecure=value",
"sessionid=value",
"steamCountry=value"
]);
const cookies = new Cookies(jar);
export(): {key: String, value: String, domain: String, ...}[]
- returns Cookie.Serialized[] (code)
clone(): Cookies
- returns Cookies' deep clone
type CookieArray = CookieJar | (Cookie | String | Object)[];
import { CookieArray } from "steam-weblogin";
message: String = "Must be logged in";
new LoginError();
/* Example usage */
import { LoginError } from "steam-weblogin";
if (error instanceof LoginError) {
// do something
}
Released under MIT license