authenticating with a key in nip05 list by extention

This commit is contained in:
Chris kerr 2024-04-14 20:42:01 -04:00
parent 119eaeb574
commit 514491ea62

View File

@ -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