-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix extension WebUSB permission issue #1079
Conversation
🦙 MegaLinter status: ✅ SUCCESS
See errors details in artifact MegaLinter reports on CI Job page |
Codecov Report
@@ Coverage Diff @@
## master #1079 +/- ##
==========================================
+ Coverage 84.88% 85.05% +0.17%
==========================================
Files 121 126 +5
Lines 2249 2309 +60
Branches 539 559 +20
==========================================
+ Hits 1909 1964 +55
- Misses 340 345 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
|
b3369fc
to
0430931
Compare
</Box> | ||
)} | ||
{connection === 'connected' && ( | ||
<ConnectionStatusIcon label={t('ledger.extension.succeed', 'Device connected')} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra popup should probably automatically close after this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checked both dev and prod builds and I cannot repro this
{webExtensionLedgerAccess ? ( | ||
<Button | ||
style={{ width: 'fit-content' }} | ||
onClick={webExtensionLedgerAccess} | ||
label={t('ledger.extension.grantAccess', 'Grant access to your Ledger')} | ||
primary | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flow should only be needed the first time for each unpaired ledger device, not every time. Background page already has the needed permissions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only problem is that permission can be revoked at any time, right after it was granted, and we have no knowledge about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about on click: attempt to get a device and if it fails openLedgerAccessPopup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share more details? Do you want to dispatch saga action first and handle "LedgerNoDeviceSelected" differently or there is some way to get a device and checked if it's paired?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just try { await TransportWebUSB.create(); to="ledger" } catch (e) { openLedgerAccessPopup() }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to create usb transport here we will have to close it in React component as well to avoid USB Transport error: Failed to execute 'claimInterface' on 'USBDevice': Unable to claim interface.
At this point everything looks fine, but when I will revoke usb access and go through process again it will end up with USB Transport error: Failed to execute 'open' on 'USBDevice': The device was disconnected.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I am able to reproduce this
try {
await (await TransportWebUSB.create()).close()
navigate('/open-wallet/ledger')
} catch (e) {
webExtensionLedgerAccess()
}
what's very odd is that it works after reloading background page, as if close()
doesn't fully reset device communication
- start with extension having USB permission
- enumerate accounts works, cancel
- remove USB permission
- connect ledger flow, enumerate accounts does not work, cancel
- reload background page
- enumerate accounts works, cancel
- remove USB permission
- reload background page
- connect ledger flow, enumerate accounts works, cancel
9dbc6fa
to
e79968f
Compare
cb8e38e
to
5b56312
Compare
4e3c61f
to
68eb66e
Compare
68eb66e
to
117dbe3
Compare
117dbe3
to
e07f288
Compare
Fixes #1045





During sync meeting we decided to go with a popup like in a current ext.
error:
