@@ -352,7 +352,8 @@ <h1>📝 Live Notes</h1>
352352 < div id ="keyPanel " class ="key-panel ">
353353 < label > Nostr Private Key (hex)</ label >
354354 < input type ="password " id ="privkeyInput " placeholder ="Enter your private key to enable editing... " oninput ="onPrivkeyChange() ">
355- < div class ="hint "> Your key is stored locally and used to sign commits and Nostr events.</ div >
355+ < div class ="hint "> Your key is stored locally and used to sign commits and Nostr events.< br >
356+ For testing: < code style ="font-size:11px;color:#a78bfa; "> 07f689807708ca937e1fdbea750ea70802fdec379f890306f6dc4716d0798948</ code > </ div >
356357 < div id ="pubkeyDisplay " class ="pubkey "> </ div >
357358 </ div >
358359
@@ -629,15 +630,14 @@ <h3>${titleCased}</h3>
629630
630631 showSaving ( 'Pushing to server...' ) ;
631632
632- // Push to remote
633- const http = createHttpClient ( ) ;
633+ // Push to remote with NIP-98 auth
634+ const http = createNip98HttpClient ( privkey ) ;
634635 await git . push ( {
635636 fs,
636637 http,
637638 dir,
638639 url : REPO ,
639- ref : 'main' ,
640- onAuth : ( ) => ( { username : privkey , password : '' } )
640+ ref : 'main'
641641 } ) ;
642642
643643 showSaving ( 'Publishing to Nostr...' ) ;
@@ -676,6 +676,43 @@ <h3>${titleCased}</h3>
676676 }
677677 } ;
678678
679+ // Create HTTP client with NIP-98 auth for git operations
680+ function createNip98HttpClient ( privkey ) {
681+ const baseHttp = createHttpClient ( ) ;
682+
683+ return {
684+ async request ( { url, method, headers, body } ) {
685+ // Create NIP-98 auth event
686+ const pubkey = nostrTools . getPublicKey ( privkey ) ;
687+
688+ const authEvent = {
689+ kind : 27235 ,
690+ pubkey,
691+ created_at : Math . floor ( Date . now ( ) / 1000 ) ,
692+ tags : [
693+ [ 'u' , url ] ,
694+ [ 'method' , method || 'GET' ]
695+ ] ,
696+ content : ''
697+ } ;
698+
699+ authEvent . id = nostrTools . getEventHash ( authEvent ) ;
700+ authEvent . sig = nostrTools . getSignature ( authEvent , privkey ) ;
701+
702+ // Base64 encode the event
703+ const authHeader = 'Nostr ' + btoa ( JSON . stringify ( authEvent ) ) ;
704+
705+ // Add auth header
706+ const authHeaders = {
707+ ...headers ,
708+ 'Authorization' : authHeader
709+ } ;
710+
711+ return baseHttp . request ( { url, method, headers : authHeaders , body } ) ;
712+ }
713+ } ;
714+ }
715+
679716 async function publishNostrEvent ( commit ) {
680717 const pubkey = nostrTools . getPublicKey ( privkey ) ;
681718
0 commit comments