diff --git a/claims_test.go b/claims_test.go index 6dbde94..016261d 100644 --- a/claims_test.go +++ b/claims_test.go @@ -1,14 +1,15 @@ -package paseto +package paseto_test import ( "testing" "time" + "aidanwoods.dev/go-paseto" "github.com/stretchr/testify/require" ) func TestAllClaimsPassV2(t *testing.T) { - token := NewToken() + token := paseto.NewToken() token.SetAudience("a") token.SetJti("b") @@ -19,20 +20,20 @@ func TestAllClaimsPassV2(t *testing.T) { token.SetNotBefore(time.Now().Add(25 * time.Second)) token.SetIssuedAt(time.Now()) - key := NewV2SymmetricKey() - secretKey := NewV2AsymmetricSecretKey() + key := paseto.NewV2SymmetricKey() + secretKey := paseto.NewV2AsymmetricSecretKey() encrypted := token.V2Encrypt(key) signed := token.V2Sign(secretKey) - parser := NewParser() - parser.AddRule(ForAudience("a")) - parser.AddRule(IdentifiedBy("b")) - parser.AddRule(IssuedBy("c")) - parser.AddRule(NotExpired()) - parser.AddRule(Subject("d")) - parser.AddRule(ValidAt(time.Now().Add(30 * time.Second))) + parser := paseto.NewParser() + parser.AddRule(paseto.ForAudience("a")) + parser.AddRule(paseto.IdentifiedBy("b")) + parser.AddRule(paseto.IssuedBy("c")) + parser.AddRule(paseto.NotExpired()) + parser.AddRule(paseto.Subject("d")) + parser.AddRule(paseto.ValidAt(time.Now().Add(30 * time.Second))) _, err := parser.ParseV2Local(key, encrypted) require.NoError(t, err) @@ -42,7 +43,7 @@ func TestAllClaimsPassV2(t *testing.T) { } func TestAllClaimsPassV3(t *testing.T) { - token := NewToken() + token := paseto.NewToken() token.SetAudience("a") token.SetJti("b") @@ -53,20 +54,20 @@ func TestAllClaimsPassV3(t *testing.T) { token.SetNotBefore(time.Now().Add(25 * time.Second)) token.SetIssuedAt(time.Now()) - key := NewV3SymmetricKey() - secretKey := NewV3AsymmetricSecretKey() + key := paseto.NewV3SymmetricKey() + secretKey := paseto.NewV3AsymmetricSecretKey() encrypted := token.V3Encrypt(key, nil) signed := token.V3Sign(secretKey, nil) - parser := NewParser() - parser.AddRule(ForAudience("a")) - parser.AddRule(IdentifiedBy("b")) - parser.AddRule(IssuedBy("c")) - parser.AddRule(NotExpired()) - parser.AddRule(Subject("d")) - parser.AddRule(ValidAt(time.Now().Add(30 * time.Second))) + parser := paseto.NewParser() + parser.AddRule(paseto.ForAudience("a")) + parser.AddRule(paseto.IdentifiedBy("b")) + parser.AddRule(paseto.IssuedBy("c")) + parser.AddRule(paseto.NotExpired()) + parser.AddRule(paseto.Subject("d")) + parser.AddRule(paseto.ValidAt(time.Now().Add(30 * time.Second))) _, err := parser.ParseV3Local(key, encrypted, nil) require.NoError(t, err) @@ -76,7 +77,7 @@ func TestAllClaimsPassV3(t *testing.T) { } func TestAllClaimsPassV4(t *testing.T) { - token := NewToken() + token := paseto.NewToken() token.SetAudience("a") token.SetJti("b") @@ -87,20 +88,20 @@ func TestAllClaimsPassV4(t *testing.T) { token.SetNotBefore(time.Now().Add(25 * time.Second)) token.SetIssuedAt(time.Now()) - key := NewV4SymmetricKey() - secretKey := NewV4AsymmetricSecretKey() + key := paseto.NewV4SymmetricKey() + secretKey := paseto.NewV4AsymmetricSecretKey() encrypted := token.V4Encrypt(key, nil) signed := token.V4Sign(secretKey, nil) - parser := NewParser() - parser.AddRule(ForAudience("a")) - parser.AddRule(IdentifiedBy("b")) - parser.AddRule(IssuedBy("c")) - parser.AddRule(NotExpired()) - parser.AddRule(Subject("d")) - parser.AddRule(ValidAt(time.Now().Add(30 * time.Second))) + parser := paseto.NewParser() + parser.AddRule(paseto.ForAudience("a")) + parser.AddRule(paseto.IdentifiedBy("b")) + parser.AddRule(paseto.IssuedBy("c")) + parser.AddRule(paseto.NotExpired()) + parser.AddRule(paseto.Subject("d")) + parser.AddRule(paseto.ValidAt(time.Now().Add(30 * time.Second))) _, err := parser.ParseV4Local(key, encrypted, nil) require.NoError(t, err) @@ -110,64 +111,64 @@ func TestAllClaimsPassV4(t *testing.T) { } func TestFutureIat(t *testing.T) { - token := NewToken() + token := paseto.NewToken() // simulated check will be 30 seconds from now token.SetExpiration(time.Now().Add(time.Minute)) token.SetNotBefore(time.Now().Add(25 * time.Second)) token.SetIssuedAt(time.Now().Add(35 * time.Second)) - key := NewV4SymmetricKey() + key := paseto.NewV4SymmetricKey() encrypted := token.V4Encrypt(key, nil) - parser := NewParser() - parser.AddRule(ValidAt(time.Now().Add(30 * time.Second))) + parser := paseto.NewParser() + parser.AddRule(paseto.ValidAt(time.Now().Add(30 * time.Second))) _, err := parser.ParseV4Local(key, encrypted, nil) require.Error(t, err) } func TestFutureNbf(t *testing.T) { - token := NewToken() + token := paseto.NewToken() // simulated check will be 30 seconds from now token.SetExpiration(time.Now().Add(time.Minute)) token.SetNotBefore(time.Now().Add(35 * time.Second)) token.SetIssuedAt(time.Now()) - key := NewV4SymmetricKey() + key := paseto.NewV4SymmetricKey() encrypted := token.V4Encrypt(key, nil) - parser := NewParser() - parser.AddRule(ValidAt(time.Now().Add(30 * time.Second))) + parser := paseto.NewParser() + parser.AddRule(paseto.ValidAt(time.Now().Add(30 * time.Second))) _, err := parser.ParseV4Local(key, encrypted, nil) require.Error(t, err) } func TestPastExp(t *testing.T) { - token := NewToken() + token := paseto.NewToken() // simulated check will be 30 seconds from now token.SetExpiration(time.Now().Add(29 * time.Second)) token.SetNotBefore(time.Now().Add(25 * time.Second)) token.SetIssuedAt(time.Now()) - key := NewV4SymmetricKey() + key := paseto.NewV4SymmetricKey() encrypted := token.V4Encrypt(key, nil) - parser := NewParser() - parser.AddRule(ValidAt(time.Now().Add(30 * time.Second))) + parser := paseto.NewParser() + parser.AddRule(paseto.ValidAt(time.Now().Add(30 * time.Second))) _, err := parser.ParseV4Local(key, encrypted, nil) require.Error(t, err) } func TestReadMeExample(t *testing.T) { - token := NewToken() + token := paseto.NewToken() token.SetAudience("audience") token.SetJti("identifier") @@ -179,20 +180,20 @@ func TestReadMeExample(t *testing.T) { token.SetIssuedAt(time.Now()) secretKeyHex := "b4cbfb43df4ce210727d953e4a713307fa19bb7d9f85041438d9e11b942a37741eb9dbbbbc047c03fd70604e0071f0987e16b28b757225c11f00415d0e20b1a2" - secretKey, _ := NewV4AsymmetricSecretKeyFromHex(secretKeyHex) + secretKey, _ := paseto.NewV4AsymmetricSecretKeyFromHex(secretKeyHex) signed := token.V4Sign(secretKey, nil) - parser := NewParser() - parser.AddRule(ForAudience("audience")) - parser.AddRule(IdentifiedBy("identifier")) - parser.AddRule(IssuedBy("issuer")) - parser.AddRule(Subject("subject")) - parser.AddRule(NotExpired()) - parser.AddRule(ValidAt(time.Now())) + parser := paseto.NewParser() + parser.AddRule(paseto.ForAudience("audience")) + parser.AddRule(paseto.IdentifiedBy("identifier")) + parser.AddRule(paseto.IssuedBy("issuer")) + parser.AddRule(paseto.Subject("subject")) + parser.AddRule(paseto.NotExpired()) + parser.AddRule(paseto.ValidAt(time.Now())) publicKeyHex := "1eb9dbbbbc047c03fd70604e0071f0987e16b28b757225c11f00415d0e20b1a2" - publicKey, _ := NewV4AsymmetricPublicKeyFromHex(publicKeyHex) + publicKey, _ := paseto.NewV4AsymmetricPublicKeyFromHex(publicKeyHex) parsedToken, err := parser.ParseV4Public(publicKey, signed, nil) require.NoError(t, err) diff --git a/export_internal_test.go b/export_internal_test.go new file mode 100644 index 0000000..26a2127 --- /dev/null +++ b/export_internal_test.go @@ -0,0 +1,37 @@ +package paseto + +// This file is only compiled during tests due to the _test suffix. It serves +// the purpose of exporting some internal functions, which are used in +// paseto_test. + +type Packet = packet + +var NewMessage = newMessage +var NewPacket = newPacket + +var V2LocalDecrypt = v2LocalDecrypt +var V2LocalEncrypt = v2LocalEncrypt +var V2PublicVerify = v2PublicVerify +var V2PublicSign = v2PublicSign + +var V3LocalDecrypt = v3LocalDecrypt +var V3LocalEncrypt = v3LocalEncrypt +var V3PublicVerify = v3PublicVerify +var V3PublicSign = v3PublicSign + +var V4LocalDecrypt = v4LocalDecrypt +var V4LocalEncrypt = v4LocalEncrypt +var V4PublicVerify = v4PublicVerify +var V4PublicSign = v4PublicSign + +func (m message) Encoded() string { + return m.encoded() +} + +func (p packet) Content() []byte { + return p.content +} + +func (p packet) Footer() []byte { + return p.footer +} diff --git a/token_test.go b/token_test.go index c4f085f..b31658c 100644 --- a/token_test.go +++ b/token_test.go @@ -1,13 +1,14 @@ -package paseto +package paseto_test import ( "testing" + "aidanwoods.dev/go-paseto" "github.com/stretchr/testify/require" ) func TestSomeString(t *testing.T) { - token := NewToken() + token := paseto.NewToken() err := token.Set("foo", "bar") require.NoError(t, err) @@ -20,7 +21,7 @@ func TestSomeString(t *testing.T) { } func TestSomeInt(t *testing.T) { - token := NewToken() + token := paseto.NewToken() err := token.Set("foo", 3) require.NoError(t, err) @@ -37,7 +38,7 @@ func TestSomeInt(t *testing.T) { } func TestSomeBool(t *testing.T) { - token := NewToken() + token := paseto.NewToken() err := token.Set("foo", true) require.NoError(t, err) @@ -62,7 +63,7 @@ func TestSomeStruct(t *testing.T) { someStruct := SomeStruct{"boo", 3, true} - token := NewToken() + token := paseto.NewToken() err := token.Set("baz", someStruct) require.NoError(t, err) @@ -83,7 +84,7 @@ func TestSomeWrongType(t *testing.T) { someStruct := SomeStruct{"boo", 3, true} - token := NewToken() + token := paseto.NewToken() err := token.Set("baz", someStruct) require.NoError(t, err) @@ -94,7 +95,7 @@ func TestSomeWrongType(t *testing.T) { } func TestSomeWrongKey(t *testing.T) { - token := NewToken() + token := paseto.NewToken() err := token.Set("foo", "bar") require.NoError(t, err) @@ -113,7 +114,7 @@ func TestFromMap(t *testing.T) { someStruct := SomeStruct{"boo", 3, true} - token, err := MakeToken( + token, err := paseto.MakeToken( map[string]interface{}{ "foo": "bar", "baz": someStruct, @@ -144,7 +145,7 @@ func TestJsonEncode(t *testing.T) { someStruct := SomeStruct{"boo", 3, true} - token, err := MakeToken( + token, err := paseto.MakeToken( map[string]interface{}{ "foo": "bar", "baz": someStruct, @@ -162,7 +163,7 @@ func TestJsonEncode(t *testing.T) { func TestJsonParse(t *testing.T) { data := `{"foo":"bar","baz":{"Field1":"boo","Field2":3,"Field3":true}}` - token, err := NewTokenFromClaimsJSON([]byte(data), nil) + token, err := paseto.NewTokenFromClaimsJSON([]byte(data), nil) require.NoError(t, err) type SomeStruct struct { @@ -197,7 +198,7 @@ func TestSignSelfConsistent(t *testing.T) { someStruct := SomeStruct{"boo", 3, true} - token, err := MakeToken( + token, err := paseto.MakeToken( map[string]interface{}{ "foo": "bar", "baz": someStruct, @@ -206,9 +207,9 @@ func TestSignSelfConsistent(t *testing.T) { ) require.NoError(t, err) - parser := NewParserWithoutExpiryCheck() + parser := paseto.NewParserWithoutExpiryCheck() - key := NewV4AsymmetricSecretKey() + key := paseto.NewV4AsymmetricSecretKey() signed := token.V4Sign(key, nil) @@ -232,7 +233,7 @@ func TestEncryptSelfConsistent(t *testing.T) { someStruct := SomeStruct{"boo", 3, true} - token, err := MakeToken( + token, err := paseto.MakeToken( map[string]interface{}{ "foo": "bar", "baz": someStruct, @@ -241,9 +242,9 @@ func TestEncryptSelfConsistent(t *testing.T) { ) require.NoError(t, err) - parser := NewParserWithoutExpiryCheck() + parser := paseto.NewParserWithoutExpiryCheck() - key := NewV4SymmetricKey() + key := paseto.NewV4SymmetricKey() encrypted := token.V4Encrypt(key, nil) @@ -257,10 +258,10 @@ func TestEncryptSelfConsistent(t *testing.T) { } func TestReadmePublicExample(t *testing.T) { - publicKey, _ := NewV4AsymmetricPublicKeyFromHex("1eb9dbbbbc047c03fd70604e0071f0987e16b28b757225c11f00415d0e20b1a2") + publicKey, _ := paseto.NewV4AsymmetricPublicKeyFromHex("1eb9dbbbbc047c03fd70604e0071f0987e16b28b757225c11f00415d0e20b1a2") signed := "v4.public.eyJkYXRhIjoidGhpcyBpcyBhIHNpZ25lZCBtZXNzYWdlIiwiZXhwIjoiMjAyMi0wMS0wMVQwMDowMDowMCswMDowMCJ9v3Jt8mx_TdM2ceTGoqwrh4yDFn0XsHvvV_D0DtwQxVrJEBMl0F2caAdgnpKlt4p7xBnx1HcO-SPo8FPp214HDw.eyJraWQiOiJ6VmhNaVBCUDlmUmYyc25FY1Q3Z0ZUaW9lQTlDT2NOeTlEZmdMMVc2MGhhTiJ9" - parser := NewParserWithoutExpiryCheck() + parser := paseto.NewParserWithoutExpiryCheck() token, err := parser.ParseV4Public(publicKey, signed, nil) require.NoError(t, err) diff --git a/vectors_test.go b/vectors_test.go index b8d89e7..70ee28e 100644 --- a/vectors_test.go +++ b/vectors_test.go @@ -1,4 +1,4 @@ -package paseto +package paseto_test import ( "encoding/hex" @@ -7,6 +7,7 @@ import ( "os" "testing" + "aidanwoods.dev/go-paseto" "github.com/stretchr/testify/require" ) @@ -38,22 +39,22 @@ func TestV2(t *testing.T) { for _, test := range tests.Tests { t.Run(test.Name, func(t *testing.T) { - var decoded packet + var decoded paseto.Packet switch test.Key { // Local mode default: - sk, err := V2SymmetricKeyFromHex(test.Key) + sk, err := paseto.V2SymmetricKeyFromHex(test.Key) require.NoError(t, err) - message, err := newMessage(V2Local, test.Token) + message, err := paseto.NewMessage(paseto.V2Local, test.Token) if test.ExpectFail { require.Error(t, err) return } require.NoError(t, err) - decoded, err = v2LocalDecrypt(message, sk) + decoded, err = paseto.V2LocalDecrypt(message, sk) if test.ExpectFail { require.Error(t, err) return @@ -62,17 +63,17 @@ func TestV2(t *testing.T) { // Public mode case "": - pk, err := NewV2AsymmetricPublicKeyFromHex(test.PublicKey) + pk, err := paseto.NewV2AsymmetricPublicKeyFromHex(test.PublicKey) require.NoError(t, err) - message, err := newMessage(V2Public, test.Token) + message, err := paseto.NewMessage(paseto.V2Public, test.Token) if test.ExpectFail { require.Error(t, err) return } require.NoError(t, err) - decoded, err = v2PublicVerify(message, pk) + decoded, err = paseto.V2PublicVerify(message, pk) if test.ExpectFail { require.Error(t, err) return @@ -80,34 +81,34 @@ func TestV2(t *testing.T) { require.NoError(t, err) } - require.Equal(t, test.Payload, string(decoded.content)) - require.Equal(t, test.Footer, string(decoded.footer)) + require.Equal(t, test.Payload, string(decoded.Content())) + require.Equal(t, test.Footer, string(decoded.Footer())) - packet := newPacket([]byte(test.Payload), []byte(test.Footer)) + packet := paseto.NewPacket([]byte(test.Payload), []byte(test.Footer)) switch test.Key { // Local mode default: - sk, err := V2SymmetricKeyFromHex(test.Key) + sk, err := paseto.V2SymmetricKeyFromHex(test.Key) require.NoError(t, err) unitTestNonce, err := hex.DecodeString(test.Nonce) require.NoError(t, err) - encrypted := v2LocalEncrypt(packet, sk, unitTestNonce) + encrypted := paseto.V2LocalEncrypt(packet, sk, unitTestNonce) require.NoError(t, err) - require.Equal(t, test.Token, encrypted.encoded()) + require.Equal(t, test.Token, encrypted.Encoded()) // Public mode case "": - sk, err := NewV2AsymmetricSecretKeyFromHex(test.SecretKey) + sk, err := paseto.NewV2AsymmetricSecretKeyFromHex(test.SecretKey) require.NoError(t, err) - signed := v2PublicSign(packet, sk) + signed := paseto.V2PublicSign(packet, sk) require.NoError(t, err) - require.Equal(t, test.Token, signed.encoded()) + require.Equal(t, test.Token, signed.Encoded()) } }) } @@ -123,22 +124,22 @@ func TestV3(t *testing.T) { for _, test := range tests.Tests { t.Run(test.Name, func(t *testing.T) { - var decoded packet + var decoded paseto.Packet switch test.Key { // Local mode default: - sk, err := V3SymmetricKeyFromHex(test.Key) + sk, err := paseto.V3SymmetricKeyFromHex(test.Key) require.NoError(t, err) - message, err := newMessage(V3Local, test.Token) + message, err := paseto.NewMessage(paseto.V3Local, test.Token) if test.ExpectFail { require.Error(t, err) return } require.NoError(t, err) - decoded, err = v3LocalDecrypt(message, sk, []byte(test.ImplicitAssertation)) + decoded, err = paseto.V3LocalDecrypt(message, sk, []byte(test.ImplicitAssertation)) if test.ExpectFail { require.Error(t, err) return @@ -147,17 +148,17 @@ func TestV3(t *testing.T) { // Public mode case "": - pk, err := NewV3AsymmetricPublicKeyFromHex(test.PublicKey) + pk, err := paseto.NewV3AsymmetricPublicKeyFromHex(test.PublicKey) require.NoError(t, err) - message, err := newMessage(V3Public, test.Token) + message, err := paseto.NewMessage(paseto.V3Public, test.Token) if test.ExpectFail { require.Error(t, err) return } require.NoError(t, err) - decoded, err = v3PublicVerify(message, pk, []byte(test.ImplicitAssertation)) + decoded, err = paseto.V3PublicVerify(message, pk, []byte(test.ImplicitAssertation)) if test.ExpectFail { require.Error(t, err) return @@ -165,43 +166,43 @@ func TestV3(t *testing.T) { require.NoError(t, err) } - require.Equal(t, test.Payload, string(decoded.content)) - require.Equal(t, test.Footer, string(decoded.footer)) + require.Equal(t, test.Payload, string(decoded.Content())) + require.Equal(t, test.Footer, string(decoded.Footer())) - packet := newPacket([]byte(test.Payload), []byte(test.Footer)) + packet := paseto.NewPacket([]byte(test.Payload), []byte(test.Footer)) implicit := []byte(test.ImplicitAssertation) switch test.Key { // Local mode default: - sk, err := V3SymmetricKeyFromHex(test.Key) + sk, err := paseto.V3SymmetricKeyFromHex(test.Key) require.NoError(t, err) unitTestNonce, err := hex.DecodeString(test.Nonce) require.NoError(t, err) - encrypted := v3LocalEncrypt(packet, sk, implicit, unitTestNonce) + encrypted := paseto.V3LocalEncrypt(packet, sk, implicit, unitTestNonce) require.NoError(t, err) - require.Equal(t, test.Token, encrypted.encoded()) + require.Equal(t, test.Token, encrypted.Encoded()) // Public mode case "": - sk, err := NewV3AsymmetricSecretKeyFromHex(test.SecretKey) + sk, err := paseto.NewV3AsymmetricSecretKeyFromHex(test.SecretKey) require.NoError(t, err) - signed := v3PublicSign(packet, sk, implicit) + signed := paseto.V3PublicSign(packet, sk, implicit) // v3 signatures are not deterministic in this implementation, so just check that something signed can be verified - pk, err := NewV3AsymmetricPublicKeyFromHex(test.PublicKey) + pk, err := paseto.NewV3AsymmetricPublicKeyFromHex(test.PublicKey) require.NoError(t, err) - decoded, err = v3PublicVerify(signed, pk, []byte(test.ImplicitAssertation)) + decoded, err = paseto.V3PublicVerify(signed, pk, []byte(test.ImplicitAssertation)) require.NoError(t, err) - require.JSONEq(t, test.Payload, string(decoded.content)) - require.Equal(t, test.Footer, string(decoded.footer)) + require.Equal(t, test.Payload, string(decoded.Content())) + require.Equal(t, test.Footer, string(decoded.Footer())) } }) } @@ -223,22 +224,22 @@ func TestV4(t *testing.T) { for _, test := range tests.Tests { t.Run(test.Name, func(t *testing.T) { - var decoded packet + var decoded paseto.Packet switch test.Key { // Local mode default: - sk, err := V4SymmetricKeyFromHex(test.Key) + sk, err := paseto.V4SymmetricKeyFromHex(test.Key) require.NoError(t, err) - message, err := newMessage(V4Local, test.Token) + message, err := paseto.NewMessage(paseto.V4Local, test.Token) if test.ExpectFail { require.Error(t, err) return } require.NoError(t, err) - decoded, err = v4LocalDecrypt(message, sk, []byte(test.ImplicitAssertation)) + decoded, err = paseto.V4LocalDecrypt(message, sk, []byte(test.ImplicitAssertation)) if test.ExpectFail { require.Error(t, err) return @@ -247,17 +248,17 @@ func TestV4(t *testing.T) { // Public mode case "": - pk, err := NewV4AsymmetricPublicKeyFromHex(test.PublicKey) + pk, err := paseto.NewV4AsymmetricPublicKeyFromHex(test.PublicKey) require.NoError(t, err) - message, err := newMessage(V4Public, test.Token) + message, err := paseto.NewMessage(paseto.V4Public, test.Token) if test.ExpectFail { require.Error(t, err) return } require.NoError(t, err) - decoded, err = v4PublicVerify(message, pk, []byte(test.ImplicitAssertation)) + decoded, err = paseto.V4PublicVerify(message, pk, []byte(test.ImplicitAssertation)) if test.ExpectFail { require.Error(t, err) return @@ -265,35 +266,35 @@ func TestV4(t *testing.T) { require.NoError(t, err) } - require.Equal(t, test.Payload, string(decoded.content)) - require.Equal(t, test.Footer, string(decoded.footer)) + require.Equal(t, test.Payload, string(decoded.Content())) + require.Equal(t, test.Footer, string(decoded.Footer())) - packet := newPacket([]byte(test.Payload), []byte(test.Footer)) + packet := paseto.NewPacket([]byte(test.Payload), []byte(test.Footer)) implicit := []byte(test.ImplicitAssertation) switch test.Key { // Local mode default: - sk, err := V4SymmetricKeyFromHex(test.Key) + sk, err := paseto.V4SymmetricKeyFromHex(test.Key) require.NoError(t, err) unitTestNonce, err := hex.DecodeString(test.Nonce) require.NoError(t, err) - encrypted := v4LocalEncrypt(packet, sk, implicit, unitTestNonce) + encrypted := paseto.V4LocalEncrypt(packet, sk, implicit, unitTestNonce) require.NoError(t, err) - require.Equal(t, test.Token, encrypted.encoded()) + require.Equal(t, test.Token, encrypted.Encoded()) // Public mode case "": - sk, err := NewV4AsymmetricSecretKeyFromHex(test.SecretKey) + sk, err := paseto.NewV4AsymmetricSecretKeyFromHex(test.SecretKey) require.NoError(t, err) - signed := v4PublicSign(packet, sk, implicit) + signed := paseto.V4PublicSign(packet, sk, implicit) require.NoError(t, err) - require.Equal(t, test.Token, signed.encoded()) + require.Equal(t, test.Token, signed.Encoded()) } }) }