Skip to content

Commit

Permalink
Merge pull request #237 from aeternity/release/0.0.22
Browse files Browse the repository at this point in the history
Release 0.0.22
  • Loading branch information
davidyuk authored Apr 30, 2020
2 parents a18f55a + 966cee2 commit 5e3cb5b
Show file tree
Hide file tree
Showing 100 changed files with 1,583 additions and 1,165 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ISC License

Copyright (c) 2019, SuperHero
Copyright (c) 2019, Superhero

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Superhero Wallet

**SuperHero is a browser extension that allows you to send and recieve value to URLs and content accross Internet.**
**Superhero is a browser extension that allows you to send and recieve value to URLs and content accross Internet.**

[![Build Status](https://travis-ci.com/aeternity/superhero-wallet.svg?branch=develop)](https://travis-ci.com/aeternity/superhero-wallet)

Expand Down
8 changes: 4 additions & 4 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.superhero.cordova" version="0.0.21" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>SuperHero</name>
<description>SuperHero wallet</description>
<widget id="com.superhero.cordova" version="0.0.22" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Superhero</name>
<description>Superhero wallet</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
SuperHero
Superhero
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
Expand Down
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "superhero-wallet",
"version": "0.0.21",
"version": "0.0.22",
"description": "Superhero wallet",
"author": "SuperHero",
"author": "Superhero",
"license": "MIT",
"private": true,
"scripts": {
Expand Down Expand Up @@ -59,7 +59,7 @@
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-wkwebview-engine": "github:mwchambers/cordova-plugin-wkwebview-engine#da67d6bb6ce8597c38fc69e66b84566e34efea8d",
"crypto-browserify": "^3.12.0",
"detect-browser": "^4.7.0",
"detect-browser": "^4.8.0",
"emailjs-com": "^2.4.0",
"extensionizer": "^1.0.1",
"file-saver": "^2.0.2",
Expand All @@ -74,6 +74,7 @@
"rxjs-etc": "^9.7.4",
"tweetnacl": "^1.0.3",
"uuid": "^3.3.3",
"validator": "^13.0.0",
"vue": "^2.6.10",
"vue-awesome": "^3.5.4",
"vue-clipboard2": "^0.3.1",
Expand Down
125 changes: 70 additions & 55 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -1,83 +1,74 @@
import { setInterval } from 'timers';
import uid from 'uuid';
import { setController, switchNode } from './lib/background-utils';
import './lib/initPolyfills';
import { phishingCheckUrl, getPhishingUrls, setPhishingUrl } from './popup/utils/phishing-detect';
import { detectConnectionType } from './popup/utils/helper';
import { buildTx } from './popup/utils';
import WalletController from './wallet-controller';
import Notification from './notifications';
import { PopupConnections } from './lib/popup-connection';
import RedirectChainNames from './lib/redirect-chain-names';
import rpcWallet from './lib/rpcWallet';
import TipClaimRelay from './lib/tip-claim-relay';
import Notification from './notifications';
import { buildTx } from './popup/utils';
import { popupProps } from './popup/utils/config';
import {
HDWALLET_METHODS,
AEX2_METHODS,
NOTIFICATION_METHODS,
CONNECTION_TYPES,
DEFAULT_NETWORK,
HDWALLET_METHODS,
NOTIFICATION_METHODS,
} from './popup/utils/constants';
import { popupProps } from './popup/utils/config';
import TipClaimRelay from './lib/tip-claim-relay';
import RedirectChainNames from './lib/redirect-chain-names';
import { setController, switchNode } from './lib/background-utils';
import { PopupConnections } from './lib/popup-connection';
import { detectConnectionType } from './popup/utils/helper';
import { getPhishingUrls, phishingCheckUrl, setPhishingUrl } from './popup/utils/phishing-detect';
import WalletController from './wallet-controller';
import Logger from './lib/logger';

const controller = new WalletController();

if (process.env.IS_EXTENSION && require.main.i === module.id) {
Logger.init({ background: true });
RedirectChainNames.init();
setInterval(() => {
browser.windows.getAll({}).then(wins => {
if (wins.length === 0) {
sessionStorage.removeItem('phishing_urls');
}
});
}, 5000);

const notification = new Notification();
setController(controller);

const postPhishingData = async data => {
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
const message = { method: 'phishingCheck', data };
const message = { method: 'phishingCheck', ...data };
tabs.forEach(({ id }) => browser.tabs.sendMessage(id, message));
};

browser.runtime.onMessage.addListener(async (msg, sender) => {
switch (msg.method) {
case 'phishingCheck': {
const data = { ...msg, extUrl: browser.extension.getURL('./') };
const host = new URL(msg.params.href).hostname;
data.host = host;
const { result } = await phishingCheckUrl(host);
if (result === 'blocked') {
const whitelist = getPhishingUrls().filter(url => url === host);
if (whitelist.length) {
data.blocked = false;
return postPhishingData(data);
}
data.blocked = true;
return postPhishingData(data);
}
data.blocked = false;
return postPhishingData(data);
}
case 'setPhishingUrl': {
const urls = getPhishingUrls();
urls.push(msg.params.hostname);
setPhishingUrl(urls);
break;
const { method, params, from, type, data } = msg;
if (method === 'phishingCheck') {
const host = new URL(params.href).hostname;
let blocked = false;
const { result } = await phishingCheckUrl(host);
if (result === 'blocked') {
const whitelist = getPhishingUrls().filter(url => url === host);
blocked = !whitelist.length;
}
default:
break;
return postPhishingData({
...msg,
data: {
method,
extUrl: browser.extension.getURL('./'),
host,
href: params.href,
blocked,
},
});
}

if (method === 'setPhishingUrl') {
const urls = getPhishingUrls();
urls.push(params.hostname);
setPhishingUrl(urls);
return true;
}

if (
msg.from === 'content' &&
msg.type === 'readDom' &&
(msg.data.address || msg.data.chainName)
) {
if (from === 'content' && type === 'readDom' && (data.address || data.chainName)) {
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
tabs.forEach(({ url }) => {
if (sender.url === url && DEFAULT_NETWORK === 'Mainnet') {
TipClaimRelay.checkUrlHasBalance(url, msg.data);
TipClaimRelay.checkUrlHasBalance(url, data);
}
});
}
Expand Down Expand Up @@ -109,15 +100,39 @@ if (process.env.IS_EXTENSION && require.main.i === module.id) {

popupConnections.addConnection(id, port);
} else if (connectionType === CONNECTION_TYPES.OTHER) {
const check = rpcWallet.sdkReady(() => {
// eslint-disable-next-line no-param-reassign
port.uuid = uid();
if (rpcWallet.sdkReady()) {
rpcWallet.addConnection(port);
});
} else {
rpcWallet.addConnectionToQueue(port);
}
port.onDisconnect.addListener(() => {
clearInterval(check);
rpcWallet.removeConnectionFromQueue(port);
});
}
}
});

const contextMenuItem = {
id: 'superheroTip',
title: 'Tip',
};

browser.contextMenus.removeAll();
browser.contextMenus.create(contextMenuItem);
browser.contextMenus.onClicked.addListener(({ menuItemId, pageUrl }) => {
if (menuItemId === 'superheroTip') {
const url = `/tip?url=${pageUrl}`;
localStorage.setItem('tipUrl', url);
browser.windows.create({
url: `popup/popup.html#${url}`,
type: 'popup',
height: 600,
width: 375,
});
}
});
}

// eslint-disable-next-line import/prefer-default-export
Expand Down
2 changes: 1 addition & 1 deletion src/common/extension.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ a {
border-color: $nav-border-color !important;
}
.error-msg {
color: $secondary-color !important;
color: $input-error-color !important;
margin-top:22px;
font-size: .88rem;
}
Expand Down
8 changes: 4 additions & 4 deletions src/common/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ $ledger-color: #203040;

/** Colors for new designs */

$bg-color: #16161d;
$bg-color: #12121B;
$white-color: #f1f1f1;
$border-color: #34343b;
$input-bg-color: #121217;
$border-color: #33343E;
$input-bg-color: #0D0D13;
$button-color: #2a9cff;
$button-text-color: #ffffff;
$modal-background: #1b1b23;
$placeholder-color: #67676d;
$text-color: #bcbcc4;
$accent-color: #67f7b8;
$secondary-color: #2a9cff;
$nav-bg-color: #21212a;
$nav-bg-color: #1C1C24;
$input-focus-color: #2a9cff;
$input-error-color: #ff5857;
$transactions-bg: #12121b;
Expand Down
12 changes: 12 additions & 0 deletions src/icons/badges/blacklisted-big.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/icons/badges/blacklisted.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/icons/badges/default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/icons/badges/not-verified-big.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/icons/badges/not-verified.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/icons/badges/verified-big.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/icons/badges/verified.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions src/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ window.addEventListener('load', () => {

// Handle message from background and redirect to page
browser.runtime.onMessage.addListener(({ data }) => {
const { method, blocked, params, extUrl, host, uuid } = data;

const { method, blocked, extUrl, host, uuid, href } = data;
if (method === 'phishingCheck' && blocked) {
redirectToWarning(host, params.href, extUrl);
redirectToWarning(host, href, extUrl);
} else if (method === 'getAddresses') {
browser.runtime.sendMessage({ uuid, data: { ...getAddresses() } });
}
Expand Down
Loading

3 comments on commit 5e3cb5b

@davidyuk
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidyuk
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidyuk
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.