update
This commit is contained in:
@@ -1,42 +1,187 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>NIP-07 Proxy</title>
|
<meta charset="UTF-8">
|
||||||
<link rel="stylesheet" href="style.css">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Coop — Web Signer Proxy</title>
|
||||||
|
<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=Nunito:wght@800;900&display=swap" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
|
:root {
|
||||||
|
--brand: #F8FF37;
|
||||||
|
--ink: #111111;
|
||||||
|
--ink-soft: #333333;
|
||||||
|
--muted: #666666;
|
||||||
|
--paper: #FFFFFF;
|
||||||
|
--edge: rgba(17, 17, 17, 0.14);
|
||||||
|
--radius-sm: 1rem;
|
||||||
|
--radius-md: 1.5rem;
|
||||||
|
--radius-lg: 2.5rem;
|
||||||
|
--green: #2E8B57;
|
||||||
|
--red: #D32F2F;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
margin: 0;
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: Arial, sans-serif;
|
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||||
padding: 20px;
|
color: var(--ink);
|
||||||
background-color: #f0f0f0;
|
background: var(--brand);
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 2rem;
|
||||||
}
|
}
|
||||||
.container {
|
|
||||||
max-width: 600px;
|
.card {
|
||||||
margin: 0 auto;
|
background: var(--paper);
|
||||||
background: white;
|
border-radius: var(--radius-md);
|
||||||
padding: 20px;
|
padding: 2.5rem;
|
||||||
border-radius: 8px;
|
max-width: 440px;
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
width: 100%;
|
||||||
|
box-shadow: 0 8px 0 rgba(17, 17, 17, 0.12), 0 2px 20px rgba(17, 17, 17, 0.06);
|
||||||
}
|
}
|
||||||
.status-box {
|
|
||||||
background: #f9f9f9;
|
.logo {
|
||||||
padding: 10px;
|
display: flex;
|
||||||
border-radius: 4px;
|
align-items: center;
|
||||||
margin: 10px 0;
|
gap: 0.6rem;
|
||||||
border-left: 4px solid #ccc;
|
margin-bottom: 1.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo__mark {
|
||||||
|
width: 2.5rem;
|
||||||
|
height: 2.5rem;
|
||||||
|
background: var(--ink);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-family: "Nunito", system-ui, sans-serif;
|
||||||
|
font-weight: 900;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
color: var(--brand);
|
||||||
|
letter-spacing: -0.02em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo__text {
|
||||||
|
font-family: "Nunito", system-ui, sans-serif;
|
||||||
|
font-weight: 900;
|
||||||
|
font-size: 1.3rem;
|
||||||
|
letter-spacing: -0.02em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heading {
|
||||||
|
font-family: "Nunito", system-ui, sans-serif;
|
||||||
|
font-weight: 900;
|
||||||
|
font-size: 1.6rem;
|
||||||
|
letter-spacing: -0.03em;
|
||||||
|
line-height: 1.15;
|
||||||
|
margin: 0 0 0.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: var(--ink-soft);
|
||||||
|
margin: 0 0 1.75rem;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
transition: background 300ms ease, color 300ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status--checking {
|
||||||
|
background: rgba(17, 17, 17, 0.05);
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status--connected {
|
||||||
|
background: rgba(46, 139, 87, 0.1);
|
||||||
|
color: var(--green);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status--error {
|
||||||
|
background: rgba(211, 47, 47, 0.08);
|
||||||
|
color: var(--red);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status__dot {
|
||||||
|
width: 0.7rem;
|
||||||
|
height: 0.7rem;
|
||||||
|
border-radius: 50%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status--checking .status__dot {
|
||||||
|
background: var(--muted);
|
||||||
|
animation: pulse 1.2s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status--connected .status__dot {
|
||||||
|
background: var(--green);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status--error .status__dot {
|
||||||
|
background: var(--red);
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse {
|
||||||
|
0%, 100% { opacity: 0.4; transform: scale(0.85); }
|
||||||
|
50% { opacity: 1; transform: scale(1); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.hint {
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
padding-top: 1.25rem;
|
||||||
|
border-top: 1px solid var(--edge);
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: var(--muted);
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hint strong {
|
||||||
|
color: var(--ink-soft);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="card">
|
||||||
<h1>NIP-07 Proxy</h1></h1>
|
<div class="logo">
|
||||||
<p>This page acts</p> as a proxy between your native application and the NIP-07 browser extension.</p>
|
<div class="logo__mark">C</div>
|
||||||
<div class="status-box">
|
<span class="logo__text">Coop</span>
|
||||||
<strong></strong>Status:</strong> <span id="nip07-proxy-status">Checking...</span>
|
|
||||||
</div>
|
</div>
|
||||||
<p><small></small>Keep this tab open while using your application. The page will automatically poll for requests from your native app.</small></p>
|
|
||||||
|
|
||||||
<h3>Debug</h3> Info</h3>
|
<h1 class="heading">Web Signer</h1>
|
||||||
<p><small>Check</small> the browser console (F12) for detailed logs.</small></p>
|
<p class="subtitle">
|
||||||
|
This page connects the app to your Nostr Web Signer extension so you can sign in and use Coop securely.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div id="nip07-status" class="status status--checking">
|
||||||
|
<div class="status__dot"></div>
|
||||||
|
<span id="nip07-status-text">Checking extension…</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hint">
|
||||||
|
<strong>Keep this tab open</strong> while using the app — it automatically handles sign-in requests in the background.
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="proxy.js"></script>
|
<script src="proxy.js"></script>
|
||||||
|
|||||||
@@ -129,13 +129,12 @@ async function handleNip07Request(request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateStatus(message, status) {
|
function updateStatus(message, state) {
|
||||||
const statusEl = document.getElementById('nip07-proxy-status');
|
const container = document.getElementById('nip07-status');
|
||||||
if (statusEl) {
|
const textEl = document.getElementById('nip07-status-text');
|
||||||
statusEl.textContent = message;
|
if (container && textEl) {
|
||||||
statusEl.style = status === "connected" ?
|
container.className = 'status status--' + state;
|
||||||
"color: green; font-weight: bold;" :
|
textEl.textContent = message;
|
||||||
"color: red; font-weight: bold;";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,10 +145,10 @@ window.addEventListener('load', () => {
|
|||||||
// Check if NIP-07 extension is available
|
// Check if NIP-07 extension is available
|
||||||
if (window.nostr) {
|
if (window.nostr) {
|
||||||
console.log('NIP-07 extension detected');
|
console.log('NIP-07 extension detected');
|
||||||
updateStatus('Connected to NIP-07 extension - Ready', 'connected');
|
updateStatus('Connected — ready', 'connected');
|
||||||
} else {
|
} else {
|
||||||
console.log('NIP-07 extension not found');
|
console.log('NIP-07 extension not found');
|
||||||
updateStatus('NIP-07 extension not found', 'error');
|
updateStatus('No NIP-07 extension found', 'error');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start polling every 500 ms
|
// Start polling every 500 ms
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ nostr-sdk.workspace = true
|
|||||||
nostr-gossip-memory.workspace = true
|
nostr-gossip-memory.workspace = true
|
||||||
nostr-blossom.workspace = true
|
nostr-blossom.workspace = true
|
||||||
nostr-connect.workspace = true
|
nostr-connect.workspace = true
|
||||||
browser-signer-proxy = { path = "../browser-signer-proxy" }
|
|
||||||
|
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
instant.workspace = true
|
instant.workspace = true
|
||||||
@@ -29,6 +28,7 @@ mime_guess = "2.0.4"
|
|||||||
nostr-memory.workspace = true
|
nostr-memory.workspace = true
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
|
browser-signer-proxy = { path = "../browser-signer-proxy" }
|
||||||
nostr-lmdb.workspace = true
|
nostr-lmdb.workspace = true
|
||||||
smol.workspace = true
|
smol.workspace = true
|
||||||
gpui_tokio.workspace = true
|
gpui_tokio.workspace = true
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use anyhow::{Error, anyhow};
|
use anyhow::{Error, anyhow};
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use browser_signer_proxy::prelude::*;
|
use browser_signer_proxy::prelude::*;
|
||||||
use common::config_dir;
|
use common::config_dir;
|
||||||
use gpui::{App, AppContext, Context, Entity, EventEmitter, Global, Task, Window};
|
use gpui::{App, AppContext, Context, Entity, EventEmitter, Global, Task, Window};
|
||||||
@@ -265,6 +266,7 @@ impl NostrRegistry {
|
|||||||
cx.notify();
|
cx.notify();
|
||||||
})?;
|
})?;
|
||||||
} else if content == "proxy" {
|
} else if content == "proxy" {
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| {
|
||||||
this.connect_proxy(cx);
|
this.connect_proxy(cx);
|
||||||
})?;
|
})?;
|
||||||
@@ -314,6 +316,7 @@ impl NostrRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Start the browser proxy
|
/// Start the browser proxy
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub fn connect_proxy(&mut self, cx: &mut Context<Self>) {
|
pub fn connect_proxy(&mut self, cx: &mut Context<Self>) {
|
||||||
let proxy = BrowserSignerProxy::new(BrowserSignerProxyOptions::default());
|
let proxy = BrowserSignerProxy::new(BrowserSignerProxyOptions::default());
|
||||||
let (tx, rx) = flume::bounded::<String>(1);
|
let (tx, rx) = flume::bounded::<String>(1);
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ impl ImportIdentity {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fn proxy(&mut self, cx: &mut Context<Self>) {
|
fn proxy(&mut self, cx: &mut Context<Self>) {
|
||||||
let nostr = NostrRegistry::global(cx);
|
let nostr = NostrRegistry::global(cx);
|
||||||
nostr.update(cx, |this, cx| {
|
nostr.update(cx, |this, cx| {
|
||||||
@@ -209,6 +210,7 @@ impl Render for ImportIdentity {
|
|||||||
const BUNKER_WARN: &str = "Nostr Connect will usually take more time to get all your messages. Please keep your session open until you see all your messages.";
|
const BUNKER_WARN: &str = "Nostr Connect will usually take more time to get all your messages. Please keep your session open until you see all your messages.";
|
||||||
const KEY_WARN: &str = "Coop won't store your identity key on the local device. You need to re-login again in the next session. You can use Nostr Connect for persistent login.";
|
const KEY_WARN: &str = "Coop won't store your identity key on the local device. You need to re-login again in the next session. You can use Nostr Connect for persistent login.";
|
||||||
|
|
||||||
|
let is_wasm = cfg!(target_arch = "wasm32");
|
||||||
let require_password = self.key_input.read(cx).value().starts_with("ncryptsec1");
|
let require_password = self.key_input.read(cx).value().starts_with("ncryptsec1");
|
||||||
let key_warning = self.key_input.read(cx).value().starts_with("nsec1") || require_password;
|
let key_warning = self.key_input.read(cx).value().starts_with("nsec1") || require_password;
|
||||||
let bunker_warning = self.key_input.read(cx).value().starts_with("bunker://");
|
let bunker_warning = self.key_input.read(cx).value().starts_with("bunker://");
|
||||||
@@ -265,7 +267,8 @@ impl Render for ImportIdentity {
|
|||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.child(divider(cx))
|
.child(divider(cx))
|
||||||
.child(
|
.when(!is_wasm, |this| {
|
||||||
|
this.child(
|
||||||
Button::new("proxy")
|
Button::new("proxy")
|
||||||
.label("Connect via Web Extension (Experimental)")
|
.label("Connect via Web Extension (Experimental)")
|
||||||
.ghost_alt()
|
.ghost_alt()
|
||||||
@@ -275,6 +278,7 @@ impl Render for ImportIdentity {
|
|||||||
this.proxy(cx);
|
this.proxy(cx);
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
})
|
||||||
.when_some(self.error.read(cx).as_ref(), |this, error| {
|
.when_some(self.error.read(cx).as_ref(), |this, error| {
|
||||||
this.child(
|
this.child(
|
||||||
div()
|
div()
|
||||||
|
|||||||
Reference in New Issue
Block a user