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 #697 from 3box/release/1.16.0
Browse files Browse the repository at this point in the history
Release/1.16.0
  • Loading branch information
oed authored Jan 10, 2020
2 parents cce4bb9 + 7cf2f6f commit 4f0acd6
Show file tree
Hide file tree
Showing 28 changed files with 840 additions and 371 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
.git
node_modules
14 changes: 14 additions & 0 deletions Dockerfile.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:10

WORKDIR /3box-js

COPY package.json package-lock.json ./
RUN npm install

COPY src ./src
COPY webpack*.config.js .babelrc ./
COPY example ./example

EXPOSE 30000

CMD npm run example-server:start | npm run build:dist:dev
80 changes: 73 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ 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 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)).
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)).
```js
const box = await Box.create(provider)
```
Expand All @@ -72,7 +72,7 @@ When you first authenticate the box in your dapp all data might not be synced fr
```js
await box.syncDone
```
This will allow you to know when all the user's data is available to you. We advise against *setting* any data before this sync has happened. However, reading data before the sync is complete is fine and encouraged - just remember to check for updates once the sync is finished!
This will allow you to know when all the user's data is available to you. We advise against *setting* any data before this sync has happened. However, reading data before the sync is complete is fine and encouraged - just remember to check for updates once the sync is finished! Please note, `box.syncDone` can only be called once the user has been authenticated, it is not possible if only the `Box.create` method has been called.

If you prefer to not use promises you can add a callback using the `onSyncDone` method.

Expand Down Expand Up @@ -113,11 +113,12 @@ 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.
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 (required for them 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 })
```
Once a thread has been opened you can call the `getPosts()` method to retrive the posts.


<!-- commenting this out for now, not really needed when we're not using the iframe
Expand Down Expand Up @@ -184,6 +185,7 @@ You can get all posts made in a thread without opening a space. This is great fo
const posts = await Box.getThread(spaceName, threadName, firstModerator, membersThread)
console.log(posts)
```
Threads can also be viewed without opening space, or authenticating by calling the `getPosts()` method on the thread object returned from `openThread` (see Open a thread section above).

