diff --git a/client.go b/client.go index d059b83..86a4dfe 100644 --- a/client.go +++ b/client.go @@ -218,6 +218,7 @@ func ChallengeTs(window time.Duration) Criterion { if diff := now().Sub(r.ChallengeTs); diff > window { return &InvalidChallengeTsError{ ChallengeTs: r.ChallengeTs, + Diff: diff, } } return nil diff --git a/client_test.go b/client_test.go index e2850ab..f020d30 100644 --- a/client_test.go +++ b/client_test.go @@ -325,6 +325,7 @@ func TestVerify(t *testing.T) { }, expected: &InvalidChallengeTsError{ ChallengeTs: now().Add(-time.Second), + Diff: time.Second, }, }, { diff --git a/errors.go b/errors.go index 53eddcd..16db355 100644 --- a/errors.go +++ b/errors.go @@ -58,8 +58,9 @@ func (e *InvalidScoreError) Error() string { // window. type InvalidChallengeTsError struct { ChallengeTs time.Time + Diff time.Duration } func (e *InvalidChallengeTsError) Error() string { - return fmt.Sprintf("invalid reCAPTCHA: invalid challenge timestamp: %s", e.ChallengeTs) + return fmt.Sprintf("invalid reCAPTCHA: invalid challenge timestamp: %s (%s old)", e.ChallengeTs, e.Diff) }