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 #533 from 3box/hotfix/v1.10.1
Browse files Browse the repository at this point in the history
Hotfix/v1.10.1
  • Loading branch information
oed authored Jul 24, 2019
2 parents 3c194d6 + 000b284 commit 194df24
Show file tree
Hide file tree
Showing 9 changed files with 1,825 additions and 1,453 deletions.
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@
To view the contribution guide, go to the main 3box repo here:

<https://github.com/uport-project/3box/blob/master/CONTRIBUTING.md>


## Release checklist
- [ ] Add release notes and update version in package.json
- [ ] Make sure correct dependencies are installed and that tests and builds pass
- [ ] Create release branch `release/vX.X.X` and a PR to `master`
- [ ] Get at least one review and merge
- [ ] Checkout `master` locally
- [ ] When tests pass on CI tag the version `$ git tag vX.X.X` and push
- [ ] Publish to npmjs.com `$ npm publish`
- [ ] Add release notes to the tag on github
- [ ] Checkout `develop` and merge `master` into it, `$ git merge master`
- [ ] Push updated `develop` to origin, `$ git push`
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release Notes

## v1.10.1 - 2019-07-23
* fix: support usage of multiple tabs without data loss

## v1.10.0 - 2019-07-17
* feat: added ability to link multiple ethereum addresses to a 3Box
* feat: added ability to add a link proof manually
Expand Down
3,178 changes: 1,762 additions & 1,416 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3box",
"version": "1.10.0",
"version": "1.10.1",
"description": "Interact with user data",
"main": "lib/3box.js",
"directories": {
Expand Down Expand Up @@ -47,7 +47,7 @@
"3box-orbitdb-plugins": "^1.0.5",
"3id-resolver": "^0.0.5",
"@babel/runtime": "^7.4.5",
"did-jwt": "^0.1.3",
"did-jwt": "^0.2.0",
"ethers": "^4.0.28",
"events": "^3.0.0",
"graphql-request": "^1.8.2",
Expand All @@ -59,7 +59,7 @@
"js-sha256": "^0.9.0",
"muport-did-resolver": "^0.3.0",
"node-fetch": "^2.6.0",
"orbit-db": "^0.21.2",
"orbit-db": "^0.21.4",
"orbit-db-cache-postmsg-proxy": "^0.1.1",
"store": "^2.0.12",
"tweetnacl": "^1.0.1",
Expand All @@ -80,7 +80,7 @@
"ipfsd-ctl": "^0.40.3",
"jest": "^23.6.0",
"jsdoc-to-markdown": "^5.0.0",
"standard": "^12.0.1",
"standard": "^13.0.2",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.2"
}
Expand Down
15 changes: 11 additions & 4 deletions src/3box.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const PINNING_ROOM = config.pinning_room
// const IFRAME_STORE_VERSION = '0.0.3'
// const IFRAME_STORE_URL = `https://iframe.3box.io/${IFRAME_STORE_VERSION}/iframe.html`
const IPFS_OPTIONS = config.ipfs_options
const ORBITDB_OPTS = config.orbitdb_options

let globalIPFS, globalOrbitDB // , ipfsProxy, cacheProxy, iframeLoadedPromise

