steamutils 1.4.7 → 1.4.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +43 -28
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -6881,33 +6881,40 @@ export default class SteamUser {
6881
6881
  return result;
6882
6882
  }
6883
6883
 
6884
- return protoDecode(Protos.csgo.CPlayer_GetPlayerLinkDetails_Response, result.data)?.accounts?.map(function (account) {
6885
- const { sha_digest_avatar, steamid, ...public_data } = account.public_data;
6886
- const private_data = account.private_data;
6887
- let rich_presence_kv = private_data.rich_presence_kv;
6888
- if (rich_presence_kv.startsWith(`"rp`)) {
6889
- try {
6890
- rich_presence_kv = JSON.parse("{" + rich_presence_kv.substringAfter("{").trim().replaceAll("\n\t", ",").replaceAll("\t\t", ":").trim());
6891
- } catch (e) {}
6892
- }
6893
- return {
6894
- public_data: {
6895
- ...public_data,
6896
- steamId: steamid.toString(),
6897
- avatarHash: sha_digest_avatar.toString("hex"),
6898
- },
6899
- private_data: {
6900
- ...private_data,
6901
- game_id: private_data.game_id.toNumber(),
6902
- game_server_steam_id: private_data.game_server_steam_id.toNumber(),
6903
- lobby_steam_id: private_data.lobby_steam_id.toNumber(),
6904
- broadcast_session_id: private_data.broadcast_session_id.toNumber(),
6905
- rich_presence_kv,
6906
- },
6907
- };
6908
- });
6909
- const example = [
6910
- {
6884
+ let accounts = [];
6885
+ try {
6886
+ accounts = protoDecode(Protos.csgo.CPlayer_GetPlayerLinkDetails_Response, result.data).accounts || [];
6887
+ } catch (e) {}
6888
+
6889
+ return accounts
6890
+ .map(function ({ public_data: { sha_digest_avatar, steamid, ...public_data }, private_data: { rich_presence_kv, ...private_data } }) {
6891
+ if (rich_presence_kv.startsWith(`"rp`)) {
6892
+ try {
6893
+ rich_presence_kv = JSON.parse("{" + rich_presence_kv.substringAfter("{").trim().replaceAll("\n\t", ",").replaceAll("\t\t", ":").trim());
6894
+ } catch (e) {}
6895
+ }
6896
+ return {
6897
+ public_data: {
6898
+ ...public_data,
6899
+ steamId: steamid.toString(),
6900
+ avatarHash: sha_digest_avatar.toString("hex"),
6901
+ },
6902
+ private_data: {
6903
+ ...private_data,
6904
+ game_id: private_data.game_id.toNumber(),
6905
+ game_server_steam_id: private_data.game_server_steam_id.toNumber(),
6906
+ lobby_steam_id: private_data.lobby_steam_id.toNumber(),
6907
+ broadcast_session_id: private_data.broadcast_session_id.toNumber(),
6908
+ rich_presence_kv,
6909
+ },
6910
+ };
6911
+ })
6912
+ .reduce(function (previousValue, currentValue) {
6913
+ previousValue[currentValue.public_data.steamId] = currentValue;
6914
+ return previousValue;
6915
+ }, {});
6916
+ const example = {
6917
+ "76561199243542939": {
6911
6918
  public_data: {
6912
6919
  visibility_state: 3,
6913
6920
  privacy_state: 0,
@@ -6950,7 +6957,7 @@ export default class SteamUser {
6950
6957
  game_is_private: false,
6951
6958
  },
6952
6959
  },
6953
- ];
6960
+ };
6954
6961
  }
6955
6962
  async getFriendsGameplayInfo(accessToken, appId) {
6956
6963
  if (!appId) {
@@ -7260,6 +7267,14 @@ export default class SteamUser {
7260
7267
  },
7261
7268
  };
7262
7269
  }
7270
+
7271
+ async hasToken(accessToken, tokenId) {
7272
+ const tokens = (await this.enumerateTokens(accessToken))?.response?.refresh_tokens;
7273
+ if (!Array.isArray(tokens) || !tokens.length) {
7274
+ return null;
7275
+ }
7276
+ return tokens.some((token) => token.token_id == tokenId);
7277
+ }
7263
7278
  async queryRefreshTokenByID(accessToken, tokenId) {
7264
7279
  const Protos = helpers([
7265
7280
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.4.07",
3
+ "version": "1.4.10",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",