3box v0.0.5-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 |
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.getProfile(address) ⇒ Object
Get the public profile of the given address
Kind: static method of ThreeBox
Returns: Object - the threeBox instance for the given address
| Param | Type | Description |
|---|---|---|
| address | String | an ethereum address |
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, linkProfile)
- .get(key) ⇒ String
- .set(key, value) ⇒ Boolean
- .remove(key) ⇒ Boolean
- ._sync(hash)
new ProfileStore(ipfs, updateRoot, linkProfile)
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 |
| linkProfile | function | A callback function that is called if the profile is not made public yet |
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._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