0.0.124
A simple key-value pair with helper functions.
Constructor: new Attribute(value), new Attribute(type, value) or new Attribute({type, value})
Generate a visually recognizable representation of the attribute
(object
= {width:50}
)
{width}
HTMLElement
:
identicon div element
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.
(Object)
{key, gun, onMessage, participants}
Useful for notifications
(integer)
last seen msg time (default: now)
Useful for notifications
(any)
For "seen" status indicator
(any)
Send a message to the chat
(any)
string or {time, author, text} object
An Iris identity profile. Usually you don't create them yourself, but get them from Index methods such as get() and search().
Appends an identity search widget to the given HTMLElement
(HTMLElement)
element where the search widget is added and event listener attached
(Index)
index root to use for search
(Object)
(optional) an IPFS instance that is used to fetch images
HTMLElement
:
profile card html element describing the identity
(Object
= {}
)
{width: 50, border: 4, showDistance: true, ipfs: null, outerGlow: false}
HTMLElement
:
identicon element that can be appended to DOM
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.
(Object)
see default options in example
Index
:
index object
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
}
}
Return existing chats and listen to new chats initiated by friends
(any)
Add a list of messages to the index. Useful for example when adding a new WoT dataset that contains previously unknown authors.
Iteratively performs sorted merge joins on [previously known identities] and [new msgs authors], until all messages from within the WoT have been added.
(Array)
an array of messages.
boolean
:
true on success
Key management utils. Wraps GUN's SEA. https://gun.eco/docs/SEA
Load default key from datadir/private.key on node.js or from local storage 'iris.myKey' in browser.
If default key does not exist, it is generated.
(string
= `.`
)
directory to find key from. In browser, localStorage is used instead.
(any
= `identifi.key`
)
Promise<Object>
:
keypair object
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.
(Object)
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'
}
Create an iris message. Message time is automatically set. If signingKey is specified and author omitted, signingKey will be used as author.
(Object)
message data object including author, recipient and other possible attributes
(Object)
optionally, you can set the key to sign the message with
Promise<Message>
:
message
(any)
(any)
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/"