1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Stop adding permissions middleware to trusted connections (#8701)

* don't add permissions middleware to trusted connections

* fix test case
This commit is contained in:
Erik Marks 2020-05-29 10:53:31 -07:00 committed by GitHub
parent ddaa492751
commit cf60c8e1f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -1548,7 +1548,7 @@ export default class MetamaskController extends EventEmitter {
tabId = sender.tab.id
}
const engine = this.setupProviderEngine({ origin, location: sender.url, extensionId, tabId })
const engine = this.setupProviderEngine({ origin, location: sender.url, extensionId, tabId, isInternal })
// setup connection
const providerStream = createEngineStream({ engine })
@ -1581,8 +1581,9 @@ export default class MetamaskController extends EventEmitter {
* @param {string} options.location - The full URL of the sender
* @param {extensionId} [options.extensionId] - The extension ID of the sender, if the sender is an external extension
* @param {tabId} [options.tabId] - The tab ID of the sender - if the sender is within a tab
* @param {boolean} [options.isInternal] - True if called for a connection to an internal process
**/
setupProviderEngine ({ origin, location, extensionId, tabId }) {
setupProviderEngine ({ origin, location, extensionId, tabId, isInternal = false }) {
// setup json rpc engine stack
const engine = new RpcEngine()
const provider = this.provider
@ -1610,8 +1611,10 @@ export default class MetamaskController extends EventEmitter {
// filter and subscription polyfills
engine.push(filterMiddleware)
engine.push(subscriptionManager.middleware)
// permissions
engine.push(this.permissionsController.createMiddleware({ origin, extensionId }))
if (!isInternal) {
// permissions
engine.push(this.permissionsController.createMiddleware({ origin, extensionId }))
}
// watch asset
engine.push(this.preferencesController.requestWatchAsset.bind(this.preferencesController))
// forward to metamask primary provider

View File

@ -102,8 +102,8 @@ describe('permissions controller', function () {
assert.deepEqual(cAccounts, [], 'origin should have no accounts')
})
it('does not handle "MetaMask" origin as special case', async function () {
const metamaskAccounts = await permController.getAccounts('MetaMask')
it('does not handle "metamask" origin as special case', async function () {
const metamaskAccounts = await permController.getAccounts('metamask')
assert.deepEqual(metamaskAccounts, [], 'origin should have no accounts')
})
})