#!/usr/bin/env bash # Quick E2E helper: create session on backend-api and print a URL you can open in the Broadcast Panel (with token in query) or use to postMessage. # Set these env vars before running if needed: # TOKEN_SERVER (default: http://localhost:4000) # BROADCAST_URL (default: http://localhost:5175) TOKEN_SERVER=${TOKEN_SERVER:-http://localhost:4000} BROADCAST_URL=${BROADCAST_URL:-http://localhost:5175} ROOM=${1:-e2e-room} USERNAME=${2:-e2e-runner} set -e echo "Creating session on ${TOKEN_SERVER} for room=${ROOM} username=${USERNAME}" RESP=$(curl -sS -X POST "${TOKEN_SERVER%/}/api/session" -H 'Content-Type: application/json' -d '{"room":"'"${ROOM}"'","username":"'"${USERNAME}"'"}') || true if [ -z "$RESP" ]; then echo "No response from token server" exit 1 fi echo "Session response: $RESP" ID=$(echo "$RESP" | jq -r '.id // empty') TOKEN=$(echo "$RESP" | jq -r '.token // empty') URL=$(echo "$RESP" | jq -r '.redirectUrl // .studioUrl // .url // empty') if [ -n "$TOKEN" ]; then echo "\nToken created (truncated): ${TOKEN:0:40}..." fi if [ -n "$URL" ]; then echo "Returned URL: $URL" fi # Print a Broadcast Panel friendly URL that includes token in query (useful if INCLUDE_TOKEN_IN_REDIRECT flow is enabled) if [ -n "$TOKEN" ]; then echo "\nOpen this in Broadcast Panel to auto-open the StudioPortal overlay (if it's integrated):" echo "${BROADCAST_URL}?token=${TOKEN}&url=${URL}&room=${ROOM}" fi # Also print a JS postMessage snippet you can paste in browser console to simulate the Broadcast Panel sending token to an open Broadcast/Studio page if [ -n "$TOKEN" ]; then cat <