@paladin-privacy/profiles
TypeScript icon, indicating that this package has built-in type declarations

0.0.10 • Public • Published

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, 'jane@example.com', 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, 'bob@example.org', forFriends([ alice.toFriend() ]));

console.log(bob.getField(Fields.Email, alice));
// Result: bob@example.org

Readme

Keywords

none

Package Sidebar

Install

npm i @paladin-privacy/profiles

Weekly Downloads

1

Version

0.0.10

License

GPL-3.0

Unpacked Size

341 kB

Total Files

62

Last publish

Collaborators

  • matteskridge