npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

steam-appticket

v1.0.1

Published

Decrypts and parses Steam app tickets

Downloads

96,291

Readme

Steam App Ticket Parser

This module enables you to parse Steam encrypted app tickets provided you know the proper decryption key. This allows you to authenticate Steam users from your game backend without needing to verify with Steam that the ticket is valid.

Usage

parseEncryptedAppTicket(ticket, encryptionKey)

  • ticket - A Buffer containing the encrypted app ticket
  • encryptionKey - A Buffer or hex string containing the app's decryption key
const AppTicket = require('steam-appticket');

const ticket = Buffer.from('<ticket hex>', 'hex');
const decryptionKey = '6ef99262a7da9e9979737d0822d5d66d03eb0c580b305981a505648b3e21b12e';

console.log(AppTicket.parseEncryptedAppTicket(ticket, decryptionKey));

parseEncryptedAppTicket returns an object containing these properties:

  • version - The version of the app ownership ticket
  • steamID - The ticket owner's SteamID, as a SteamID object
  • appID - The ID of the app this ticket authenticates
  • ownershipTicketExternalIP - A string containing the external IP address of the ticket owner as reported by Steam at the time when the ownership ticket was assigned
  • ownershipTicketInternalIP - Same as above but for their internal IP. If the ticket was generated by steam-user then this may be random
  • ownershipFlags - A number containing some (probably uninteresting) flags
  • ownershipTicketGenerated - A Date object containing the time when this ticket's ownership ticket was assigned
  • licenses - An array of integers containing the package IDs for all the licenses the ticket owner owns which grant them this app
  • dlc - An array of objects, each of which contains:
    • appID - The AppID of the piece of DLC
    • licenses - An array of integers containing the package IDs for all the licenses the ticket owner owns which grant them this DLC. Seems to not work right now.
  • userData - Whatever data was sent by the user to Steam when they requested the ticket

Returns null if the provided ticket could not be parsed or could not be verified for authenticity. If you get data returned, it is guaranteed that it has not been tampered with, provided your encryption key has not been compromised.

To determine if a ticket is valid, you should do the following:

  1. Check that the AppID matches the AppID you expect
  2. If the user has already supplied their SteamID, make sure it matches the one in the ticket
  3. Make sure it hasn't been generated too far in the past for your liking
  4. If you built a nonce into the ticket, make sure the userData matches what you expect

If you want to have a relatively long grace period in which an encrypted app ticket can be used, but you also want to make sure that it wasn't reused, you can send a nonce to the client and have them build that into their encrypted app ticket's userData.

Parsing Unencrypted App Tickets

parseAppTicket(ticket[, allowInvalidSignature])

  • ticket - A Buffer containing the ticket you want to parse
  • allowInvalidSignature - Optional. Pass true to get back data even if the ticket has no valid signature. Defaults to false.

You can also parse an app ticket that isn't encrypted. To do so, use AppTicket.parseAppTicket(ticket). It returns an object with these properties:

  • authTicket - A Buffer containing the part of the ticket that's sent to Steam for validation
  • gcToken - A string containing a 64-bit number which is the ticket's "GC token" (GC stands for "game connect")
  • tokenGenerated - A Date object containing the time when this ticket's GC token was generated
  • sessionExternalIP - A string containing the ticket owner's external IP address (as reported by Steam) at time of connection
  • clientConnectionTime - Time in milliseconds the ticket owner was connected to Steam when they generated this ticket (?)
  • clientConnectionCount - Number of tickets generated by the ticket owner for this Steam connection (?)
  • version - The version of the app ownership ticket
  • steamID - The ticket owner's SteamID, as a SteamID object
  • appID - The ID of the app this ticket authenticates
  • ownershipTicketExternalIP - A string containing the external IP address of the ticket owner as reported by Steam at the time when the ownership ticket was assigned
  • ownershipTicketInternalIP - Same as above but for their internal IP. If the ticket was generated by steam-user then this may be random
  • ownershipFlags - A number containing some (probably uninteresting) flags
  • ownershipTicketGenerated - A Date object containing the time when this ticket's ownership ticket was assigned
  • ownershipTicketExpires - Same as above but for when the ownership ticket expires
  • licenses - An array of integers containing the package IDs for all the licenses the ticket owner owns which grant them this app
  • dlc - An array of objects, each of which contains:
    • appID - The AppID of the piece of DLC
    • licenses - An array of integers containing the package IDs for all the licenses the ticket owner owns which grant them this DLC. Seems to not work right now.
  • signature - A Buffer containing the signature for the app ownership ticket (uninteresting to you)
  • isExpired - A boolean indicating whether the app ownership ticket is expired
  • hasValidSignature - A boolean indicating whether the app ownership ticket signature is valid
  • isValid - A boolean indicating whether the app ownership ticket is valid
    • If you passed true for allowInvalidSignature and the signature is missing, this will be true if the ticket is not expired!

Note that you shouldn't rely on an unencrypted app ticket without first verifying it with Steam.