Giter VIP home page Giter VIP logo

node-steamstore's Introduction

steamstore

A module for interacting with the Steam store site from Node.js. Currently not a lot of functionality is supported.

Logging In

This module cannot facilitate logins to the store site directly. You'll need to use something like steam-user or steamcommunity to login, and then use setCookies to set your login cookies in this module.

The cookies are the same for the store site and for the community site.

Patterns

Please read this section in its entirety before starting work with SteamStore.

Callbacks and Promises

All methods listed in this document that accept a callback also return a Promise. You may use either callbacks or promises.

Legacy callbacks return their data spanning across multiple arguments. All promises (which return any data at all) return a single object containing one or more properties. The names of these properties for legacy callbacks are the names of the callback arguments listed in this readme. Newer callbacks return a single object response argument, which is identical to the promise output for that method.

Some methods indicate that their callback is required or optional. You are never required to use callbacks over promises, but if a callback is listed as optional then an unhandled promise rejection will not raise a warning/error. If a callback is listed as required and you neither supply a callback nor handle the promise rejection, then a promise rejection will raise a warning, and eventually a crash in a future Node.js release.

Properties

steamID

v1.1.0 or later is required to use this property

A SteamID object for the currently logged-in user.

Methods

Constructor([options])

  • options - An optional object containing zero or more of these properties:
    • timeout - The timeout to use for HTTP(S) requests, in milliseconds; default is 50000 (50 seconds)
    • userAgent - The user-agent header value; default is Chrome 56
    • request - A request instance
      • This allows you to specify your own defaults on the request instance
      • These options will always be overridden on the request instance: jar, timeout, gzip, headers['User-Agent']

Constructs a new instance of steamstore. Example:

const SteamStore = require('steamstore');
let store = new SteamStore();

or

const SteamStore = require('steamstore');
let store = new SteamStore({"timeout": 30000});

setCookie(cookie)

  • cookie - The cookie, in "name=value" string format

Sets a single cookie to steamstore's internal cookie jar.

setCookies(cookies)

  • cookies - An array of cookies, in "name=value" string format

Simply calls setCookie for each cookie in the array.

getSessionID()

Returns the value of the sessionid cookie, or creates a new random one and adds it to the cookie jar if not present.

addPhoneNumber(number[, bypassConfirmation], callback)

  • number - Your phone number, with a leading plus and the country code
    • Example: +18885550123
  • bypassConfirmation - true if you want to ignore any confirmation-level errors (see below). Default false
  • callback - A function to be called when the request completes
    • err - An Error object on failure, or null on success. The confirmation property will be true if this is a confirmation-level error which can be overridden by setting bypassConfirmation to true

Adds a new phone number to your account. This triggers a verification Email to be sent. You can continue the process by calling sendPhoneNumberVerificationMessage

sendPhoneNumberVerificationMessage(callback)

  • callback - A function to be called when the request completes
    • err - An Error object on failure, or null on success

v2.3.0 or later is required to use this method

Call this method after you've clicked on the link in the email you received after you called addPhoneNumber(). This triggers a verification SMS to be sent. You can provide the verification code to verifyPhoneNumber to finalize the process.

resendVerificationSMS(callback)

  • callback - A function to be called when the request completes
    • err - An Error object on failure, or null on success

Asks the Steam servers to resend the verification SMS to your pending-confirmation phone number. This will fail if you request it too soon after the last SMS was sent.

verifyPhoneNumber(code, callback)

  • code - Your SMS verification code
  • callback - A function to be called when the request completes
    • err - An Error object on failure, or null on success

Verify your pending-verification phone number using the SMS code.

removePhoneNumber(callback)

  • callback - A function to be called when the request completes
    • err - An Error object on failure, or null on success

Starts the process to remove your phone number from your account. This will send an SMS verification code to your phone. Call confirmRemovePhoneNumber with the code to finalize the process.

confirmRemovePhoneNumber(code, callback)

  • code - Your SMS verification code
  • callback - A function to be called when the request completes
    • err - An Error object on failure, or null on success

Finalizes the process of removing your phone number from your account.

