From ade987c9ac319775ee0c68f1660b0c4aa84534c7 Mon Sep 17 00:00:00 2001 From: mleku Date: Thu, 9 Oct 2025 15:01:14 +0100 Subject: [PATCH] working export my/all events --- .gitignore | 3 ++- app/web/dist/index.html | 24 ++++++++++++------------ app/web/src/App.svelte | 39 ++++++++++++++++++++++++++++----------- 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 35f7173..f57a6fb 100644 --- a/.gitignore +++ b/.gitignore @@ -121,4 +121,5 @@ pkg/database/testrealy /.idea/inspectionProfiles/Project_Default.xml /.idea/.name /ctxproxy.config.yml -cmd/benchmark/external/** \ No newline at end of file +cmd/benchmark/external/** +app/web/dist/** diff --git a/app/web/dist/index.html b/app/web/dist/index.html index 256329e..7cb2a8f 100644 --- a/app/web/dist/index.html +++ b/app/web/dist/index.html @@ -1,14 +1,14 @@ - - - - Next Orly - - - - -
- - - \ No newline at end of file + + + + Next Orly + + + + +
+ + + diff --git a/app/web/src/App.svelte b/app/web/src/App.svelte index ffca744..ea5109d 100644 --- a/app/web/src/App.svelte +++ b/app/web/src/App.svelte @@ -9,6 +9,7 @@ let authMethod = ''; let userProfile = null; let userRole = ''; + let userSigner = null; let showSettingsDrawer = false; let selectedTab = 'export'; let isSearchMode = false; @@ -47,6 +48,12 @@ isLoggedIn = true; userPubkey = storedPubkey; authMethod = storedAuthMethod; + + // Restore signer for extension method + if (storedAuthMethod === 'extension' && window.nostr) { + userSigner = window.nostr; + } + // Fetch user role for already logged in users fetchUserRole(); } @@ -97,6 +104,7 @@ isLoggedIn = true; userPubkey = pubkey; authMethod = method; + userSigner = signer; showLoginModal = false; // Initialize Nostr client and fetch profile @@ -118,6 +126,7 @@ authMethod = ''; userProfile = null; userRole = ''; + userSigner = null; showSettingsDrawer = false; // Clear stored authentication @@ -402,12 +411,6 @@ 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 const authEvent = { kind: 27235, @@ -420,13 +423,27 @@ pubkey: userPubkey }; - // Sign the event (simplified - in a real implementation you'd use proper signing) - // For now, we'll create a mock signature - authEvent.id = 'mock-id'; - authEvent.sig = 'mock-signature'; + let signedEvent; + + if (userSigner && authMethod === 'extension') { + // 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 - const eventJson = JSON.stringify(authEvent); + const eventJson = JSON.stringify(signedEvent); const base64Event = btoa(eventJson); return `Nostr ${base64Event}`;