mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Merge pull request #1739 from MetaMask/origin-header
metamask - append dapp origin domain to rpc request
This commit is contained in:
commit
ce3d374d80
@ -184,7 +184,9 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
eth_syncing: false,
|
||||
web3_clientVersion: `MetaMask/v${version}`,
|
||||
},
|
||||
// rpc data source
|
||||
rpcUrl: this.networkController.getCurrentRpcAddress(),
|
||||
originHttpHeaderKey: 'X-Metamask-Origin',
|
||||
// account mgmt
|
||||
getAccounts: (cb) => {
|
||||
const isUnlocked = this.keyringController.memStore.getState().isUnlocked
|
||||
@ -356,8 +358,13 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
}
|
||||
|
||||
setupProviderConnection (outStream, originDomain) {
|
||||
streamIntoProvider(outStream, this.provider, logger)
|
||||
function logger (err, request, response) {
|
||||
streamIntoProvider(outStream, this.provider, onRequest, onResponse)
|
||||
// append dapp origin domain to request
|
||||
function onRequest (request) {
|
||||
request.origin = originDomain
|
||||
}
|
||||
// log rpc activity
|
||||
function onResponse (err, request, response) {
|
||||
if (err) return console.error(err)
|
||||
if (response.error) {
|
||||
console.error('Error in RPC response:\n', response.error)
|
||||
|
@ -124,8 +124,8 @@
|
||||
"valid-url": "^1.0.9",
|
||||
"vreme": "^3.0.2",
|
||||
"web3": "0.19.1",
|
||||
"web3-provider-engine": "^13.0.3",
|
||||
"web3-stream-provider": "^2.0.6",
|
||||
"web3-provider-engine": "^13.1.1",
|
||||
"web3-stream-provider": "^3.0.1",
|
||||
"xtend": "^4.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
Loading…
Reference in New Issue
Block a user