Stomp connected: CONNECTED user-name:1920240 heart-beat:0,0 version:1.2 content-length:0

index-DWOj3h1o.js:10 WebSocket: subscribed to: /topic/lobby index-DWOj3h1o.js:10 WebSocket: subscribed to: /user/topic/game index-DWOj3h1o.js:10 WebSocket: subscribed to: /user/topic/game/instance/b9d551c1-6885-11f1-aebc-f53e107f214b


WebSocket: subscribed to: /user/topic/game/instance/faf364e6-6885-11f1-aebc-95ae51a656f5 GameViewWrapper-DvvSVPf3.js:16 request to timer update on focus index-DWOj3h1o.js:10 WebSocket: subscribed to: /user/topic/game/instance/faf364e6-6885-11f1-aebc-95ae51a656f5 GameViewWrapper-DvvSVPf3.js:6 coordToPiece rebuild Proxy(Array) {0: Array(8), 1: Array(8), 2: Array(8), 3: Array(8), 4: Array(8), 5: Array(8), 6: Array(8), 7: Array(8)} GameViewWrapper-DvvSVPf3.js:6 coordToPiece rebuild Proxy(Array) {0: Array(8), 1: Array(8), 2: Array(8), 3: Array(8), 4: Array(8), 5: Array(8), 6: Array(8), 7: Array(8)} index-DWOj3h1o.js:10 game: Proxy(qt) {id: ‘faf364e6-6885-11f1-aebc-95ae51a656f5’, board: ‘rnbqkb1r/pppppppp/8/7n/4P2P/R7/PPPPBPP1/RNBK2N1’, _boardLocal: ‘rnbqkb1r/pppppppp/8/7n/4P2P/R7/PPPPBPP1/RNBK2N1’, _wasRebuilt: false, _dices: Array(0), …} faf364e6-6885-11f1-aebc-95ae51a656f5 Proxy(Object) {faf364e6-6885-11f1-aebc-95ae51a656f5: qt} index-DWOj3h1o.js:10 game: Proxy(qt) {id: ‘faf364e6-6885-11f1-aebc-95ae51a656f5’, board: ‘rnbqkb1r/pppppppp/8/7B/4P2P/R7/PPPP1PP1/RNBK2N1’, _boardLocal: ‘rnbqkb1r/pppppppp/8/7B/4P2P/R7/PPPP1PP1/RNBK2N1’, _wasRebuilt: false, _dices: Array(3), …} faf364e6-6885-11f1-aebc-95ae51a656f5 Proxy(Object) {faf364e6-6885-11f1-aebc-95ae51a656f5: qt}

(async () => {
  const j = async (u) => {
    const r = await fetch(u, { headers: { Accept: 'application/json' } });
    let b; try { b = await r.json(); } catch { b = await r.text(); }
    return { status: r.status, body: b };
  };
 
  // U1 + U3: список идущих партий
  const active = await j('/api/games/active');
  console.log('=== /api/games/active ===', active.status);
  const list = Array.isArray(active.body) ? active.body
    : (active.body?.games || active.body?.content || active.body?.list || active.body);
  console.log('count:', Array.isArray(list) ? list.length : '(не массив)');
  console.log('sample[0]:', JSON.stringify(Array.isArray(list) ? list[0] : list, null, 2));
 
  // U2: канон по ОДНОЙ завершённой партии — впиши id:
  const gameId = '910b1a3f-2e19-11f1-aff2-c5662bc51b05';
  if (gameId !== 'ВПИШИ_ЗАВЕРШЁННЫЙ_GAMEID') {
    const h = await j('/api/game-move-history?gameId=' + encodeURIComponent(gameId));
    console.log('=== /api/game-move-history ===', h.status);
    console.log('top-level keys:', h.body && typeof h.body === 'object' ? Object.keys(h.body) : h.body);
    const map = h.body?.gameMoveHistoryStateMap;
    if (map) {
      const ks = Object.keys(map);
      console.log('state entries:', ks.length);
      console.log('first:', JSON.stringify(map[ks[0]], null, 2));
      console.log('with-move:', JSON.stringify(Object.values(map).find(v => v?.gameMoveHistoryMove), null, 2));
    }
  }
})();
(async () => {
  const j = async (u, opts) => {
    const r = await fetch(u, opts);
    const t = await r.text();
    let b; try { b = JSON.parse(t); } catch { b = t; }
    return { status: r.status, body: b, raw: t };
  };
  const looksJwt = v => typeof v === 'string' &&
    /^(Bearer\s+)?[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(v.trim());
  const findToken = () => {
    for (const s of [localStorage, sessionStorage]) for (let i = 0; i < s.length; i++) {
      const v = s.getItem(s.key(i));
      if (looksJwt(v)) return v.trim();
      if (v && v[0] === '{') { try { for (const x of Object.values(JSON.parse(v))) if (looksJwt(x)) return String(x).trim(); } catch {} }
    }
    for (const p of document.cookie.split(';')) {
      const v = decodeURIComponent(p.split('=').slice(1).join('=').trim());
      if (looksJwt(v)) return v;
    }
    return null;
  };
  const tok = findToken();
  const auth = tok ? (/^Bearer\s/i.test(tok) ? tok : 'Bearer ' + tok) : undefined;
  const headers = { Accept: 'application/json', ...(auth ? { Authorization: auth } : {}) };
  console.log('JWT:', tok ? 'найден ' + tok.slice(0, 10) + '…' : 'НЕ найден');

  const diag = (name, res) => {
    console.log(`=== ${name} ===`, res.status);
    if (res.status !== 200) {
      const s = (res.raw || '').slice(0, 300);
      console.log('body[0:300]:', s);
      console.log(/just a moment|challenge|cloudflare|cf-/i.test(s) ? '→ CLOUDFLARE' : '→ ошибка ПРИЛОЖЕНИЯ (скорее всего auth)');
      return false;
    }
    return true;
  };

  const active = await j('/api/games/active', { headers });
  if (diag('/api/games/active', active)) {
    const list = Array.isArray(active.body) ? active.body
      : (active.body?.games || active.body?.content || active.body?.list || active.body);
    console.log('count:', Array.isArray(list) ? list.length : '(не массив)');
    console.log('sample[0]:', JSON.stringify(Array.isArray(list) ? list[0] : list, null, 2));
  }

  const gameId = '910b1a3f-2e19-11f1-aff2-c5662bc51b05';
  if (gameId !== 'ВПИШИ_ЗАВЕРШЁННЫЙ_GAMEID') {
    const h = await j('/api/game-move-history?gameId=' + encodeURIComponent(gameId), { headers });
    if (diag('/api/game-move-history', h)) {
      console.log('top-level keys:', Object.keys(h.body));
      const map = h.body?.gameMoveHistoryStateMap, ks = map ? Object.keys(map) : [];
      console.log('state entries:', ks.length);
      if (ks.length) {
        console.log('first:', JSON.stringify(map[ks[0]], null, 2));
        console.log('with-move:', JSON.stringify(Object.values(map).find(v => v?.gameMoveHistoryMove), null, 2));
      }
    }
  }
})();