1.22.12 • Published 3 years ago

@mc3-aether/aether v1.22.12

Weekly downloads
-
License
Apache-2.0
Repository
gitlab
Last release
3 years ago

Install | Usage | Example | Data Standards | API Docs

Docs at docs.mc3.network/aether

Aether-js

This is a library which allows you to set, get, and remove private and public data associated with an ethereum account. It can be used to store identity data, user settings, etc. by dapps that use a web3 enabled browser. The data will be retrievable as long as the user has access to the private key for the used ethereum account. The data is encrypted and can not be read by any third party that the user hasn't authorized. There is one shared space for data which all authorized dapps access by default, then there are spaces which dapps have to request explicit consent to access.

Getting Started

Installation

Install Æther in your npm project:

$ npm install Aether

Usage

Import Æther into your project

Import the Aether module

const Aether = require('Aether')

Import using the dist build in your html code

<script type="text/javascript" src="../dist/aether.js"></script>

Or optionally by loading remote copy from unpkg CDN.

<!-- The most recent version  -->
<script src="https://unpkg.com/mc2-universe/aether/dist/aether.js"></script>
<!-- The most recent minified version  -->
<script src="https://unpkg.com/mc2-universe/aether/dist/aether.min.js"></script>
<!-- Load specific versions by specifying the version as follows -->
<script src="https://unpkg.com/mc2-universe/aether@<version>/dist/aether.js"></script>

Profiles API

Get the existing public profile of an address (or DID)

Æther allows users to create a public profile for their Ethereum address. In your dapp you might have multiple ethereum addresses that you would like to display a name, image, and other basic social metadata for. The getProfile method allows you to fetch the public profile of any ethereum address (if it has one). This is a static method so you can call it directly from the Box object.

const profile = await Aether.getProfile('0x12345abcde')
console.log(profile)

Update (get, set, remove) public and private profile data

Æther allows applications to create, read, update, and delete public and private data stored in a user's Æther. To enable this functionality, applications must first authenticate the user's Æther by calling the auth method. This method prompts the user to authenticate (sign-in) to your dapp and returns a promise with a threeBox instance. You can only update (set, get, remove) data for users that have authenticated to and are currently interacting with your dapp. Below ethereumProvider refers to the object that you would get from web3.currentProvider, or window.ethereum.

1. Create a Æther instance

To create a Æther session you call the create method. This creates an instance of the Box class which can be used to openThreads and authenticate the user in any order. This is best to call on page load, so it can begin initializing and connecting services like IPFS in background.

const mc3 = await Aether.create()

2. Authenticate user

Calling the auth method will authenticate the user. If you want to authenticate the user to one or multiple spaces you can specify this here. A provider needs to be passed, this can be an ethereum provider (from web3.currentProvider, or window.ethereum) or a UPI Provider (from IdentityWallet). If using an ethereum provider you need to pass an ethereum address to the auth method as well. If the user does not have an existing Æther account, this method will automatically create one for them in the background.

const address = '0x12345abcde'
const spaces = ['myDapp']
await mc3.auth(spaces, { address, provider })

3. Sync user's available Æther data from the network

When you first authenticate the box in your dapp all data might not be synced from the network yet. You should therefore wait for the data to be fully synced. To do this you can simply await the mc3.syncDone promise:

await mc3.syncDone

This will allow you to know when all the user's data is available to you. We advise against setting any data before this sync has happened. However, reading data before the sync is complete is fine and encouraged - just remember to check for updates once the sync is finished! Please note, mc3.syncDone can only be called once the user has been authenticated, it is not possible if only the Aether.create method has been called.

If you prefer to not use promises you can add a callback using the onSyncDone method.

3. Interact with Æther profile data

You can now use the box instance object to interact with public and private data stored in the user's profile. In both the public and the private data store you use a key to set a value.

