steamutils 1.5.36 → 1.5.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +124 -0
- package/package.json +1 -1
package/index.js
CHANGED
@@ -7215,6 +7215,27 @@ export default class SteamUser {
|
|
7215
7215
|
];
|
7216
7216
|
}
|
7217
7217
|
|
7218
|
+
/**
|
7219
|
+
* @typedef {Object} RedeemPointsResponse
|
7220
|
+
* @property {number[]} bundle_community_item_ids - Array of community item IDs in the bundle. May be empty.
|
7221
|
+
* @property {number} communityitemid - The redeemed community item ID.
|
7222
|
+
*/
|
7223
|
+
|
7224
|
+
/**
|
7225
|
+
* Redeems Steam Points for a specified reward definition.
|
7226
|
+
*
|
7227
|
+
* @async
|
7228
|
+
* @param {string} accessToken - The user's Steam OAuth access token.
|
7229
|
+
* @param {number|string} definitionId - The definition ID for the reward to redeem.
|
7230
|
+
* @returns {Promise<?RedeemPointsResponse>} A promise that resolves to the redemption response object,
|
7231
|
+
* or null/undefined if unsuccessful.
|
7232
|
+
*
|
7233
|
+
* @example
|
7234
|
+
* {
|
7235
|
+
* bundle_community_item_ids: [],
|
7236
|
+
* communityitemid: 34336330688
|
7237
|
+
* }
|
7238
|
+
*/
|
7218
7239
|
async redeemPoints(accessToken, definitionId) {
|
7219
7240
|
if (!definitionId) {
|
7220
7241
|
return;
|
@@ -8020,6 +8041,56 @@ export default class SteamUser {
|
|
8020
8041
|
} catch (e) {}
|
8021
8042
|
}
|
8022
8043
|
|
8044
|
+
/**
|
8045
|
+
* Fetches information about one or more Steam apps by their app IDs using the Steam Community GetApps API.
|
8046
|
+
*
|
8047
|
+
* Each app object in the response may include fields such as:
|
8048
|
+
* - appid: {number} The Steam application ID
|
8049
|
+
* - name: {string} Name of the app
|
8050
|
+
* - icon: {string} App icon hash
|
8051
|
+
* - logo, logo_small: {string} App logo (if any)
|
8052
|
+
* - tool, demo, media: {boolean} App type flags
|
8053
|
+
* - community_visible_stats: {boolean} If the app has community stats visible
|
8054
|
+
* - friendly_name: {string} Optional, usually empty for event apps
|
8055
|
+
* - propagation: {string} Propagation mode
|
8056
|
+
* - has_adult_content: {boolean} If app contains adult content
|
8057
|
+
* - is_visible_in_steam_china: {boolean} Visibility on Steam China
|
8058
|
+
* - app_type: {number} App type code
|
8059
|
+
* - has_adult_content_sex: {boolean}
|
8060
|
+
* - has_adult_content_violence: {boolean}
|
8061
|
+
* - content_descriptorids: {Array<number>}
|
8062
|
+
*
|
8063
|
+
* @async
|
8064
|
+
* @static
|
8065
|
+
* @param {number|number[]} appIds - A single app ID or array of app IDs to request.
|
8066
|
+
* @returns {Promise<{
|
8067
|
+
* apps: Array<{
|
8068
|
+
* content_descriptorids: number[],
|
8069
|
+
* appid: number,
|
8070
|
+
* name: string,
|
8071
|
+
* icon: string,
|
8072
|
+
* logo: string,
|
8073
|
+
* logo_small: string,
|
8074
|
+
* tool: boolean,
|
8075
|
+
* demo: boolean,
|
8076
|
+
* media: boolean,
|
8077
|
+
* community_visible_stats: boolean,
|
8078
|
+
* friendly_name: string,
|
8079
|
+
* propagation: string,
|
8080
|
+
* has_adult_content: boolean,
|
8081
|
+
* is_visible_in_steam_china: boolean,
|
8082
|
+
* app_type: number,
|
8083
|
+
* has_adult_content_sex: boolean,
|
8084
|
+
* has_adult_content_violence: boolean
|
8085
|
+
* }>
|
8086
|
+
* }|ResponseError|undefined>} Returns an object containing an 'apps' array with the app data on success,
|
8087
|
+
* a ResponseError if the request fails, or undefined if no appIds are supplied.
|
8088
|
+
*
|
8089
|
+
* @example
|
8090
|
+
* const result = await SteamUser.cCommunityGetAppsRequest(3558910);
|
8091
|
+
* console.log(result);
|
8092
|
+
* // { apps: [ { appid: 3558910, name: '...', ... } ] }
|
8093
|
+
*/
|
8023
8094
|
static async cCommunityGetAppsRequest(appIds) {
|
8024
8095
|
if (!appIds) {
|
8025
8096
|
return;
|
@@ -8054,6 +8125,59 @@ export default class SteamUser {
|
|
8054
8125
|
return response;
|
8055
8126
|
}
|
8056
8127
|
|
8128
|
+
/**
|
8129
|
+
* @typedef {Object} EligibleEventApp
|
8130
|
+
* @property {number} appid The unique Steam app ID.
|
8131
|
+
* @property {number} has_items_anyone_can_purchase 1 if anyone can purchase items, 0 otherwise.
|
8132
|
+
* @property {number} event_app 1 if the app is considered an event app, 0 otherwise.
|
8133
|
+
* @property {string|null} hero_carousel_image The filename for the hero carousel image, or null if not present.
|
8134
|
+
* @property {null} owned Reserved, always null in current data.
|
8135
|
+
*/
|
8136
|
+
|
8137
|
+
/**
|
8138
|
+
* Fetches the list of eligible event apps from the Steam Points Shop events store.
|
8139
|
+
* This function retrieves the event page's HTML, parses out the loyalty store data,
|
8140
|
+
* and returns all eligible apps that are marked as event apps.
|
8141
|
+
*
|
8142
|
+
* @returns {Promise<EligibleEventApp[]>} Array of eligible event app objects (empty array if an error occurs).
|
8143
|
+
*/
|
8144
|
+
static async getEligibleEventApps() {
|
8145
|
+
let html;
|
8146
|
+
try {
|
8147
|
+
({ data: html } = await axios.get("https://store.steampowered.com/points/shop/c/events"));
|
8148
|
+
} catch (e) {
|
8149
|
+
console.error("Failed to fetch Steam Points Shop events page:", e);
|
8150
|
+
return [];
|
8151
|
+
}
|
8152
|
+
if (!html) {
|
8153
|
+
console.error("No HTML received from the events page.");
|
8154
|
+
return [];
|
8155
|
+
}
|
8156
|
+
|
8157
|
+
const $ = cheerio.load(html);
|
8158
|
+
const loyaltyStr = $("#application_config").attr("data-loyaltystore");
|
8159
|
+
if (!loyaltyStr) {
|
8160
|
+
console.error("Loyalty store data not found in HTML.");
|
8161
|
+
return [];
|
8162
|
+
}
|
8163
|
+
|
8164
|
+
let loyaltyObj;
|
8165
|
+
try {
|
8166
|
+
loyaltyObj = JSON.parse(loyaltyStr);
|
8167
|
+
} catch (e) {
|
8168
|
+
console.error("Failed to parse loyalty store JSON:", e);
|
8169
|
+
return [];
|
8170
|
+
}
|
8171
|
+
|
8172
|
+
const apps = loyaltyObj?.eligible_apps?.apps;
|
8173
|
+
if (!Array.isArray(apps)) {
|
8174
|
+
console.error("No valid eligible_apps array found in loyalty store object.");
|
8175
|
+
return [];
|
8176
|
+
}
|
8177
|
+
|
8178
|
+
return apps.filter((app) => app.event_app);
|
8179
|
+
}
|
8180
|
+
|
8057
8181
|
static async decodeQRImage(imageURL) {
|
8058
8182
|
let response = null;
|
8059
8183
|
try {
|