Attribute

A simple key-value pair with helper functions.

Constructor: new Attribute(value), new Attribute(type, value) or new Attribute({type, value})

new Attribute(a: string, b: string)
Parameters
a (string)
b (string)
Static Members
getUuid()
getUniqueIdValidators()
isUniqueType(type)
guessTypeOf(value)
equals(a, b)
Instance Members
isUniqueType()
equals(a)
uri()
identicon(options)

Chat

Private communication channel between two or more participants. Can be used independently of other Iris stuff.

Messages are encrypted, but currently anyone can see which public keys are communicating with each other. This will change in later versions.

new Chat(options: Object)
Parameters
options (Object) {key, gun, onMessage, participants}
Static Members
setOnline(gun, isOnline)
getOnline(gun, pubKey, callback)
Instance Members
setMyMsgsLastSeenTime(time)
getMyMsgsLastSeenTime(callback)
getTheirMsgsLastSeenTime(callback)
addPub(pub)
send(msg)

Identity

An Iris identity profile. Usually you don't create them yourself, but get them from Index methods such as get() and search().

new Identity(gun: Object, linkTo: any, index: any)
Parameters
gun (Object) node where the Identity data lives
linkTo (any)
index (any)
Static Members
appendSearchWidget(parentElement, index)
Instance Members
sent(options)
received(options)
verified(attribute)
profileCard(ipfs)
identicon(options)

Index

A database of Messages and Identities within the indexer's web of trust.

To use someone else's index (read-only): set options.pubKey

To use your own index: set options.keypair or omit it to use Key.getDefaultKey().

Each added Message updates the Message and Identity indexes and web of trust accordingly.

You can pass options.gun to use custom gun storages and networking settings.

If you want messages saved to IPFS, pass options.ipfs = instance.

Wait for index.ready promise to resolve before calling instance methods.

new Index(options: Object): Index
Parameters
options (Object) see default options in example
Returns
Index: index object
Example
Default options:
{
 ipfs: undefined,
 keypair: undefined,
 pubKey: undefined,
 gun: undefined,
 self: undefined,
 indexSync: {
   importOnAdd: {
     enabled: true,
     maxMsgCount: 500,
     maxMsgDistance: 2
   },
   subscribe: {
     enabled: true,
     maxMsgDistance: 1
   },
   query: {
     enabled: true
   },
   msgTypes: {
     all: false,
     rating: true,
     verification: true,
     unverification: true
   },
   debug: false
 }
}
Instance Members
setOnline(isOnline)
getOnline(pubKey, callback)
getViewpoint()
get(a, b, reload)
getChats(callback)
addMessages(msgs)
addMessage(msg, options)
search(value, type, callback, limit, cursor)
getMessageByHash(hash)
getMessagesByTimestamp(callback, limit, cursor, desc, filter)
getMessagesByDistance(callback, limit, cursor, desc, filter)

Key

Key management utils. Wraps GUN's SEA. https://gun.eco/docs/SEA

new Key()
Static Members
getDefault(datadir, keyfile)
toString(key)
getId(key)
fromString(str)
generate()
sign(msg, pair)
verify(msg, pubKey)

Message

Messages are objects containing fields signedData, signer (public key) and signature. Message identifier is the base64 sha256 hash derived from its canonical utf8 string representation.

signedData has an author, recipient, signer, type, time and optionally other fields.

signature covers the utf8 string representation of signedData. Since messages are digitally signed, users only need to care about the message signer and not who relayed it or whose index it was found from.

signer is the entity that verified its origin. In other words: message author and signer can be different entities, and only the signer needs to use Iris.

For example, a crawler can import and sign other people's messages from Twitter. Only the users who trust the crawler will see the messages.

"Rating" type messages, when added to an Index, can add or remove Identities from the web of trust. Verification/unverification messages can add or remove Attributes from an Identity. Other types of messages such as social media "post" are just indexed by their author, recipient and time.

Constructor: creates a message from the param obj.signedData that must contain at least the mandatory fields: author, recipient, type and time. You can use createRating() and createVerification() to automatically populate some of these fields and optionally sign the message.

new Message(obj: Object)
Parameters
obj (Object)
Example
Rating message:
{
  signedData: {
    author: {name:'Alice', key:'ABCD1234'},
    recipient: {name:'Bob', email:'bob@example.com'},
    type: 'rating',
    rating: 1,
    maxRating: 10,
    minRating: -10,
    text: 'Traded 1 BTC'
  },
  signer: 'ABCD1234',
  signature: '1234ABCD'
}

Verification message:
{
  signedData: {
    author: {name:'Alice', key:'ABCD1234'},
    recipient: {
      name: 'Bob',
      email: ['bob@example.com', 'bob.saget@example.com'],
      bitcoin: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
    },
    type: 'verification'
  },
  signer: 'ABCD1234',
  signature: '1234ABCD'
}
Static Members
create(signedData, signingKey)
createVerification(signedData, signingKey)
createRating(signedData, signingKey)
loadFromIpfs(ipfs, uri)
fromString(s)
Instance Members
getAuthorIterable()
getRecipientIterable()
getAuthorArray()
getRecipientArray()
getSignerKeyID()
isPositive()
isNegative()
isNeutral()
sign(key)
getAuthor(index)
getRecipient(index)
getHash()
verify()
saveToIpfs(ipfs)
toString()

readFile

Stand-alone iris node service wrapper. If NODE_ENV is 'production', uses ../dist/irisLib.js, else uses the version in src or cjs directly. Development version assumes that it is running directly under the checked-out source tree from git, or in an irisnode-dev container, built with docker-compose build irisnode.

Run with: NODE_ENV='production' yarn serve or NODE_ENV='development' yarn build:run or (for running tests + server) NODE_ENV='development' yarn dev

Special environment variables: IRIS_GUN_PEERS - colon-separated peers that gun should try to connect to. Example: "http://localhost:123/gun/;http://1.2.3.4:5678/gun/"

readFile