// use the public profile
// get
const nickname = await mc3.public.get('name')
console.log(nickname)
// set
await mc3.public.set('name', 'oed')
// remove
await mc3.public.remove('name')

// use the private store
// get
const email = await mc3.private.get('email')
console.log(email)
// set
await mc3.private.set('email', 'oed@email.service')
// remove
await mc3.private.remove('email')
Set multiple fields at once:
const fields = ['name', 'website', 'employer']
const values = ['Jon Schwartz', 'openworklabs.com', 'Open Work Labs']

await mc3.public.setMultiple(fields, values)

const privateFields = ['age', 'coinBalance']
const privateValues = ['xxx', 'yyy']

await mc3.private.setMultiple(privateFields, privateValues)
Open a thread

Once you have created a Æther session you can open a thread to view data in it. This can be done before you authenticate the user (required for them to post in the thread). When opening a thread the moderation options need to be given. You can pass firstModerator, a UPI (or ethereum address) of the first moderator, and a members boolean which indicates if it is a members thread or not.

const thread = await mc3.openThread('myDapp', 'myThread', { firstModerator: 'did:3:bafy...', members: true })

Once a thread has been opened you can call the getPosts() method to retrive the posts.

Spaces API (Storage)

Open a space

A space is a named section of a users Æther. Each space has both a public and a private store, and for every space you open the user has to grant explicit consent to view that space. This means that if your dapp uses a space that no other dapp uses, only your dapp is allowed to update the data and read the private store of that particular space. To open a space called narwhal you simply call:

const space = await mc3.openSpace('narwhal')

Sync user's available space data from the network

Similarly to how you need to wait for data to sync in a users main data storage, you may also do the same thing for a space:

await space.syncDone

Get, set, and remove space data

Interacting with data in a space is done in the same way as interacting with mc3.public and mc3.private (see here). For example:

const config = await space.private.get('dapp-config')

Threads API (Messaging)

Add public and confidential message threads to your app

Threads are a shared datastore that enable decentralized communication between users, by allowing one or more users to post messages in a sequence. This functionality is great for adding commenting, chat, messaging, feed, and stream features to your application. Threads are saved within a space and users that join a thread (with the same name, space, moderation configs, and access configs) will be able to communicate in that thread.

For the fully detailed spec, view the documentation.

Viewing a Public Thread

You can get all posts made in a public thread without opening a space. This is great for allowing visitors of your site view comments made by other users. This is achieved by calling the getThread method on the Box object. A thread can be referenced by all its configuration options or by its address.

const posts = await Aether.getThread(spaceName, threadName, firstModerator, membersThread)
console.log(posts)

Threads can also be viewed without opening space, or authenticating by calling the getPosts() method on the thread object returned from openThread (see Open a thread section above).

const posts = await Aether.getThreadByAddress(threadAddress)
console.log(posts)

However if applications want to add interactivity to the thread, such as allowing the user to post in a thread or follow updates in a thread, you will need to open their space to enable additional functionality. Same is true for a confidential thread, which requires you autheticate to get access to view the posts in a confidential thread.

Interacting with a Thread

1.a Creating a Public Thread

To create and join a public thread, you can simply join the thread. This will implicitly use the moderation options where the current user is the firstModerator and members is false.

const thread = await space.joinThread('myThread')

A thread can also be given the moderation options when joining. You can pass firstModerator, a UPI of the first moderator, and a members boolean which indicates if it is a members thread or not. Moderators can add other moderators, add members, and delete any posts in the thread. Members can post in member only threads.

const thread = await space.joinThread('myThread', { firstModerator: 'someUPI', members: true })
1.b Creating a Confidential Thread

To create and join a confidential thread.

const thread = await space.createConfidentialThread('myConfThread')

At creation you will likely want to add other members so that they can read and write messages to the thread, as shown below.

2. Joining a Thread

An existing public or confidential thread can be joined by its address. Confidential threads are best referenced by their address.

