feature/default_network_editable
brunobar79 6 years ago
parent 728aeb9344
commit 814c642d95
  1. 3
      app/manifest.json
  2. 6765
      app/vendor/trezor/connect.js
  3. 42
      app/vendor/trezor/usb-permissions.js
  4. 18
      package-lock.json

@ -28,8 +28,7 @@
"background": { "background": {
"scripts": [ "scripts": [
"chromereload.js", "chromereload.js",
"background.js", "background.js"
"vendor/trezor/connect.js"
], ],
"persistent": true "persistent": true
}, },

File diff suppressed because it is too large Load Diff

@ -2,6 +2,39 @@
Handling messages from usb permissions iframe Handling messages from usb permissions iframe
*/ */
const switchToPopupTab = (event) => {
window.removeEventListener('beforeunload', switchToPopupTab);
if (!event) {
// triggered from 'usb-permissions-close' message
// switch tab to previous index and close current
chrome.tabs.query({
currentWindow: true,
active: true,
}, (current) => {
if (current.length < 0) return;
chrome.tabs.query({
index: current[0].index - 1
}, popup => {
if (popup.length < 0) return;
chrome.tabs.update(popup[0].id, { active: true });
})
chrome.tabs.remove(current[0].id);
});
return;
}
// triggered from 'beforeunload' event
// find tab by popup pattern and switch to it
chrome.tabs.query({
url: "*://connect.trezor.io/*/popup.html"
}, (tabs) => {
if (tabs.length < 0) return;
chrome.tabs.update(tabs[0].id, { active: true });
});
}
window.addEventListener('message', event => { window.addEventListener('message', event => {
if (event.data === 'usb-permissions-init') { if (event.data === 'usb-permissions-init') {
const iframe = document.getElementById('trezor-usb-permissions'); const iframe = document.getElementById('trezor-usb-permissions');
@ -10,11 +43,8 @@ window.addEventListener('message', event => {
extension: chrome.runtime.id, extension: chrome.runtime.id,
}, '*'); }, '*');
} else if (event.data === 'usb-permissions-close') { } else if (event.data === 'usb-permissions-close') {
chrome.tabs.query({ switchToPopupTab();
currentWindow: true,
active: true,
}, (tabs) => {
chrome.tabs.remove(tabs[0].id);
});
} }
}); });
window.addEventListener('beforeunload', switchToPopupTab);

18
package-lock.json generated

@ -8558,12 +8558,13 @@
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz", "resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=", "integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
"requires": { "requires": {
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"ethereumjs-util": "^5.1.1" "ethereumjs-util": "^5.1.1"
}, },
"dependencies": { "dependencies": {
"ethereumjs-abi": { "ethereumjs-abi": {
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7", "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7", "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"requires": { "requires": {
"bn.js": "^4.10.0", "bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0" "ethereumjs-util": "^5.0.0"
@ -8793,7 +8794,7 @@
"ethereumjs-util": "^5.1.5", "ethereumjs-util": "^5.1.5",
"events": "^2.0.0", "events": "^2.0.0",
"hdkey": "0.8.0", "hdkey": "0.8.0",
"trezor-connect": "^5.0.28" "trezor-connect": "^5.0.29"
}, },
"dependencies": { "dependencies": {
"ethereum-common": { "ethereum-common": {
@ -30424,6 +30425,7 @@
"version": "3.1.5", "version": "3.1.5",
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
"dev": true,
"requires": { "requires": {
"is-typedarray": "^1.0.0" "is-typedarray": "^1.0.0"
} }
@ -31428,6 +31430,7 @@
"resolved": "https://registry.npmjs.org/web3/-/web3-0.20.3.tgz", "resolved": "https://registry.npmjs.org/web3/-/web3-0.20.3.tgz",
"integrity": "sha1-yqRDc9yIFayHZ73ba6cwc5ZMqos=", "integrity": "sha1-yqRDc9yIFayHZ73ba6cwc5ZMqos=",
"requires": { "requires": {
"bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
"crypto-js": "^3.1.4", "crypto-js": "^3.1.4",
"utf8": "^2.1.1", "utf8": "^2.1.1",
"xhr2": "*", "xhr2": "*",
@ -31436,7 +31439,7 @@
"dependencies": { "dependencies": {
"bignumber.js": { "bignumber.js": {
"version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", "version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
"from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934" "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git"
} }
} }
}, },
@ -31935,7 +31938,8 @@
"dev": true, "dev": true,
"requires": { "requires": {
"underscore": "1.8.3", "underscore": "1.8.3",
"web3-core-helpers": "1.0.0-beta.34" "web3-core-helpers": "1.0.0-beta.34",
"websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2"
}, },
"dependencies": { "dependencies": {
"underscore": { "underscore": {
@ -31946,7 +31950,8 @@
}, },
"websocket": { "websocket": {
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2", "version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"from": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2", "from": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
"dev": true,
"requires": { "requires": {
"debug": "^2.2.0", "debug": "^2.2.0",
"nan": "^2.3.3", "nan": "^2.3.3",
@ -33287,7 +33292,8 @@
"yaeti": { "yaeti": {
"version": "0.0.6", "version": "0.0.6",
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=" "integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=",
"dev": true
}, },
"yallist": { "yallist": {
"version": "2.1.2", "version": "2.1.2",

Loading…
Cancel
Save