1.0.0-beta-2 • Published 8 years ago

3box v1.0.0-beta-2

Weekly downloads
1,208
License
Apache-2.0
Repository
github
Last release
8 years ago

3box-js

Warning: This project is under active development, APIs are subject to change.

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. Currently it supports one shared space which all dapps can access. In the future there will be support for more granular access control using namespaces.

Data Schema

API Documentation

Usage

Simply install using npm

$ npm install 3box

and then import into your project

const ThreeBox = require('3box')

ThreeBox.openBox(web3.eth.accounts[0]).then(threeBox => {
  // Code goes here...
})

Classes

ThreeBox

Kind: global class

new ThreeBox(muportDID, web3provider, opts)

Instantiates a threeBox

Returns: ThreeBox - self

ParamTypeDescription
muportDIDMuPortA MuPort DID instance
web3providerWeb3ProviderA Web3 provider
optsObjectOptional parameters
opts.ipfsIPFSA custom ipfs instance
opts.hashServerStringA url to a custom hash server

threeBox.profileStore

Kind: instance property of ThreeBox
Properties

NameTypeDescription
profileStoreProfileStoreaccess the profile store of the users threeBox

threeBox.privateStore

Kind: instance property of ThreeBox
Properties

NameTypeDescription
privateStorePrivateStoreaccess the private store of the users threeBox

threeBox.close()

Closes the 3box instance without clearing the local cache. Should be called after you are done using the 3Box instance, but without logging the user out.

Kind: instance method of ThreeBox

threeBox.logout()

Closes the 3box 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 openBox.

Kind: instance method of ThreeBox

ThreeBox.getProfile(address, opts) ⇒ Object

Get the public profile of the given address

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

ParamTypeDescription
addressStringan ethereum address
optsObjectOptional parameters
opts.ipfsIPFSA custom ipfs instance

ThreeBox.openBox(address, web3provider, opts) ⇒ ThreeBox

Opens the user space associated with the given address

Kind: static method of ThreeBox
Returns: ThreeBox - the threeBox instance for the given address

ParamTypeDescription
addressStringan ethereum address
web3providerWeb3ProviderA Web3 provider
optsObjectOptional parameters
opts.ipfsIPFSA custom ipfs instance

PrivateStore

Kind: global class

new PrivateStore(muportDID, ipfs, updateRoot)

Instantiates a PrivateStore

Returns: PrivateStore - self

ParamTypeDescription
muportDIDMuPortA MuPort DID instance
ipfsIPFSAn instance of the ipfs api
updateRootfunctionA callback function that is called when the store has been updated

privateStore.get(key) ⇒ String

Get the value of the given key

Kind: instance method of PrivateStore
Returns: String - the value associated with the key

ParamTypeDescription
keyStringthe key

privateStore.set(key, value) ⇒ Boolean

Set a value for the given key

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

ParamTypeDescription
keyStringthe key
valueStringthe value

privateStore.remove(key) ⇒ Boolean

Remove the value for the given key

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

ParamTypeDescription
keyStringthe key

privateStore._sync(hash)

Sync the private store with the given ipfs hash

Kind: instance method of PrivateStore

ParamTypeDescription
hashStringThe hash of the private store OrbitDB

ProfileStore

Kind: global class

new ProfileStore(ipfs, updateRoot)

Instantiates a ProfileStore

Returns: ProfileStore - self

ParamTypeDescription
ipfsIPFSAn instance of the ipfs api
updateRootfunctionA callback function that is called when the store has been updated

profileStore.get(key) ⇒ String

Get the value of the given key

Kind: instance method of ProfileStore
Returns: String - the value associated with the key

ParamTypeDescription
keyStringthe key

profileStore.set(key, value) ⇒ Boolean

Set a value for the given key

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

ParamTypeDescription
keyStringthe key
valueStringthe value

profileStore.remove(key) ⇒ Boolean

Remove the value for the given key

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

ParamTypeDescription
keyStringthe key

profileStore._uploadProfile() ⇒ Boolean

Upload the instanced profile to IPFS

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

profileStore._sync(hash)

Sync the profile store with the given ipfs hash

Kind: instance method of ProfileStore

ParamTypeDescription
hashStringThe hash of the profile object
1.19.1

5 years ago

1.22.2

5 years ago

1.22.2-beta.0

5 years ago

1.22.1

5 years ago

1.22.1-alpha.0

5 years ago

1.22.0

5 years ago