const thread = await space.joinThreadByAddress('/orbitdb/zdpuAp5QpBKR4BBVTvqe3KXVcNgo4z8Rkp9C5eK38iuEZj3jq/aether.thread.testSpace.testThread')

While public threads can be joined by address or by passing known configs (same as above).

const publicThread = await space.joinThread('myThread', { firstModerator: 'someUPI', members: true })

An address of a thread can be found as follows once joined.

const threadAddress = thread.address
3. Posting to a thread

This allows the user to add a message to the thread. The author of the message will be the user's UPI / DID. When a user posts in a thread, they are automatically subscribed to the thread and it is saved in the space used by the application under the key thread-threadName.

await thread.post('hello world')
4. Getting all posts in a thread

This allows applications to get the posts in a thread.

const posts = await thread.getPosts()
console.log(posts)
5. Listening for updates in thread

This allows applications to listen for new posts in the thread, and perform an action when this occurs, such as adding the new message to the application's UI.

thread.onUpdate(myCallbackFunction)
6. Handling moderation and capabilities

Add a moderator and list all existing moderators

await thread.addModerator('someUPI')

const mods = await thread.listModerators()

Add a member and list all existing members, if a members only thread

await thread.addMember('someUPI')

const members = await thread.listMembers()

Listen for when there has been moderators or member added.

thread.onNewCapabilities(myCallbackFunction)

Example Application

You can quickly run and interact with some code by looking at the files in the /example folder. You run the example with the following commands:

$ npm ci
$ npm run example:start

This runs a simple server at http://localhost:3000/ that serves the static example/index.html file. This allows it easily interact with metamask. You can edit the example/index.html file to try differnt code.

Build

Optimize build for read-only Æther API

If you only want to fetch profile data from Æther's profile APIs you can optimize by importing only those functions or the API specific dist file. Since this includes minimal dependencies, file size is ~ 80kb vs 4+mb for the full build.

const { profileGraphQL, getProfile, getProfiles, getVerifiedAccounts } = require('aether/lib/api')
<script src="https://unpkg.com/mc2-universe/aether/dist/aether.api.min.js"></script>

Resolving build size issues and out of memory errors

Some platforms, tooling, or configs have caused the build process to throw out of memory errors. This is a combination of the size of our library (plus dependencies) and the specific configs you have for your build. It could be things like tooling running on dependencies and not just your source or dependencies be recursively resolved. You can attempt to build the library anyways by adding the follow environment variable to increase memory for the node process.

NODE_OPTIONS=--max_old_space_size=4096 npm run build

Data Standards

Dapps can store data about users that relate to only their dapp. However we encurage dapps to share data between them for a richer web3 experience. Therefore we have created Key Conventions in order to facilitate this. Feel free to make a PR to this file to explain to the community how you use Æther

Validate claims

Use the idUtils module to validate claims. See the did-jwt library for more details.

const { idUtils } = require('aether')

