diff --git a/.gitignore b/.gitignore index 801902a73..23900fae9 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,4 @@ lib/* js/copayBundle.js config.js webapp - +chrome-extension diff --git a/bower.json b/bower.json index 80e3c20d3..7197b53f0 100644 --- a/bower.json +++ b/bower.json @@ -17,6 +17,7 @@ "crypto-js": "http://crypto-js.googlecode.com/files/CryptoJS%20v3.1.2.zip", "sjcl": "1.0.0", "file-saver": "*", - "qrcode-decoder-js": "*" + "qrcode-decoder-js": "*", + "bitcore": "~0.1.19" } } diff --git a/css/main.css b/css/main.css index 18ee8a8c4..f44f11a5e 100644 --- a/css/main.css +++ b/css/main.css @@ -631,3 +631,7 @@ p.dr-notification-text { margin-top: -5px; font-size: 12px; } + +input.ng-invalid-wallet-secret { + background: #FFB6C1; +} diff --git a/ghpages.sh b/ghpages.sh deleted file mode 100755 index 8aa6e11cd..000000000 --- a/ghpages.sh +++ /dev/null @@ -1,51 +0,0 @@ -#! /bin/bash - -#Description: A simple script to compile and copy only the needed files for the web app. - -# Configs -APPDIR="webapp" -LIBDIR="$APPDIR/lib" -DOWNLOADDIR="$APPDIR/download" -ZIPFILE="copay_webapp_.zip" - -OpenColor="\033[" -Red="1;31m" -Yellow="1;33m" -Green="1;32m" -CloseColor="\033[0m" - -# Create/Clean temp dir -echo -e "${OpenColor}${Green}* Checking temp dir...${CloseColor}" -if [ -d $APPDIR ]; then - rm -rf $APPDIR -fi - -mkdir -p $APPDIR - -# Generate and copy bitcore bundle -if [ ! -d node_modules/bitcore ]; then - echo -e "${OpenColor}${Red}X The node_modules/bitcore dir does not exist. \nRun npm install and try again.${CloseColor}" - exit 1 -else - echo -e "${OpenColor}${Green}* Generating bitcore bundle...${CloseColor}" - cd node_modules/bitcore - grunt --target=dev shell - cd ../.. -fi - -# Re-compile copayBundle.js -echo -e "${OpenColor}${Green}* Generating copay bundle...${CloseColor}" -grunt --target=dev shell - -# Copy all app files -echo -e "${OpenColor}${Green}* Copying all app files...${CloseColor}" -cp -af {css,font,img,js,lib,config.js,index.html} $APPDIR -cp -af node_modules/bitcore/browser/bundle.js $LIBDIR/ -mv $LIBDIR/bundle.js $LIBDIR/bitcore.js - -echo -e "${OpenColor}${Green}* Zipping all app files...${CloseColor}" -zip -r $ZIPFILE $APPDIR -mkdir -p $DOWNLOADDIR -mv $ZIPFILE $DOWNLOADDIR - -echo -e "${OpenColor}${Yellow}\nAwesome! You just need to copy and paste the ./webapp content to your local repository and push it.${CloseColor}" diff --git a/img/icons/icon.png b/img/icons/icon.png new file mode 100644 index 000000000..47cdc4b1f Binary files /dev/null and b/img/icons/icon.png differ diff --git a/index-download-chrome.html b/index-download-chrome.html new file mode 100644 index 000000000..675112999 --- /dev/null +++ b/index-download-chrome.html @@ -0,0 +1,22 @@ + + + + + + Copay Chrome Extension - Install + + + +
+

Copay Installation:

+ +
+ + diff --git a/index.html b/index.html index 5c8116cb7..186c92917 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,5 @@ - + @@ -7,6 +7,7 @@ Copay - Multisignature Wallet + @@ -192,7 +193,7 @@

Join a Wallet in Creation

- + @@ -592,7 +593,7 @@

{{title}}

- Network Name + Bitcoin Network
@@ -662,7 +663,7 @@ on supported browsers please check http://www.w - + diff --git a/js/directives.js b/js/directives.js index 78124f461..5ee0993dd 100644 --- a/js/directives.js +++ b/js/directives.js @@ -64,6 +64,21 @@ angular.module('copay.directives') }; } ]) + .directive('walletSecret', ['walletFactory', + function(walletFactory) { + return { + require: 'ngModel', + link: function(scope, elem, attrs, ctrl) { + var validator = function(value) { + ctrl.$setValidity('walletSecret', Boolean(walletFactory.decodeSecret(value))); + return value; + }; + + ctrl.$parsers.unshift(validator); + } + }; + } + ]) .directive('loading', function() { return { restrict: 'A', diff --git a/js/models/core/WalletFactory.js b/js/models/core/WalletFactory.js index 4f110a279..0db065eeb 100644 --- a/js/models/core/WalletFactory.js +++ b/js/models/core/WalletFactory.js @@ -162,16 +162,20 @@ WalletFactory.prototype.remove = function(walletId) { this.log('TODO: remove wallet contents'); }; +WalletFactory.prototype.decodeSecret = function(secret) { + try { + return Wallet.decodeSecret(secret); + } catch (e) { + return false; + } +} + WalletFactory.prototype.joinCreateSession = function(secret, nickname, passphrase, cb) { var self = this; - var s; - try { - s=Wallet.decodeSecret(secret); - } catch (e) { - return cb('badSecret'); - } + var s = self.decodeSecret(secret); + if (!s) return cb('badSecret'); //Create our PrivateK var privateKey = new PrivateKey({ networkName: this.networkName }); diff --git a/js/routes.js b/js/routes.js index bfc5061d7..301b9d68a 100644 --- a/js/routes.js +++ b/js/routes.js @@ -74,4 +74,7 @@ angular } } }); + }) + .config(function($compileProvider) { + $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel|chrome-extension):/); }); diff --git a/manifest.json b/manifest.json new file mode 100644 index 000000000..53a67fa2b --- /dev/null +++ b/manifest.json @@ -0,0 +1,19 @@ +{ + "manifest_version": 2, + "name": "Copay", + "description": "A multisignature bitcoin wallet", + "version": "0.0.1", + "homepage_url": "http://bitpay.github.io/copay", + "browser_action": { + "default_title": "Copay", + "default_icon": "img/icons/icon.png", + "default_popup": "popup.html" + }, + "permissions": [ + "tabs", "storage" + ], + "options_page": "index.html#/settings", + "icons": { + "128": "img/icons/icon.png" + } +} diff --git a/popup.html b/popup.html new file mode 100644 index 000000000..99e584da6 --- /dev/null +++ b/popup.html @@ -0,0 +1,31 @@ + + + + + + Copay + + + + Open wallet + Settings + + diff --git a/util/generate-app-extension.sh b/util/generate-app-extension.sh new file mode 100755 index 000000000..f065d42e7 --- /dev/null +++ b/util/generate-app-extension.sh @@ -0,0 +1,65 @@ +#! /bin/bash + +#Description: A simple script to compile and copy only the needed files for the web app. + +# Moving to root path +cd ../ + +# Configs +APPDIR="./webapp" +CHROMEDIR="./chrome-extension" + +LIBDIR="$APPDIR/lib" +DOWNLOADDIR="$APPDIR/download" +CHROMEDOWNLOADDIR="$DOWNLOADDIR/chrome" + +ZIPFILE="copay.zip" +CHROMEZIPFILE="copay-chrome-extension.zip" + +OpenColor="\033[" +Red="1;31m" +Yellow="1;33m" +Green="1;32m" +CloseColor="\033[0m" + +# Create/Clean temp dir +echo -e "${OpenColor}${Green}* Checking temp dir...${CloseColor}" +if [ -d $APPDIR ]; then + rm -rf $APPDIR +fi + +mkdir -p $APPDIR + +# Create/Clean chrome-extension dir +if [ -d $CHROMEDIR ]; then + rm -rf $CHROMEDIR +fi + +mkdir -p $CHROMEDIR + +# Re-compile copayBundle.js +echo -e "${OpenColor}${Green}* Generating copay bundle...${CloseColor}" +grunt --target=dev shell + +# Copy all app files +echo -e "${OpenColor}${Green}* Copying all app files...${CloseColor}" +cp -af {css,font,img,js,lib,sound,config.js,index.html} $APPDIR + +# Copy all chrome-extension files +echo -e "${OpenColor}${Green}* Copying all chrome-extension files...${CloseColor}" +cp -af {css,font,img,js,lib,sound,config.js,index.html,popup.html,manifest.json} $CHROMEDIR + +# Zipping apps +echo -e "${OpenColor}${Green}* Zipping all app files...${CloseColor}" +zip -r $ZIPFILE $APPDIR + +# Zipping chrome-extension +echo -e "${OpenColor}${Green}* Zipping all chrome-extension files...${CloseColor}" +zip -r $CHROMEZIPFILE $CHROMEDIR + +mkdir -p $CHROMEDOWNLOADDIR +mv $ZIPFILE $DOWNLOADDIR +mv $CHROMEZIPFILE $CHROMEDOWNLOADDIR +cp index-download-chrome.html $CHROMEDOWNLOADDIR/index.html + +echo -e "${OpenColor}${Yellow}\nAwesome! Now you have the webapp in ./webapp and the chrome extension files in ./webapp/download/.${CloseColor}"