iris-messenger/iris-lib
2022-10-13 21:57:03 +03:00
..
.github/workflows iris-lib to typescript, build with tsdx 2022-10-13 14:47:36 +03:00
dist . 2022-10-13 21:57:03 +03:00
example add iris-lib/dist to git for now 2022-10-13 15:00:18 +03:00
gun . 2022-10-13 21:57:03 +03:00
src . 2022-10-13 21:57:03 +03:00
test iris-lib to typescript, build with tsdx 2022-10-13 14:47:36 +03:00
.gitignore add iris-lib/dist to git for now 2022-10-13 15:00:18 +03:00
documentation.yml iris-lib to typescript, build with tsdx 2022-10-13 14:47:36 +03:00
LICENSE iris-lib to typescript, build with tsdx 2022-10-13 14:47:36 +03:00
package.json . 2022-10-13 21:57:03 +03:00
README.md . 2022-10-13 21:57:03 +03:00
tsconfig.json iris-lib to typescript, build with tsdx 2022-10-13 14:47:36 +03:00
tsdx.config.js iris-lib to typescript, build with tsdx 2022-10-13 14:47:36 +03:00
tsdx.md iris-lib readme 2022-10-13 16:36:38 +03:00
yarn.lock iris-lib to typescript, build with tsdx 2022-10-13 14:47:36 +03:00

Iris-lib

Decentralize everything.

Iris is a fully decentralized p2p database that you can use to build all kinds of decentralized applications.

  • "Accounts" are just key pairs that can be created at will. No signup required.
  • Stores everything offline-first, and syncs with other users over a publish-subscribe network.
  • Callback system for real-time updates.
  • Supports public and private (encrypted) data.
  • Make aggregate queries from your social network or other group. For example:
    • Fetch the latest 10 posts from your extended social network.
    • Fetch the latest posts from the users on a list maintained by a moderator of your choice.
    • Fetch 3d objects in a virtual room from your friends.
  • Super simple API

Installation

npm install iris-lib

or

yarn add iris-lib

Import:

import iris from 'iris-lib';

or include the script in your html:

<script src="https://raw.githubusercontent.com/irislib/iris-messenger/master/iris-lib/dist/iris.umd.production.min.js"></script>

Usage

Read/write public profiles:

iris.public().get('profile').get('name').on((name) => {
  console.log('My name is', name);
});
iris.public().get('profile').get('name').put('John Doe');
iris.public('hyECQHwSo7fgr2MVfPyakvayPeixxsaAWVtZ-vbaiSc.TXIp8MnCtrnW6n2MrYquWPcc-DTmZzMBmc2yaGv9gIU').get('profile').get('name').on((name) => {
  console.log('Someone else\'s name is', name);
});

Make a public post and get posts from everyone in your social network:

iris.session.init(); // Generate a new keypair and crawl the Iris social network using a default entry point.
iris.public().get('msgs').get(new Date().toISOString()).put({text: 'Hello world!'});
iris.group('everyone').map('msgs', (msg, from) => {
  console.log('msg from', from.slice(0,6), msg);
});

Private messaging, browser 1:

const user1 = iris.session.getKey();
console.log('User 1 key:', user1);
iris.private(user2.pub).send('Hello, user 2!');
iris.private(user2.pub).getMessages(msg => {
  console.log('User 1 received a message:', msg);
});

Private messaging, browser 2:

const user2 = iris.session.getKey();
console.log('User 2 key:', user2);
iris.private(user1.pub).send('Hello, user 1!');
iris.private(user1.pub).getMessages(msg => {
  console.log('User 2 received a message:', msg);
});