const claim = 'eyJ0eX...'
idUtils.verifyClaim(claim)
  .then(valid => console.info('details:', valid)
  .catch(err => console.error('claim verification failed:', err)

API Documentation

Box ⇐ BoxApi

Kind: global class
Extends: BoxApi

new Box()

Please use the openBox method to instantiate a MC3 Me

mc3.public

Kind: instance property of Box
Properties

NameTypeDescription
publicKeyValueStoreaccess the profile store of the users MC3 Me

mc3.private

Kind: instance property of Box
Properties

NameTypeDescription
privateKeyValueStoreaccess the private store of the users MC3 Me

mc3.verified

Kind: instance property of Box
Properties

NameTypeDescription
verifiedVerifiedcheck and create verifications

mc3.spaces

Kind: instance property of Box
Properties

NameTypeDescription
spacesObjectan object containing all open spaces indexed by their name.

mc3.syncDone

Kind: instance property of Box
Properties

NameTypeDescription
syncDonePromiseA promise that is resolved when the box is synced

mc3.DID

Kind: instance property of Box
Properties

NameTypeDescription
DIDStringthe DID of the user

mc3.auth(spaces, opts)

Authenticate the user

Kind: instance method of Box

ParamTypeDescription
spacesArray.<String>A list of spaces to authenticate (optional)
optsObjectOptional parameters
opts.addressStringAn ethereum address
opts.providerStringA UPI provider, or ethereum provider
opts.consentCallbackfunctionA function that will be called when the user has consented to opening the box

mc3.openSpace(name, opts) ⇒ Space

Opens the space with the given name in the users MC3 Me

Kind: instance method of Box
Returns: Space - the Space instance for the given space name

ParamTypeDescription
nameStringThe name of the space
optsObjectOptional parameters
opts.consentCallbackfunctionA function that will be called when the user has consented to opening the box
opts.onSyncDonefunctionA function that will be called when the space has finished syncing with the pinning node

mc3.openThread(space, name, opts) ⇒ Thread

Open a thread. Use this to start receiving updates

Kind: instance method of Box
Returns: Thread - An instance of the thread class for the joined thread

ParamTypeDescription
spaceStringThe name of the space for this thread
nameStringThe name of the thread
optsObjectOptional parameters
opts.firstModeratorStringDID of first moderator of a thread, by default, user is first moderator
opts.membersBooleanjoin a members only thread, which only members can post in, defaults to open thread
opts.noAutoSubBooleanDisable auto subscription to the thread when posting to it (default false)
opts.ghostBooleanEnable ephemeral messaging via Ghost Thread
opts.ghostBacklogLimitNumberThe number of posts to maintain in the ghost backlog
opts.ghostFiltersArray.<function()>Array of functions for filtering messages

mc3.onSyncDone(syncDone) ⇒ Promise

Sets the callback function that will be called once when the box is fully synced.

Kind: instance method of Box
Returns: Promise - A promise that is fulfilled when the box is syned

ParamTypeDescription
syncDonefunctionThe function that will be called

mc3.linkAddress(link)

Creates a proof that links an ethereum address to the MC3 Me account of the user. If given proof, it will simply be added to the root store.

Kind: instance method of Box

ParamTypeDescription
linkObjectOptional link object with type or proof
link.proofObjectProof object, should follow spec

mc3.removeAddressLink(address)

Remove given address link, returns true if successful

Kind: instance method of Box

ParamTypeDescription
addressStringaddress that is linked

mc3.isAddressLinked(query)

Checks if there is a proof that links an external account to the MC3 Me account of the user. If not params given and any link exists, returns true

Kind: instance method of Box

ParamTypeDescription
queryObjectOptional object with address and/or type.
query.typeStringDoes the given type of link exist
query.addressStringIs the given adressed linked

mc3.listAddressLinks() ⇒ Array

Lists address links associated with this MC3 Me

Kind: instance method of Box
Returns: Array - An array of link objects

mc3.logout()

Closes the Æther instance and clears local cache. If you call this, users will need to sign a consent message to log in the next time you call openAether.

Kind: instance method of Box

Aether.idUtils

A module to verify & validate claims

Kind: static property of Box

idUtils.verifyClaim ⇒ Object

Verify a claim and return its content. See https://github.com/uport-project/did-jwt/ for more details.

Kind: static property of idUtils
Returns: Object - The validated claim

ParamTypeDescription
claimString
optsObjectOptional parameters
opts.audiencestringThe DID of the JWT's audience

idUtils.isSupportedDID(did) ⇒ * | boolean

Check whether a string is a muport did or not

Kind: static method of idUtils
Returns: * | boolean - Whether the did is a supported did or not

ParamTypeDescription
didStringA string containing a user did

idUtils.isClaim(claim, opts) ⇒ Promise.<boolean>

Check whether a string is a valid claim or not

Kind: static method of idUtils
Returns: Promise.<boolean> - whether the parameter is an actual claim

ParamTypeDescription
claimString
optsObjectOptional parameters
opts.audiencestringThe DID of the audience of the JWT

Aether.create(provider, opts) ⇒ Box

Creates an instance of MC3 Me

Kind: static method of Box
Returns: Box - the MC3 Me session instance

ParamTypeDescription
providerproviderA UPI provider, or ethereum provider
optsObjectOptional parameters
opts.pinningNodeStringA string with an ipfs multi-address to a Æther pinning node
opts.ipfsObjectA js-ipfs ipfs object
opts.addressServerStringURL of the Address Server
opts.ghostPinbotStringMultiAddress of a Ghost Pinbot node
opts.supportCheckStringGives browser alert if Aetherjs/ipfs not supported in browser env, defaults to true. You can also set to false to implement your own alert and call Aether.support to check if supported.
opts.iframeCacheBooleanEnable iframe cache for ipfs/orbit, defaults to true

Aether.supported() ⇒ Boolean

Determines if this browser environment supports Aetherjs and ipfs.

Kind: static method of Box

Aether.openBox(address, provider, opts) ⇒ Box

Opens the MC3 Me associated with the given address

Kind: static method of Box
Returns: Box - the MC3 Me instance for the given address

ParamTypeDescription
addressStringAn ethereum address
providerproviderAn ethereum or UPI provider
optsObjectOptional parameters
opts.consentCallbackfunctionA function that will be called when the user has consented to opening the box
opts.pinningNodeStringA string with an ipfs multi-address to a Aether pinning node
opts.ipfsObjectA js-ipfs ipfs object
opts.addressServerStringURL of the Address Server
opts.contentSignatureStringA signature, provided by a client of Aether using the private keys associated with the given address, of the Aether consent message

Aether.isLoggedIn(address) ⇒ Boolean

Check if the given address is logged in

Kind: static method of Box
Returns: Boolean - true if the user is logged in

ParamTypeDescription
addressStringAn ethereum address

Aether.getIPFS() ⇒ IPFS

Instanciate ipfs used by MC3 Me without calling openAether.

Kind: static method of Box
Returns: IPFS - the ipfs instance

BoxApi

Kind: global class

BoxApi.listSpaces(address, opts) ⇒ Object

Get the names of all spaces a user has

Kind: static method of BoxApi
Returns: Object - an array with all spaces as strings

ParamTypeDescription
addressStringAn ethereum address
optsObjectOptional parameters
opts.profileServerStringURL of Profile API server

BoxApi.getSpace(address, name, opts) ⇒ Object

Get the public data in a space of a given address with the given name

Kind: static method of BoxApi
Returns: Object - a json object with the public space data

ParamTypeDescription
addressStringAn ethereum address
nameStringA space name
optsObjectOptional parameters
opts.blocklistfunctionA function that takes an address and returns true if the user has been blocked
opts.metadataStringflag to retrieve metadata
opts.profileServerStringURL of Profile API server

BoxApi.getThread(space, name, firstModerator, members, opts) ⇒ Array.<Object>

Get all posts that are made to a thread.

Kind: static method of BoxApi
Returns: Array.<Object> - An array of posts

ParamTypeDescription
spaceStringThe name of the space the thread is in
nameStringThe name of the thread
firstModeratorStringThe DID (or ethereum address) of the first moderator
membersBooleanTrue if only members are allowed to post
optsObjectOptional parameters
opts.profileServerStringURL of Profile API server

BoxApi.getThreadByAddress(address, opts) ⇒ Array.<Object>

Get all posts that are made to a thread.

Kind: static method of BoxApi
Returns: Array.<Object> - An array of posts

ParamTypeDescription
addressStringThe orbitdb-address of the thread
optsObjectOptional parameters
opts.profileServerStringURL of Profile API server

BoxApi.getConfig(address, opts) ⇒ Array.<Object>

Get the configuration of a users MC3 Me

Kind: static method of BoxApi
Returns: Array.<Object> - An array of posts

ParamTypeDescription
addressStringThe ethereum address
optsObjectOptional parameters
opts.profileServerStringURL of Profile API server

BoxApi.getProfile(address, opts) ⇒ Object

Get the public profile of a given address

Kind: static method of BoxApi
Returns: Object - a json object with the profile for the given address

ParamTypeDescription
addressStringAn ethereum address
optsObjectOptional parameters
opts.blocklistfunctionA function that takes an address and returns true if the user has been blocked
opts.metadataStringflag to retrieve metadata
opts.profileServerStringURL of Profile API server

BoxApi.getProfiles(address, opts) ⇒ Object

Get a list of public profiles for given addresses. This relies on Æther profile API.

Kind: static method of BoxApi
Returns: Object - a json object with each key an address and value the profile

ParamTypeDescription
addressArrayAn array of ethereum addresses
optsObjectOptional parameters
opts.profileServerStringURL of Profile API server

BoxApi.profileGraphQL(query, opts) ⇒ Object

GraphQL for Æther profile API

Kind: static method of BoxApi
Returns: Object - a json object with each key an address and value the profile

ParamTypeDescription
queryObjectA graphQL query object.
optsObjectOptional parameters
opts.graphqlServerStringURL of graphQL Æther profile service

BoxApi.getVerifiedAccounts(profile) ⇒ Object

Verifies the proofs of social accounts that is present in the profile.

Kind: static method of BoxApi
Returns: Object - An object containing the accounts that have been verified

ParamTypeDescription
profileObjectA user profile object, received from the getProfile function

KeyValueStore

Kind: global class

new KeyValueStore()

Please use mc3.public or mc3.private to get the instance of this class

keyValueStore.get(key, opts) ⇒ String | Object

Get the value and optionally metadata of the given key

Kind: instance method of KeyValueStore
Returns: String | Object - the value associated with the key, undefined if there's no such key

ParamTypeDescription
keyStringthe key
optsObjectoptional parameters
opts.metadataBooleanreturn both value and metadata

keyValueStore.getMetadata(key) ⇒ Metadata

Get metadata for for a given key

Kind: instance method of KeyValueStore
Returns: Metadata - Metadata for the key, undefined if there's no such key

ParamTypeDescription
keyStringthe key

keyValueStore.set(key, value) ⇒ Boolean

Set a value for the given key

Kind: instance method of KeyValueStore
Returns: Boolean - true if successful

ParamTypeDescription
keyStringthe key
valueStringthe value

keyValueStore.setMultiple(keys, values) ⇒ Boolean

Set multiple values for multiple keys

Kind: instance method of KeyValueStore
Returns: Boolean - true if successful, throw error if not

ParamTypeDescription
keysArray.<String>the keys
valuesArray.<String>the values

keyValueStore.remove(key) ⇒ Boolean

Remove the value for the given key

Kind: instance method of KeyValueStore
Returns: Boolean - true if successful

ParamTypeDescription
keyStringthe key

keyValueStore.all(opts) ⇒ Array.<(String|{value: String, timestamp: Number})>

Get all values and optionally metadata

Kind: instance method of KeyValueStore
Returns: Array.<(String|{value: String, timestamp: Number})> - the values

ParamTypeDescription
optsObjectoptional parameters
opts.metadataBooleanreturn both values and metadata

keyValueStore.log() ⇒ Array.<Object>

Returns array of underlying log entries. In linearized order according to their Lamport clocks. Useful for generating a complete history of all operations on store.

Kind: instance method of KeyValueStore
Returns: Array.<Object> - Array of ordered log entry objects
Example

const log = store.log
 const entry = log[0]
 console.log(entry)
 // { op: 'PUT', key: 'Name', value: 'Botbot', timeStamp: '1538575416068' }

User

Class representing a user.

Kind: global class

user.DID

Kind: instance property of User
Properties

NameTypeDescription
DIDStringthe DID of the user

user.signClaim(payload, opts) ⇒ String

Sign a JWT claim

Kind: instance method of User
Returns: String - The signed JWT

ParamTypeDescription
payloadObjectThe payload to sign
optsObjectOptional parameters

user.encrypt(message, opts, to) ⇒ Object

Encrypt a message. By default encrypts messages symmetrically with the users private key. If the to parameter is used, the message will be asymmetrically encrypted to the recipient.

Kind: instance method of User
Returns: Object - An object containing the encrypted payload

ParamTypeDescription
messageStringThe message to encrypt
optsObjectOptional parameters
toStringThe receiver of the message, a DID or an ethereum address

user.decrypt(encryptedObject) ⇒ String

Decrypts a message if the user owns the correct key to decrypt it.

Kind: instance method of User
Returns: String - The clear text message

ParamTypeDescription
encryptedObjectObjectThe encrypted message to decrypt (as encoded by the encrypt method

Space

Kind: global class

new Space()

Please use mc3.openSpace to get the instance of this class

space.public

Kind: instance property of Space
Properties

NameTypeDescription
publicKeyValueStoreaccess the profile store of the space

space.private

Kind: instance property of Space
Properties

NameTypeDescription
privateKeyValueStoreaccess the private store of the space

space.syncDone

Kind: instance property of Space
Properties

NameTypeDescription
syncDonePromiseA promise that is resolved when the space data is synced

space.user

Kind: instance property of Space
Properties

NameTypeDescription
userUseraccess the user object to encrypt data and sign claims

space.joinThread(name, opts) ⇒ Thread

Join a thread. Use this to start receiving updates from, and to post in threads

Kind: instance method of Space
Returns: Thread - An instance of the thread class for the joined thread

ParamTypeDescription
nameStringThe name of the thread
optsObjectOptional parameters
opts.firstModeratorStringDID of first moderator of a thread, by default, user is first moderator
opts.membersBooleanjoin a members only thread, which only members can post in, defaults to open thread
opts.confidentialBooleancreate a confidential thread with true or join existing confidential thread with an encKeyId string
opts.noAutoSubBooleanDisable auto subscription to the thread when posting to it (default false)
opts.ghostBooleanEnable ephemeral messaging via Ghost Thread
opts.ghostPinbotStringMultiAddress of a Ghost Pinbot node
opts.ghostBacklogLimitNumberThe number of posts to maintain in the ghost backlog
opts.ghostFiltersArray.<function()>Array of functions for filtering messages

space.createConfidentialThread(name) ⇒ Thread

Create a confidential thread

Kind: instance method of Space
Returns: Thread - An instance of the thread class for the created thread

ParamTypeDescription
nameStringThe name of the thread

space.joinThreadByAddress(address, opts) ⇒ Thread

Join a thread by full thread address. Use this to start receiving updates from, and to post in threads

Kind: instance method of Space
Returns: Thread - An instance of the thread class for the joined thread

ParamTypeDescription
addressStringThe full address of the thread
optsObjectOptional parameters
opts.noAutoSubBooleanDisable auto subscription to the thread when posting to it (default false)

space.subscribeThread(address, config)

Subscribe to the given thread, if not already subscribed

Kind: instance method of Space

ParamTypeDescription
addressStringThe address of the thread
configObjectconfiguration and thread meta data
opts.nameStringName of thread
opts.firstModeratorStringDID of the first moderator
opts.membersStringBoolean string, true if a members only thread

space.unsubscribeThread(address)

Unsubscribe from the given thread, if subscribed

Kind: instance method of Space

ParamTypeDescription
addressStringThe address of the thread

space.subscribedThreads() ⇒ Array.<Objects>

Get a list of all the threads subscribed to in this space

Kind: instance method of Space
Returns: Array.<Objects> - A list of thread objects as { address, firstModerator, members, name}

Thread

Kind: global class

new Thread()

Please use space.joinThread to get the instance of this class

thread.post(message) ⇒ String

Post a message to the thread

Kind: instance method of Thread
Returns: String - The postId of the new post

ParamTypeDescription
messageObjectThe message

thread.addModerator(id)

Add a moderator to this thread, throws error is user can not add a moderator

Kind: instance method of Thread

ParamTypeDescription
idStringModerator Id

thread.listModerators() ⇒ Array.<String>

List moderators

Kind: instance method of Thread
Returns: Array.<String> - Array of moderator DIDs

thread.addMember(id)

Add a member to this thread, throws if user can not add member, throw is not member thread

Kind: instance method of Thread

ParamTypeDescription
idStringMember Id

thread.listMembers() ⇒ Array.<String>

List members, throws if not member thread

Kind: instance method of Thread
Returns: Array.<String> - Array of member DIDs

thread.deletePost(id)

Delete post

Kind: instance method of Thread

ParamTypeDescription
idStringModerator Id

thread.getPosts(opts) ⇒ Array.<Object>

Returns an array of posts, based on the options. If hash not found when passing gt, gte, lt, or lte, the iterator will return all items (respecting limit and reverse).

Kind: instance method of Thread
Returns: Array.<Object> - true if successful

ParamTypeDescription
optsObjectOptional parameters
opts.gtStringGreater than, takes an postId
opts.gteStringGreater than or equal to, takes an postId
opts.ltStringLess than, takes an postId
opts.lteStringLess than or equal to, takes an postId
opts.limitIntegerLimiting the number of entries in result, defaults to -1 (no limit)
opts.reverseBooleanIf set to true will result in reversing the result

thread.onUpdate(updateFn)

Register a function to be called after new updates have been received from the network or locally.

Kind: instance method of Thread

ParamTypeDescription
updateFnfunctionThe function that will get called

thread.onNewCapabilities(updateFn)

Register a function to be called for every new capability that is added to the thread access controller. This inlcudes when a moderator or member is added. The function takes one parameter, which is the capabilities obj, or you can call listModerator / listMembers again instead.

Kind: instance method of Thread

ParamTypeDescription
updateFnfunctionThe function that will get called

Verified

Kind: global class

new Verified()

Please use mc3.verified to get the instance of this class

verified.DID() ⇒ String

Returns the verified DID of the user

Kind: instance method of Verified
Returns: String - The DID of the user

verified.github() ⇒ Object

Verifies that the user has a valid github account Throws an error otherwise.

Kind: instance method of Verified
Returns: Object - Object containing username, and proof

verified.addGithub(gistUrl) ⇒ Object

Adds a github verification to the users profile Throws an error if the verification fails.

Kind: instance method of Verified
Returns: Object - Object containing username, and proof

ParamTypeDescription
gistUrlObjectURL of the proof

verified.twitter() ⇒ Object

Verifies that the user has a valid twitter account Throws an error otherwise.

Kind: instance method of Verified
Returns: Object - Object containing username, proof, and the verifier

verified.addTwitter(claim) ⇒ Object

Adds a twitter verification to the users profile Throws an error if the verification fails.

Kind: instance method of Verified
Returns: Object - Object containing username, proof, and the verifier

ParamTypeDescription
claimStringA did-JWT claim ownership of a twitter username

verified.email() ⇒ Object

Verifies that the user has a verified email account Throws an error otherwise.

Kind: instance method of Verified
Returns: Object - Object containing username, proof, and the verifier

verified.addEmail(claim) ⇒ Object

Adds an email verification to the users profile Throws an error if the verification fails.

Kind: instance method of Verified
Returns: Object - Object containing username, proof, and the verifier

ParamTypeDescription
claimStringA did-JWT claim ownership of an email username