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

Commit

Permalink
release v1.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zachferland committed Jun 16, 2020
1 parent 7c9b28a commit d99cb5d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ console.log(profile)
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. 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 openThreads 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)). It is now suggested to use the 3ID Connect Provider, which is a 3ID provider that wraps available `ethereum providers` and will manage/permission 3ID keys, authentication and blockchain account links inside an iframe. This will become the default soon and will overide passed `ethereum providers`. You can get the 3ID Connect Provider as follows.
To create a 3Box 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.

```js
const provider = await Box.get3idConnectProvider()
const box = await Box.create(provider)
const box = await Box.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. 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.
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 `3ID Provider` (from [IdentityWallet](https://github.com/3box/identity-wallet-js)). 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 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 })
await box.auth(spaces, { address, provider })
```

#### 3. Sync user's available 3Box data from the network
Expand Down Expand Up @@ -361,7 +361,7 @@ idUtils.verifyClaim(claim)
* [.isSupportedDID(did)](#Box.idUtils.isSupportedDID) ⇒ <code>\*</code> \| <code>boolean</code>
* [.isClaim(claim, opts)](#Box.idUtils.isClaim) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [.create(provider, opts)](#Box.create) ⇒ [<code>Box</code>](#Box)
* [.get3idConnectProvider()](#Box.get3idConnectProvider) ⇒ <code>3IDProvider</code>
* [.supported()](#Box.supported) ⇒ <code>Boolean</code>
* [.openBox(address, provider, opts)](#Box.openBox) ⇒ [<code>Box</code>](#Box)
* [.isLoggedIn(address)](#Box.isLoggedIn) ⇒ <code>Boolean</code>
* [.getIPFS()](#Box.getIPFS) ⇒ <code>IPFS</code>
Expand Down Expand Up @@ -443,6 +443,7 @@ Authenticate the user
| spaces | <code>Array.&lt;String&gt;</code> | A list of spaces to authenticate (optional) |
| opts | <code>Object</code> | Optional parameters |
| opts.address | <code>String</code> | An ethereum address |
| opts.provider | <code>String</code> | A 3ID provider, or ethereum provider |
| opts.consentCallback | <code>function</code> | A function that will be called when the user has consented to opening the box |
<a name="Box+openSpace"></a>
Expand Down Expand Up @@ -612,14 +613,14 @@ Creates an instance of 3Box
| opts.ipfs | <code>Object</code> | A js-ipfs ipfs object |
| opts.addressServer | <code>String</code> | URL of the Address Server |
| opts.ghostPinbot | <code>String</code> | MultiAddress of a Ghost Pinbot node |
| opts.supportCheck | <code>String</code> | Gives browser alert if 3boxjs/ipfs not supported in browser env, defaults to true. You can also set to false to implement your own alert and call Box.support to check if supported. |
<a name="Box.get3idConnectProvider"></a>
<a name="Box.supported"></a>
#### Box.get3idConnectProvider() ⇒ <code>3IDProvider</code>
Returns and 3ID Connect Provider to manage keys, authentication and account links. Becomes default in future.
#### Box.supported() ⇒ <code>Boolean</code>
Determines if this browser environment supports 3boxjs and ipfs.
**Kind**: static method of [<code>Box</code>](#Box)
**Returns**: <code>3IDProvider</code> - Promise that resolves to a 3ID Connect Provider
<a name="Box.openBox"></a>
#### Box.openBox(address, provider, opts) ⇒ [<code>Box</code>](#Box)
Expand Down
18 changes: 18 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Release Notes

## v1.20.0 - 2020-06-15
This release brings new IPFS features/performance in 0.44.0, and decreases bundled size by 1mb. Based on feedback from our first 3ID-Connect release, this brings a new more lightweight version and refactor. With these changes you need to pass a provider (as before) when creating or authenticating. The function get3idConnectProvider() is no longer available, when passing a provider we create a 3ID-Connect provider in the background. The recommended way to initialize a session is now as follows.

```
// On page load create
const box = await Box.create()
// Later authenticate user
const spaces = ['myDapp']
await box.auth(spaces, { address: '0x12345abcde', provider: ethProvider })
```

* feat: default to 3ID-Connect, pass an eth provider and 3id-connect will be created in background
* feat: supported function for browser feature support detection
* ref: pass a provider at box.auth instead of Box.create, so create can be called on page load.
* chore: upgrade to ipfs 0.44.0, libp2p-webrtc
* feat: ghostpinbot pass address
* ref: link address on auth

## v1.19.0 - 2020-05-12
* chore: upgrade did-jwt and did resolver libraries

Expand Down
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.19.0",
"version": "1.20.0",
"description": "Interact with user data",
"main": "lib/3box.js",
"directories": {
Expand Down Expand Up @@ -46,7 +46,7 @@
"dependencies": {
"3box-orbitdb-plugins": "^2.1.0",
"3id-blockchain-utils": "^0.4.0",
"3id-connect": "^0.1.0",
"3id-connect": "0.1.0",
"3id-resolver": "^1.0.0",
"@babel/runtime": "^7.4.5",
"@ethersproject/hdnode": "5.0.0-beta.137",
Expand Down
3 changes: 1 addition & 2 deletions src/3box.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ class Box extends BoxApi {
}

static get3idConnectProvider () {
// TODO Could add blogpost link
throw new Error('3idConnectProvider now consumes an eth provider, initialize 3box as you did before 3idconnectProvider, and 3box will create a 3idConnectProvider by default')
throw new Error('3idConnectProvider function is no longer supported, initialize 3box as you did before 3idConnectProvider by passing a provider to Box.create or box.auth, and 3box will create a 3idConnectProvider in the background using your given provider - https://medium.com/3box/introducing-3id-connect-531af4f84d3f')
}

async _setProvider (provider) {
Expand Down

0 comments on commit d99cb5d

Please sign in to comment.