wwwg / kahoot.js

A library for interacting with Kahoot API.
MIT License
28 stars 8 forks source link

token.js eval'ing throws an error #5

Closed period closed 7 years ago

period commented 7 years ago

This has been an issue for a few weeks now, not really sure how to go about fixing this myself as a quick look at dev tools doesn't really lead me to the actual part that is being eval'd

The error in full:


var _ = {       replace: function() {           var args = arguments;          var str = arguments[0];          return str.replace(args[1], args[2]);   }}; var log = function(){};return decode.call(this, '3UNFtEEksrRaLp3rsvUCcjiXlve2g5ZmRwAw4tlkN1r7daXo4pdJIimXy9UsMWITgftNCleMTH9FpLMrGNL8GOgXWU4wsRh0LRlS'); function decode(message) {var offset = (59 * 81 * 84 * 39 + 38 + 98); if (this.angular.isObject(offset)) {console.log("Offset derived as: {", offset, "}");}return _.replace(message, /./g, function(char, position) {return String.fromCharCode((((char.charCodeAt(0) * position) + offset) % 77) + 48);});}

TypeError: Cannot read property 'isObject' of undefined
    at decode (eval at <anonymous> (/root/hakoot/node_modules/kahoot.js/src/token.js:47:17), <anonymous>:2:363)
    at eval (eval at <anonymous> (/root/hakoot/node_modules/kahoot.js/src/token.js:47:17), <anonymous>:2:161)
    at /root/hakoot/node_modules/kahoot.js/src/token.js:49:13
    at Function.solveChallenge (/root/hakoot/node_modules/kahoot.js/src/token.js:50:5)
    at me.requestToken (/root/hakoot/node_modules/kahoot.js/src/token.js:71:22)
    at IncomingMessage.res.on.chunk (/root/hakoot/node_modules/kahoot.js/src/token.js:33:5)
    at emitOne (events.js:96:13)
    at IncomingMessage.emit (events.js:191:7)
    at IncomingMessage.Readable.read (_stream_readable.js:383:10)
    at flow (_stream_readable.js:763:34)
rectof commented 7 years ago

Hey Thomas :)

Having the same issue aswell..

csprl commented 7 years ago

The problem seems to happen due to this.angular being undefined. I fixed this by adding challenge = challenge.replace('this.angular.isObject(offset)', 'true'); below line 43 in token.js to force the if-statement (where this function is called) to always be true and execute. Additionally I added the lines challenge = challenge.replace('this.angular.isString(offset)', 'true'); challenge = challenge.replace('this.angular.isDate(offset)', 'true'); challenge = challenge.replace('this.angular.isArray(offset)', 'true'); to get rid of a few more missing this.angular functions.

period commented 7 years ago

Appears to be working, thank you! @casperlofgren

Will probably PR this at some point.