mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
Token Caching now works
This commit is contained in:
@@ -41,10 +41,9 @@ var TokenCacher = (function (_EventEmitter) {
|
||||
|
||||
TokenCacher.prototype.setToken = function setToken(email, password, token) {
|
||||
console.log("wanting to cache", token);
|
||||
token = new Buffer(token).toString("base64");
|
||||
var cipher = _crypto2["default"].createCipher(algo, password);
|
||||
var crypted = cipher.update(token, 'utf8', 'base64');
|
||||
crypted += cipher.final('base64');
|
||||
var crypted = cipher.update("valid" + token, 'utf8', 'hex');
|
||||
crypted += cipher.final('hex');
|
||||
this.data[email] = crypted;
|
||||
this.save();
|
||||
};
|
||||
@@ -59,10 +58,11 @@ var TokenCacher = (function (_EventEmitter) {
|
||||
|
||||
try {
|
||||
var decipher = _crypto2["default"].createDecipher(algo, password);
|
||||
var dec = decipher.update(this.data[email], "base64", 'utf8');
|
||||
var dec = decipher.update(this.data[email], "hex", 'utf8');
|
||||
dec += decipher.final('utf8');
|
||||
return new Buffer(dec, "base64").toString("ascii");
|
||||
return dec.indexOf("valid") === 0 ? dec.substr(5) : false;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user