slashtags-contacts
Slashtags contacts management.
Install
npm install @synonymdev/slashtags-contacts
Usage
Initialize
const coreData = new SlashtagsCoreData()
const contacts = new SlashtagsContacts(coreData)
await contacts.ready()
await contacts.set('slash:kencdz6km9xde46iph165d6isidssy9uate7b6srfaur8stm5br7', { name: "Foo" })
const contact = contacts.get('slash:kencdz6km9xde46iph165d6isidssy9uate7b6srfaur8stm5br7')
for (let [id, contact] contacts.list() {
}
API
const contacts = new SlashtagsContacts(coreData)
Create a new contacts instance from a CoreData instance
await contacts.ready()
Await opening the contacts list from storage.
await contacts.set(url, contact)
Await setting the value of contact and storing it as persistent encrypted data. contact
has to be in the shape:
{
name: string,
}
const contact = contacts.get(url)
Return contact value from contact's Slashtags url.
for (let [id, contact] contacts.list() {}
Return an iterator of entries in the internal Map. id
is z-base32 endoced key of the contact. Internal map will be populated after contacts.ready()
contact.close()
Close underlying coreData instance and all subscriptions.