keratin / authn-js

JavaScript client library for Keratin AuthN
GNU Lesser General Public License v3.0
45 stars 20 forks source link

Should JWTSession handle malformed token? #12

Closed praxxis closed 7 years ago

praxxis commented 7 years ago

Tested by running localStorage.setItem('empatico-session', 'asdf123'), got the following stack trace:

JWTSession.js?a3d0:21 Uncaught DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
    at jwt_claims (eval at <anonymous> (http://localhost:8080/vendor.9210e3be8341d4623c22.js:2344:1), <anonymous>:21:23)
    at new JWTSession (eval at <anonymous> (http://localhost:8080/vendor.9210e3be8341d4623c22.js:2344:1), <anonymous>:5:23)
    at SessionManager.setStore (eval at <anonymous> (http://localhost:8080/vendor.9210e3be8341d4623c22.js:2358:1), <anonymous>:10:34)
    at setStore (eval at <anonymous> (http://localhost:8080/vendor.9210e3be8341d4623c22.js:391:1), <anonymous>:8:13)
    at Object.setLocalStorageStore (eval at <anonymous> (http://localhost:8080/vendor.9210e3be8341d4623c22.js:391:1), <anonymous>:16:5)
    at eval (eval at 283 (http://localhost:8080/app.5f7485fdef982d649c19.js:207:1), <anonymous>:4:9)
    at Object.283 (http://localhost:8080/app.5f7485fdef982d649c19.js:207:1)
    at __webpack_require__ (http://localhost:8080/login:64:30)
    at eval (eval at 261 (http://localhost:8080/app.5f7485fdef982d649c19.js:39:1), <anonymous>:27:1)
    at Object.261 (http://localhost:8080/app.5f7485fdef982d649c19.js:39:1)
    at __webpack_require__ (http://localhost:8080/login:64:30)
    at Object.632 (http://localhost:8080/app.5f7485fdef982d649c19.js:337:18)
    at __webpack_require__ (http://localhost:8080/login:64:30)
    at webpackJsonpCallback (http://localhost:8080/login:35:23)
    at http://localhost:8080/app.5f7485fdef982d649c19.js:1:1

The claims function might catch and re throw this with a more descriptive error message?