storing contact details works

This commit is contained in:
counterweight 2025-02-14 01:32:03 +01:00
parent 00fc6bb258
commit 6b52d06b3e
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
10 changed files with 138 additions and 15 deletions

View file

@ -45,6 +45,12 @@ class ContactDetails {
return fragment;
}
async getEncryptedContactDetails() {
const jsonString = JSON.stringify(this.details);
const encryptedContactDetails = await window.nostr.nip04.encrypt(await window.nostr.getPublicKey(), jsonString);
return encryptedContactDetails;
}
}
let contactDetails;
@ -67,4 +73,21 @@ window.onload = () => {
input.value = '';
});
});
document
.querySelector('#submit-details-button')
.addEventListener(
'click',
async () => {
const encryptedContactDetails = await contactDetails.getEncryptedContactDetails();
await fetch('/api/set-contact-details',
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ encryptedContactDetails })
});
}
);
};