#!/usr/bin/env bash
# Quick reference guide for JWT authentication

cat <<'REF'
╔════════════════════════════════════════════════════════════════╗
║           JWT Authentication - Quick Reference                 ║
╚════════════════════════════════════════════════════════════════╝

📋 ENDPOINTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Permissioned (JWT Required):
  • https://rpc-http-prv.d-bis.org
  • wss://rpc-ws-prv.d-bis.org

Public (No Auth):
  • https://rpc-http-pub.d-bis.org
  • wss://rpc-ws-pub.d-bis.org

🔑 GENERATE TOKEN
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
./scripts/generate-jwt-token.sh [username] [expiry_days]

Example:
  ./scripts/generate-jwt-token.sh my-app 30

🧪 TEST ENDPOINT
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
TOKEN="your-token-here"
curl -k \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' \
  https://rpc-http-prv.d-bis.org

🔍 CHECK STATUS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ssh root@192.168.11.10 "pct exec 2501 -- systemctl status nginx jwt-validator"

📊 VIEW LOGS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Access logs
ssh root@192.168.11.10 "pct exec 2501 -- tail -f /var/log/nginx/rpc-http-prv-access.log"

# Error logs
ssh root@192.168.11.10 "pct exec 2501 -- tail -f /var/log/nginx/rpc-http-prv-error.log"

# JWT validator logs
ssh root@192.168.11.10 "pct exec 2501 -- journalctl -u jwt-validator -f"

🔧 TROUBLESHOOTING
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Restart services
ssh root@192.168.11.10 "pct exec 2501 -- systemctl restart nginx jwt-validator"

# Test nginx config
ssh root@192.168.11.10 "pct exec 2501 -- nginx -t"

# Check JWT secret
ssh root@192.168.11.10 "pct exec 2501 -- cat /etc/nginx/jwt_secret"

📚 DOCUMENTATION
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
docs/04-configuration/RPC_JWT_AUTHENTICATION.md
docs/04-configuration/RPC_JWT_SETUP_COMPLETE.md
docs/04-configuration/RPC_DNS_CONFIGURATION.md

REF
