aidantwoods / go-paseto

Platform-Agnostic Security Tokens implementation in Golang.
https://pkg.go.dev/aidanwoods.dev/go-paseto
MIT License
284 stars 16 forks source link

Use json.RawMessage to delay serialisation/deserialisation #48

Closed aidantwoods closed 7 months ago

aidantwoods commented 8 months ago

Fixes: #47

Instead of serialising and deserialising stored claim values multiple times, use json.RawMessage to allow serialisation to be delayed (when parsing) and done up-front (when creating a new token). This is necessary because the exact encoding used will depend on the original type, and this information is lost when decoding and then re-encoding absent that type information.