atproto user agency toolkit for individuals and groups
1#!/bin/bash
2# Check if the auth token persists across restarts.
3# Usage: npm run check-token
4# Reads the token from the running node 1, restarts it, and compares.
5set -e
6
7PORTFILE="/tmp/p2pds-node1.port"
8if [ ! -f "$PORTFILE" ]; then
9 echo "Node 1 not running. Start with: npm run start:node1"
10 exit 1
11fi
12PORT=$(cat "$PORTFILE")
13
14TOKEN_BEFORE=$(curl -s "http://localhost:$PORT/" | grep -o 'const TOKEN = "[^"]*"' | sed 's/const TOKEN = "//;s/"//')
15echo "Token before restart: ${TOKEN_BEFORE:0:16}..."
16
17# Restart
18npm run start:node1 >/dev/null 2>&1
19PORT=$(cat "$PORTFILE")
20
21TOKEN_AFTER=$(curl -s "http://localhost:$PORT/" | grep -o 'const TOKEN = "[^"]*"' | sed 's/const TOKEN = "//;s/"//')
22echo "Token after restart: ${TOKEN_AFTER:0:16}..."
23
24if [ "$TOKEN_BEFORE" = "$TOKEN_AFTER" ]; then
25 echo "PASS: Token persisted across restart"
26else
27 echo "FAIL: Token changed on restart"
28 exit 1
29fi