```js
const posts = await Box.getThreadByAddress(threadAddress)
Expand Down Expand Up @@ -876,6 +878,70 @@ const log = store.log
console.log(entry)
// { op: 'PUT', key: 'Name', value: 'Botbot', timeStamp: '1538575416068' }
```
<a name="User"></a>
### User
Class representing a user.
**Kind**: global class
* [User](#User)
* [.DID](#User+DID)
* [.signClaim(payload, opts)](#User+signClaim) ⇒ <code>String</code>
* [.encrypt(message, opts, to)](#User+encrypt) ⇒ <code>Object</code>
* [.decrypt(encryptedObject)](#User+decrypt) ⇒ <code>String</code>
<a name="User+DID"></a>
#### user.DID
**Kind**: instance property of [<code>User</code>](#User)
**Properties**
| Name | Type | Description |
| --- | --- | --- |
| DID | <code>String</code> | the DID of the user |
<a name="User+signClaim"></a>
#### user.signClaim(payload, opts) ⇒ <code>String</code>
Sign a JWT claim
**Kind**: instance method of [<code>User</code>](#User)
**Returns**: <code>String</code> - The signed JWT
| Param | Type | Description |
| --- | --- | --- |
| payload | <code>Object</code> | The payload to sign |
| opts | <code>Object</code> | Optional parameters |
<a name="User+encrypt"></a>
#### user.encrypt(message, opts, to) ⇒ <code>Object</code>
Encrypt a message. By default encrypts messages symmetrically
with the users private key. If the `to` parameter is used,
the message will be asymmetrically encrypted to the recipient.
**Kind**: instance method of [<code>User</code>](#User)
**Returns**: <code>Object</code> - An object containing the encrypted payload
| Param | Type | Description |
| --- | --- | --- |
| message | <code>String</code> | The message to encrypt |
| opts | <code>Object</code> | Optional parameters |
| to | <code>String</code> | The receiver of the message, a DID or an ethereum address |
<a name="User+decrypt"></a>
#### user.decrypt(encryptedObject) ⇒ <code>String</code>
Decrypts a message if the user owns the correct key to decrypt it.
**Kind**: instance method of [<code>User</code>](#User)
**Returns**: <code>String</code> - The clear text message
| Param | Type | Description |
| --- | --- | --- |
| encryptedObject | <code>Object</code> | The encrypted message to decrypt (as encoded by the `encrypt` method |
<a name="Space"></a>
### Space
Expand All @@ -886,7 +952,7 @@ const log = store.log
* [.public](#Space+public)
* [.private](#Space+private)
* [.syncDone](#Space+syncDone)
* [.DID](#Space+DID)
* [.user](#Space+user)
* [.joinThread(name, opts)](#Space+joinThread) ⇒ [<code>Thread</code>](#Thread)
* [.joinThreadByAddress(address, opts)](#Space+joinThreadByAddress) ⇒ [<code>Thread</code>](#Thread)
* [.subscribeThread(address, config)](#Space+subscribeThread)
Expand Down Expand Up @@ -928,15 +994,15 @@ Please use **box.openSpace** to get the instance of this class
| --- | --- | --- |
| syncDone | <code>Promise</code> | A promise that is resolved when the space data is synced |
<a name="Space+DID"></a>
<a name="Space+user"></a>
#### space.DID
#### space.user
**Kind**: instance property of [<code>Space</code>](#Space)
**Properties**
| Name | Type | Description |
| --- | --- | --- |
| DID | <code>String</code> | the did of the user in this space |
| user | [<code>User</code>](#User) | access the user object to encrypt data and sign claims |
<a name="Space+joinThread"></a>
Expand Down
11 changes: 11 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Release Notes

## v1.16.0 - 2020-01-10
This release brings a few performance updates as well as minor features in preparation for the upcoming Confidential Threads feature.

---
* feat: support for asymmetric encryption in spaces
* feat: fully migrate to 3ID, no more references to legacy "muport" DID
* chore: update OrbitDB for improved performance
* fix: IdentityWallet now works in a browser context
* fix: issue with using ghost threads while not authenticated resolved
* fix: linkAddress now works as expected with externally provided proof

## 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.

Expand Down
85 changes: 44 additions & 41 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</head>

<body>
<!-- Open Box -->
<button id="bopen" type="button" class="btn btn-primary" style="margin: 50px 100px;">Open 3box</button>
<!-- Auth Box -->
<button id="bauth" type="button" class="btn btn-primary" style="margin: 50px 100px;" disabled=true>Auth 3box</button>

<div id="controlls" style="display: none; padding: 5px 100px;">

Expand Down Expand Up @@ -97,45 +97,6 @@ <h5 style="padding: 20px 0px 10px 0px" id="spacePriv"> </h5>
<span id="spaceDataPriv"></span>
</p>

<h3> Threads: </h3>
<input type="text" id="threadName" placeholder="Name or Address"></br>
<input type="text" id="threadfirstModerator" placeholder="Thread Root Moderator"></br>
<span > Members Only Thread </span>
<input type="radio" name="members" id='members' value="true"> </br>
<span > Ghost ? </span>
<input type="radio" name="ghostCheck" id='ghostCheck' value="true"> </br>
<button id="joinThread" type="button" class="btn btn btn-primary" >Join thread</button> </br></br>

<div id="threadModeration" style="display: none;">
<input type="text" id="threadMod" placeholder="Thread Moderator">
<button id="addThreadMod" type="button" class="btn btn btn-primary" >Add Thread Moderator</button></br>
<h5> Moderators: </h5>
<p>
<span id="threadModeratorList"></span>
</p>
</div>
<div id="threadMembers" style="display: none;">
<input type="text" id="threadMember" placeholder="Thread Member">
<button id="addThreadMember" type="button" class="btn btn btn-primary" >Add Thread Member</button></br>
<h5> Members: </h5>
<p>
<span id="threadMemberList"></span>
</p>
</div></br>

<p>
<span id="threadACError"></span>
</p>

<div id="posts" style="display: none;">
<h4> Posts: </h4>
<p>
<span id="threadData"></span>
</p>
<input type="text" id="postMsg" placeholder="Type your message">
<button id="postThread" type="button" class="btn btn btn-primary">Post</button>
</div>

</div>
</div>

Expand All @@ -145,6 +106,48 @@ <h4> Posts: </h4>
</div>
</div>

<div style="padding: 0px 0px 25px 100px;">
<h3> Threads: </h3>
<input type="text" id="threadName" placeholder="Name of thread"></br>
<input type="text" id="threadSpaceName" placeholder="Space name"></br>
<input type="text" id="threadfirstModerator" placeholder="Thread Root Moderator"></br>
<span > Members Only Thread </span>
<input type="radio" name="members" id='members' value="true"> </br>
<span > Ghost ? </span>
<input type="radio" name="ghostCheck" id='ghostCheck' value="true"> </br>
<button id="openThread" type="button" class="btn btn btn-primary" disabled=true>Open thread</button> </br></br>

<div id="threadModeration" style="display: none;">
<input type="text" id="threadMod" placeholder="Thread Moderator">
<button id="addThreadMod" type="button" class="btn btn btn-primary" >Add Thread Moderator</button></br>
<h5> Moderators: </h5>
<p>
<span id="threadModeratorList"></span>
</p>
</div>
<div id="threadMembers" style="display: none;">
<input type="text" id="threadMember" placeholder="Thread Member">
<button id="addThreadMember" type="button" class="btn btn btn-primary" >Add Thread Member</button></br>
<h5> Members: </h5>
<p>
<span id="threadMemberList"></span>
</p>
</div></br>

<p>
<span id="threadACError"></span>
</p>

<div id="posts" style="display: none;">
<h4> Posts: </h4>
<p>
<span id="threadData"></span>
</p>
<input type="text" id="postMsg" placeholder="Type your message">
<button id="postThread" type="button" class="btn btn btn-primary">Post</button>
</div>
</div>

<hr />
<div style="padding: 5px 100px;">
<!-- Get Profile Div -->
Expand Down
Loading

0 comments on commit 4f0acd6

Please sign in to comment.