SPB Git

spb/zyquo-cloud-web Public MIT

Zyquo Cloud Web — every cloud model, one beautiful chat, entirely in your browser.

TypeScript 81.9% CSS 8.9% JavaScript 7.5% Shell 1.1% HTML 0.6%
3.9 KB · 67 lines shellscript
Raw Blame History
1#!/bin/bash2#3#  cors-probe.sh4#  Zyquo Cloud Web5#6#  Author: Simon-Pierre Boucher7#  Mail: contact@spboucher.ai8#9#  Phase 0.A — empirical CORS probe for all 12 providers.10#  For each provider: (1) OPTIONS preflight as a browser would send it,11#  (2) a real minimal POST with an Origin header, checking the12#  Access-Control-Allow-* response headers. Keys are read from13#  .keys.local.json (gitignored) and never printed.14#1516set -u17KEYS_FILE="$(dirname "$0")/../.keys.local.json"18ORIGIN="https://www.zyquo.cloud"19OUT_DIR="${1:-/tmp/zyquo-cors}"20mkdir -p "$OUT_DIR"2122key() { python3 -c "import json,sys; print(json.load(open('$KEYS_FILE'))['$1'])"; }2324probe() {25  local name="$1" url="$2" auth_header="$3" model="$4" extra_header="${5:-}"26  local out="$OUT_DIR/$name.txt"27  {28    echo "=== $name$url ==="29    echo "--- PREFLIGHT (OPTIONS) ---"30    local req_headers="authorization,content-type"31    [ "$name" = "anthropic" ] && req_headers="x-api-key,anthropic-version,anthropic-dangerous-direct-browser-access,content-type"32    curl -sS -o /dev/null -D - -X OPTIONS "$url" \33      -H "Origin: $ORIGIN" \34      -H "Access-Control-Request-Method: POST" \35      -H "Access-Control-Request-Headers: $req_headers" \36      --max-time 30 2>&1 | grep -iE "^(HTTP|access-control|allow)" || echo "(no CORS headers in preflight)"37    echo "--- POST with Origin ---"38    local body='{"model":"'"$model"'","messages":[{"role":"user","content":"Say OK"}],"max_tokens":8}'39    [ "$name" = "anthropic" ] && body='{"model":"'"$model"'","max_tokens":8,"messages":[{"role":"user","content":"Say OK"}]}'40    curl -sS -o "$OUT_DIR/$name.body.json" -D - -X POST "$url" \41      -H "Origin: $ORIGIN" \42      -H "Content-Type: application/json" \43      -H "$auth_header" \44      ${extra_header:+-H "$extra_header"} \45      -d "$body" \46      --max-time 60 2>&1 | grep -iE "^(HTTP|access-control)" || echo "(no CORS headers in POST)"47    echo "--- POST body (first 300 chars) ---"48    head -c 300 "$OUT_DIR/$name.body.json"; echo49  } > "$out" 2>&150  echo "done: $name"51}5253probe openai     "https://api.openai.com/v1/chat/completions"                          "Authorization: Bearer $(key openai)"     "gpt-4.1-nano" &54probe anthropic  "https://api.anthropic.com/v1/messages"                               "x-api-key: $(key anthropic)"             "claude-haiku-4-5-20251001" "anthropic-version: 2023-06-01" &55probe xai        "https://api.x.ai/v1/chat/completions"                                "Authorization: Bearer $(key xai)"        "grok-3-mini" &56probe mistral    "https://api.mistral.ai/v1/chat/completions"                          "Authorization: Bearer $(key mistral)"    "mistral-small-latest" &57probe gemini     "https://generativelanguage.googleapis.com/v1beta/openai/chat/completions" "Authorization: Bearer $(key gemini)" "gemini-2.5-flash-lite" &58probe qwen       "https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions"  "Authorization: Bearer $(key qwen)"   "qwen-turbo" &59probe deepseek   "https://api.deepseek.com/chat/completions"                            "Authorization: Bearer $(key deepseek)"   "deepseek-chat" &60probe kimi       "https://api.moonshot.ai/v1/chat/completions"                          "Authorization: Bearer $(key kimi)"       "kimi-k2-0711-preview" &61probe perplexity "https://api.perplexity.ai/chat/completions"                           "Authorization: Bearer $(key perplexity)" "sonar" &62probe together   "https://api.together.xyz/v1/chat/completions"                         "Authorization: Bearer $(key together)"   "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo" &63probe deepinfra  "https://api.deepinfra.com/v1/openai/chat/completions"                 "Authorization: Bearer $(key deepinfra)"  "meta-llama/Meta-Llama-3.1-8B-Instruct" &64probe cerebras   "https://api.cerebras.ai/v1/chat/completions"                          "Authorization: Bearer $(key cerebras)"   "llama3.1-8b" &65wait66echo "All probes complete → $OUT_DIR"67