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

No longer force unwrap footer result #41

Closed aidantwoods closed 1 year ago

aidantwoods commented 1 year ago

Avoid force unwrapping here. I ended up using UnwrappedResults() erroneously to match the existing signature ([]byte, error) over Results() which would more safely return (*[]byte, error). The existing signature is the way it is because []byte can have a nil state, which isn't expressible at a generic level.

Add some special casing to transform the Option[[]byte] into []byte by mapping the None case to nil == []byte{}.