steamutils 1.5.23 → 1.5.24

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.
Files changed (4) hide show
  1. package/index.js +55 -0
  2. package/package.json +1 -1
  3. package/remote.js +2268 -2258
  4. package/steamproto.js +4 -0
package/index.js CHANGED
@@ -7208,6 +7208,61 @@ export default class SteamUser {
7208
7208
  ];
7209
7209
  }
7210
7210
 
7211
+ async redeemPoints(accessToken, definitionId) {
7212
+ if (!definitionId) {
7213
+ return;
7214
+ }
7215
+
7216
+ const protobufEncoded = new SteamProto(SteamProtoType.CLoyaltyRewards_RedeemPoints_Request).protoEncodeBase64({
7217
+ defid: definitionId,
7218
+ expected_points_cost: 0,
7219
+ });
7220
+
7221
+ const params = {
7222
+ access_token: accessToken,
7223
+ spoof_steamid: "",
7224
+ origin: "https://store.steampowered.com",
7225
+ };
7226
+
7227
+ const result = await this._httpRequest({
7228
+ url: `https://api.steampowered.com/ILoyaltyRewardsService/RedeemPoints/v1?${Object.keys(params)
7229
+ .map((k) => `${k}=${encodeURIComponent(params[k])}`)
7230
+ .join("&")}`,
7231
+ data: {
7232
+ input_protobuf_encoded: protobufEncoded,
7233
+ },
7234
+ method: "POST",
7235
+ headers: {
7236
+ "Content-Type": "multipart/form-data",
7237
+ },
7238
+ responseType: "arraybuffer",
7239
+ });
7240
+ if (result instanceof ResponseError) {
7241
+ return result;
7242
+ }
7243
+
7244
+ if (!result || result.status === 401 || result.status === 405) {
7245
+ //Unauthorized
7246
+ //Method Not Allowed
7247
+ return;
7248
+ }
7249
+
7250
+ if (!result.data) {
7251
+ return;
7252
+ }
7253
+
7254
+ const data = new SteamProto(SteamProtoType.CLoyaltyRewards_RedeemPoints_Response).protoDecode(result.data);
7255
+ if (!data) {
7256
+ return;
7257
+ }
7258
+
7259
+ data.communityitemid = Number(data.communityitemid);
7260
+ if(!data.communityitemid){
7261
+ return
7262
+ }
7263
+ return data;
7264
+ }
7265
+
7211
7266
  async getRecentMessages(accessToken, steamId) {
7212
7267
  const params = {
7213
7268
  access_token: accessToken,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.5.23",
3
+ "version": "1.5.24",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",