Files
botfights/frontend/index.html
T
DorianandClaude Fable 5 2c039f2af3
CI / check (push) Failing after 6m19s
fix(nostr): reactive extension detection + native Archipelago signer bridge
Two fixes found during live signer-login verification:

1. hasExtension was `computed(() => !!window.nostr)` — window.nostr is a
   plain global with no Vue reactivity, so this evaluated once, lazily, on
   first read and cached forever. If the extension's content script hadn't
   injected yet at that moment (common — extensions often inject slightly
   after page scripts start), "SIGN IN WITH EXTENSION" disappeared
   permanently, even once the extension finished injecting moments later.
   Reported live as "no browser extension or signer option ever shows".
   Fixed: hasExtension is now backed by a real ref, seeded from the current
   value and upgraded by a short poll (existing waitForSigner() precedent,
   same 200ms/timeout shape) so the UI reacts when the extension actually
   appears.

2. Added Archipelago's native NIP-07 signer bridge (frontend/public/
   nostr-provider.js, copied verbatim from neode-ui/public/nostr-provider.js
   — the canonical source) via a <script> tag in index.html. This no-ops
   immediately outside an iframe (window === window.top), so a real browser
   extension in a standalone tab is unaffected. Inside the Archipelago node
   dashboard's iframe, it provides window.nostr backed by the node's own
   identity via postMessage to
   neode-ui/src/views/appSession/useNostrBridge.ts (already generic — no
   per-app allowlist needed for the getPublicKey/signEvent bridge itself,
   only for the optional auto-login/identity-picker convenience flow, which
   this app doesn't use). Existing login() flow (buildNip98Token ->
   POST /api/auth/nostr/session) works unchanged through this bridge.

Together: signing in now works reliably both in the dashboard iframe (no
extension needed at all) and in a direct tab (real extension, now reliably
detected).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-31 06:58:53 -04:00

39 lines
2.0 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<title>BOTFIGHTS -- A safe place to hash it out</title>
<meta name="description" content="A safe place to hash it out" />
<meta name="theme-color" content="#0a0a0a" />
<link rel="icon" href="/favicon.ico" sizes="32x32" />
<link rel="icon" href="/icon.svg" type="image/svg+xml" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="BOTFIGHTS" />
<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=Press+Start+2P&family=Orbitron:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;700&family=Bungee+Shade&family=Monoton&family=Permanent+Marker&family=Rubik+Glitch&family=Honk&family=Silkscreen:wght@400;700&display=swap"
rel="stylesheet"
/>
</head>
<body class="bg-black text-white min-h-screen antialiased">
<div id="app"></div>
<!--
Archipelago's native NIP-07 signer bridge. No-ops immediately when this
page is the top-level document (window === window.top) — a real
browser extension is used in that case, unchanged. When embedded in
the Archipelago node dashboard's iframe, it provides window.nostr via
postMessage to the parent, which signs with the node's own identity
(see neode-ui/src/views/appSession/useNostrBridge.ts — canonical
source of this file is neode-ui/public/nostr-provider.js, kept in
sync manually; both must be under CSP script-src 'self', which this
is since it's built into this app's own static assets).
-->
<script src="/nostr-provider.js"></script>
<script type="module" src="/src/main.ts"></script>
</body>
</html>