authenticating with a key in nip05 list by extention
This commit is contained in:
parent
119eaeb574
commit
514491ea62
12
index.js
12
index.js
@ -35,9 +35,9 @@ async function login() {
|
|||||||
|
|
||||||
// Fetch user profile
|
// Fetch user profile
|
||||||
const userProfile = await fetchUserProfile(user.npub, ndk);
|
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
|
// Check if user's public key exists in the nostr.json
|
||||||
const nostrJsonResponse = await fetch('/.well-known/nostr.json');
|
const nostrJsonResponse = await fetch('/.well-known/nostr.json');
|
||||||
@ -47,7 +47,13 @@ async function login() {
|
|||||||
const nostrJson = await nostrJsonResponse.json();
|
const nostrJson = await nostrJsonResponse.json();
|
||||||
console.log("nostrJson object:", nostrJson);
|
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
|
// User exists in nostr.json, proceed with further authentication or actions
|
||||||
console.log('User authenticated successfully.');
|
console.log('User authenticated successfully.');
|
||||||
// Redirect or show UI for file upload
|
// Redirect or show UI for file upload
|
||||||
|
Loading…
Reference in New Issue
Block a user