refactor: 统一 PKCE 挑战值生成逻辑

This commit is contained in:
2026-07-14 11:11:48 +08:00
parent 85d72a1c8c
commit dd1ddd6ead
4 changed files with 12 additions and 15 deletions
@@ -7,15 +7,15 @@ import (
"time"
)
func TestLoginTransactionIsEncryptedBoundedAndPKCES256(t *testing.T) {
func TestLoginTransactionIsEncryptedAndBounded(t *testing.T) {
now := time.Date(2026, 7, 13, 12, 0, 0, 0, time.UTC)
cipher, _ := NewCipher(bytes.Repeat([]byte{9}, 32))
transaction, challenge, err := NewLoginTransaction("/workspace?tab=wallet", now)
transaction, err := NewLoginTransaction("/workspace?tab=wallet", now)
if err != nil {
t.Fatal(err)
}
if transaction.State == transaction.Nonce || len(challenge) != 43 || challenge == transaction.PKCEVerifier {
t.Fatal("state, nonce and PKCE values are not independent S256 material")
if transaction.State == transaction.Nonce || len(transaction.PKCEVerifier) != 43 || transaction.State == transaction.PKCEVerifier {
t.Fatal("state, nonce and PKCE verifier are not independent security material")
}
encoded, err := cipher.EncodeLoginTransaction(transaction)
if err != nil {