1.21.0

6 years ago

1.20.4-beta.2

6 years ago

1.20.4-beta.1

6 years ago

1.20.3

6 years ago

1.20.2

6 years ago

1.20.2-beta.1

6 years ago

1.20.1

6 years ago

1.20.0

6 years ago

1.20.0-beta.0

6 years ago

1.19.0

6 years ago

1.19.0-rc.1

6 years ago

1.18.1

6 years ago

1.18.0

6 years ago

1.18.0-beta.1

6 years ago

1.17.2-beta.2

6 years ago

1.17.2-beta.1

6 years ago

1.17.1

6 years ago

1.17.0

6 years ago

1.16.3

6 years ago

1.16.3-beta.1

6 years ago

1.16.2

6 years ago

1.16.2-beta.4

6 years ago

1.16.2-beta.3

6 years ago

1.16.2-beta.2

6 years ago

1.16.2-beta.1

6 years ago

1.16.1

6 years ago

1.16.0

6 years ago

1.16.0-beta.3

6 years ago

1.16.0-beta.2

6 years ago

1.16.0-beta.1

6 years ago

1.15.0

6 years ago

1.14.1-beta.1

6 years ago

1.14.0

6 years ago

1.13.3-beta.2

6 years ago

1.13.3-beta.1

6 years ago

1.13.2

6 years ago

1.13.1

6 years ago

1.13.1-beta.1

6 years ago

1.13.0

6 years ago

1.13.0-beta.2

6 years ago

1.13.0-beta.1

6 years ago

1.12.0

6 years ago

1.12.0-beta.2

6 years ago

1.12.0-beta.1

6 years ago

1.11.0

6 years ago

1.10.10

7 years ago

1.10.9

7 years ago

1.10.8

7 years ago

1.10.7

7 years ago

1.11.0-beta.1

7 years ago

1.10.6

7 years ago

1.10.6-beta.1

7 years ago

1.10.5

7 years ago

1.10.5-beta.2

7 years ago

1.10.5-beta.1

7 years ago

1.10.4

7 years ago

1.10.3

7 years ago

1.10.2

7 years ago

1.10.1

7 years ago

1.10.0

7 years ago

1.9.1

7 years ago

1.9.0

7 years ago

1.9.0-rc.4

7 years ago

1.9.0-rc.3

7 years ago

1.9.0-rc.2

7 years ago

1.9.0-rc.1

7 years ago

1.9.0-beta.1

7 years ago

1.8.5

7 years ago

1.8.4

7 years ago

1.8.4-beta.1

7 years ago

1.8.3

7 years ago

1.8.2

7 years ago

1.8.1

7 years ago

1.8.1-beta.1

7 years ago

1.8.0

7 years ago

1.7.2

7 years ago

1.7.2-beta.3

7 years ago

1.7.2-beta.2

7 years ago

1.7.2-beta.1

7 years ago

1.7.1

7 years ago

1.7.0-node-1

7 years ago

1.7.0

7 years ago

1.7.0-beta.2

7 years ago

1.7.0-beta.1

7 years ago

1.6.2

7 years ago

1.6.1-node-1

7 years ago

1.6.1

7 years ago

1.6.1-beta.1

7 years ago

1.6.0

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.4.0-beta.1

7 years ago

1.3.0

7 years ago

1.3.0-beta.2

7 years ago

1.3.0-beta.1

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.2.0-beta.6

7 years ago

1.2.0-beta.5

7 years ago

1.2.0-beta.4

7 years ago

1.2.0-beta.3

7 years ago

1.2.0-beta.2

7 years ago

1.2.0-beta.1

7 years ago

1.1.0

7 years ago

1.1.0-beta-1

7 years ago

1.0.7-beta-2

7 years ago

1.0.7-beta-1

7 years ago

1.0.6-beta-1

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

1.0.0-beta-13

7 years ago

1.0.0-beta-12

7 years ago

1.0.0-beta-11

7 years ago

1.0.0-beta-10

7 years ago

1.0.0-beta-9

7 years ago

1.0.0-beta-8

7 years ago

1.0.0-beta-7

7 years ago

1.0.0-beta-6

7 years ago

1.0.0-beta-5

7 years ago

1.0.0-beta-4

7 years ago

1.0.0-beta-3

8 years ago

1.0.0-beta-2

8 years ago

1.0.0-beta-1

8 years ago

0.0.5-beta-2

8 years ago

0.0.5-beta-1

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago