@@ -696,11 +696,11 @@ <h3>${titleCased}</h3>
696696 content : ''
697697 } ;
698698
699- authEvent . id = nostrTools . getEventHash ( authEvent ) ;
700- authEvent . sig = nostrTools . getSignature ( authEvent , privkey ) ;
699+ // Use finalizeEvent which hashes and signs
700+ const signedEvent = nostrTools . finalizeEvent ( authEvent , nostrTools . hexToBytes ( privkey ) ) ;
701701
702702 // Base64 encode the event
703- const authHeader = 'Nostr ' + btoa ( JSON . stringify ( authEvent ) ) ;
703+ const authHeader = 'Nostr ' + btoa ( JSON . stringify ( signedEvent ) ) ;
704704
705705 // Add auth header
706706 const authHeaders = {
@@ -714,11 +714,10 @@ <h3>${titleCased}</h3>
714714 }
715715
716716 async function publishNostrEvent ( commit ) {
717- const pubkey = nostrTools . getPublicKey ( privkey ) ;
717+ const secretKey = nostrTools . hexToBytes ( privkey ) ;
718718
719- const event = {
719+ const eventTemplate = {
720720 kind : 30618 ,
721- pubkey,
722721 created_at : Math . floor ( Date . now ( ) / 1000 ) ,
723722 tags : [
724723 [ 'd' , REPO_ID ] ,
@@ -727,16 +726,15 @@ <h3>${titleCased}</h3>
727726 content : ''
728727 } ;
729728
730- event . id = nostrTools . getEventHash ( event ) ;
731- event . sig = nostrTools . getSignature ( event , privkey ) ;
729+ const signedEvent = nostrTools . finalizeEvent ( eventTemplate , secretKey ) ;
732730
733731 // Publish to relays
734732 for ( const url of RELAYS ) {
735733 try {
736734 const ws = new WebSocket ( url ) ;
737735 await new Promise ( ( resolve , reject ) => {
738736 ws . onopen = ( ) => {
739- ws . send ( JSON . stringify ( [ 'EVENT' , event ] ) ) ;
737+ ws . send ( JSON . stringify ( [ 'EVENT' , signedEvent ] ) ) ;
740738 setTimeout ( ( ) => { ws . close ( ) ; resolve ( ) ; } , 1000 ) ;
741739 } ;
742740 ws . onerror = reject ;
0 commit comments