package provider import ( "encoding/base64" "encoding/json" "strings" "time" ) // Expiry is read in memory and never included in evidence or diagnostics. func credentialsExpired(raw []byte, now time.Time) bool { var v struct { Claude struct { ExpiresAt int64 `json:"expiresAt"` } `json:"claudeAiOauth"` Tokens struct { Access string `json:"access_token"` } `json:"tokens"` } if json.Unmarshal(raw, &v) != nil { return false } if v.Claude.ExpiresAt > 0 && v.Claude.ExpiresAt <= now.UnixMilli() { return true } parts := strings.Split(v.Tokens.Access, ".") if len(parts) != 3 { return false } data, err := base64.RawURLEncoding.DecodeString(parts[1]) if err != nil { return false } var claims struct { Exp int64 `json:"exp"` } return json.Unmarshal(data, &claims) == nil && claims.Exp > 0 && claims.Exp <= now.Unix() }