node-steam-totp
node-steam-totp copied to clipboard
fix bug proxy
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected]
for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/steam-totp/index.js b/node_modules/steam-totp/index.js
index f557f2c..2aba8c5 100644
--- a/node_modules/steam-totp/index.js
+++ b/node_modules/steam-totp/index.js
@@ -1,6 +1,7 @@
'use strict';
const Crypto = require('crypto');
+const StdLib = require('@doctormckay/stdlib');
/**
* Returns the current local Unix time
@@ -17,9 +18,9 @@ exports.time = function(timeOffset) {
* @param {number} [timeOffset=0] - If you know how far off your clock is from the Steam servers, put the offset here in seconds
* @returns {string}
*/
-exports.generateAuthCode = exports.getAuthCode = function(secret, timeOffset) {
+exports.generateAuthCode = exports.getAuthCode = function(secret, timeOffset, httpProxy) {
if (typeof timeOffset === 'function') {
- exports.getTimeOffset((err, offset, latency) => {
+ exports.getTimeOffset(httpProxy, (err, offset, latency) => {
if (err) {
timeOffset(err);
return;
@@ -91,15 +92,17 @@ exports.generateConfirmationKey = exports.getConfirmationKey = function(identity
return hmac.update(buffer).digest('base64');
};
-exports.getTimeOffset = function(callback) {
- let start = Date.now();
+exports.getTimeOffset = function(httpProxy, callback) {
+ let start = Date.now();
+
let req = require('https').request({
"hostname": "api.steampowered.com",
"path": "/ITwoFactorService/QueryTime/v1/",
"method": "POST",
"headers": {
"Content-Length": 0
- }
+ },
+ "agent": httpProxy ? StdLib.HTTP.getProxyAgent(true, httpProxy) : undefined
}, (res) => {
if (res.statusCode != 200) {
callback(new Error("HTTP error " + res.statusCode));
This issue body was partially generated by patch-package.