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 #840 from 3box/release/v1.20.0
Browse files Browse the repository at this point in the history
release v1.20.0
  • Loading branch information
zachferland authored Jun 16, 2020
2 parents 2581795 + d99cb5d commit 6f819b2
Show file tree
Hide file tree
Showing 32 changed files with 16,635 additions and 35,394 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ jobs:
sudo npm i -g codecov node-gyp
npm ci
- run:
name: test
command: npm test && codecov

- run:
name: lint
command: npm run lint

- run:
name: test
command: npm test && codecov

- run:
name: code-coverage
command: bash <(curl -s https://codecov.io/bash)
Expand Down
14 changes: 14 additions & 0 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 1
update_configs:
- package_manager: "javascript"
target_branch: "develop"
directory: "/"
update_schedule: "weekly"
default_reviewers:
- "zachferland"
default_assignees:
- "zachferland"
allowed_updates:
- match:
dependency_type: "production"
update_type: "all"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ tmp/
.DS_Store
yarn.lock
orbitdb
.idea
26 changes: 16 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 @@ -327,6 +327,9 @@ idUtils.verifyClaim(claim)
.catch(err => console.error('claim verification failed:', err)
```
## Maintainers
[@oed](https://github.com/oed)
## <a name="api"></a> API Documentation
<a name="Box"></a>
Expand Down Expand Up @@ -358,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 @@ -440,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 @@ -608,14 +612,15 @@ Creates an instance of 3Box
| opts.pinningNode | <code>String</code> | A string with an ipfs multi-address to a 3box pinning node |
| 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 Expand Up @@ -1058,6 +1063,7 @@ Join a thread. Use this to start receiving updates from, and to post in threads
| opts.confidential | <code>Boolean</code> | create a confidential thread with true or join existing confidential thread with an encKeyId string |
| opts.noAutoSub | <code>Boolean</code> | Disable auto subscription to the thread when posting to it (default false) |
| opts.ghost | <code>Boolean</code> | Enable ephemeral messaging via Ghost Thread |
| opts.ghostPinbot | <code>String</code> | MultiAddress of a Ghost Pinbot node |
| opts.ghostBacklogLimit | <code>Number</code> | The number of posts to maintain in the ghost backlog |
| opts.ghostFilters | <code>Array.&lt;function()&gt;</code> | Array of functions for filtering messages |
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 example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<html>
<head>
<title>3box Demo</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, minimum-scale=1" />
</head>

<body>
Expand Down Expand Up @@ -205,6 +205,6 @@ <h5 style="padding: 20px 0px 10px 0px"> Profile: </h5>
</div>
</body>
<script type="text/javascript" src="../dist/3box.js"></script>
<script type="text/javascript" src="index.js"></script>
<script type="text/javascript" src="build.js"></script>

</html>
25 changes: 15 additions & 10 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import web3Modal from './providers.js'

const syncComplete = (res) => {
console.log('Sync Complete')
updateProfileData(window.box)
}

Box.get3idConnectProvider().then(provider => {
Box.create(provider).then(box => {
window.box = box
bauth.disabled = false
openThread.disabled = false
})
Box.create().then(box => {
window.box = box
bauth.disabled = false
openThread.disabled = false
})

bauth.addEventListener('click', event => {

window.ethereum.enable().then(addresses => {
window.box.auth([], { address: addresses[0] }).then(() => {
bauth.addEventListener('click', (event) => {
let ethProvider
web3Modal.connect()
.then(provider => {
ethProvider = provider
return provider.enable() })
.then(addresses => {
window.box.auth([], { address: addresses[0], provider: ethProvider })
.then(() => {
box.onSyncDone(syncComplete)
console.log('authed')

Expand Down
39 changes: 39 additions & 0 deletions example/providers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import Web3Modal from "web3modal"
import Portis from "@portis/web3";
import Authereum from "authereum";
import Fortmatic from "fortmatic";
import WalletConnectProvider from "@walletconnect/web3-provider";

const providerOptions = {
portis: {
package: Portis,
options: {
id: "8f5cf962-ad62-4861-ab0c-7b234b6e6cff"
}
},
walletconnect: {
package: WalletConnectProvider,
options: {
infuraId: "e87f83fb85bf4aa09bdf6605ebe144b7"
}
},
fortmatic: {
package: Fortmatic,
options: {
key: "pk_live_EC842EEAC7F08995"
}
},
authereum: {
package: Authereum,
options: {}
}
};

const web3Modal = new Web3Modal({
network: "mainnet",
cacheProvider: true,
providerOptions
});


export default web3Modal
Loading

0 comments on commit 6f819b2

Please sign in to comment.