steamutils 1.3.63 → 1.3.65

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 (3) hide show
  1. package/SteamClient.js +9 -9
  2. package/index.js +106 -0
  3. package/package.json +1 -1
package/SteamClient.js CHANGED
@@ -2303,15 +2303,15 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
2303
2303
  ];
2304
2304
  },
2305
2305
  uploadRichPresence(appid, richPresence) {
2306
- if (Array.isArray(richPresence)) {
2307
- richPresence = richPresence.reduce(function (previousValue, currentValue, currentIndex, array) {
2308
- if (currentValue.key) {
2309
- previousValue[currentValue.key] = currentValue.value?.toString() || "";
2310
- }
2311
- return previousValue;
2312
- });
2313
- }
2314
- steamClient.uploadRichPresence(appid, richPresence);
2306
+ const _richPresence = Array.isArray(richPresence)
2307
+ ? richPresence.reduce(function (previousValue, currentValue, currentIndex, array) {
2308
+ if (currentValue.key) {
2309
+ previousValue[currentValue.key] = currentValue.value?.toString() || "";
2310
+ }
2311
+ return previousValue;
2312
+ }, {})
2313
+ : richPresence;
2314
+ steamClient.uploadRichPresence(appid, _richPresence);
2315
2315
  },
2316
2316
  getUserOwnedApps,
2317
2317
  getPlayingAppIds,
package/index.js CHANGED
@@ -6410,12 +6410,23 @@ export default class SteamUser {
6410
6410
  }
6411
6411
 