Expand Down Expand Up @@ -65,6 +66,7 @@ class Box {
this._ipfs = ipfs
this._serverUrl = opts.addressServer || ADDRESS_SERVER_URL
this._onSyncDoneCB = () => {}
this._boxSynced = false
/**
* @property {KeyValueStore} public access the profile store of the users 3Box
*/
Expand Down Expand Up @@ -100,6 +102,7 @@ class Box {

const key = this._3id.getKeyringBySpaceName(rootStoreName).getPublicKeys(true).signingKey
this._rootStore = await this._orbitdb.feed(rootStoreName, {
...ORBITDB_OPTS,
format: 'dag-pb',
accessController: {
write: [key],
Expand Down Expand Up @@ -129,7 +132,7 @@ class Box {
])

let syncPromises = []
let hasResponse = {}
const hasResponse = {}

// Filters and store space related messages for 3secs, the best effort
// simple approach, until refactor
Expand Down Expand Up @@ -157,6 +160,7 @@ class Box {
const promises = syncPromises
syncPromises = []
await Promise.all(promises)
this._boxSynced = true
this._onSyncDoneCB()
// this._pubsub.unsubscribe(PINNING_ROOM)
}
Expand Down Expand Up @@ -306,7 +310,7 @@ class Box {
// opts = Object.assign({ iframeStore: true }, opts)
const rootStoreAddress = await API.getRootStoreAddress(address.toLowerCase(), opts.addressServer)
let usingGlobalIPFS = false
let usingGlobalOrbitDB = false
// let usingGlobalOrbitDB = false
let ipfs
let orbitdb
if (globalIPFS) {
Expand Down Expand Up @@ -356,7 +360,7 @@ class Box {
const closeAll = async () => {
await rootStore.close()
await publicStore.close()
if (!usingGlobalOrbitDB) await orbitdb.stop()
// if (!usingGlobalOrbitDB) await orbitdb.stop()
if (!usingGlobalIPFS) {} // await ipfs.stop()
}
// close but don't wait for it
Expand Down Expand Up @@ -450,6 +454,9 @@ class Box {
*/
onSyncDone (syncDone) {
this._onSyncDoneCB = syncDone
if (this._boxSynced) {
this._onSyncDoneCB()
}
}

async _publishRootStore (rootStoreAddress) {
Expand Down Expand Up @@ -543,7 +550,7 @@ class Box {
if (query.address) query.address = query.address.toLowerCase()
const links = await this._readAddressLinks()
const linksQuery = links.find(link => {
let res = query.address ? link.address === query.address : true
const res = query.address ? link.address === query.address : true
return query.type ? res && link.type === query.type : res
})
return Boolean(linksQuery)
Expand Down
45 changes: 18 additions & 27 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,40 +67,31 @@ async function getThread (space, name, firstModerator, members, opts = {}) {
if (firstModerator.startsWith('0x')) {
firstModerator = await getSpaceDID(firstModerator, space, opts)
}
return new Promise(async (resolve, reject) => {
try {
let url = `${serverUrl}/thread?space=${encodeURIComponent(space)}&name=${encodeURIComponent(name)}`
url += `&mod=${encodeURIComponent(firstModerator)}&members=${encodeURIComponent(members)}`
const res = await utils.fetchJson(url)
resolve(res)
} catch (err) {
reject(err)
}
})
try {
let url = `${serverUrl}/thread?space=${encodeURIComponent(space)}&name=${encodeURIComponent(name)}`
url += `&mod=${encodeURIComponent(firstModerator)}&members=${encodeURIComponent(members)}`
return await utils.fetchJson(url)
} catch (err) {
throw new Error(err)
}
}

async function getThreadByAddress (address, opts = {}) {
const serverUrl = opts.profileServer || PROFILE_SERVER_URL
return new Promise(async (resolve, reject) => {
try {
const res = await utils.fetchJson(`${serverUrl}/thread?address=${encodeURIComponent(address)}`)
resolve(res)
} catch (err) {
reject(err)
}
})
try {
return await utils.fetchJson(`${serverUrl}/thread?address=${encodeURIComponent(address)}`)
} catch (err) {
throw new Error(err)
}
}

async function getConfig (address, opts = {}) {
const serverUrl = opts.profileServer || PROFILE_SERVER_URL
return new Promise(async (resolve, reject) => {
try {
const res = await utils.fetchJson(`${serverUrl}/config?address=${encodeURIComponent(address)}`)
resolve(res)
} catch (err) {
reject(err)
}
})
try {
return await utils.fetchJson(`${serverUrl}/config?address=${encodeURIComponent(address)}`)
} catch (err) {
throw new Error(err)
}
}

async function getProfile (address, serverUrl = PROFILE_SERVER_URL, { metadata, blocklist } = {}) {
Expand Down Expand Up @@ -151,7 +142,7 @@ async function profileGraphQL (query, opts = {}) {
}

async function getVerifiedAccounts (profile) {
let verifs = {}
const verifs = {}
try {
const did = await verifier.verifyDID(profile.proof_did)

Expand Down
7 changes: 6 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const Log = require('ipfs-log')
const IFRAME_STORE_VERSION = '0.0.3'

module.exports = {
Expand All @@ -12,9 +13,13 @@ module.exports = {
},
preload: { enabled: false },
config: {
Bootstrap: [ ]
Bootstrap: []
}
},
orbitdb_options: {
syncLocal: true,
sortFn: Log.Sorting.SortByEntryHash // this option is required now but will likely not be in the future.
},
graphql_server_url: process.env.GRAPHQL_SERVER_URL || 'https://api.3box.io/graph/',
profile_server_url: process.env.PROFILE_SERVER_URL || 'https://ipfs.3box.io',
muport_ipfs_host: process.env.MUPORT_IPFS_HOST || 'ipfs.infura.io',
Expand Down
6 changes: 5 additions & 1 deletion src/keyValueStore.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const { throwIfUndefined, throwIfNotEqualLenArrays } = require('./utils/index')
const config = require('./config')

const ORBITDB_OPTS = config.orbitdb_options

class KeyValueStore {
/**
Expand Down Expand Up @@ -171,6 +174,7 @@ class KeyValueStore {
async _load (odbAddress) {
const key = this._3id.getKeyringBySpaceName(this._name).getPublicKeys(true).signingKey
const opts = {
...ORBITDB_OPTS,
format: 'dag-pb',
accessController: {
write: [key],
Expand Down Expand Up @@ -205,7 +209,7 @@ class KeyValueStore {
async all (opts = {}) {
this._requireLoad()
const entries = this._db.all
let allSimple = {}
const allSimple = {}
Object.keys(entries).map(key => {
const entry = entries[key]

Expand Down
3 changes: 3 additions & 0 deletions src/thread.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const isIPFS = require('is-ipfs')
const API = require('./api')
const config = require('./config')

const ORBITDB_OPTS = config.orbitdb_options
const MODERATOR = 'MODERATOR'
const MEMBER = 'MEMBER'

Expand Down Expand Up @@ -181,6 +183,7 @@ class Thread {
await this._initConfigs()
const identity = this._identity
this._db = await this._orbitdb.feed(odbAddress || this._name, {
...ORBITDB_OPTS,
identity,
accessController: this._accessController
})
Expand Down

0 comments on commit 194df24

Please sign in to comment.