Add channel key loading option to first-boot wizard
Step 3 now offers three choices: - Skip (public mode) - Generate new key - Enter existing key (for joining team deployments) Validates entered keys using Python channel module before accepting. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -179,7 +179,13 @@ This is useful if you want to share encoded images only with
|
||||
specific people (family, team, etc)."
|
||||
echo ""
|
||||
|
||||
if gum confirm "Generate a private channel key?" --default=false; then
|
||||
CHANNEL_CHOICE=$(gum choose \
|
||||
"Skip (public mode)" \
|
||||
"Generate new key" \
|
||||
"Enter existing key")
|
||||
|
||||
case "$CHANNEL_CHOICE" in
|
||||
"Generate new key")
|
||||
echo ""
|
||||
# Generate key to temp file (gum spin doesn't capture stdout well)
|
||||
KEY_FILE=$(mktemp)
|
||||
@@ -221,11 +227,53 @@ if gum confirm "Generate a private channel key?" --default=false; then
|
||||
echo ""
|
||||
gum confirm "Continue" --default=true --affirmative="OK" --negative=""
|
||||
fi
|
||||
else
|
||||
gum style --foreground 214 "→ Using public mode"
|
||||
sleep 0.5
|
||||
;;
|
||||
|
||||
"Enter existing key")
|
||||
echo ""
|
||||
gum style --foreground 245 "Enter the channel key from your team/deployment."
|
||||
gum style --foreground 245 "Format: XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX"
|
||||
echo ""
|
||||
|
||||
while true; do
|
||||
ENTERED_KEY=$(gum input --placeholder "ABCD-1234-EFGH-5678-IJKL-9012-MNOP-3456" --width 50)
|
||||
|
||||
if [ -z "$ENTERED_KEY" ]; then
|
||||
gum style --foreground 214 "→ Cancelled, using public mode"
|
||||
CHANNEL_KEY=""
|
||||
break
|
||||
fi
|
||||
|
||||
# Validate the key using Python
|
||||
VENV_PYTHON="$INSTALL_DIR/venv/bin/python"
|
||||
if "$VENV_PYTHON" -c "from stegasoo.channel import validate_channel_key, format_channel_key; k='$ENTERED_KEY'; exit(0 if validate_channel_key(k) else 1)" 2>/dev/null; then
|
||||
# Get formatted key
|
||||
CHANNEL_KEY=$("$VENV_PYTHON" -c "from stegasoo.channel import format_channel_key; print(format_channel_key('$ENTERED_KEY'))" 2>/dev/null)
|
||||
echo ""
|
||||
gum style --foreground 82 "✓ Channel key accepted!"
|
||||
gum style --foreground 245 "Key: $CHANNEL_KEY"
|
||||
break
|
||||
else
|
||||
echo ""
|
||||
gum style --foreground 196 "Invalid key format. Please check and try again."
|
||||
gum style --foreground 245 "Expected: 32 alphanumeric characters (with or without dashes)"
|
||||
echo ""
|
||||
if ! gum confirm "Try again?" --default=true; then
|
||||
gum style --foreground 214 "→ Using public mode"
|
||||
CHANNEL_KEY=""
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
*)
|
||||
gum style --foreground 214 "→ Using public mode"
|
||||
CHANNEL_KEY=""
|
||||
sleep 0.5
|
||||
;;
|
||||
esac
|
||||
|
||||
# =============================================================================
|
||||
# Step 4: Overclock Configuration
|
||||
# =============================================================================
|
||||
|
||||
Reference in New Issue
Block a user