Skip to content

Steam Confirmation Polling

Alex Corn edited this page May 2, 2019 · 8 revisions

As of v3.12.1, node-steamcommunity can automatically poll for your account/trade confirmations and emit events when a new one comes in. Use these methods and events on SteamCommunity to use this feature.

Sometimes confirmations can just not appear. See issue #27 for more information. This is a Steam issue and can't be fixed on our end.

THIS IS DEPRECATED

The confirmation checker is deprecated and will be removed in a future release. It is highly recommended that you use acceptConfirmationForObject instead as needed. This will prevent you from getting rate-limited by Steam as heavily, will reduce load on Steam servers, and is generally just more reliable.

NO SUPPORT WILL BE PROVIDED for applications which use the confirmation checker.

Methods

startConfirmationChecker(pollInterval[, identitySecret])

  • pollInterval - The time between polls in milliseconds. This probably should be at least 10,000 to avoid rate-limits.
  • identitySecret - Optional. Your identity_secret as a Buffer, or base64/hex string.

v3.14.0 or later is required to use identitySecret

Start automatic polling. If you provide your identitySecret, then no events will be emitted and all confirmations will always be accepted. Use at your own risk!

stopConfirmationChecker()

Stop automatic polling. If you set your identitySecret previously, this will delete it.

checkConfirmations()

Trigger a confirmation poll right now. This will reset the poll timer. It might be handy to call this right after you send/accept a trade that requires confirmation.

Events

confKeyNeeded

  • tag - The tag that should be used to generate this key
  • callback - You should call this function when you have the key ready
    • err - If an error occurred when you were getting the key, pass an Error object here and no further arguments. If successful, pass null here.
    • time - The Unix timestamp that you used to generate this key
    • key - The base64 string key

This event will be emitted when the confirmation checker needs a new confirmation key to continue. Keys that can be reused will be saved for up to five minutes before they are requested again.

The checker will pause until you call the callback. Because of this, it is very important that you call the callback, even if an error occurred. Generating the key is a synchronous operation, but some implementations may store the secrets on an external server and request a key asynchronously. For this reason, the callback accepts an err argument.

Here's a basic example:

community.on('confKeyNeeded', function(tag, callback) {
    var time = Math.floor(Date.now() / 1000);
    callback(null, time, SteamTotp.getConfirmationKey(identitySecret, time, tag));
});

newConfirmation

Emitted when a new confirmation is received. This will be emitted once per confirmation.

A special property offerID will be defined which is the ID of the trade offer that the confirmation is confirming. If this confirmation isn't for an offer, this will be undefined. Adding this property requires one request per confirmation to find the offer ID. If you don't need these IDs and you want to save requests, always return an error in the confKeyNeeded event when the tag is "details".

This event will be emitted at most once per second. This is to ensure that you don't accidentally generate the same key twice for two confirmations.

confirmationAccepted

v3.28.0 or later is required to use this event

Emitted when the automatic confirmation checker auto-accepts a confirmation with success.