Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #677 from 3box/release/1.15.0
Browse files Browse the repository at this point in the history
Release/1.15.0
  • Loading branch information
oed authored Dec 13, 2019
2 parents e9e60d6 + 6d81353 commit cce4bb9
Show file tree
Hide file tree
Showing 25 changed files with 848 additions and 549 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To view the contribution guide, go to the main 3box repo here:
- [ ] Add release notes and update version in package.json
- [ ] Run `$ npm run generate-readme`
- [ ] Make sure correct dependencies are installed and that tests and builds pass
- [ ] Create release branch `release/vX.X.X`
- [ ] Create release branch `release/X.X.X`
- [ ] Make a commit `$ git commit -m "Release vX.X.X"` and make a PR to `master`
- [ ] Get at least one review and merge
- [ ] Checkout `master` locally
Expand Down
256 changes: 165 additions & 91 deletions README.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release Notes

## v1.15.0 - 2019-12-13
This release features a new interface for how to create and authenticate to a 3Box, it also adds the ability to open a thread before being authenticated to a space.

---
* feat: new initialization interface
* fix: add postId to ghost chat messages
* fix: don't allow space names with dots

## v1.14.0 - 2019-12-02
* feat: Support IdentityWallet v1.0.0 🎉
* chore: use ethers v5
Expand Down
53 changes: 25 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3box",
"version": "1.14.0",
"version": "1.15.0",
"description": "Interact with user data",
"main": "lib/3box.js",
"directories": {
Expand Down Expand Up @@ -77,7 +77,7 @@
"babel-core": "7.0.0-bridge.0",
"babel-loader": "^8.0.6",
"express": "^4.17.0",
"identity-wallet": "^1.0.0-beta.2",
"identity-wallet": "^1.0.0",
"jest": "^23.6.0",
"jsdoc-to-markdown": "^5.0.0",
"standard": "^14.3.1",
Expand Down
28 changes: 22 additions & 6 deletions readme-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,24 @@ console.log(profile)
```

### Update (get, set, remove) public and private profile data
3Box allows applications to create, read, update, and delete public and private data stored in a user's 3Box. To enable this functionality, applications must first open the user's 3Box by calling the openBox 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`.
3Box allows applications to create, read, update, and delete public and private data stored in a user's 3Box. To enable this functionality, applications must first authenticate the user's 3Box 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. Authenticate users to begin new 3Box session
Calling the openBox method will open a new 3Box session. If the user's ethereum address already has a 3Box account, your application will gain access to it. If the user does not have an existing 3Box account, this method will automatically create one for them in the background.
#### 1. Create a 3Box instance
To create a 3Box session you call the `create` method. This creates an instance of the Box class which can be used to joinThreads and authenticate the user in any order. In order to create a 3Box session a `provider` needs to be passed. This can be an `ethereum provider` (from `web3.currentProvider`, or `window.ethereum`) or a `3ID Provider` (from [IdentityWallet](https://github.com/3box/identity-wallet-js)).
```js
const box = await Box.openBox('0x12345abcde', ethereumProvider)
const box = await Box.create(provider)
```

#### 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. If when you created the 3Box session you used an ethereum provider you need to pass an ethereum address to the `auth` method. If the user does not have an existing 3Box account, this method will automatically create one for them in the background.
```js
const address = '0x12345abcde'
const spaces = ['myDapp']
await box.auth(spaces, { address })
```

#### 2. Sync user's available 3Box data from the network
When you first open 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 `box.syncDone` promise:
#### 3. Sync user's available 3Box 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 `box.syncDone` promise:
```js
await box.syncDone
```
Expand Down Expand Up @@ -104,6 +112,14 @@ const privateValues = ['xxx', 'yyy']
await box.private.setMultiple(privateFields, privateValues)
```

##### Open a thread
Once you have created a 3Box session you can open a thread to view data in it. This can be done before you authenticate the user to be able to post in the thread.
When opening a thread the moderation options need to be given. You can pass `firstModerator`, a 3ID (or ethereum address) of the first moderator, and a `members` boolean which indicates if it is a members thread or not.
```js
const thread = await box.openThread('myDapp', 'myThread', { firstModerator: 'did:3:bafy...', members: true })
```


<!-- commenting this out for now, not really needed when we're not using the iframe
#### IPFS Configs
Expand Down
Loading

0 comments on commit cce4bb9

Please sign in to comment.