-
Notifications
You must be signed in to change notification settings - Fork 17
Fix bug when decoding JWT in browser #422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## 6-dev #422 +/- ##
=====================================
Coverage 96.3% 96.3%
=====================================
Files 32 32
Lines 1517 1517
=====================================
Hits 1461 1461
Misses 56 56
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## 6-dev #422 +/- ##
=========================================
+ Coverage 96.3% 96.38% +0.07%
=========================================
Files 32 32
Lines 1517 1522 +5
=========================================
+ Hits 1461 1467 +6
+ Misses 56 55 -1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be a unit test making sure that this error is permanently fixed
# [6.2.0](https://github.com/kuzzleio/sdk-javascript/releases/tag/6.2.0) (2019-07-31) #### Bug fixes - [ [#428](#428) ] Properly handle boolean flags in HTTP querystrings ([scottinet](https://github.com/scottinet)) - [ [#427](#427) ] Solve promise+event+memory leaks when the network fails ([scottinet](https://github.com/scottinet)) - [ [#424](#424) ] Prevent pending request leak when disconnect the SDK ([Aschen](https://github.com/Aschen)) - [ [#422](#422) ] Fix bug when decoding JWT in browser ([Aschen](https://github.com/Aschen)) - [ [#420](#420) ] Fix http protocol unresolved promise on connection error ([Aschen](https://github.com/Aschen)) #### New features - [ [#419](#419) ] Add bulk:write and bulk:mWrite ([Aschen](https://github.com/Aschen)) #### Enhancements - [ [#421](#421) ] Get api routes from server:publicApi ([Aschen](https://github.com/Aschen)) - [ [#423](#423) ] Emit queryError event on malformed request ([Aschen](https://github.com/Aschen)) - [ [#417](#417) ] Security controller documentation ([benoitvidis](https://github.com/benoitvidis)) ---
What does this PR do?
Since the SDK is available for Node.js and for browsers, the decoding of the JWT from base64 is done either with
Buffer.from(jwt, 'base64')
for Node.js oratob(base64)
for browsers.The check to know the runtime was
if (Buffer)
, and since this class is undefined in the browsers, this line throw an exception who is catched by theJSON.parse
try...catch
.This PR fix the check to infer the runtime with
if (typeof Buffer !== 'undefined')
instead.Fix #407
How should this be manually tested?