Added steam auth using encrypted application tickets

Not tested working though yet
This commit is contained in:
2025-11-07 16:53:17 +00:00
parent 18b9641360
commit 4ce607a1e1
4 changed files with 22050 additions and 8642 deletions

30651
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -38,6 +38,7 @@
"redis": "2.8.0", "redis": "2.8.0",
"request": "2.85.0", "request": "2.85.0",
"semver": "5.5.0", "semver": "5.5.0",
"steam-appticket": "1.0.1",
"tv4": "1.3.0", "tv4": "1.3.0",
"uuid": "^3.1.0", "uuid": "^3.1.0",
"winston": "2.4.1", "winston": "2.4.1",

View File

@@ -16,6 +16,7 @@ const vkontakte = require("./vkontakte");
const qq = require("./qq"); const qq = require("./qq");
const wechat = require("./wechat"); const wechat = require("./wechat");
const weibo = require("./weibo"); const weibo = require("./weibo");
const steam = require("./steam");
const anonymous = { const anonymous = {
validateAuthData: () => { validateAuthData: () => {
@@ -43,7 +44,8 @@ const providers = {
vkontakte, vkontakte,
qq, qq,
wechat, wechat,
weibo weibo,
steam
} }
function authDataValidator(adapter, appIds, options) { function authDataValidator(adapter, appIds, options) {
return function(authData) { return function(authData) {

View File

@@ -0,0 +1,36 @@
var Parse = require('parse/node').Parse;
const AppTicket = require('steam-appticket');
// todo move these to a config file.
const decryptionKey = '3e3e2a3cbd54dc6c7cb5e51520dfa819dd7f9c12d062d54a1f8c14ddd231377f';
const appId = '3414340';
// Returns a promise that fulfills iff this application ticket is valid
function validateAuthData(authData) {
var encrypted_ticket = Buffer.from(authData.app_ticket, 'hex');
var ticket = AppTicket.parseEncryptedAppTicket(encrypted_ticket, decryptionKey)
if (ticket === null) {
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Steam auth is invalid for this user.');
}
var user_id = authData.id;
if (user_id != ticket.steamID.accountid) {
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'The provided application ticket does not match the given user id'
);
}
if (appId !== ticket.appID && demoAppId != ticket.appID) {
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'The provided application ticket does not match the Kami 2 or Kami 2 Demo application ids'
);
}
return Promise.resolve();
}
// steam auth bundles the app id in the auth data so don't validate seperately
function validateAppId() {
return Promise.resolve();
}