1.1.12 • Published 5 years ago

your-user v1.1.12

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

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.

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago