Skip to content

Commit

Permalink
Merge pull request #460 from poanetwork/develop
Browse files Browse the repository at this point in the history
5.2.5
  • Loading branch information
vbaranov committed May 21, 2021
2 parents e283648 + 0cb6d65 commit 99df293
Show file tree
Hide file tree
Showing 9 changed files with 561 additions and 296 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Current Master

## 5.2.5 Fri May 21 2021

- [#459](https://github.com/poanetwork/nifty-wallet/pull/459) - (Fix) Phishing detection

## 5.2.4 Sat Feb 27 2021

- [#451](https://github.com/poanetwork/nifty-wallet/pull/451) - (Fix) Fix export private key when switching between chains
Expand Down
2 changes: 1 addition & 1 deletion app/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_appName__",
"short_name": "__MSG_appName__",
"version": "5.2.4",
"version": "5.2.5",
"manifest_version": 2,
"author": "POA Network",
"description": "__MSG_appDescription__",
Expand Down
121 changes: 0 additions & 121 deletions app/scripts/controllers/blacklist.js

This file was deleted.

6 changes: 2 additions & 4 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ const { importTypes } = require('../../old-ui/app/accounts/import/enums')
const { LEDGER, TREZOR } = require('../../old-ui/app/components/connect-hardware/enum')
const { ifPOA, ifXDai, ifRSK, getNetworkID, getDPath, setDPath } = require('../../old-ui/app/util')
const { GasPriceOracle } = require('gas-price-oracle')

import {
PhishingController,
} from 'gaba'
} from '@metamask/controllers'

const {
CLASSIC_CODE,
Expand Down Expand Up @@ -525,8 +524,7 @@ module.exports = class MetamaskController extends EventEmitter {
setFeatureFlag: nodeify(preferencesController.setFeatureFlag, preferencesController),
setPreference: nodeify(preferencesController.setPreference, preferencesController),

// BlacklistController
// whitelistPhishingDomain: this.whitelistPhishingDomain.bind(this),
whitelistPhishingDomain: this.whitelistPhishingDomain.bind(this),

// AddressController
setAddressBook: nodeify(addressBookController.setAddressBook, addressBookController),
Expand Down
66 changes: 21 additions & 45 deletions app/scripts/phishing-detect.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,35 @@
window.onload = function () {
if (window.location.pathname === '/phishing.html') {
const {hostname} = parseHash()
document.getElementById('esdbLink').innerHTML = '<b>To read more about this scam, navigate to: <a href="https://etherscamdb.info/domain/' + hostname + '"> https://etherscamdb.info/domain/' + hostname + '</a></b>'
}
}

const querystring = require('querystring')
const dnode = require('dnode')
const { EventEmitter } = require('events')
import querystring from 'querystring'
import PortStream from 'extension-port-stream'
const extension = require('extensionizer')
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
const { getEnvironmentType } = require('./lib/util')
import extension from 'extensionizer'
import createRandomId from '../../shared/modules/random-id'
import { setupMultiplex } from './lib/stream-utils'
import { getEnvironmentType } from './lib/util'
import ExtensionPlatform from './platforms/extension'

document.addEventListener('DOMContentLoaded', start)

function start () {
const windowType = getEnvironmentType(window.location.href)
const hash = window.location.hash.substring(1)
const suspect = querystring.parse(hash)

document.getElementById('csdbLink').href = `https://cryptoscamdb.org/search`

global.platform = new ExtensionPlatform()
global.METAMASK_UI_TYPE = windowType

const extensionPort = extension.runtime.connect({ name: windowType })
const extensionPort = extension.runtime.connect({
name: getEnvironmentType(),
})
const connectionStream = new PortStream(extensionPort)
const mx = setupMultiplex(connectionStream)
setupControllerConnection(mx.createStream('controller'), (err, metaMaskController) => {
if (err) {
return
}

const suspect = parseHash()
const unsafeContinue = () => {
window.location.href = suspect.href
}
const continueLink = document.getElementById('unsafe-continue')
continueLink.addEventListener('click', () => {
metaMaskController.whitelistPhishingDomain(suspect.hostname)
unsafeContinue()
const backgroundConnection = mx.createStream('controller')
const continueLink = document.getElementById('unsafe-continue')
continueLink.addEventListener('click', () => {
backgroundConnection.write({
jsonrpc: '2.0',
method: 'safelistPhishingDomain',
params: [suspect.hostname],
id: createRandomId(),
})
window.location.href = suspect.href
})
}

function setupControllerConnection (connectionStream, cb) {
const eventEmitter = new EventEmitter()
const accountManagerDnode = dnode({
sendUpdate (state) {
eventEmitter.emit('update', state)
},
})
connectionStream.pipe(accountManagerDnode).pipe(connectionStream)
accountManagerDnode.once('remote', (accountManager) => cb(null, accountManager))
}

function parseHash () {
const hash = window.location.hash.substring(1)
return querystring.parse(hash)
}
Loading

0 comments on commit 99df293

Please sign in to comment.