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 #264 from 3box/release/1.2.1
Browse files Browse the repository at this point in the history
Release v1.2.1
  • Loading branch information
Joel Torstensson authored Jan 17, 2019
2 parents fa1982c + a15d621 commit 3e6eec5
Show file tree
Hide file tree
Showing 8 changed files with 313 additions and 64 deletions.
7 changes: 7 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release Notes

## v1.2.1 - 2019-01-17
* Fixes bug in getVerifiedAccounts to work with earlier accounts #258
* Fix to allow openBox to be called with no options
* Replace bip39 dependency with more lightweight ethers.js dependency
* Removes stale lib files during build
* Modify example to work in additional environments including github pages

## v1.2.0 - 2019-01-08
* Implemented new "verified" api that checks and verifies various claims
* Reconnects to pinning node if connection is lost
Expand Down
2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h2> Get Profile GraphQL </h2>
name
image
emoji
did
proof_did
}
}
</textarea>
Expand Down
6 changes: 3 additions & 3 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const syncComplete = (res) => {
bopen.addEventListener('click', event => {

window.ethereum.enable().then(addresses => {
Box.openBox(addresses[0], window.ethereum, {}).then(box => {
window.Box.openBox(addresses[0], window.ethereum, {}).then(box => {
box.onSyncDone(syncComplete)
window.box = box
console.log(box)
Expand Down Expand Up @@ -52,7 +52,7 @@ bopen.addEventListener('click', event => {

getProfile.addEventListener('click', () => {
console.log(ethAddr.value)
Box.getProfile(ethAddr.value, {}).then(profile => {
window.Box.getProfile(ethAddr.value, {}).then(profile => {
console.log(profile)
Object.entries(profile).map(kv => {
getProfileData.innerHTML += kv[0] + ': ' + kv[1] + '<br />'
Expand All @@ -63,7 +63,7 @@ getProfile.addEventListener('click', () => {
profileGraphQL.addEventListener('click', () => {
const query = profileGraphQLQuery.value
console.log(query)
Box.profileGraphQL(query).then(res => {
window.Box.profileGraphQL(query).then(res => {
console.log(res)
profileGraphQLData.innerHTML = ''
if (res.profile) {
Expand Down
157 changes: 116 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3box",
"version": "1.2.0",
"version": "1.2.1",
"description": "Interact with user data",
"main": "lib/3box.js",
"directories": {
Expand All @@ -9,7 +9,7 @@
"scripts": {
"lint": "./node_modules/.bin/standard --verbose src/**",
"test": "rm -rf ./tmp ; jest --forceExit --detectOpenHandles --coverage --runInBand --testURL=\"http://localhost\"",
"build:es5": "./node_modules/.bin/babel src --out-dir lib --ignore=src/__tests__/,src/__mocks__/",
"build:es5": "rm -rf ./lib; ./node_modules/.bin/babel src --out-dir lib --ignore=src/__tests__/,src/__mocks__/",
"build:dist": "./node_modules/.bin/webpack --config webpack.config.js --mode=development",
"build:dist:prod": "./node_modules/.bin/webpack --config webpack.config.js --mode=production --output-filename 3box.min.js",
"build": "npm run build:es5; npm run build:dist; npm run build:dist:prod",
Expand Down Expand Up @@ -41,7 +41,7 @@
"homepage": "https://github.com/uport-project/3box-js#readme",
"dependencies": {
"@babel/runtime": "^7.1.2",
"bip39": "^2.5.0",
"ethers": "^4.0.20",
"graphql-request": "^1.8.2",
"https-did-resolver": "0.0.3",
"ipfs": "^0.33.1",
Expand Down
36 changes: 20 additions & 16 deletions src/3box.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const MuPort = require('muport-core')
const bip39 = require('bip39')
const { HDNode } = require('ethers').utils
const localstorage = require('store')
const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')
Expand Down Expand Up @@ -277,20 +277,24 @@ class Box {
*/
static async getVerifiedAccounts (profile) {
let verifs = {}
const did = await verifier.verifyDID(profile.proof_did)
if (profile.proof_github) {
try {
verifs.github = await verifier.verifyGithub(did, profile.proof_github)
} catch (err) {
console.error('Invalid github verification:', err.message)
try {
const did = await verifier.verifyDID(profile.proof_did)
if (profile.proof_github) {
try {
verifs.github = await verifier.verifyGithub(did, profile.proof_github)
} catch (err) {
// Invalid github verification
}
}
}
if (profile.proof_twitter) {
try {
verifs.twitter = await verifier.verifyTwitter(did, profile.proof_twitter)
} catch (err) {
console.error('Invalid twitter verification:', err.message)
if (profile.proof_twitter) {
try {
verifs.twitter = await verifier.verifyTwitter(did, profile.proof_twitter)
} catch (err) {
// Invalid twitter verification
}
}
} catch (err) {
// Invalid proof for DID return an empty profile
}
return verifs
}
Expand All @@ -309,7 +313,7 @@ class Box {
* @param {Boolean} opts.iframeStore Use iframe for storage, allows shared store across domains. Default true when run in browser.
* @return {Box} the 3Box instance for the given address
*/
static async openBox (address, ethereumProvider, opts) {
static async openBox (address, ethereumProvider, opts = {}) {
// opts = Object.assign({ iframeStore: true }, opts)
const normalizedAddress = address.toLowerCase()
let muportDID
Expand All @@ -320,8 +324,8 @@ class Box {
} else {
const sig = await utils.openBoxConsent(normalizedAddress, ethereumProvider)
if (opts.consentCallback) opts.consentCallback(true)
const entropy = utils.sha256(sig.slice(2))
const mnemonic = bip39.entropyToMnemonic(entropy)
const entropy = '0x' + utils.sha256(sig.slice(2))
const mnemonic = HDNode.entropyToMnemonic(entropy)
muportDID = await MuPort.newIdentity(null, null, {
externalMgmtKey: normalizedAddress,
mnemonic
Expand Down
Loading

0 comments on commit 3e6eec5

Please sign in to comment.