your-user v1.1.12
your-user
A Library to manage users within the Solid architecture.
Dependencies
This library is dependent on:
Functionalities
- Listing profile Information
- Listing/Adding/Removing friends
- Listing messages
Usage:
To make use of the functionality in this library you will have to instantiate a User Object with the webId of the User want to use:
const user = new User("https://user.example.org/profile/card#me");
Listing Profile Information
There are several methods to get information from a users profile:
.getName()
to get the name of the user (FOAF('name') or VCARD('fn')).getBio()
to get the bio of the user (VCARD('note')).getJob()
to get the job of the user (VCARD('role')).getPicture()
to get the profile picture of the user (VCARD('hasPicture')).getEmails()
to get a list of email-addresses and their blank-ids (VCARD('hasEmail')).getTelephones()
to get a list of telephone numbers and their blank-ids (VCARD('hasTelephone'))
They can be used in the following way:
user.getName().then((name) => {
console.log(name)
});
Or with a prefilled graph of information that is passed as a function argument:
const store = rdf.graph();
const fetcher = new rdf.Fetcher(store);
fetcher.load(user.webId).then(() => {
const name = user.getName(store);
}):
To quickly get all of the information from these functions you use the .getProfile()
method:
user.getProfile().then((profile) => {
console.log(profile);
})
This will return a dictionary consisting of all the fields that are returned by the individual getter methods that were described above.
Listing/Adding/Removing Friends
To get a list of a users friends and their respective profiles you can use the .getFriends()
method:
user.getFriends().then((friends) => {
console.log(friends);
});
To add/remove a friend simply call the respective functions with the webId of the friend to add/remove. They, again, provide you with a Promise that you can await:
user
.addFriend("https://alice.example.org/profile/card#me")
.then(() => {
console.log("Friend has been added");
});
user
.removeFriend("https://bob.example.org/profile/card#me")
.then(() => {
console.log("Friend has been deleted");
});
Listing Messages
To get a list of a users messages (that means chats that include both messages from the user as well as messages from persons the user chats with) you can use the .getMessages()
method:
user.getMessages().then((messages) => {
console.log(messages);
});
This method will look into /inbox of the user, looking for Chat files. For the chat files it finds, it also fetches the respective counterpart that sits inside the /inbox folder of the person chatted with. It sorts all the messages it finds by date & time, labels them with either by: "own" or by: "friend" and puts them into a dictionary that can be accessed by using the chat-partner's webId as a key.
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago