Something went wrong. Try again.
Web frontend and supporting services for lance.blue
Something went wrong. Try again.
1.6 kB · 39 lines
Shell
12345678910111213141516171819202122232425262728293031323334353637383940#!/usr/bin/env bash# Seeds a signed-in session into a scripts/dev-instance.sh instance and# prints the cookie value - the piece devauth.ts's VITE_LOCAL_AUTH=1 does# not cover, since it fakes only the frontend's sign-in and never touches# headquarters-api, so a screen that calls the API as a signed-in player# still sees no session under it.## scripts/dev-session.sh STATE_DIR [DID] [HANDLE]## STATE_DIR is what `dev-instance.sh start` printed. DID defaults to a fixed# obviously-fake one; HANDLE is optional and, if given, also seeds an# `account` row so the UI has a real-looking handle to show instead of the# raw DID.## Prints exactly one line to stdout: the cookie value. Use it as a `Cookie:# headquarters_session=<value>` header, or as a raw `document.cookie`# equivalent injected at the network layer - it is HttpOnly, so page# JavaScript cannot set it itself.set -euo pipefail
cd "$(dirname "$0")/.."
state_dir="${1:?usage: $0 STATE_DIR [DID] [HANDLE]}"did="${2:-}"handle="${3:-}"
[ -f "$state_dir/db.sqlite" ] || { echo "dev-session: $state_dir/db.sqlite does not exist - did dev-instance.sh start run first?" >&2 exit 1}
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$HOME/.cache/lance-blue-target}"export DEV_SESSION_DB="$state_dir/db.sqlite"export SESSION_SECRET="${SESSION_SECRET:-0123456789abcdef0123456789abcdef}"[ -n "$did" ] && export DEV_SESSION_DID="$did"[ -n "$handle" ] && export DEV_SESSION_HANDLE="$handle"
cargo build -p headquarters-api --bin dev_session -j 2 >&2"$CARGO_TARGET_DIR/debug/dev_session"