6412
6412
  async acceptConfirmationForObject(accessToken, identitySecret, objectID) {
6413
+ if (!accessToken || typeof accessToken !== "string") {
6414
+ return { error: "Invalid accessToken: " + accessToken };
6415
+ }
6416
+ if (!identitySecret || typeof identitySecret !== "string") {
6417
+ return { error: "Invalid identitySecret: " + identitySecret };
6418
+ }
6419
+
6413
6420
  let error = null;
6414
6421
  for (const cookie of this._cookies) {
6415
6422
  try {
6416
6423
  const community = new SteamCommunity();
6417
6424
  community.setCookies(cookie.toString().split(";"));
6418
6425
  community.oAuthToken = accessToken;
6426
+ try {
6427
+ community.setMobileAppAccessToken(accessToken);
6428
+ } catch (e) {}
6429
+
6419
6430
  error = await new Promise((resolve) => {
6420
6431
  community.acceptConfirmationForObject(identitySecret, objectID, resolve);
6421
6432
  });
@@ -6429,13 +6440,69 @@ export default class SteamUser {
6429
6440
  return { error };
6430
6441
  }
6431
6442
 
6443
+ async denyConfirmationForObject(accessToken, identitySecret, objectID) {
6444
+ if (!accessToken || typeof accessToken !== "string") {
6445
+ return { error: "Invalid accessToken: " + accessToken };
6446
+ }
6447
+ if (!identitySecret || typeof identitySecret !== "string") {
6448
+ return { error: "Invalid identitySecret: " + identitySecret };
6449
+ }
6450
+
6451
+ let error = null;
6452
+ for (const cookie of this._cookies) {
6453
+ try {
6454
+ const community = new SteamCommunity();
6455
+ community.setCookies(cookie.toString().split(";"));
6456
+ community.oAuthToken = accessToken;
6457
+ try {
6458
+ community.setMobileAppAccessToken(accessToken);
6459
+ } catch (e) {}
6460
+
6461
+ error = await new Promise((resolve) => {
6462
+ let time = SteamTotp.time();
6463
+ let confKey = SteamTotp.getConfirmationKey(identitySecret, time, "list");
6464
+ community.getConfirmations(time, { tag: "list", key: confKey }, function (err, confs) {
6465
+ if (err) {
6466
+ resolve(err);
6467
+ return;
6468
+ }
6469
+
6470
+ const conf = confs.find((conf) => conf.creator == objectID);
6471
+ if (!conf) {
6472
+ resolve("Could not find confirmation for object " + objectID);
6473
+ return;
6474
+ }
6475
+ confKey = SteamTotp.getConfirmationKey(identitySecret, time, "accept");
6476
+ conf.respond(time, { tag: "accept", key: confKey }, false, resolve);
6477
+ });
6478
+ });
6479
+ if (!error) {
6480
+ return {
6481
+ success: true,
6482
+ };
6483
+ }
6484
+ } catch (e) {}
6485
+ }
6486
+ return { error };
6487
+ }
6488
+
6432
6489
  async getConfirmations(accessToken, identitySecret) {
6490
+ if (!accessToken || typeof accessToken !== "string") {
6491
+ return { error: "Invalid accessToken: " + accessToken };
6492
+ }
6493
+ if (!identitySecret || typeof identitySecret !== "string") {
6494
+ return { error: "Invalid identitySecret: " + identitySecret };
6495
+ }
6496
+
6433
6497
  let error = null;
6434
6498
  for (const cookie of this._cookies) {
6435
6499
  try {
6436
6500
  const community = new SteamCommunity();
6437
6501
  community.setCookies(cookie.toString().split(";"));
6438
6502
  community.oAuthToken = accessToken;
6503
+ try {
6504
+ community.setMobileAppAccessToken(accessToken);
6505
+ } catch (e) {}
6439
6506
  const time = SteamTotp.time();
6440
6507
  const key = SteamTotp.getConfirmationKey(identitySecret, time, "conf");
6441
6508
  // err.message === "Not Logged In";
@@ -6458,13 +6525,52 @@ export default class SteamUser {
6458
6525
  return { error };
6459
6526
  }
6460
6527
 
6528
+ async enableTwoFactor(accessToken) {
6529
+ if (!accessToken || typeof accessToken !== "string") {
6530
+ return { error: "Invalid accessToken: " + accessToken };
6531
+ }
6532
+
6533
+ let error = null;
6534
+ for (const cookie of this._cookies) {
6535
+ try {
6536
+ const community = new SteamCommunity();
6537
+ community.setCookies(cookie.toString().split(";"));
6538
+ community.oAuthToken = accessToken;
6539
+ try {
6540
+ community.setMobileAppAccessToken(accessToken);
6541
+ } catch (e) {}
6542
+ const response = await new Promise((resolve) => {
6543
+ community.enableTwoFactor((error, response) => {
6544
+ resolve({ error, response });
6545
+ });
6546
+ });
6547
+ if (!response.error) {
6548
+ return { ...response, success: true };
6549
+ } else {
6550
+ error = response.error;
6551
+ }
6552
+ } catch (e) {}
6553
+ }
6554
+ return { error };
6555
+ }
6556
+
6461
6557
  async finalizeTwoFactor(accessToken, identitySecret, finalizeTwoFactorCode) {
6558
+ if (!accessToken || typeof accessToken !== "string") {
6559
+ return { error: "Invalid accessToken: " + accessToken };
6560
+ }
6561
+ if (!identitySecret || typeof identitySecret !== "string") {
6562
+ return { error: "Invalid identitySecret: " + identitySecret };
6563
+ }
6564
+
6462
6565
  let error = null;
6463
6566
  for (const cookie of this._cookies) {
6464
6567
  try {
6465
6568
  const community = new SteamCommunity();
6466
6569
  community.setCookies(cookie.toString().split(";"));
6467
6570
  community.oAuthToken = accessToken;
6571
+ try {
6572
+ community.setMobileAppAccessToken(accessToken);
6573
+ } catch (e) {}
6468
6574
  error = await new Promise((resolve) => {
6469
6575
  community.finalizeTwoFactor(identitySecret, finalizeTwoFactorCode, resolve);
6470
6576
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.3.63",
3
+ "version": "1.3.65",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",