Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

5.2 KB
Raw Blame
<!doctype html>
<html lang="en" data-theme="night">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Xerj Console · sign in</title>
<meta name="color-scheme" content="dark light">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@800;900&family=JetBrains+Mono:wght@400;500&family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/tokens.css">
<link rel="stylesheet" href="assets/base.css">
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ctext y='13' font-family='monospace' font-size='14' font-weight='900' fill='%23EEBB00'%3Ez%3C/text%3E%3C/svg%3E">
<style>
  body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 2rem;
  }
  .auth-card {
    background: var(--bg-surface, #15171a);
    border: 1px solid var(--border, #2a2d33);
    border-radius: 8px; padding: 2rem;
    max-width: 420px; width: 100%;
    color: var(--fg, #e6e8eb);
  }
  .auth-card h1 {
    font-family: 'Big Shoulders Display', sans-serif;
    font-weight: 900; font-size: 2.25rem; letter-spacing: -0.02em;
    margin: 0 0 .25rem; color: #EEBB00;
  }
  .auth-card p.lead { color: var(--fg-mute, #8a8e95); margin: 0 0 1.5rem; }
  label { display: block; font-weight: 500; margin: 1rem 0 .25rem; font-size: 0.875rem; }
  input[type="email"] {
    width: 100%; padding: 0.625rem 0.75rem;
    background: var(--bg, #0c0d10);
    border: 1px solid var(--border, #2a2d33);
    border-radius: 4px; color: var(--fg, #e6e8eb);
    font-family: inherit; font-size: 0.9rem;
  }
  input:focus { outline: 2px solid #EEBB00; outline-offset: 1px; }
  button {
    background: #EEBB00; color: #0c0d10;
    border: none; padding: 0.75rem 1.5rem;
    font-weight: 600; border-radius: 4px;
    cursor: pointer; margin-top: 1.5rem;
    font-family: inherit; font-size: 0.9rem;
    width: 100%;
  }
  button:disabled { opacity: 0.5; cursor: not-allowed; }
  .err {
    background: #3a1a1a; color: #ff8a8a;
    padding: 0.75rem 1rem; border-radius: 4px;
    margin: 1rem 0; font-size: 0.875rem;
    font-family: 'JetBrains Mono', monospace;
  }
  .footnote {
    color: var(--fg-mute, #8a8e95);
    font-size: 0.8rem; margin-top: 1.5rem;
    text-align: center;
  }
  .footnote a { color: #EEBB00; text-decoration: none; }
</style>
</head>
<body>
  <div class="auth-card">
    <h1>XERJ CONSOLE</h1>
    <p class="lead">Sign in with your passkey.</p>

    <div id="err" class="err" hidden></div>

    <form id="form" autocomplete="on">
      <label for="email">Email</label>
      <input id="email" type="email" placeholder="[email protected]" required autocomplete="email username webauthn">

      <button type="submit" id="btn">Sign in</button>
    </form>

    <p class="footnote">
      First launch has no passkey yet. The node printed a one-time setup link
      when it started — open that URL (it contains <code>#token=</code>).
      A restart prints a new link while the owner account is still unclaimed.
    </p>
  </div>

<script type="module">
import { beginLogin, finishLogin, b64uToBuf, bufToB64u } from './src/xerj-console-auth.js';
import { takeNext } from './src/data/next-route.js';

const $err = document.getElementById('err');
const $form = document.getElementById('form');
const $btn = document.getElementById('btn');
const $email = document.getElementById('email');

function showError(msg) {
  $err.textContent = msg; $err.hidden = false;
}

$form.addEventListener('submit', async (ev) => {
  ev.preventDefault();
  $err.hidden = true;
  $btn.disabled = true;
  $btn.textContent = 'Authenticating…';

  try {
    const email = $email.value.trim();
    if (!email) throw new Error('Email is required.');

    const begin = await beginLogin(email);
    const opts = JSON.parse(JSON.stringify(begin.request_options.publicKey));
    opts.challenge = b64uToBuf(opts.challenge);
    if (opts.allowCredentials) {
      for (const c of opts.allowCredentials) c.id = b64uToBuf(c.id);
    }

    const cred = await navigator.credentials.get({ publicKey: opts });
    if (!cred) throw new Error('Browser returned no credential.');

    const ass = cred.response;
    const credPayload = {
      id: cred.id,
      rawId: bufToB64u(cred.rawId),
      type: cred.type,
      response: {
        clientDataJSON:    bufToB64u(ass.clientDataJSON),
        authenticatorData: bufToB64u(ass.authenticatorData),
        signature:         bufToB64u(ass.signature),
        userHandle:        ass.userHandle ? bufToB64u(ass.userHandle) : null,
      },
      extensions: cred.getClientExtensionResults ? cred.getClientExtensionResults() : {},
    };

    await finishLogin(begin.challenge_id, credPayload);
    // Back to the deep link that sent the person here (boot.js stashed it);
    // takeNext only ever returns an in-console `#/…` route, or ''.
    window.location.href = '/_xerj-console/' + takeNext(window.sessionStorage);
  } catch (e) {
    showError(e.message || String(e));
    $btn.disabled = false;
    $btn.textContent = 'Sign in';
  }
});
</script>
</body>
</html>