#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# shellcheck source=../lib/common.sh
source "${ROOT}/lib/common.sh"

# Optional TOKEN: when set, response may include allowCredentials for that user.
if [[ -n "${TOKEN:-}" ]]; then
  curl -sS -X POST "${AUTH_BASE}/passkey/generate-authenticate-options" \
    -H "Authorization: Bearer ${TOKEN}" \
    -H "Content-Type: application/json" \
    -d '{}' | pretty
else
  curl -sS -X POST "${AUTH_BASE}/passkey/generate-authenticate-options" \
    -H "Content-Type: application/json" \
    -d '{}' | pretty
fi
