diff --git a/index.js b/index.js index b9b429b..4174855 100644 --- a/index.js +++ b/index.js @@ -35,9 +35,9 @@ async function login() { // Fetch user profile const userProfile = await fetchUserProfile(user.npub, ndk); - const displayName = userProfile.profile.displayName; + const nip05 = userProfile.profile.nip05; - console.log("User's display name:", displayName); + console.log("User's nip05:", nip05); // Check if user's public key exists in the nostr.json const nostrJsonResponse = await fetch('/.well-known/nostr.json'); @@ -47,7 +47,13 @@ async function login() { const nostrJson = await nostrJsonResponse.json(); console.log("nostrJson object:", nostrJson); - if (nostrJson.names[displayName] === user.pubkey) { + // Extract the username from the NIP-05 identifier + const nip05Username = nip05.split('@')[0]; + + //TODO AUTHENTICATE USER AND SEND TO UPLOAD// + //PROBABLY NEED SESSION MANAGEMENT TO ENSURE SECURE UPLOAD + //AND TO REMEMBER LOGIN + if (nostrJson.names[nip05Username] === user.pubkey) { // User exists in nostr.json, proceed with further authentication or actions console.log('User authenticated successfully.'); // Redirect or show UI for file upload