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

Commit 6f819b2

Browse files
authored
Merge pull request #840 from 3box/release/v1.20.0
release v1.20.0
2 parents 2581795 + d99cb5d commit 6f819b2

32 files changed

+16635
-35394
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ jobs:
1818
sudo npm i -g codecov node-gyp
1919
npm ci
2020
21-
- run:
22-
name: test
23-
command: npm test && codecov
24-
2521
- run:
2622
name: lint
2723
command: npm run lint
2824

25+
- run:
26+
name: test
27+
command: npm test && codecov
28+
2929
- run:
3030
name: code-coverage
3131
command: bash <(curl -s https://codecov.io/bash)

.dependabot/config.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 1
2+
update_configs:
3+
- package_manager: "javascript"
4+
target_branch: "develop"
5+
directory: "/"
6+
update_schedule: "weekly"
7+
default_reviewers:
8+
- "zachferland"
9+
default_assignees:
10+
- "zachferland"
11+
allowed_updates:
12+
- match:
13+
dependency_type: "production"
14+
update_type: "all"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ tmp/
77
.DS_Store
88
yarn.lock
99
orbitdb
10+
.idea

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,19 @@ console.log(profile)
5454
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`.
5555

5656
#### 1. Create a 3Box instance
57-
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.
57+
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.
5858

5959
```js
60-
const provider = await Box.get3idConnectProvider()
61-
const box = await Box.create(provider)
60+
const box = await Box.create()
6261
```
6362

6463
#### 2. Authenticate user
65-
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.
64+
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.
65+
6666
```js
6767
const address = '0x12345abcde'
6868
const spaces = ['myDapp']
69-
await box.auth(spaces, { address })
69+
await box.auth(spaces, { address, provider })
7070
```
7171

7272
#### 3. Sync user's available 3Box data from the network
@@ -327,6 +327,9 @@ idUtils.verifyClaim(claim)
327327
.catch(err => console.error('claim verification failed:', err)
328328
```
329329
330+
## Maintainers
331+
[@oed](https://github.com/oed)
332+
330333
## <a name="api"></a> API Documentation
331334
<a name="Box"></a>
332335
@@ -358,7 +361,7 @@ idUtils.verifyClaim(claim)
358361
* [.isSupportedDID(did)](#Box.idUtils.isSupportedDID) ⇒ <code>\*</code> \| <code>boolean</code>
359362
* [.isClaim(claim, opts)](#Box.idUtils.isClaim) ⇒ <code>Promise.&lt;boolean&gt;</code>
360363
* [.create(provider, opts)](#Box.create) ⇒ [<code>Box</code>](#Box)
361-
* [.get3idConnectProvider()](#Box.get3idConnectProvider) ⇒ <code>3IDProvider</code>
364+
* [.supported()](#Box.supported) ⇒ <code>Boolean</code>
362365
* [.openBox(address, provider, opts)](#Box.openBox) ⇒ [<code>Box</code>](#Box)
363366
* [.isLoggedIn(address)](#Box.isLoggedIn) ⇒ <code>Boolean</code>
364367
* [.getIPFS()](#Box.getIPFS) ⇒ <code>IPFS</code>
@@ -440,6 +443,7 @@ Authenticate the user
440443
| spaces | <code>Array.&lt;String&gt;</code> | A list of spaces to authenticate (optional) |
441444
| opts | <code>Object</code> | Optional parameters |
442445
| opts.address | <code>String</code> | An ethereum address |
446+
| opts.provider | <code>String</code> | A 3ID provider, or ethereum provider |
443447
| opts.consentCallback | <code>function</code> | A function that will be called when the user has consented to opening the box |
444448
445449
<a name="Box+openSpace"></a>
@@ -608,14 +612,15 @@ Creates an instance of 3Box
608612
| opts.pinningNode | <code>String</code> | A string with an ipfs multi-address to a 3box pinning node |
609613
| opts.ipfs | <code>Object</code> | A js-ipfs ipfs object |
610614
| opts.addressServer | <code>String</code> | URL of the Address Server |
615+
| opts.ghostPinbot | <code>String</code> | MultiAddress of a Ghost Pinbot node |
616+
| 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. |
611617
612-
<a name="Box.get3idConnectProvider"></a>
618+
<a name="Box.supported"></a>
613619
614-
#### Box.get3idConnectProvider() ⇒ <code>3IDProvider</code>
615-
Returns and 3ID Connect Provider to manage keys, authentication and account links. Becomes default in future.
620+
#### Box.supported() ⇒ <code>Boolean</code>
621+
Determines if this browser environment supports 3boxjs and ipfs.
616622
617623
**Kind**: static method of [<code>Box</code>](#Box)
618-
**Returns**: <code>3IDProvider</code> - Promise that resolves to a 3ID Connect Provider
619624
<a name="Box.openBox"></a>
620625
621626
#### Box.openBox(address, provider, opts) ⇒ [<code>Box</code>](#Box)
@@ -1058,6 +1063,7 @@ Join a thread. Use this to start receiving updates from, and to post in threads
10581063
| opts.confidential | <code>Boolean</code> | create a confidential thread with true or join existing confidential thread with an encKeyId string |
10591064
| opts.noAutoSub | <code>Boolean</code> | Disable auto subscription to the thread when posting to it (default false) |
10601065
| opts.ghost | <code>Boolean</code> | Enable ephemeral messaging via Ghost Thread |
1066+
| opts.ghostPinbot | <code>String</code> | MultiAddress of a Ghost Pinbot node |
10611067
| opts.ghostBacklogLimit | <code>Number</code> | The number of posts to maintain in the ghost backlog |
10621068
| opts.ghostFilters | <code>Array.&lt;function()&gt;</code> | Array of functions for filtering messages |
10631069

RELEASE-NOTES.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Release Notes
22

3+
## v1.20.0 - 2020-06-15
4+
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.
5+
6+
```
7+
// On page load create
8+
const box = await Box.create()
9+
// Later authenticate user
10+
const spaces = ['myDapp']
11+
await box.auth(spaces, { address: '0x12345abcde', provider: ethProvider })
12+
```
13+
14+
* feat: default to 3ID-Connect, pass an eth provider and 3id-connect will be created in background
15+
* feat: supported function for browser feature support detection
16+
* ref: pass a provider at box.auth instead of Box.create, so create can be called on page load.
17+
* chore: upgrade to ipfs 0.44.0, libp2p-webrtc
18+
* feat: ghostpinbot pass address
19+
* ref: link address on auth
20+
321
## v1.19.0 - 2020-05-12
422
* chore: upgrade did-jwt and did resolver libraries
523

example/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<html>
44
<head>
55
<title>3box Demo</title>
6-
76
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
7+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, minimum-scale=1" />
88
</head>
99

1010
<body>
@@ -205,6 +205,6 @@ <h5 style="padding: 20px 0px 10px 0px"> Profile: </h5>
205205
</div>
206206
</body>
207207
<script type="text/javascript" src="../dist/3box.js"></script>
208-
<script type="text/javascript" src="index.js"></script>
208+
<script type="text/javascript" src="build.js"></script>
209209

210210
</html>

example/index.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1+
import web3Modal from './providers.js'
2+
13
const syncComplete = (res) => {
24
console.log('Sync Complete')
35
updateProfileData(window.box)
46
}
57

6-
Box.get3idConnectProvider().then(provider => {
7-
Box.create(provider).then(box => {
8-
window.box = box
9-
bauth.disabled = false
10-
openThread.disabled = false
11-
})
8+
Box.create().then(box => {
9+
window.box = box
10+
bauth.disabled = false
11+
openThread.disabled = false
1212
})
1313

14-
bauth.addEventListener('click', event => {
15-
16-
window.ethereum.enable().then(addresses => {
17-
window.box.auth([], { address: addresses[0] }).then(() => {
14+
bauth.addEventListener('click', (event) => {
15+
let ethProvider
16+
web3Modal.connect()
17+
.then(provider => {
18+
ethProvider = provider
19+
return provider.enable() })
20+
.then(addresses => {
21+
window.box.auth([], { address: addresses[0], provider: ethProvider })
22+
.then(() => {
1823
box.onSyncDone(syncComplete)
1924
console.log('authed')
2025

example/providers.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import Web3Modal from "web3modal"
2+
import Portis from "@portis/web3";
3+
import Authereum from "authereum";
4+
import Fortmatic from "fortmatic";
5+
import WalletConnectProvider from "@walletconnect/web3-provider";
6+
7+
const providerOptions = {
8+
portis: {
9+
package: Portis,
10+
options: {
11+
id: "8f5cf962-ad62-4861-ab0c-7b234b6e6cff"
12+
}
13+
},
14+
walletconnect: {
15+
package: WalletConnectProvider,
16+
options: {
17+
infuraId: "e87f83fb85bf4aa09bdf6605ebe144b7"
18+
}
19+
},
20+
fortmatic: {
21+
package: Fortmatic,
22+
options: {
23+
key: "pk_live_EC842EEAC7F08995"
24+
}
25+
},
26+
authereum: {
27+
package: Authereum,
28+
options: {}
29+
}
30+
};
31+
32+
const web3Modal = new Web3Modal({
33+
network: "mainnet",
34+
cacheProvider: true,
35+
providerOptions
36+
});
37+
38+
39+
export default web3Modal

0 commit comments

Comments
 (0)