*/ private const SENSITIVE_KEYS = [ 'access_token', 'refresh_token', 'id_token', 'token', 'code', 'client_secret', 'authorization', 'encrypted_refresh_token', ]; /** * @param array $context * @return array */ public static function context(array $context): array { $clean = []; foreach ($context as $key => $value) { $normalized = strtolower((string) $key); if (in_array($normalized, self::SENSITIVE_KEYS, true) || str_contains($normalized, 'token') || str_contains($normalized, 'secret')) { continue; } if (is_array($value)) { $clean[$key] = self::context($value); continue; } if (is_string($value) && self::looksLikeSecret($value)) { continue; } $clean[$key] = $value; } return $clean; } public static function looksLikeSecret(string $value): bool { if ($value === '') { return false; } foreach (['refresh-secret', 'access-secret', 'ya29.', '1//'] as $marker) { if (str_contains($value, $marker)) { return true; } } return false; } }