hasPhone(callback)

  • callback - A function to be called when the request completes
    • err - An Error object on failure, or null on success
    • hasVerifiedPhone - true if your account has a phone number linked, false if not
    • lastDigits - If you have a phone number, this is a string containing the last 4 digits of your number

v1.3.0 or later is required to use this method

Checks whether your account has a phone number linked or not.

getAccountData(callback)

  • callback - A function to be called when the request completes
    • err - An Error object on failure, or null on success
    • ownedApps - An array containing the AppID of each app which your account owns
    • ownedPackages - An array containing the PackageID of each package which your account owns
    • wishlistedApps - An array containing the AppID of each app that's on your wishlist
    • ignoredApps - An array containing the AppID of each app which you've clicked "Not Interested" on
    • suggestedTags - An object containing the tags which are suggested for you. Keys are TagIDs, values are the tag names.

v1.1.0 or later is required to use this method

Gets information about products that your account owns, ignores, wants, or is recommended.

sendGift(giftID, recipient, recipientName, message, closing, signature[, callback])

  • giftID - The gift's ID (also known as the asset ID of the item in your Steam gift inventory)
  • recipient - The recipient's SteamID (as a SteamID object or string) to send it over Steam. You need to be friends with the user.
  • recipientName - The name of the recipient to put in the gift email/popup
  • message - The message to include in the email/popup
  • closing - The closing to include in the email/popup
  • signature - Your name to include in the email/popup
  • callback - Optional. Called when the request completes.
    • err - An Error object on failure, or null on success

v1.4.0 or later is required to use this method

Sends a Steam gift in your inventory to another user. The gift will remain in your inventory until the recipient accepts it. You can re-send a gift which you've already sent. Gifts don't have to be tradable in order to be sent.

createWallet(walletCode, billingAddress, callback)

  • walletCode - A Steam wallet code you want to redeem
  • billingAddress - An object containing these properties:
    • address - Your street address
    • city - Your city
    • country - Your country code, e.g. "US"
    • state - Your state, e.g. "FL"
    • postalCode - Your postal/ZIP code
  • callback - Required. Called when the requested data is available.
    • err - An Error object if the request fails, or null otherwise
    • eresult - An EResult value from SteamStore.EResult
    • detail - A value from SteamStore.EPurchaseResult or undefined
    • redeemable - true if this code can be redeemed, false if not
    • amount - If redeemable, this is how much the code is worth, in its currency's lowest denomination (e.g. USD cents)
    • currencyCode - If redeemable, this is the currency of amount

v1.7.0 or later is required to use this method

Before you can redeem a Steam Wallet code, your account needs to have a wallet. If you don't yet have a wallet you can use this method to create one. Creating a wallet requires you to provide a wallet code, but the code won't be redeemed until you actually call redeemWalletCode.

checkWalletCode()

THIS METHOD IS NO LONGER FUNCTIONAL. IT WILL BE REMOVED IN A FUTURE RELEASE.

redeemWalletCode(walletCode[, callback])

  • walletCode - The Steam wallet code you want to redeem
  • callback - Optional. Called when the request completes.
    • err - An Error object if the request fails, or null on success
    • eresult - An EResult value from SteamStore.EResult
    • detail - A value from SteamStore.EPurchaseResult or undefined
    • formattedNewWalletBalance - If redeemed successfully, this is your new wallet balance as a string, formatted for human display (e.g. $20.00)
    • amount - If redeemable, this is how much the code is worth, in its currency's lowest denomination (e.g. USD cents)

v1.5.0 or later is required to use this method

Attempts to redeem a Steam Wallet code on your account. This will call checkWalletCode first, and if the code is not redeemable, the callback will be invoked with an Error passed as the first parameter. That Error will have message Wallet code is not valid, with eresult and purchaseresultdetail properties defined on that Error object.

getWalletBalance([callback])

  • callback - Called when the request completes.
    • err - An Error object if the request fails, or null on success
    • response - The response object
      • formattedBalance - Your wallet balance as a string, formatted in your local currency (e.g. "$1.23")

v2.1.0 or later is required to use this method

Gets your current Steam wallet balance.

