@@ -28,14 +28,19 @@ type VerificationKeySet struct {
2828// Token represents a JWT Token. Different fields will be used depending on
2929// whether you're creating or parsing/verifying a token.
3030type Token struct {
31- Raw string // Raw contains the raw token. Populated when you [Parse] a token
32- Method SigningMethod // Method is the signing method used or to be used
33- Header map [string ]interface {} // Header is the first segment of the token in decoded form
34- Claims Claims // Claims is the second segment of the token in decoded form
35- Signature []byte // Signature is the third segment of the token in decoded form. Populated when you Parse a token
36- Valid bool // Valid specifies if the token is valid. Populated when you Parse/Verify a token
37- jsonEncoder JSONMarshalFunc // jsonEncoder is the custom json encoder/decoder
38- base64Encoder Base64EncodeFunc // base64Encoder is the custom base64 encoder/decoder
31+ Raw string // Raw contains the raw token. Populated when you [Parse] a token
32+ Method SigningMethod // Method is the signing method used or to be used
33+ Header map [string ]interface {} // Header is the first segment of the token in decoded form
34+ Claims Claims // Claims is the second segment of the token in decoded form
35+ Signature []byte // Signature is the third segment of the token in decoded form. Populated when you Parse a token
36+ Valid bool // Valid specifies if the token is valid. Populated when you Parse/Verify a token
37+
38+ encoders
39+ }
40+
41+ type encoders struct {
42+ jsonMarshal JSONMarshalFunc // jsonEncoder is the custom json encoder/decoder
43+ base64Encode Base64EncodeFunc // base64Encoder is the custom base64 encoder/decoder
3944}
4045
4146// New creates a new [Token] with the specified signing method and an empty map
@@ -85,8 +90,8 @@ func (t *Token) SignedString(key interface{}) (string, error) {
8590// straight for the SignedString.
8691func (t * Token ) SigningString () (string , error ) {
8792 var marshal JSONMarshalFunc
88- if t .jsonEncoder != nil {
89- marshal = t .jsonEncoder
93+ if t .jsonMarshal != nil {
94+ marshal = t .jsonMarshal
9095 } else {
9196 marshal = json .Marshal
9297 }
@@ -110,8 +115,8 @@ func (t *Token) SigningString() (string, error) {
110115// than a global function.
111116func (t * Token ) EncodeSegment (seg []byte ) string {
112117 var enc Base64EncodeFunc
113- if t .base64Encoder != nil {
114- enc = t .base64Encoder
118+ if t .base64Encode != nil {
119+ enc = t .base64Encode
115120 } else {
116121 enc = base64 .RawURLEncoding .EncodeToString
117122 }
0 commit comments