jonasroussel / dart_jsonwebtoken

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

Solve _TypeError issue on sign method #4

Closed parkmap closed 3 years ago

parkmap commented 3 years ago

_TypeError (type 'int' is not a subtype of type 'String' of 'value')

Sign with payload without int value, made error on type.

jsonwebtoken-error

jonasroussel commented 3 years ago

Can you send me an example of your code. I don't understand why payload ('iat', 'nbf', 'exp') can't store int value.

I don't want to merge your PR because in RFC 7519 (https://tools.ietf.org/html/rfc7519)

The "iat" (issued at) claim [...].  Its value MUST be a number containing a NumericDate value.  [...]

So I can't store String value to respect JWT norms.

parkmap commented 3 years ago

My environment is Flutter 1.22.5

In debuging, passing dynamic Map(only String) to Sign.. cause Type problem.

dynamic type not work properly.

error case : final jwt = JWT( {"only":"String" } token = jwt.sign(SecretKey("$key"));

success case : final jwt = JWT( {"any int value": 1234, "with":"String" } token = jwt.sign(SecretKey("$key"));

jonasroussel commented 3 years ago

Oh ! ok, I understand why its failed. I will patch this issue and update my lib soon.

Thanks you for reporting your errors.