setDisplayLanguages(primary[, secondary][, callback])

  • primary - Your desired primary (display) language, as a string (e.g. english or danish)
  • secondary - Your desired secondary languages, as an array of strings of the same format as primary
  • callback - Optional. Called when the request completes.
    • err - An Error object on failure, or null on success

v1.5.0 or later is required to use this method

Updates your account's display languages for the Steam store.

addFreeLicense(subID[, callback])

  • subID - The ID of the free-on-demand package you would like to claim
  • callback - Optional. Called when the request completes.
    • err - An Error object on failure, or null on success

v2.0.0 or later is required to use this method

Request to add an eligible free-on-demand package to your Steam account.

removeLicense(subID[, callback])

  • subID - The ID of the complimentary license you would like to remove
  • callback - Optional. Called when the request completes.
    • err - An Error objecton failure, or null on success

v2.2.0 or later is required to use this method

Removes an eligible complimentary license from your Steam account.

node-steamstore's People

Contributors

doctormckay avatar fabsolute avatar heartz66 avatar maarethyu avatar rob-- avatar spyfly avatar zirxi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-steamstore's Issues

checkWalletCode timeout

Hello, I am trying to use checkWalletCode to check a list of wallet codes and spit out their validity. I am using async.series to prevent spamming of the codes. However, the eresult is still 16 (timeout)

    checkSteamCodes(codes) {
        let that = this
        let series = []
        codes.forEach((code) => {
            series.push((callback) => {
                if(!that._cookies) callback("Not logged in", null)

                that._store_client.checkWalletCode(code, (err, eresult, detail, redeemable, amount, currency) => {
                    if(err) callback(err, null)
                    console.log(eresult)
                    console.info({valid: redeemable, value: amount/100, currency: currency})
                    callback(null, {valid: redeemable, value: amount/100, currency: currency})
                })
            })
        })

        return new Promise((resolve, reject) => {
            async.series(series, (err, results) => {
                if(err) reject(err)
                console.log("series result: ", results)
                resolve(results)
            })
        })
    }

is there some sort of rate limit?

Missed "email_verification" op to complete adding phone number flow

store.addPhoneNumber throws error.message "Unknown state email_verification" which successfully calls email send from steam.
After confirming intentions to add phone number. The next step is to request sms code which unfortunately is not implemented in package.

Though I manually request sms code:

private async requestSMSCode(): Promise<boolean> {
	const params = new URLSearchParams();
	params.append("op", "email_verification");
	params.append("input", "");
	params.append("sessionID", this.steam.sessionID);
	params.append("confirmed", "1");
	params.append("checkfortos", "1");
	params.append("bisediting", "0");
	params.append("token", "0");

	const {
		data: { success }
	} = await axios.post("https://store.steampowered.com/phone/add_ajaxop", params, {
		headers: {
			"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
			Cookie: this.steam.serializedCookies
		}
	});

	return success;
}

Bug, WalletCode: Cannot read property 'success' of undefined

createWallet, checkWalletCode and redeemWalletCode always return an error:

