From 514491ea62f8907995c65552287e947e4e341b64 Mon Sep 17 00:00:00 2001 From: Chris kerr Date: Sun, 14 Apr 2024 20:42:01 -0400 Subject: [PATCH] authenticating with a key in nip05 list by extention --- index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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