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 #650 from 3box/hotfix/v1.13.2
Browse files Browse the repository at this point in the history
Hotfix/v1.13.2
  • Loading branch information
zachferland authored Nov 14, 2019
2 parents 094391e + c6a9a24 commit bbb311b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 22 deletions.
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Release Notes
j
## v1.13.2 - 2019-11-15
* fix: check for 3id provider support in a better way

## v1.13.1 - 2019-10-25
* feat: return all messages seen in a ghost thread on getPost
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3box",
"version": "1.13.1",
"version": "1.13.2",
"description": "Interact with user data",
"main": "lib/3box.js",
"directories": {
Expand Down
11 changes: 5 additions & 6 deletions src/3box.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,13 @@ class Box {
let consent
try {
// TODO - this should be handled in the 3ID class
consent = await utils.callRpc(this._web3provider, '3id_linkManagementKey', { did })
} catch (e) {
// an error most likely means that the provider doesn't support 3id
try {
if (this._web3provider.is3idProvider) {
consent = await utils.callRpc(this._web3provider, '3id_linkManagementKey', { did })
} else {
consent = await utils.getLinkConsent(address, did, this._web3provider)
} catch (e) {
throw new Error('Link consent message must be signed before adding data, to link address to store')
}
} catch (e) {
throw new Error('Link consent message must be signed before adding data, to link address to store')
}

const addressType = await this._detectAddressType(address)
Expand Down
5 changes: 4 additions & 1 deletion src/3id/__tests__/3id.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ describe('3id', () => {
describe('get 3ID using IdentityWallet', () => {
it('instantiate threeId with IdentityWallet', async () => {
const idWallet = new IdentityWallet({ seed: ID_WALLET_SEED })
idw3id = await ThreeId.getIdFromEthAddress(null, idWallet.get3idProvider(), ipfs)
const provider = idWallet.get3idProvider()
// monkey patch because we're not using latest version of idwallet
provider.is3idProvider = true
idw3id = await ThreeId.getIdFromEthAddress(null, provider, ipfs)
expect(idw3id.DID).toBeUndefined()
await idw3id.authenticate()
expect(idw3id.DID).toMatchSnapshot()
Expand Down
11 changes: 1 addition & 10 deletions src/3id/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class ThreeId {
}

static async getIdFromEthAddress (address, provider, ipfs, opts = {}) {
opts.has3idProv = await has3idSupport(provider)
opts.has3idProv = Boolean(provider.is3idProvider)
if (opts.has3idProv) {
return new ThreeId(provider, ipfs, opts)
} else {
Expand Down Expand Up @@ -304,15 +304,6 @@ class ThreeId {
}
}

const has3idSupport = async provider => {
try {
await utils.callRpc(provider, '3id_getLink')
// no error thrown, provider has 3id support
return true
} catch (e) {}
return false
}

const createMuportDocument = (signingKey, managementKey, asymEncryptionKey) => {
return {
version: 1,
Expand Down
20 changes: 16 additions & 4 deletions src/__tests__/idWallet.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ describe('Integration Test: IdentityWallet', () => {
})

it('should openBox correctly when idWallet is passed', async () => {
const box = await Box.openBox(null, idWallet.get3idProvider(), opts)
const provider = idWallet.get3idProvider()
// monkey patch because we're not using latest version of idwallet
provider.is3idProvider = true
const box = await Box.openBox(null, provider, opts)
await box.syncDone
await box.public.set('a', 1)
await box.public.set('b', 2)
Expand All @@ -109,7 +112,10 @@ describe('Integration Test: IdentityWallet', () => {

it('should get same state on second openBox', async () => {
publishHasEntries()
const box = await Box.openBox(null, idWallet.get3idProvider(), opts)
const provider = idWallet.get3idProvider()
// monkey patch because we're not using latest version of idwallet
provider.is3idProvider = true
const box = await Box.openBox(null, provider, opts)
await box.syncDone
expect(await box.public.all()).toEqual(pubState)

Expand All @@ -124,7 +130,10 @@ describe('Integration Test: IdentityWallet', () => {
it('should get same state on openBox with IdentityWallet opened using first authSecret', async () => {
publishHasEntries()
idWallet = new IdentityWallet({ authSecret: AUTH_1, ethereumAddress: ADDRESS })
const box = await Box.openBox(null, idWallet.get3idProvider(), opts)
const provider = idWallet.get3idProvider()
// monkey patch because we're not using latest version of idwallet
provider.is3idProvider = true
const box = await Box.openBox(null, provider, opts)
await box.syncDone
expect(await box.public.all()).toEqual(pubState)

Expand All @@ -139,7 +148,10 @@ describe('Integration Test: IdentityWallet', () => {
it('should get same state on openBox with IdentityWallet opened using second authSecret', async () => {
publishHasEntries()
idWallet = new IdentityWallet({ authSecret: AUTH_2, ethereumAddress: ADDRESS })
const box = await Box.openBox(null, idWallet.get3idProvider(), opts)
const provider = idWallet.get3idProvider()
// monkey patch because we're not using latest version of idwallet
provider.is3idProvider = true
const box = await Box.openBox(null, provider, opts)
await box.syncDone
expect(await box.public.all()).toEqual(pubState)
await box.close()
Expand Down

0 comments on commit bbb311b

Please sign in to comment.