jonasroussel / dart_jsonwebtoken

A dart implementation of the famous javascript library 'jsonwebtoken'
MIT License
87 stars 29 forks source link

JWT sign by JWTAlgorithm.RS256 will hand the entire UI thread 2~3 second. #21

Closed evilandeath closed 2 years ago

evilandeath commented 2 years ago

When generating the JWT token by JWTAlgorithm.RS256, during the JWT.sign() execution to the below String b64Payload; try { b64Payload = base64Unpadded( payload is String ? base64.encode(utf8.encode(payload)) : jsonBase64.encode(payload), ); } catch (ex) { throw JWTError( 'invalid payload json format (Map keys must be String type)', ); }

, will hang the entire UI thread for about 2~3 seconds, because the base64Unpadded wrap in the dart_jsonwebtoken library, the invoker has no way to wrap async-await which makes no effect on it.

version: 2.4.2.

Please help to fix this issue.

jonasroussel commented 2 years ago

Can you specify on which the code is executed:

Do you try to use HS256 algorithm ? Have you tested if that really the base64 convertion that takes so much time ?

Because if with all other algorithms it works well, it cannot come from the base64 conversion, because the invocation of this method does not depend on the algorithm.

jonasroussel commented 2 years ago

No response...