mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-01-04 06:22:22 +08:00
Remember time offset for purposes of acceptConfirmationForObject
Closes #147
This commit is contained in:
parent
41c87501c4
commit
95a36b00c1
@ -156,12 +156,28 @@ SteamCommunity.prototype.acceptConfirmationForObject = function(identitySecret,
|
||||
var self = this;
|
||||
this._usedConfTimes = this._usedConfTimes || [];
|
||||
|
||||
SteamTotp.getTimeOffset(function(err, offset) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
if (typeof this._timeOffset !== 'undefined') {
|
||||
// time offset is already known and saved
|
||||
doConfirmation();
|
||||
} else {
|
||||
SteamTotp.getTimeOffset(function(err, offset) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
self._timeOffset = offset;
|
||||
doConfirmation();
|
||||
|
||||
setTimeout(function() {
|
||||
// Delete the saved time offset after 12 hours because why not
|
||||
delete self._timeOffset;
|
||||
}, 1000 * 60 * 60 * 12);
|
||||
});
|
||||
}
|
||||
|
||||
function doConfirmation() {
|
||||
var offset = self._timeOffset;
|
||||
var time = SteamTotp.time(offset);
|
||||
self.getConfirmations(time, SteamTotp.getConfirmationKey(identitySecret, time, "conf"), function(err, confs) {
|
||||
if (err) {
|
||||
@ -190,7 +206,7 @@ SteamCommunity.prototype.acceptConfirmationForObject = function(identitySecret,
|
||||
|
||||
conf.respond(time, SteamTotp.getConfirmationKey(identitySecret, time, "allow"), true, callback);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user