components\account.js:353
                        if (!body.success && !body.detail && !body.wallet) {
TypeError: Cannot read property 'success' of undefined

Any other methods work fine.

[Bug] Cannot read property 'accountid' of undefined

error trace:

 2018-12-27 | 01:02:30.450 | ERROR | crashBot                       | TypeError: Cannot read property 'accountid' of undefined
    at SteamStore.getAccountData (C:\Users\Administrator\OneDrive\Projects\NodeJS\node_modules\steamstore\components\account.js:190:22)
    at syncBarterLibrary (C:\Users\Administrator\OneDrive\Projects\NodeJS\master-bot\index.js:1905:17)
    at appids (C:\Users\Administrator\OneDrive\Projects\NodeJS\master-bot\index.js:953:13)
    at steam.user.getProductInfo (C:\Users\Administrator\OneDrive\Projects\NodeJS\master-bot\index.js:2623:9)
    at C:\Users\Administrator\OneDrive\Projects\NodeJS\node_modules\steam-user\components\apps.js:292:6
    at Object.cb (C:\Users\Administrator\OneDrive\Projects\NodeJS\node_modules\steam-user\components\messages.js:174:4)
    at CMClient._netMsgReceived (C:\Users\Administrator\OneDrive\Projects\NodeJS\node_modules\steam-user\node_modules\steam-client\lib\cm_client.js:321:26)
    at CMClient.handlers.(anonymous function) (C:\Users\Administrator\OneDrive\Projects\NodeJS\node_modules\steam-user\node_modules\steam-client\lib\cm_client.js:609:8)
    at CMClient._netMsgReceived (C:\Users\Administrator\OneDrive\Projects\NodeJS\node_modules\steam-user\node_modules\steam-client\lib\cm_client.js:305:24)
    at emitOne (events.js:115:13)

Related code


    function syncBarterLibrary(appids, callback) {
    steam.store.getAccountData((error, ownedApps, ownedPackages) => {
        if (!error && ownedApps.length > 0 && ownedPackages.length > 0) {
            const formdata = {
                bulk_IDs: `app/${ownedApps.join(`,app/`)},sub/${ownedPackages.join(`,sub/`)}`,
                add_IDs: `+ Add IDs`,
                action: `Edit`,
                change_attempted: 1,
                add_from: `IDs`
            };
            httprequest.public.post({
                url: `https://barter.vg/u/my/l/e/`,
                form: formdata
            }, function() {
                if (callback) callback();
            });
        } else if (callback) {
            callback();
        }
    });
    }

Again, maybe it's because I have the steam store instance loaded into the steam object?

checkWalletCode and redeemWalletCode need sessionID parameter

Both these functions need sessionID parameter, otherwise they return EResult 21 (NotLoggedOn).
Something like:

SteamStore.prototype.checkWalletCode = function(code, sessionID, callback) {
	var self = this;
	this.request.post({
		"uri": "https://store.steampowered.com/account/validatewalletcode/",
		"form": {
			"sessionid": sessionID,
			"wallet_code": code
		},

and same for redeemWalletCode

Sending a digital gift card

This is great! I really appreciate your work (and the contributors) for this project. I am planning to rewrite this partially within Rust for a personal project (and to release as a library). However, I need to somehow implement sending a digital gift card.

I would love it if you could consider investigating this and adding it to the npm library!

checkWalletCode error

Hello, I am currently trying to use the checkWalletCode method. I am doing this inside my webSession event callback, from steam-user. The cookies appear to be correct, includes sessionid, steamLogin, steamLoginSecure.

            that._client.on("webSession", function (session_id, cookies) {
                console.log(cookies) // cookies appear fine
                that._cookies = cookies 
                that._store_client.setCookies = cookies // all i need?
                that._store_client.checkWalletCode("xxxx-xxxx-xxxx", (err, eresult, detail, redeemable, amount, currency) => {
                    console.log(err)
                })
            })

This callback is inside a promise within a class method, if that's relevant.

redeemWalletCode not working on new Accounts

Hello,

On new accounts, who never redeemed any Wallet Code, you have to enter billig address, billing city etc.

So eresult is always 2 (fail).

The lib doesn't provide such things right now. If you enter your first WalletCode manually with all provided data the wallet code works, the second walletcode via libary work also.

Game Key redemption

I noticed that it is now possible to redeem the game keys via the web interface:
https://store.steampowered.com/account/registerkey

Redeeming a key sends a POST request to the URL https://store.steampowered.com/account/ajaxregisterkey/ with the parameters product_key and sessionid. I saw that there was a sessionid that is used in this package.
Maybe it is possible to make this feature available for this package as well.

I might try that on the weekend and report to this issue. ;)

Add method to check if account already have phone

I did this for myself, but this function queries not store but steamcommunity, so we should add cookies for that domain too. Because of that I'm not sure where it belongs, steam-user or steamstore. I hope you will find a place for this function. Also would be nice if you add function to check if 2FA already activated, but I don't know if it possible.

SteamStore.prototype.getPhoneData = function(callback) {
    var self = this;
    this.request.get({
        "uri": "https://steamcommunity.com/steamguard/phoneajax",
        "qs": {
            "op": "has_phone"
        },
        "json": true
    }, function(err, response, body) {
        if(self._checkHttpError(err, response, callback)) {
            return;
        }
        callback(null, {has_phone: (body.success && body.has_phone)});
    });
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.