3box v1.0.0-beta-2
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.
Usage
Simply install using npm
$ npm install 3boxand 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
| Param | Type | Description |
|---|---|---|
| muportDID | MuPort | A MuPort DID instance |
| web3provider | Web3Provider | A Web3 provider |
| opts | Object | Optional parameters |
| opts.ipfs | IPFS | A custom ipfs instance |
| opts.hashServer | String | A url to a custom hash server |
threeBox.profileStore
Kind: instance property of ThreeBox
Properties
| Name | Type | Description |
|---|---|---|
| profileStore | ProfileStore | access the profile store of the users threeBox |
threeBox.privateStore
Kind: instance property of ThreeBox
Properties
| Name | Type | Description |
|---|---|---|
| privateStore | PrivateStore | access 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
| Param | Type | Description |
|---|---|---|
| address | String | an ethereum address |
| opts | Object | Optional parameters |
| opts.ipfs | IPFS | A 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
| Param | Type | Description |
|---|---|---|
| address | String | an ethereum address |
| web3provider | Web3Provider | A Web3 provider |
| opts | Object | Optional parameters |
| opts.ipfs | IPFS | A custom ipfs instance |
PrivateStore
Kind: global class
- PrivateStore
- new PrivateStore(muportDID, ipfs, updateRoot)
- .get(key) ⇒ String
- .set(key, value) ⇒ Boolean
- .remove(key) ⇒ Boolean
- ._sync(hash)
new PrivateStore(muportDID, ipfs, updateRoot)
Instantiates a PrivateStore
Returns: PrivateStore - self
| Param | Type | Description |
|---|---|---|
| muportDID | MuPort | A MuPort DID instance |
| ipfs | IPFS | An instance of the ipfs api |
| updateRoot | function | A 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
| Param | Type | Description |
|---|---|---|
| key | String | the key |
privateStore.set(key, value) ⇒ Boolean
Set a value for the given key
Kind: instance method of PrivateStore
Returns: Boolean - true if successful
| Param | Type | Description |
|---|---|---|
| key | String | the key |
| value | String | the value |
privateStore.remove(key) ⇒ Boolean
Remove the value for the given key
Kind: instance method of PrivateStore
Returns: Boolean - true if successful
| Param | Type | Description |
|---|---|---|
| key | String | the key |
privateStore._sync(hash)
Sync the private store with the given ipfs hash
Kind: instance method of PrivateStore
| Param | Type | Description |
|---|---|---|
| hash | String | The hash of the private store OrbitDB |
ProfileStore
Kind: global class
- ProfileStore
- new ProfileStore(ipfs, updateRoot)
- .get(key) ⇒ String
- .set(key, value) ⇒ Boolean
- .remove(key) ⇒ Boolean
- ._uploadProfile() ⇒ Boolean
- ._sync(hash)
new ProfileStore(ipfs, updateRoot)
Instantiates a ProfileStore
Returns: ProfileStore - self
| Param | Type | Description |
|---|---|---|
| ipfs | IPFS | An instance of the ipfs api |
| updateRoot | function | A 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
| Param | Type | Description |
|---|---|---|
| key | String | the key |
profileStore.set(key, value) ⇒ Boolean
Set a value for the given key
Kind: instance method of ProfileStore
Returns: Boolean - true if successful
| Param | Type | Description |
|---|---|---|
| key | String | the key |
| value | String | the value |
profileStore.remove(key) ⇒ Boolean
Remove the value for the given key
Kind: instance method of ProfileStore
Returns: Boolean - true if successful
| Param | Type | Description |
|---|---|---|
| key | String | the 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
| Param | Type | Description |
|---|---|---|
| hash | String | The hash of the profile object |
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago