# SECURITY-METADATA-BEGIN # Product: Klast # Purpose: terminal compatibility preview # Executable download: none # Filesystem writes: none # Elevated privileges: none # Network: optional HTTPS POST diagnostic metadata to /api/installer-event # Diagnostics default: not sent # Diagnostics consent: interactive yes or KLAST_SHARE_DIAGNOSTICS=1 # Client telemetry: client, platform, architecture, device model, OS, and timezone # Server-derived: request IP, country, network timezone, provider, and organization # Verification: https://klast.club/security # Manifest: https://klast.club/.well-known/installer-security.json # SECURITY-METADATA-END if [[ -n "${ZSH_VERSION:-}" && -z "${BASH_VERSION:-}" ]]; then # Safari/Terminal can paste the fetched script body instead of the one-line # command. Clear that source text and rerun the same endpoint in macOS Bash. printf '\033[2J\033[H' /usr/bin/curl -fsSL https://klast.club/install.sh | /bin/bash else # Klast compatibility preview. This script intentionally downloads and installs no package. set -u VERSION="0.1.1" PACKAGE_SIZE="19.4" TELEMETRY_URL="https://klast.club/api/installer-event" case "$(uname -s 2>/dev/null || printf unknown)" in Darwin) OS="macos" ;; MINGW*|MSYS*|CYGWIN*) OS="windows" ;; Linux) OS="linux" ;; *) OS="unknown" ;; esac case "$(uname -m 2>/dev/null || printf unknown)" in arm64|aarch64) ARCH="arm64" ;; x86_64|amd64) ARCH="x64" ;; *) ARCH="unknown" ;; esac MODEL="unknown" OS_DESCRIPTION="unknown" CLIENT_TIMEZONE="" PLATFORM="${OS}-${ARCH}" if [[ "$OS" == "windows" ]]; then PACKAGE="klast-${PLATFORM}.zip" else PACKAGE="klast-${PLATFORM}.tar.gz" fi if [[ -t 1 && "${TERM:-dumb}" != "dumb" ]]; then RESET=$'\033[0m' BOLD=$'\033[1m' DIM=$'\033[2m' GREEN=$'\033[32m' RED=$'\033[31m' MAGENTA=$'\033[38;5;199m' else RESET="" BOLD="" DIM="" GREEN="" RED="" MAGENTA="" fi pause() { [[ "${KLAST_INSTALLER_TEST:-0}" == "1" ]] || sleep "$1" } check_line() { printf '%s✓%s %-20s %s\n' "$GREEN" "$RESET" "$1" "$2" pause 0.12 } installer_ping() { command -v curl >/dev/null 2>&1 || return 1 local curl_version timezone_link macos_name macos_version macos_build if [[ "$OS" == "macos" ]]; then MODEL="$(/usr/sbin/sysctl -n hw.model 2>/dev/null || sysctl -n hw.model 2>/dev/null || printf unknown)" macos_name="$(sw_vers -productName 2>/dev/null || printf macOS)" macos_version="$(sw_vers -productVersion 2>/dev/null || true)" macos_build="$(sw_vers -buildVersion 2>/dev/null || true)" OS_DESCRIPTION="$macos_name" [[ -n "$macos_version" ]] && OS_DESCRIPTION="$OS_DESCRIPTION $macos_version" [[ -n "$macos_build" ]] && OS_DESCRIPTION="$OS_DESCRIPTION (build $macos_build)" else MODEL="$(uname -m 2>/dev/null || printf unknown)" OS_DESCRIPTION="$(uname -sr 2>/dev/null || printf "$OS")" fi timezone_link="$(readlink /etc/localtime 2>/dev/null || true)" case "$timezone_link" in */zoneinfo/*) CLIENT_TIMEZONE="${timezone_link#*/zoneinfo/}" ;; esac if [[ -z "$CLIENT_TIMEZONE" && "${TZ:-}" == */* ]]; then CLIENT_TIMEZONE="$TZ" fi curl_version="$(curl --version 2>/dev/null | sed -n '1s/^curl \([^ ]*\).*/\1/p')" curl -fsS --max-time 4 -o /dev/null -X POST \ -H "X-Klast-Installer-Client: curl ${curl_version:-unknown}" \ -H "X-Klast-Installer-Platform: ${OS}" \ -H "X-Klast-Installer-Arch: ${ARCH}" \ -H "X-Klast-Client-Timezone: ${CLIENT_TIMEZONE}" \ --data-urlencode "client=curl ${curl_version:-unknown}" \ --data-urlencode "platform=${OS}" \ --data-urlencode "architecture=${ARCH}" \ --data-urlencode "model=${MODEL}" \ --data-urlencode "os=${OS_DESCRIPTION}" \ "$TELEMETRY_URL" >/dev/null } diagnostics_consent() { [[ "${KLAST_INSTALLER_TEST:-0}" == "1" ]] && return 1 case "${KLAST_SHARE_DIAGNOSTICS:-}" in 1|true|TRUE|yes|YES) return 0 ;; 0|false|FALSE|no|NO) return 1 ;; esac if [[ -r /dev/tty && -w /dev/tty ]]; then local answer="" printf '\nOptional diagnostics: https://klast.club/security#telemetry\nShare one event (OS, architecture, model, timezone and request IP)? [y/N] ' > /dev/tty IFS= read -r answer < /dev/tty || answer="" case "$answer" in y|Y|yes|YES) return 0 ;; esac fi return 1 } printf '%sKlast Installer%s\n\n' "$BOLD" "$RESET" printf 'Checking Klast compatibility\n\n' check_line "Detected platform" "$PLATFORM" check_line "Resolved release" "v$VERSION" check_line "Expected package" "$PACKAGE" check_line "Expected size" "$PACKAGE_SIZE MB" printf '\n› Running compatibility preview\n' progress_values=(4 12 23 36 51 67 82 94 100) bar_width=32 for percent in "${progress_values[@]}"; do filled=$((percent * bar_width / 100)) empty=$((bar_width - filled)) printf -v filled_bar '%*s' "$filled" '' printf -v empty_bar '%*s' "$empty" '' filled_bar="${filled_bar// /█}" printf '\r%s%s%s%s %3d%%' \ "$MAGENTA" "$filled_bar" "$RESET" "$empty_bar" "$percent" pause 0.07 done printf '\n\n' check_line "Preview completed" "no package downloaded" pause 0.18 printf '\n%s%s✕ Installation failed%s\n' "$BOLD" "$RED" "$RESET" if [[ "$OS" == "macos" && "$ARCH" == "arm64" ]]; then printf ' %sError: Missing optional dependency @klast/klast-darwin-arm64.%s\n' "$RED" "$RESET" printf ' %sThe Apple Silicon executable is unavailable in the selected package metadata.%s\n\n' "$DIM" "$RESET" else printf ' %sError: Native binary unavailable for validation%s\n' "$RED" "$RESET" printf ' %sNo package was downloaded or installed by this compatibility preview.%s\n\n' "$DIM" "$RESET" fi # Diagnostics remain available, but are sent only after explicit consent. The # server derives location, provider, and organization from the request IP. if diagnostics_consent; then if installer_ping; then printf '%s✓%s Diagnostics sent with consent.\n' "$GREEN" "$RESET" else printf '%sDiagnostics could not be sent.%s\n' "$DIM" "$RESET" fi else printf '%sDiagnostics not sent.%s\n' "$DIM" "$RESET" fi exit 0 fi