A community based topic aggregation platform built on atproto
at main 3.0 kB view raw
1#!/bin/bash 2 3# Script: 3-register-with-coves.sh 4# Purpose: Register your aggregator with a Coves instance 5# 6# This script calls the social.coves.aggregator.register XRPC endpoint 7# to register your aggregator DID with the Coves instance. 8 9set -e 10 11echo "================================================" 12echo "Step 3: Register with Coves Instance" 13echo "================================================" 14echo "" 15 16# Load config if available 17if [ -f "aggregator-config.env" ]; then 18 source aggregator-config.env 19 echo "✓ Loaded configuration from aggregator-config.env" 20 echo " DID: $AGGREGATOR_DID" 21 echo " Domain: $AGGREGATOR_DOMAIN" 22 echo "" 23else 24 echo "Configuration file not found. Please run previous scripts first." 25 exit 1 26fi 27 28# Validate domain is set 29if [ -z "$AGGREGATOR_DOMAIN" ]; then 30 echo "Error: AGGREGATOR_DOMAIN not set. Please run 2-setup-wellknown.sh first." 31 exit 1 32fi 33 34# Get Coves instance URL 35read -p "Enter Coves instance URL (default: https://api.coves.social): " COVES_URL 36COVES_URL=${COVES_URL:-https://api.coves.social} 37 38echo "" 39echo "Verifying .well-known/atproto-did is accessible..." 40 41# Verify .well-known is accessible 42WELLKNOWN_URL="https://$AGGREGATOR_DOMAIN/.well-known/atproto-did" 43WELLKNOWN_CONTENT=$(curl -s "$WELLKNOWN_URL" || echo "ERROR") 44 45if [ "$WELLKNOWN_CONTENT" = "ERROR" ]; then 46 echo "✗ Error: Could not access $WELLKNOWN_URL" 47 echo " Please ensure the file is uploaded and accessible." 48 exit 1 49elif [ "$WELLKNOWN_CONTENT" != "$AGGREGATOR_DID" ]; then 50 echo "✗ Error: .well-known/atproto-did contains wrong DID" 51 echo " Expected: $AGGREGATOR_DID" 52 echo " Got: $WELLKNOWN_CONTENT" 53 exit 1 54fi 55 56echo "✓ .well-known/atproto-did is correctly configured" 57echo "" 58 59echo "Registering with $COVES_URL..." 60 61# Call registration endpoint 62RESPONSE=$(curl -s -X POST "$COVES_URL/xrpc/social.coves.aggregator.register" \ 63 -H "Content-Type: application/json" \ 64 -d "{ 65 \"did\": \"$AGGREGATOR_DID\", 66 \"domain\": \"$AGGREGATOR_DOMAIN\" 67 }") 68 69# Check if successful 70if echo "$RESPONSE" | jq -e '.error' > /dev/null 2>&1; then 71 echo "✗ Registration failed:" 72 echo "$RESPONSE" | jq '.' 73 exit 1 74fi 75 76# Extract response 77REGISTERED_DID=$(echo "$RESPONSE" | jq -r '.did') 78REGISTERED_HANDLE=$(echo "$RESPONSE" | jq -r '.handle') 79MESSAGE=$(echo "$RESPONSE" | jq -r '.message') 80 81if [ -z "$REGISTERED_DID" ] || [ "$REGISTERED_DID" = "null" ]; then 82 echo "✗ Error: Unexpected response format" 83 echo "$RESPONSE" | jq '.' 84 exit 1 85fi 86 87echo "" 88echo "✓ Registration successful!" 89echo "" 90echo "=== Registration Details ====" 91echo "DID: $REGISTERED_DID" 92echo "Handle: $REGISTERED_HANDLE" 93echo "Message: $MESSAGE" 94echo "=============================" 95echo "" 96 97# Save Coves URL to config 98echo "" >> aggregator-config.env 99echo "COVES_INSTANCE_URL=\"$COVES_URL\"" >> aggregator-config.env 100 101echo "✓ Updated aggregator-config.env with Coves instance URL" 102echo "" 103echo "Next step: Run ./4-create-service-declaration.sh"