steamutils 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +26 -20
- package/package.json +1 -1
package/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import crypto from "crypto";
|
2
2
|
import sha256 from "crypto-js/sha256.js";
|
3
3
|
import _ from "lodash";
|
4
4
|
import moment from "moment";
|
@@ -809,7 +809,7 @@ export default class SteamUser {
|
|
809
809
|
}
|
810
810
|
|
811
811
|
static generateSessionID() {
|
812
|
-
return randomBytes(12).toString("hex");
|
812
|
+
return crypto.randomBytes(12).toString("hex");
|
813
813
|
}
|
814
814
|
|
815
815
|
static async communityLogin({ username, password, emailauth, cookie, steamMachineAuth }) {
|
@@ -7260,46 +7260,52 @@ export default class SteamUser {
|
|
7260
7260
|
return revokeRefreshTokenResult?.data;
|
7261
7261
|
}
|
7262
7262
|
async revokeAccessToken(accessToken, tokenId, sharedSecret) {
|
7263
|
-
const
|
7264
|
-
const
|
7265
|
-
|
7266
|
-
|
7267
|
-
|
7268
|
-
|
7269
|
-
|
7263
|
+
const u = new ArrayBuffer(20);
|
7264
|
+
const s = new DataView(u);
|
7265
|
+
let f = 0;
|
7266
|
+
let p = 0;
|
7267
|
+
for (f = 0, p = 0; p < tokenId.length && p < 20; p++, f++) {
|
7268
|
+
s.setUint8(f, tokenId.charCodeAt(p));
|
7269
|
+
}
|
7270
|
+
const y = new Uint8Array(u, 0, f);
|
7271
|
+
const signature = crypto.createHmac("sha256", secretAsBuffer(sharedSecret)).update(y).digest();
|
7270
7272
|
const Protos = helpers([
|
7271
7273
|
{
|
7272
7274
|
name: "csgo",
|
7273
7275
|
protos: loadProfos(`${__dirname}/protos/webui`),
|
7274
7276
|
},
|
7275
7277
|
]);
|
7276
|
-
|
7277
7278
|
const params = {
|
7278
7279
|
access_token: accessToken,
|
7279
7280
|
spoof_steamid: "",
|
7280
7281
|
origin: "https://store.steampowered.com",
|
7281
|
-
input_protobuf_encoded: protoEncode(Protos.csgo.CAuthentication_RefreshToken_Revoke_Request, {
|
7282
|
-
token_id: tokenId,
|
7283
|
-
steamid: this._steamIdUser,
|
7284
|
-
revoke_action: 1,
|
7285
|
-
signature: signature,
|
7286
|
-
}).toString("base64"),
|
7287
7282
|
};
|
7288
7283
|
|
7284
|
+
const protobuf = protoEncode(Protos.csgo.CAuthentication_RefreshToken_Revoke_Request, {
|
7285
|
+
token_id: tokenId,
|
7286
|
+
steamid: this._steamIdUser,
|
7287
|
+
revoke_action: 1,
|
7288
|
+
signature: signature,
|
7289
|
+
});
|
7290
|
+
|
7291
|
+
const protobufEncoded = protobuf.toString("base64");
|
7292
|
+
|
7289
7293
|
const result = await this._httpRequest({
|
7290
7294
|
url: `https://api.steampowered.com/IAuthenticationService/RevokeRefreshToken/v1?${qs.stringify(params)}`,
|
7291
7295
|
// responseType: "arraybuffer",
|
7292
7296
|
method: "POST",
|
7293
7297
|
data: {
|
7294
|
-
|
7295
|
-
steamid: this._steamIdUser,
|
7296
|
-
revoke_action: 1,
|
7297
|
-
signature: signature,
|
7298
|
+
input_protobuf_encoded: protobufEncoded,
|
7298
7299
|
},
|
7299
7300
|
headers: {
|
7300
7301
|
"Content-Type": "multipart/form-data",
|
7301
7302
|
},
|
7302
7303
|
});
|
7304
|
+
|
7305
|
+
if (typeof result?.data === "string") {
|
7306
|
+
console.log(result?.data);
|
7307
|
+
}
|
7308
|
+
|
7303
7309
|
return result?.data;
|
7304
7310
|
}
|
7305
7311
|
}
|