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:
Aaron D. Lee
2026-01-08 16:48:10 -05:00
parent 021265f3cf
commit 90bedce379

View File

@@ -179,7 +179,13 @@ This is useful if you want to share encoded images only with
specific people (family, team, etc)." specific people (family, team, etc)."
echo "" 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 "" echo ""
# Generate key to temp file (gum spin doesn't capture stdout well) # Generate key to temp file (gum spin doesn't capture stdout well)
KEY_FILE=$(mktemp) KEY_FILE=$(mktemp)
@@ -221,10 +227,52 @@ if gum confirm "Generate a private channel key?" --default=false; then
echo "" echo ""
gum confirm "Continue" --default=true --affirmative="OK" --negative="" gum confirm "Continue" --default=true --affirmative="OK" --negative=""
fi fi
else ;;
"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" 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 sleep 0.5
fi ;;
esac
# ============================================================================= # =============================================================================
# Step 4: Overclock Configuration # Step 4: Overclock Configuration