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

Commit

Permalink
fix: limit retries for uncaught errors, display iframe for accoutn link
Browse files Browse the repository at this point in the history
  • Loading branch information
zachferland committed Apr 19, 2020
1 parent c6e6e39 commit fbe7af8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const checkIsMobile = () => {
} else {
isMobile = false;
}
console.log('isMobile', isMobile)
// console.log('isMobile', isMobile)
return isMobile;
};

Expand Down
15 changes: 14 additions & 1 deletion src/threeIdConnectService.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ class ThreeIdConnectService {
}
return threeId.serializeState()
} else if (type === '3id_createLink' ) {
return this.idWallet.linkAddress(address, this.externalProvider)
// TODO could use disply hook for a link request specific card, will show consent screen again right now
this.displayIframe()
try {
await this.idWallet.linkAddress(address, this.externalProvider)
} catch(e) {
console.log(e)
}
this.hideIframe()
}
}

Expand Down Expand Up @@ -172,9 +179,14 @@ class ThreeIdConnectService {
loop = false
})

// Should not be neccessary, but sets bounds on any uncaught errors, so
// we dont have infinite loop and freeze
let tries = 0

if (message.method === '3id_authenticate') {
// Try until response valid, or canceled above
while (loop) {
tries++
try {
const res = await this.provider.send(message, domain)
if (message.method === `3id_authenticate`) this.hideIframe()
Expand All @@ -184,6 +196,7 @@ class ThreeIdConnectService {
this.errorCb(e, 'There was an error. Use the same account you used for this app.')
this._removeConsents(message, domain)
}
if (tries >= 10) loop = false
}
} else {
const res = await this.provider.send(message, domain)
Expand Down

0 comments on commit fbe7af8

Please sign in to comment.