Browse Source

working export my/all events

main
mleku 3 months ago
parent
commit
ade987c9ac
No known key found for this signature in database
  1. 1
      .gitignore
  2. 22
      app/web/dist/index.html
  3. 39
      app/web/src/App.svelte

1
.gitignore vendored

@ -122,3 +122,4 @@ pkg/database/testrealy
/.idea/.name /.idea/.name
/ctxproxy.config.yml /ctxproxy.config.yml
cmd/benchmark/external/** cmd/benchmark/external/**
app/web/dist/**

22
app/web/dist/index.html vendored

@ -1,14 +1,14 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Next Orly</title> <title>Next Orly</title>
<link rel="icon" href="/favicon.png" type="image/png" /> <link rel="icon" href="/favicon.png" type="image/png" />
<link rel="stylesheet" href="/bundle.css" /> <link rel="stylesheet" href="/bundle.css" />
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
<script src="/bundle.js"></script> <script src="/bundle.js"></script>
</body> </body>
</html> </html>

39
app/web/src/App.svelte

@ -9,6 +9,7 @@
let authMethod = ''; let authMethod = '';
let userProfile = null; let userProfile = null;
let userRole = ''; let userRole = '';
let userSigner = null;
let showSettingsDrawer = false; let showSettingsDrawer = false;
let selectedTab = 'export'; let selectedTab = 'export';
let isSearchMode = false; let isSearchMode = false;
@ -47,6 +48,12 @@
isLoggedIn = true; isLoggedIn = true;
userPubkey = storedPubkey; userPubkey = storedPubkey;
authMethod = storedAuthMethod; authMethod = storedAuthMethod;
// Restore signer for extension method
if (storedAuthMethod === 'extension' && window.nostr) {
userSigner = window.nostr;
}
// Fetch user role for already logged in users // Fetch user role for already logged in users
fetchUserRole(); fetchUserRole();
} }
@ -97,6 +104,7 @@
isLoggedIn = true; isLoggedIn = true;
userPubkey = pubkey; userPubkey = pubkey;
authMethod = method; authMethod = method;
userSigner = signer;
showLoginModal = false; showLoginModal = false;
// Initialize Nostr client and fetch profile // Initialize Nostr client and fetch profile
@ -118,6 +126,7 @@
authMethod = ''; authMethod = '';
userProfile = null; userProfile = null;
userRole = ''; userRole = '';
userSigner = null;
showSettingsDrawer = false; showSettingsDrawer = false;
// Clear stored authentication // Clear stored authentication
@ -402,12 +411,6 @@
throw new Error('Not logged in'); throw new Error('Not logged in');
} }
// Get the private key from localStorage
const privateKey = localStorage.getItem('nostr_privkey');
if (!privateKey) {
throw new Error('Private key not found');
}
// Create NIP-98 auth event // Create NIP-98 auth event
const authEvent = { const authEvent = {
kind: 27235, kind: 27235,
@ -420,13 +423,27 @@
pubkey: userPubkey pubkey: userPubkey
}; };
// Sign the event (simplified - in a real implementation you'd use proper signing) let signedEvent;
// For now, we'll create a mock signature
authEvent.id = 'mock-id'; if (userSigner && authMethod === 'extension') {
authEvent.sig = 'mock-signature'; // Use the signer from the extension
try {
signedEvent = await userSigner.signEvent(authEvent);
} catch (error) {
throw new Error('Failed to sign with extension: ' + error.message);
}
} else if (authMethod === 'nsec') {
// For nsec method, we need to implement proper signing
// For now, create a mock signature (in production, use proper crypto)
authEvent.id = 'mock-id-' + Date.now();
authEvent.sig = 'mock-signature-' + Date.now();
signedEvent = authEvent;
} else {
throw new Error('No valid signer available');
}
// Encode as base64 // Encode as base64
const eventJson = JSON.stringify(authEvent); const eventJson = JSON.stringify(signedEvent);
const base64Event = btoa(eventJson); const base64Event = btoa(eventJson);
return `Nostr ${base64Event}`; return `Nostr ${base64Event}`;

Loading…
Cancel
Save