Refresh token instead of breaking if VAPID key doesn't exist #794
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#482 added VAPID keys, and started storing
vapidKeyas part ofTokenDetails(code here).Since we were storing a stringified
vapidKeyat that point, if there was novapidKeyin an oldertokenDetailsobject, this check (comparing astringtoundefined) would simply returnfalse, and get a new token.After #649, we started to store
vapidKeyasUint8Arrayinstead of the stringified version. This also changed the check here, which meant that ifvapidKeywas still undefined, the check would refer toundefined.buffer, which throws aTypeError.Because of this, if a user updates from a version of the SDK before #482 directly to a version that includes #649 (4.13 or higher), messaging doesn't work. This PR fixes that by checking the existence of
tokenDetails.vapidKey.