@paladin-privacy/profiles
v0.0.10
Published
Javascript library to manage paladin profiles
Downloads
32
Readme
Paladin Profiles
This javascript library lets you create and manage profiles for Paladin, the distributed social network.
Basic usage
import { Profile, Fields, Visibility } from '@paladin-privacy/profiles';
const profile = new Profile();
profile.initialize();
profile.setField(Fields.Nickname, 'Jane', Visibility.Public);
profile.setField(Fields.Email, '[email protected]', Visibility.Private);
profile.sign();
const data = profile.getProfile();This will create a profile (complete with its keychain), and sign the profile using the generated private key. The data can then be persisted to a user's machine.
The profile can be loaded back into memory with the constructor on Profile.
const data = // get the data from the file system
const profile = new Profile(data);To share the profile with someone else, first use filterFor; it will strip out confidential information from the profile, such as the profile's private key.
import { Visibility } from '@paladin-privacy/profiles';
const toShare = profile.filterFor(Visibility.Public);
const dataToShare = profile.getProfile();Add friends and encrypt data for them only:
import { Profile, Fields, Visibility, forFriends } from '@paladin-privacy/profiles';
const alice = new Profile();
alice.setField(Fields.Nickname, 'Alice', Visibility.Public);
alice.sign();
const bob = new Profile();
bob.addFriend(alice);
bob.setField(Fields.Nickname, 'Bob', Visibility.Public);
bob.setField(Fields.Email, '[email protected]', forFriends([ alice.toFriend() ]));
console.log(bob.getField(Fields.Email, alice));
// Result: [email protected]