steamutils 1.5.2 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/index.js +43 -1
  2. package/package.json +1 -1
  3. package/remote.js +18 -0
package/index.js CHANGED
@@ -7,7 +7,7 @@ import SteamID from "steamid";
7
7
  import URL from "url";
8
8
  import Url from "url-parse";
9
9
  import qs from "qs";
10
- import { console_log, downloadImage, getCleanObject, JSON_parse, JSON_stringify, removeSpaceKeys, secretAsBuffer, sleep } from "./utils.js";
10
+ import { approveLogin, console_log, downloadImage, getCleanObject, JSON_parse, JSON_stringify, removeSpaceKeys, secretAsBuffer, sleep } from "./utils.js";
11
11
  import { Header, request } from "./axios.js";
12
12
  import { getTableHasHeaders, querySelectorAll, table2json } from "./cheerio.js";
13
13
  import { getJSObjectFronXML } from "./xml2json.js";
@@ -7846,6 +7846,48 @@ export default class SteamUser {
7846
7846
  console.error("Error decoding QR code:", error);
7847
7847
  }
7848
7848
  }
7849
+
7850
+ static async approveLoginRequest(steamId, url, sharedSecret, accessToken) {
7851
+ try {
7852
+ const { LoginApprover } = await import("steam-session");
7853
+ const approver = new LoginApprover(accessToken, sharedSecret, {});
7854
+ await approver.approveAuthSession({
7855
+ qrChallengeUrl: url,
7856
+ approve: true,
7857
+ });
7858
+
7859
+ return {
7860
+ steamId,
7861
+ error: null,
7862
+ };
7863
+ } catch (error) {
7864
+ console.error(`[${steamId}] approveLoginRequest Error`, error);
7865
+ return {
7866
+ steamId,
7867
+ error: error || "Error",
7868
+ };
7869
+ }
7870
+ }
7871
+
7872
+ static async getAuthSessionInfo(steamId, url, sharedSecret, accessToken) {
7873
+ try {
7874
+ const { LoginApprover } = await import("steam-session");
7875
+ const approver = new LoginApprover(accessToken, sharedSecret, {});
7876
+ const sessionInfo = await approver.getAuthSessionInfo(url);
7877
+ sessionInfo.steamId = steamId;
7878
+
7879
+ return {
7880
+ steamId,
7881
+ sessionInfo,
7882
+ };
7883
+ } catch (error) {
7884
+ console.error(`[${steamId}] getAuthSessionInfo Error`, error);
7885
+ return {
7886
+ steamId,
7887
+ error,
7888
+ };
7889
+ }
7890
+ }
7849
7891
  }
7850
7892
 
7851
7893
  SteamUser.MAX_RETRY = 10;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.5.02",
3
+ "version": "1.5.04",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",
package/remote.js CHANGED
@@ -2219,4 +2219,22 @@ export default class RemoteSteamUser {
2219
2219
  };
2220
2220
  return await doRequest(config);
2221
2221
  }
2222
+ static async approveLoginRequest(steamId, url, sharedSecret, accessToken) {
2223
+ const { __params, __cookies } = formatParams([steamId, url, sharedSecret, accessToken]);
2224
+ const config = {
2225
+ method: "approveLoginRequest",
2226
+ params: __params,
2227
+ is_static: true,
2228
+ };
2229
+ return await doRequest(config);
2230
+ }
2231
+ static async getAuthSessionInfo(steamId, url, sharedSecret, accessToken) {
2232
+ const { __params, __cookies } = formatParams([steamId, url, sharedSecret, accessToken]);
2233
+ const config = {
2234
+ method: "getAuthSessionInfo",
2235
+ params: __params,
2236
+ is_static: true,
2237
+ };
2238
+ return await doRequest(config);
2239
+ }
2222
2240
  }