-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Limit Dapp permissions to primary account #8653
Conversation
@rekmarks I tested locally with a locally running test-dapp with some console.log statements to confirm I was getting the expected length of response. ➕ It looks like its working but I'm sure this missing some finesse on how we can test it etc. |
9f2b709
to
c035cdc
Compare
test/unit/app/controllers/permissions/permissions-controller-test.js
Outdated
Show resolved
Hide resolved
test/unit/app/controllers/permissions/permissions-controller-test.js
Outdated
Show resolved
Hide resolved
Builds ready [0752434]
Page Load Metrics (689 ± 79 ms)
|
ethAccounts.caveats.push({ | ||
type: CAVEAT_TYPES.limitResponseLength, | ||
value: 1, | ||
name: CAVEAT_NAMES.primaryAccountOnly, | ||
}) | ||
|
||
ethAccounts.caveats.push({ | ||
type: CAVEAT_TYPES.filterResponse, | ||
value: finalizedAccounts, | ||
name: CAVEAT_NAMES.exposedAccounts, | ||
}) |
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 want to note for posterity that this order is unfortunately important. Fortunately, it is preserved when we call addPermittedAccount
, which calls CapabilitiesController.updateCaveatFor
on the exposedAccounts
caveat, which adds the updated caveat to the end of the caveat array.
There's currently no way to ensure that rpc-cap
enforces a particular order of caveat application, except to add/update them such that they're in the order you desire.
So, happily not a problem here, but I'll create an issue on rpc-cap
for a feature request.
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.
Ref: MetaMask/rpc-cap#100
Builds ready [d112e95]
Page Load Metrics (627 ± 61 ms)
|
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.
LGTM!
Builds ready [3e868be]
Page Load Metrics (585 ± 43 ms)
|
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.
Re-approve
The "Connected accounts" modal was throwing an exception when attempting to render an account that has no `lastActive` time. The component and related selector has been updated to no longer expect the `lastActive` time to be set. Prior to #8653 there was a guarantee that all connected accounts had a `lastActive` time set, as the time would be set on any account returned from the `eth_requestAccounts` call. But after #8653 only the primary account was returned, so only the primary account had a `lastActive` time set. Fixes #8733
The "Connected accounts" modal was throwing an exception when attempting to render an account that has no `lastActive` time. The component and related selector has been updated to no longer expect the `lastActive` time to be set. Prior to #8653 there was a guarantee that all connected accounts had a `lastActive` time set, as the time would be set on any account returned from the `eth_requestAccounts` call. But after #8653 only the primary account was returned, so only the primary account had a `lastActive` time set. Fixes #8733
Closes #8651
Uses the new limitResponseLength caveat exposed in rpc-cap to limit the Dapp's permission to only be able to access the primary account. This is step 1 of a two PR(+) contribution to add the ability for Dapp authors to request permission to interact with all connected accounts. This PR is a requirement for v8 RC