Giter Club home page Giter Club logo

unstoppable-chat's Introduction

Resolution

NPM version

A library for decentralized chat with blockchain domains and gundb

You can use UnstoppableChat in a <script> tag from a CDN

Architecture

Unstoppable Chat combines the technologies of blockchain domains and GunDB.

Gundb credentials are made from signing a blockchain domain using the domain owner's private key.

const domainName = 'example.crypto';

const username = sign(domainName, privateKey);

const password = sign(username, privateKey);

A gundb user is identified by their username and publicKey

The gundb username and publicKey are found in the blockchain domain's text record gundb.username.value and gundb.public_key.value. We recommend using the unstoppabledomains resolution library to help resolve blockchain domains.

Initialization

const GUNDB_SUPER_PEER = 'https://unstoppable-superpeer.herokuapp.com/';

const chat = new UnstoppableChat(GUNDB_SUPER_PEER);

Login

chat.join(username, password, domainName);

Contacts

const contactsListener = await chat.loadContacts();
const contactInvitesListener = await chat.loadContactInvites();

contactsListener.on((contacts) => {
    for (const contact of contacts) {
        const contactMessagesListener = await chat.loadMessagesOfContact(
            contact.pubKey,
            contact.name,
        );
        contactMessagesListener.on((messages) => {});
    }
});

// Auto accept contact invites
contactInvitesListener.on((contactInvites) => {
    for (const contactInvite of contactInvites) {
        chat.acceptContactInvite(
            contactInvite.alias,
            contactInvite.pubKey,
            contactInvite.name,
        );
    }
});

chat.addContact(username, publicKey, domainName);
chat.sendMessageToContact(publicKey, message);

Channels

const channelsListener = await chat.loadChannels();
const channelInvitesListener = await chat.loadChannelInvites();

channelsListener.on((channels) => {});
channelInvitesListener.on((channelInvites) => {
  for (const channelInvite of channelInvites) {
    chat.acceptChannelInvite(channelInvite) ||
      chat.denyChannelInvite(channelInvite);
  }
});

const channel = await chat.createChannel(channelName);

chat.inviteToChannel(channel, username, publicKey, domainName);
chat.leaveChannel(channel);

Announcements

const announcementsListener = await chat.loadAnnouncements();
const announcementInvitesListener = await chat.loadAnnouncementInvites();

announcementsListener.on((announcements) => {});
announcementInvitesListener.on((announcementInvites) => {
  for (const announcementInvite of announcementInvites) {
    chat.acceptAnnouncementInvite(announcementInvite) ||
      chat.denyAnnouncementInvite(announcementInvite);
  }
});

const announcement = await chat.createAnnouncement(announcementName);

chat.inviteToAnnouncement(announcement, username, publicKey, domainName);
chat.leaveAnnouncement(announcement);

unstoppable-chat's People

Contributors

sudoryan avatar theporpoise avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.