Permalink
Browse files

Improve pairing code security, Alter Google Authenticator Setup

  • Loading branch information...
1 parent ab4e38b commit 5f438d1a3e70b517edb53306d6c6f955d7c5de22 @zootreeves zootreeves committed Apr 26, 2013
Showing with 80 additions and 53 deletions.
  1. +50 −43 account.js
  2. +1 −1 account.min.js
  3. +28 −8 wallet.js
  4. +1 −1 wallet.min.js
View
93 account.js
@@ -36,7 +36,7 @@ var AccountSettings = new function() {
}
}
- function updateKV(txt, method, value, success, error) {
+ function updateKV(txt, method, value, success, error, extra) {
value = $.trim(value);
if ( value.length == 0) {
@@ -54,7 +54,11 @@ var AccountSettings = new function() {
MyWallet.setLoadingText(txt);
- MyWallet.securePost("wallet", { length : (value+'').length, payload : value+'', method : method }, function(data) {
+ if (!extra)
+ extra = '';
+
+
+ MyWallet.securePost("wallet"+extra, { length : (value+'').length, payload : value+'', method : method }, function(data) {
MyWallet.makeNotice('success', method + '-success', data);
if (success) success();
@@ -228,13 +232,6 @@ var AccountSettings = new function() {
$('#never-save-auth-type').prop("checked", data.never_save_auth_type == 1 ? true : false);
- //Show Google Auth QR Code
- if (data.google_secret_url != null && data.google_secret_url.length > 0) {
- loadScript('wallet/jquery.qrcode', function() {
- $('#wallet-google-qr').empty().qrcode({width: 300, height: 300, text: data.google_secret_url});
- });
- }
-
$('#wallet-http-url').val(data.http_url);
$('#wallet-skype').val(data.skype_username);
$('#wallet-boxcar').val(data.boxcar_email);
@@ -484,19 +481,6 @@ var AccountSettings = new function() {
});
- $('#pbkdf2-iterations').unbind().change(function(e) {
- var iterations = parseInt($(this).val());
-
- if (iterations <= 0) {
- MyWallet.makeNotice('error', 'misc-error', 'Iterations must be greater than 0');
- return;
- }
-
- MyWallet.setPbkdf2Iterations(iterations, function() {
- MyWallet.makeNotice('success', 'misc-success', 'Iterations set.');
- });
- });
-
$('input[name="always-keep-local-backup"]').unbind().change(function() {
MyWallet.setAlwaysKeepLocalBackup($(this).is(':checked'));
@@ -523,20 +507,21 @@ var AccountSettings = new function() {
});
$('#pairing_code').unbind().on('show', function() {
- var container = $('#device-qr-code');
-
- container.empty();
-
MyWallet.makePairingQRCode(function(device_qr) {
- container.empty().append(device_qr);
+ $('#pairing-code-v0').html(device_qr);
+ }, 0);
- setTimeout(function() {
- container.empty();
+ MyWallet.makePairingQRCode(function(device_qr) {
+ $('#pairing-code-v1').html(device_qr);
+ }, 1);
- collapseAll();
- }, 30000);
+ setTimeout(function() {
+ collapseAll();
+ }, 30000);
+ }).on('hide', function() {
+ $('#pairing-code-v1').empty();
+ $('#pairing-code-v0').empty();
});
- })
$('#update-password-btn').unbind().click(function() {
updatePassword();
@@ -570,24 +555,46 @@ var AccountSettings = new function() {
updateKV('Updating Auth Saving Settings', 'update-never-save-auth-type', $(this).is(':checked'));
});
+ $('#wallet-google-qr-code').unbind().change(function() {
+ var code = $(this).val();
+
+ updateKV('Updating Two Factor Authentication', 'update-auth-type', 4, function() {
+ $('.two-factor.t4').children().hide().eq(0).show();
+
+ MyWallet.setRealAuthType(4);
+ }, null, '?code='+code);
+ });
+
$('#two-factor-select').unbind().change(function() {
var val = parseInt($(this).val());
- updateKV('Updating Two Factor Authentication', 'update-auth-type', val, function() {
- //For Google Authenticator we need to refetch the account info to fetch the QR Code
- if (val == 4) {
- getAccountInfo();
- }
+ try {
+ localStorage.removeItem('payload');
+ } catch (e) {}
- try {
- localStorage.removeItem('payload');
- } catch (e) {}
+ var el = $('.two-factor.t'+val);
- MyWallet.setRealAuthType(val);
- });
+ if (val == 4) {
+ el.children().hide().eq(1).show();
+
+ MyWallet.securePost("wallet", { method : 'generate-google-secret' }, function(google_secret_url) {
+ //Show Google Auth QR Code
+ if (google_secret_url != null && google_secret_url.length > 0) {
+ loadScript('wallet/jquery.qrcode', function() {
+ $('#wallet-google-qr').empty().qrcode({width: 300, height: 300, text: google_secret_url});
+ });
+ }
+ }, function(data) {
+ MyWallet.makeNotice('error', 'misc-error', data.responseText);
+ });
+ } else {
+ updateKV('Updating Two Factor Authentication', 'update-auth-type', val, function() {
+ MyWallet.setRealAuthType(val);
+ });
+ }
$('.two-factor').hide(200);
- $('.two-factor.t'+val).show(200);
+ el.show(200);
});
var previous_email = '';
View
2 account.min.js
@@ -1 +1 @@
-var AccountSettings=new function(){function b(o){var n=o.lastIndexOf("@");var m=o.lastIndexOf(".");return(n<m&&n>0&&o.indexOf("@@")==-1&&m>2&&(o.length-m)>2)}function c(m){try{var n=window.applicationCache;console.log("Clear Cache Manifest");n.addEventListener("updateready",function(p){n.swapCache();if(m){m()}},false);n.addEventListener("noupdate",function(p){if(m){m()}},false);n.addEventListener("error",function(p){if(m){m()}},false);n.update()}catch(o){console.log(o);if(m){m()}}}function j(m,q,o,p,n){o=$.trim(o);if(o.length==0){MyWallet.makeNotice("error","misc-error",m+": Invalid value");return}if(o.length==0){MyWallet.makeNotice("error",q+"-error",data.responseText);if(n){n()}return}MyWallet.setLoadingText(m);MyWallet.securePost("wallet",{length:(o+"").length,payload:o+"",method:q},function(r){MyWallet.makeNotice("success",q+"-success",r);if(p){p()}},function(r){MyWallet.makeNotice("error",q+"-error",r.responseText);if(n){n()}})}function i(){if(MyWallet.getDoubleEncryption()){$(".double-encryption-off").hide();$(".double-encryption-on").show()}else{$(".double-encryption-on").hide();$(".double-encryption-off").show()}$("#double-password").val("");$("#double-password2").val("")}function l(){$("#password_mnemonic1").find("span").empty();$("#password_mnemonic2").find("span").empty()}function g(){l();var n=$("#password_mnemonic1");var m=$("#password_mnemonic2");loadScript("wallet/mnemonic",function(){MyWallet.getMainPassword(function(o){MyWallet.getSecondPassword(function(p){try{n.show().find("span").text(mn_encode_pass(o));if(p){m.show().find("span").text(mn_encode_pass(p))}else{m.hide()}}catch(q){console.log(q);f()}},function(){f()})},function(){f()})})}this.bind=function(n,m){i();e();a(n,m)};this.init=function(m,o,n){MyWallet.setLoadingText("Loading Account Settings");if(!m.is(":empty")){AccountSettings.bind(o,n);o();return}$.ajax({type:"GET",url:root+"wallet/account-settings-template",data:{format:"plain"},success:function(p){try{m.html(p);AccountSettings.bind(o,n);o()}catch(q){console.log(q);n()}},error:function(p){MyWallet.makeNotice("error","misc-error","Error Downloading Account Settings Template");n()}})};function a(n,m){$('a[data-toggle="tab"]').unbind().on("show",function(o){$(o.target.hash).trigger("show")});MyWallet.setLoadingText("Getting Wallet Info");MyWallet.securePost("wallet",{method:"get-info",format:"json"},function(u){if(u.email!=null){$("#wallet-email").val(u.email);$(".my-email").text(u.email)}$("#wallet-phrase").val(u.phrase);$("#two-factor-select").val(u.auth_type);$(".two-factor").hide();$(".two-factor.t"+u.auth_type).show(200);var v=$("#notifications-type");v.find(":checkbox").prop("checked",false);v.find('[class^="type"]').hide();for(var w in u.notifications_type){var x=u.notifications_type[w];v.find(':checkbox[value="'+x+'"]').prop("checked",true);v.find(".type-"+x).show()}$(".logl").hide();$(".logl.l"+u.logging_level).show();$("#logging-level").val(u.logging_level);$("#notifications-confirmations").val(u.notifications_confirmations);$("#notifications-on").val(u.notifications_on);$("#pbkdf2-iterations").val(MyWallet.getPbkdf2Iterations());if(u.alias!=null&&u.alias.length>0){$("#wallet-alias").val(u.alias);$(".alias").text("https://blockchain.info/wallet/"+u.alias);$(".alias").show(200)}var p=$("#local_currency").empty();for(var y in u.currencies){var B=u.currencies[y];p.append('<option value="'+y+'">'+B+"</option>")}p.val(u.currency);var s=$("#language_select").empty();for(var t in u.languages){var A=u.languages[t];s.append('<option value="'+t+'">'+A+"</option>")}s.val(u.language);$("#auto-email-backup").prop("checked",u.auto_email_backup==1?true:false);$("#never-save-auth-type").prop("checked",u.never_save_auth_type==1?true:false);if(u.google_secret_url!=null&&u.google_secret_url.length>0){loadScript("wallet/jquery.qrcode",function(){$("#wallet-google-qr").empty().qrcode({width:300,height:300,text:u.google_secret_url})})}$("#wallet-http-url").val(u.http_url);$("#wallet-skype").val(u.skype_username);$("#wallet-boxcar").val(u.boxcar_email);$("#wallet-yubikey").val(u.yubikey);if(u.password_hint1){$("#password-hint1").val(u.password_hint1)}if(u.password_hint2){$("#password-hint2").val(u.password_hint2)}$("#ip-lock").val(u.ip_lock);$("#my-ip").text(u.my_ip);$("#ip-lock-on").prop("checked",u.ip_lock_on==1?true:false);$("#block-tor-ips").prop("checked",u.block_tor_ips==1?true:false);$('input[name="fee-policy"]').each(function(){if(parseInt($(this).val())==MyWallet.getFeePolicy()){$(this).attr("checked",true)}});$('input[name="always-keep-local-backup"]').attr("checked",MyWallet.getAlwaysKeepLocalBackup()?true:false);$('input[name="inactivity-logout-time"]').each(function(){if(parseInt($(this).val())==MyWallet.getLogoutTime()){$(this).attr("checked",true)}});if(u.email_verified==0){$("#verify-email").show();$("#email-verified").hide()}else{$("#verify-email").hide();$("#email-verified").show()}$("#my-ip").text(u.my_ip);var o="1";if(u.sms_number){var r=u.sms_number.split(" ");if(u.sms_number[0]=="+"&&r.length>1){o=r[0].substring(1);$(".wallet-sms").val(r[1])}else{$(".wallet-sms").val(u.sms_number)}}if(u.sms_verified==0){$(".sms-unverified").show();$(".sms-verified").hide()}else{$(".sms-verified").show().trigger("show");$(".sms-unverified").hide()}$.ajax({type:"GET",url:resource+"wallet/country_codes.html",success:function(C){$('select[class="wallet-sms-country-codes"]').html(C).val(o)},error:function(){MyWallet.makeNotice("error","misc-error","Error Downloading SMS Country Codes")}});var z=function(G,D,E){try{if(window.webkitNotifications&&navigator.userAgent.indexOf("Chrome")>-1){var C=webkitNotifications.checkPermission();if(C==1&&E){webkitNotifications.requestPermission(z)}else{if(C==0){G()}else{D()}}}else{if(window.Notification){if(Notification.permissionLevel()==="default"&&E){Notification.requestPermission(z)}else{if(window.Notification.permissionLevel()=="granted"){G()}else{D()}}}else{D()}}}catch(F){console.log(F);D()}};var q=$("#html5-notifications-checkbox");q.unbind().change(function(){if($(this).is(":checked")){z(function(){MyWallet.makeNotice("success","misc-success","HTML5 Notifications Enabled");MyWallet.setHTML5Notifications(true);MyWallet.backupWallet()},function(){MyWallet.makeNotice("error","misc-error","Error Enabling HTML5 Notifications");MyWallet.setHTML5Notifications(false);MyWallet.backupWallet()},true)}else{MyWallet.setHTML5Notifications(false);MyWallet.backupWallet()}});if(MyWallet.getHTML5Notifications()){q.attr("checked",true)}else{q.attr("checked",false)}},function(o){if(o.responseText){MyWallet.makeNotice("error","misc-error",o.responseText)}else{MyWallet.makeNotice("error","misc-error","Error Downloading Account Settings")}if(m){m()}})}function k(){f();var m=$("#update-password-modal");m.modal({keyboard:true,backdrop:"static",show:true});m.center();m.find(".btn.btn-primary").unbind().click(function(){m.modal("hide");var n=$.trim($("#password").val());var o=$.trim($("#password2").val());if(n!=o){MyWallet.makeNotice("error","misc-error","Passwords do not match.");return false}if(n.length==0||n.length<10||n.length>255){MyWallet.makeNotice("error","misc-error","Password length must be between least 10 & 255 characters");return false}MyWallet.setMainPassword(n)});m.find(".btn.btn-secondary").unbind().click(function(){m.modal("hide")})}function f(){$(".accordion-body").collapse("hide")}function h(){MyWallet.setDoubleEncryption(false,null,function(){i()})}function d(){var m=$("#double-password").val();var n=$("#double-password2").val();if(m==null||m.length==0||m.length<4||m.length>255){MyWallet.makeNotice("error","misc-error","Password must be 4 characters or more in length");return}if(m!=n){MyWallet.makeNotice("error","misc-error","Passwords do not match.");return}if(MyWallet.isCorrectMainPassword(m)){MyWallet.makeNotice("error","misc-error","Second password should not be the same as your main password.");return}MyWallet.setDoubleEncryption(true,m,function(){i()})}function e(){var m=$("#notifications-type");m.find(":checkbox").unbind().change(function(){var p=[];m.find(":checkbox:checked").each(function(){p.push($(this).val())});if(!p.length){p.push(0)}j("Updating Notifications Type","update-notifications-type",p.join("|"));m.find(".type-"+$(this).val()).toggle();MyWallet.get_history()});$("input[name=fee-policy]").unbind().change(function(){MyWallet.setFeePolicy($("input[name=fee-policy]:checked").val());MyWallet.backupWallet()});$("#pbkdf2-iterations").unbind().change(function(q){var p=parseInt($(this).val());if(p<=0){MyWallet.makeNotice("error","misc-error","Iterations must be greater than 0");return}MyWallet.setPbkdf2Iterations(p,function(){MyWallet.makeNotice("success","misc-success","Iterations set.")})});$('input[name="always-keep-local-backup"]').unbind().change(function(){MyWallet.setAlwaysKeepLocalBackup($(this).is(":checked"));try{localStorage.removeItem("payload")}catch(p){}MyWallet.backupWallet()});$("input[name=inactivity-logout-time]").unbind().change(function(){MyWallet.setLogoutTime(parseInt($(this).val()));MyWallet.backupWallet()});$("#password_mnemonic").unbind().on("show",function(){g()}).on("hide",function(){l()});$("#pairing_code").unbind().on("show",function(){var p=$("#device-qr-code");p.empty();MyWallet.makePairingQRCode(function(q){p.empty().append(q);setTimeout(function(){p.empty();f()},30000)})});$("#update-password-btn").unbind().click(function(){k()});$("#password-hint1").unbind().change(function(){j("Updating Main Password Hint","update-password-hint1",$(this).val())});$("#password-hint2").unbind().change(function(){j("Updating Second Password Hint","update-password-hint2",$(this).val())});$("#ip-lock-on").unbind().change(function(){j("Updating IP Lock","update-ip-lock-on",$(this).is(":checked"))});$("#ip-lock").unbind().change(function(){j("Updating Locked Ip Addresses","update-ip-lock",$(this).val())});$("#notifications-on").unbind().change(function(){j("Updating Notifications Settings","update-notifications-on",$(this).val())});$("#auto-email-backup").unbind().change(function(){j("Updating Auto Backup Settings","update-auto-email-backup",$(this).is(":checked"))});$("#never-save-auth-type").unbind().change(function(){j("Updating Auth Saving Settings","update-never-save-auth-type",$(this).is(":checked"))});$("#two-factor-select").unbind().change(function(){var p=parseInt($(this).val());j("Updating Two Factor Authentication","update-auth-type",p,function(){if(p==4){a()}try{localStorage.removeItem("payload")}catch(q){}MyWallet.setRealAuthType(p)});$(".two-factor").hide(200);$(".two-factor.t"+p).show(200)});var n="";$("#wallet-email-send").click(function(){n="";$("#wallet-email").trigger("change")});$("#wallet-email").unbind().change(function(q){var p=$.trim($(this).val());if(p.length==0){return}if(n==p){return}if(!b(p)){MyWallet.makeNotice("error","misc-error","Email address is not valid");return}j("Updating Email","update-email",p,function(){n=p},function(){n=""});n=p;$("#verify-email").show(200);$("#email-verified").hide()});$("#wallet-double-encryption-enable").unbind().click(function(p){f();d()});$("#wallet-double-encryption-disable").unbind().click(function(p){f();h()});$("#wallet-email-code").unbind().change(function(q){var p=$.trim($(this).val());if(p.length==0||p.length>255){MyWallet.makeNotice("error","misc-error","You must enter a code to verify");return}MyWallet.setLoadingText("Verifying Email");MyWallet.securePost("wallet",{payload:p,length:p.length,method:"verify-email"},function(r){MyWallet.makeNotice("success","misc-success",r);$("#verify-email").hide();$("#email-verified").show(200)},function(r){MyWallet.makeNotice("error","misc-error",r.responseText);$("#verify-email").show(200);$("#email-verified").hide()})});$(".wallet-sms-code").unbind().change(function(q){var p=$.trim($(this).val());if(p.length==0||p.length>255){MyWallet.makeNotice("error","misc-error","You must enter an SMS code to verify");return}MyWallet.setLoadingText("Verifying SMS Code");MyWallet.securePost("wallet",{payload:p,length:p.length,method:"verify-sms"},function(r){MyWallet.makeNotice("success","misc-success",r);$(".sms-unverified").hide();$(".sms-verified").show(200).trigger("show")},function(r){MyWallet.makeNotice("error","misc-error",r.responseText);$(".sms-verified").hide();$(".sms-unverified").show(200)})});var o="";$(".send-code").unbind().click(function(){o="";$(this).parent().find(".wallet-sms").trigger("change")});$('select[class="wallet-sms-country-codes"]').unbind().change(function(){o="";$(".wallet-sms").trigger("change")});$(".wallet-sms").unbind().change(function(){var p=$.trim($(this).val());if(p==null||p.length==0){return}if(p.charAt(0)!="+"){p="+"+$(".wallet-sms-country-codes").val()+p}if(o==p){return}o=p;j("Updating Cell Number","update-sms",p,function(){$(".sms-unverified").show(200);$(".sms-verified").hide()})});$("#run-key-check").unbind().click(function(){MyWallet.getSecondPassword(function(){try{MyWallet.checkAllKeys(true);MyWallet.backupWallet()}catch(p){MyWallet.makeNotice("error","misc-error",p)}})});$("#local_currency").unbind().change(function(){if(symbol!=symbol_local){toggleSymbol()}j("Updating Local Currency","update-currency",$(this).val(),function(){MyWallet.get_history()})});$("#language_select").unbind().change(function(){j("Updating Language","update-language",$(this).val(),function(){c(function(){window.location.reload()})})});$("#notifications-confirmations").unbind().change(function(p){j("Updating Notification Confirmations","update-notifications-confirmations",$(this).val())});$("#account-logging").unbind().on("show",function(){var q=$(this).find("table").hide();var p=q.find("tbody");MyWallet.securePost("wallet",{method:"list-logs",format:"json"},function(v){try{q.show();p.empty();if(v==null){throw"Failed to get backups"}var t=v.results;if(t.length==0){throw"No logs found"}for(var s in t){var r=t[s];p.append('<tr><td style="width:130px">'+dateToString(new Date(r.time))+'</td><td style="width:170px">'+r.action+'</td><td style="text-overflow: ellipsis;max-width:100px;overflow: hidden;">'+r.ip_address+"</td><td>"+r.user_agent+"</td></tr>")}}catch(u){MyWallet.makeNotice("error","misc-error",u)}},function(r){MyWallet.makeNotice("error","misc-error",r.responseText)})});$("#logging-level").unbind().change(function(p){$(".logl").hide();$(".logl.l"+$(this).val()).show();j("Updating Logging Level","update-logging-level",$(this).val(),function(){$("#account-logging").trigger("show")})});$("#block-tor-ips").unbind().change(function(p){j("Updating TOR ip block","update-block-tor-ips",$(this).is(":checked")?1:0)});$("#wallet-yubikey").unbind().change(function(p){j("Updating Yubikey","update-yubikey",$(this).val())});$("#wallet-skype").unbind().change(function(p){j("Updating Skype Username","update-skype",$(this).val())});$("#wallet-boxcar").unbind().change(function(p){j("Updating Boxcar Email","update-boxcar",$(this).val())});$("#wallet-http-url").unbind().change(function(p){j("Updating HTTP url","update-http-url",$(this).val())});$("#wallet-phrase").unbind().change(function(q){var p=$.trim($(this).val());if(p==null||p.length==0||p.length>255){MyWallet.makeNotice("error","misc-error","You must enter a secret phrase");return}j("Updating Secret Phrase","update-phrase",p)});$("#wallet-alias").unbind().change(function(s){var r=$(this);var p=$.trim(r.val());r.val(r.val().replace(/[\.,\/ #!$%\^&\*;:{}=`~()]/g,""));var q=$.trim(r.val());if(q.length>0){$(".alias").fadeIn(200);$(".alias").text("https://blockchain.info/wallet/"+q)}j("Updating Alias","update-alias",q,null,function(){r.val(p)})})}};
+var AccountSettings=new function(){function b(o){var n=o.lastIndexOf("@");var m=o.lastIndexOf(".");return(n<m&&n>0&&o.indexOf("@@")==-1&&m>2&&(o.length-m)>2)}function c(m){try{var n=window.applicationCache;console.log("Clear Cache Manifest");n.addEventListener("updateready",function(p){n.swapCache();if(m){m()}},false);n.addEventListener("noupdate",function(p){if(m){m()}},false);n.addEventListener("error",function(p){if(m){m()}},false);n.update()}catch(o){console.log(o);if(m){m()}}}function j(n,r,p,q,o,m){p=$.trim(p);if(p.length==0){MyWallet.makeNotice("error","misc-error",n+": Invalid value");return}if(p.length==0){MyWallet.makeNotice("error",r+"-error",data.responseText);if(o){o()}return}MyWallet.setLoadingText(n);if(!m){m=""}MyWallet.securePost("wallet"+m,{length:(p+"").length,payload:p+"",method:r},function(s){MyWallet.makeNotice("success",r+"-success",s);if(q){q()}},function(s){MyWallet.makeNotice("error",r+"-error",s.responseText);if(o){o()}})}function i(){if(MyWallet.getDoubleEncryption()){$(".double-encryption-off").hide();$(".double-encryption-on").show()}else{$(".double-encryption-on").hide();$(".double-encryption-off").show()}$("#double-password").val("");$("#double-password2").val("")}function l(){$("#password_mnemonic1").find("span").empty();$("#password_mnemonic2").find("span").empty()}function g(){l();var n=$("#password_mnemonic1");var m=$("#password_mnemonic2");loadScript("wallet/mnemonic",function(){MyWallet.getMainPassword(function(o){MyWallet.getSecondPassword(function(p){try{n.show().find("span").text(mn_encode_pass(o));if(p){m.show().find("span").text(mn_encode_pass(p))}else{m.hide()}}catch(q){console.log(q);f()}},function(){f()})},function(){f()})})}this.bind=function(n,m){i();e();a(n,m)};this.init=function(m,o,n){MyWallet.setLoadingText("Loading Account Settings");if(!m.is(":empty")){AccountSettings.bind(o,n);o();return}$.ajax({type:"GET",url:root+"wallet/account-settings-template",data:{format:"plain"},success:function(p){try{m.html(p);AccountSettings.bind(o,n);o()}catch(q){console.log(q);n()}},error:function(p){MyWallet.makeNotice("error","misc-error","Error Downloading Account Settings Template");n()}})};function a(n,m){$('a[data-toggle="tab"]').unbind().on("show",function(o){$(o.target.hash).trigger("show")});MyWallet.setLoadingText("Getting Wallet Info");MyWallet.securePost("wallet",{method:"get-info",format:"json"},function(u){if(u.email!=null){$("#wallet-email").val(u.email);$(".my-email").text(u.email)}$("#wallet-phrase").val(u.phrase);$("#two-factor-select").val(u.auth_type);$(".two-factor").hide();$(".two-factor.t"+u.auth_type).show(200);var v=$("#notifications-type");v.find(":checkbox").prop("checked",false);v.find('[class^="type"]').hide();for(var w in u.notifications_type){var x=u.notifications_type[w];v.find(':checkbox[value="'+x+'"]').prop("checked",true);v.find(".type-"+x).show()}$(".logl").hide();$(".logl.l"+u.logging_level).show();$("#logging-level").val(u.logging_level);$("#notifications-confirmations").val(u.notifications_confirmations);$("#notifications-on").val(u.notifications_on);$("#pbkdf2-iterations").val(MyWallet.getPbkdf2Iterations());if(u.alias!=null&&u.alias.length>0){$("#wallet-alias").val(u.alias);$(".alias").text("https://blockchain.info/wallet/"+u.alias);$(".alias").show(200)}var p=$("#local_currency").empty();for(var y in u.currencies){var B=u.currencies[y];p.append('<option value="'+y+'">'+B+"</option>")}p.val(u.currency);var s=$("#language_select").empty();for(var t in u.languages){var A=u.languages[t];s.append('<option value="'+t+'">'+A+"</option>")}s.val(u.language);$("#auto-email-backup").prop("checked",u.auto_email_backup==1?true:false);$("#never-save-auth-type").prop("checked",u.never_save_auth_type==1?true:false);$("#wallet-http-url").val(u.http_url);$("#wallet-skype").val(u.skype_username);$("#wallet-boxcar").val(u.boxcar_email);$("#wallet-yubikey").val(u.yubikey);if(u.password_hint1){$("#password-hint1").val(u.password_hint1)}if(u.password_hint2){$("#password-hint2").val(u.password_hint2)}$("#ip-lock").val(u.ip_lock);$("#my-ip").text(u.my_ip);$("#ip-lock-on").prop("checked",u.ip_lock_on==1?true:false);$("#block-tor-ips").prop("checked",u.block_tor_ips==1?true:false);$('input[name="fee-policy"]').each(function(){if(parseInt($(this).val())==MyWallet.getFeePolicy()){$(this).attr("checked",true)}});$('input[name="always-keep-local-backup"]').attr("checked",MyWallet.getAlwaysKeepLocalBackup()?true:false);$('input[name="inactivity-logout-time"]').each(function(){if(parseInt($(this).val())==MyWallet.getLogoutTime()){$(this).attr("checked",true)}});if(u.email_verified==0){$("#verify-email").show();$("#email-verified").hide()}else{$("#verify-email").hide();$("#email-verified").show()}$("#my-ip").text(u.my_ip);var o="1";if(u.sms_number){var r=u.sms_number.split(" ");if(u.sms_number[0]=="+"&&r.length>1){o=r[0].substring(1);$(".wallet-sms").val(r[1])}else{$(".wallet-sms").val(u.sms_number)}}if(u.sms_verified==0){$(".sms-unverified").show();$(".sms-verified").hide()}else{$(".sms-verified").show().trigger("show");$(".sms-unverified").hide()}$.ajax({type:"GET",url:resource+"wallet/country_codes.html",success:function(C){$('select[class="wallet-sms-country-codes"]').html(C).val(o)},error:function(){MyWallet.makeNotice("error","misc-error","Error Downloading SMS Country Codes")}});var z=function(G,D,E){try{if(window.webkitNotifications&&navigator.userAgent.indexOf("Chrome")>-1){var C=webkitNotifications.checkPermission();if(C==1&&E){webkitNotifications.requestPermission(z)}else{if(C==0){G()}else{D()}}}else{if(window.Notification){if(Notification.permissionLevel()==="default"&&E){Notification.requestPermission(z)}else{if(window.Notification.permissionLevel()=="granted"){G()}else{D()}}}else{D()}}}catch(F){console.log(F);D()}};var q=$("#html5-notifications-checkbox");q.unbind().change(function(){if($(this).is(":checked")){z(function(){MyWallet.makeNotice("success","misc-success","HTML5 Notifications Enabled");MyWallet.setHTML5Notifications(true);MyWallet.backupWallet()},function(){MyWallet.makeNotice("error","misc-error","Error Enabling HTML5 Notifications");MyWallet.setHTML5Notifications(false);MyWallet.backupWallet()},true)}else{MyWallet.setHTML5Notifications(false);MyWallet.backupWallet()}});if(MyWallet.getHTML5Notifications()){q.attr("checked",true)}else{q.attr("checked",false)}},function(o){if(o.responseText){MyWallet.makeNotice("error","misc-error",o.responseText)}else{MyWallet.makeNotice("error","misc-error","Error Downloading Account Settings")}if(m){m()}})}function k(){f();var m=$("#update-password-modal");m.modal({keyboard:true,backdrop:"static",show:true});m.center();m.find(".btn.btn-primary").unbind().click(function(){m.modal("hide");var n=$.trim($("#password").val());var o=$.trim($("#password2").val());if(n!=o){MyWallet.makeNotice("error","misc-error","Passwords do not match.");return false}if(n.length==0||n.length<10||n.length>255){MyWallet.makeNotice("error","misc-error","Password length must be between least 10 & 255 characters");return false}MyWallet.setMainPassword(n)});m.find(".btn.btn-secondary").unbind().click(function(){m.modal("hide")})}function f(){$(".accordion-body").collapse("hide")}function h(){MyWallet.setDoubleEncryption(false,null,function(){i()})}function d(){var m=$("#double-password").val();var n=$("#double-password2").val();if(m==null||m.length==0||m.length<4||m.length>255){MyWallet.makeNotice("error","misc-error","Password must be 4 characters or more in length");return}if(m!=n){MyWallet.makeNotice("error","misc-error","Passwords do not match.");return}if(MyWallet.isCorrectMainPassword(m)){MyWallet.makeNotice("error","misc-error","Second password should not be the same as your main password.");return}MyWallet.setDoubleEncryption(true,m,function(){i()})}function e(){var m=$("#notifications-type");m.find(":checkbox").unbind().change(function(){var p=[];m.find(":checkbox:checked").each(function(){p.push($(this).val())});if(!p.length){p.push(0)}j("Updating Notifications Type","update-notifications-type",p.join("|"));m.find(".type-"+$(this).val()).toggle();MyWallet.get_history()});$("input[name=fee-policy]").unbind().change(function(){MyWallet.setFeePolicy($("input[name=fee-policy]:checked").val());MyWallet.backupWallet()});$('input[name="always-keep-local-backup"]').unbind().change(function(){MyWallet.setAlwaysKeepLocalBackup($(this).is(":checked"));try{localStorage.removeItem("payload")}catch(p){}MyWallet.backupWallet()});$("input[name=inactivity-logout-time]").unbind().change(function(){MyWallet.setLogoutTime(parseInt($(this).val()));MyWallet.backupWallet()});$("#password_mnemonic").unbind().on("show",function(){g()}).on("hide",function(){l()});$("#pairing_code").unbind().on("show",function(){MyWallet.makePairingQRCode(function(p){$("#pairing-code-v0").html(p)},0);MyWallet.makePairingQRCode(function(p){$("#pairing-code-v1").html(p)},1);setTimeout(function(){f()},30000)}).on("hide",function(){$("#pairing-code-v1").empty();$("#pairing-code-v0").empty()});$("#update-password-btn").unbind().click(function(){k()});$("#password-hint1").unbind().change(function(){j("Updating Main Password Hint","update-password-hint1",$(this).val())});$("#password-hint2").unbind().change(function(){j("Updating Second Password Hint","update-password-hint2",$(this).val())});$("#ip-lock-on").unbind().change(function(){j("Updating IP Lock","update-ip-lock-on",$(this).is(":checked"))});$("#ip-lock").unbind().change(function(){j("Updating Locked Ip Addresses","update-ip-lock",$(this).val())});$("#notifications-on").unbind().change(function(){j("Updating Notifications Settings","update-notifications-on",$(this).val())});$("#auto-email-backup").unbind().change(function(){j("Updating Auto Backup Settings","update-auto-email-backup",$(this).is(":checked"))});$("#never-save-auth-type").unbind().change(function(){j("Updating Auth Saving Settings","update-never-save-auth-type",$(this).is(":checked"))});$("#wallet-google-qr-code").unbind().change(function(){var p=$(this).val();j("Updating Two Factor Authentication","update-auth-type",4,function(){$(".two-factor.t4").children().hide().eq(0).show();MyWallet.setRealAuthType(4)},null,"?code="+p)});$("#two-factor-select").unbind().change(function(){var r=parseInt($(this).val());try{localStorage.removeItem("payload")}catch(q){}var p=$(".two-factor.t"+r);if(r==4){p.children().hide().eq(1).show();MyWallet.securePost("wallet",{method:"generate-google-secret"},function(s){if(s!=null&&s.length>0){loadScript("wallet/jquery.qrcode",function(){$("#wallet-google-qr").empty().qrcode({width:300,height:300,text:s})})}},function(s){MyWallet.makeNotice("error","misc-error",s.responseText)})}else{j("Updating Two Factor Authentication","update-auth-type",r,function(){MyWallet.setRealAuthType(r)})}$(".two-factor").hide(200);p.show(200)});var n="";$("#wallet-email-send").click(function(){n="";$("#wallet-email").trigger("change")});$("#wallet-email").unbind().change(function(q){var p=$.trim($(this).val());if(p.length==0){return}if(n==p){return}if(!b(p)){MyWallet.makeNotice("error","misc-error","Email address is not valid");return}j("Updating Email","update-email",p,function(){n=p},function(){n=""});n=p;$("#verify-email").show(200);$("#email-verified").hide()});$("#wallet-double-encryption-enable").unbind().click(function(p){f();d()});$("#wallet-double-encryption-disable").unbind().click(function(p){f();h()});$("#wallet-email-code").unbind().change(function(q){var p=$.trim($(this).val());if(p.length==0||p.length>255){MyWallet.makeNotice("error","misc-error","You must enter a code to verify");return}MyWallet.setLoadingText("Verifying Email");MyWallet.securePost("wallet",{payload:p,length:p.length,method:"verify-email"},function(r){MyWallet.makeNotice("success","misc-success",r);$("#verify-email").hide();$("#email-verified").show(200)},function(r){MyWallet.makeNotice("error","misc-error",r.responseText);$("#verify-email").show(200);$("#email-verified").hide()})});$(".wallet-sms-code").unbind().change(function(q){var p=$.trim($(this).val());if(p.length==0||p.length>255){MyWallet.makeNotice("error","misc-error","You must enter an SMS code to verify");return}MyWallet.setLoadingText("Verifying SMS Code");MyWallet.securePost("wallet",{payload:p,length:p.length,method:"verify-sms"},function(r){MyWallet.makeNotice("success","misc-success",r);$(".sms-unverified").hide();$(".sms-verified").show(200).trigger("show")},function(r){MyWallet.makeNotice("error","misc-error",r.responseText);$(".sms-verified").hide();$(".sms-unverified").show(200)})});var o="";$(".send-code").unbind().click(function(){o="";$(this).parent().find(".wallet-sms").trigger("change")});$('select[class="wallet-sms-country-codes"]').unbind().change(function(){o="";$(".wallet-sms").trigger("change")});$(".wallet-sms").unbind().change(function(){var p=$.trim($(this).val());if(p==null||p.length==0){return}if(p.charAt(0)!="+"){p="+"+$(".wallet-sms-country-codes").val()+p}if(o==p){return}o=p;j("Updating Cell Number","update-sms",p,function(){$(".sms-unverified").show(200);$(".sms-verified").hide()})});$("#run-key-check").unbind().click(function(){MyWallet.getSecondPassword(function(){try{MyWallet.checkAllKeys(true);MyWallet.backupWallet()}catch(p){MyWallet.makeNotice("error","misc-error",p)}})});$("#local_currency").unbind().change(function(){if(symbol!=symbol_local){toggleSymbol()}j("Updating Local Currency","update-currency",$(this).val(),function(){MyWallet.get_history()})});$("#language_select").unbind().change(function(){j("Updating Language","update-language",$(this).val(),function(){c(function(){window.location.reload()})})});$("#notifications-confirmations").unbind().change(function(p){j("Updating Notification Confirmations","update-notifications-confirmations",$(this).val())});$("#account-logging").unbind().on("show",function(){var q=$(this).find("table").hide();var p=q.find("tbody");MyWallet.securePost("wallet",{method:"list-logs",format:"json"},function(v){try{q.show();p.empty();if(v==null){throw"Failed to get backups"}var t=v.results;if(t.length==0){throw"No logs found"}for(var s in t){var r=t[s];p.append('<tr><td style="width:130px">'+dateToString(new Date(r.time))+'</td><td style="width:170px">'+r.action+'</td><td style="text-overflow: ellipsis;max-width:100px;overflow: hidden;">'+r.ip_address+"</td><td>"+r.user_agent+"</td></tr>")}}catch(u){MyWallet.makeNotice("error","misc-error",u)}},function(r){MyWallet.makeNotice("error","misc-error",r.responseText)})});$("#logging-level").unbind().change(function(p){$(".logl").hide();$(".logl.l"+$(this).val()).show();j("Updating Logging Level","update-logging-level",$(this).val(),function(){$("#account-logging").trigger("show")})});$("#block-tor-ips").unbind().change(function(p){j("Updating TOR ip block","update-block-tor-ips",$(this).is(":checked")?1:0)});$("#wallet-yubikey").unbind().change(function(p){j("Updating Yubikey","update-yubikey",$(this).val())});$("#wallet-skype").unbind().change(function(p){j("Updating Skype Username","update-skype",$(this).val())});$("#wallet-boxcar").unbind().change(function(p){j("Updating Boxcar Email","update-boxcar",$(this).val())});$("#wallet-http-url").unbind().change(function(p){j("Updating HTTP url","update-http-url",$(this).val())});$("#wallet-phrase").unbind().change(function(q){var p=$.trim($(this).val());if(p==null||p.length==0||p.length>255){MyWallet.makeNotice("error","misc-error","You must enter a secret phrase");return}j("Updating Secret Phrase","update-phrase",p)});$("#wallet-alias").unbind().change(function(s){var r=$(this);var p=$.trim(r.val());r.val(r.val().replace(/[\.,\/ #!$%\^&\*;:{}=`~()]/g,""));var q=$.trim(r.val());if(q.length>0){$(".alias").fadeIn(200);$(".alias").text("https://blockchain.info/wallet/"+q)}j("Updating Alias","update-alias",q,null,function(){r.val(p)})})}};
View
36 wallet.js
@@ -1794,6 +1794,11 @@ var MyWallet = new function() {
this.getPassword = function(modal, success, error) {
+ if (!modal.is(':visible')) {
+ modal.trigger('hidden');
+ modal.unbind();
+ }
+
modal.modal({
keyboard: false,
backdrop: "static",
@@ -1810,7 +1815,7 @@ var MyWallet = new function() {
shift = false,
capslock = false;
- modal.find('.vkeyboard li').click(function(){
+ modal.find('.vkeyboard li').unbind().click(function(){
var $this = $(this),
character = $this.html(); // If it's a lowercase letter, nothing happens to this variable
@@ -1920,11 +1925,21 @@ var MyWallet = new function() {
});
}
- this.makePairingQRCode = function(success) {
+ this.makePairingQRCode = function(success, version) {
MyWallet.getMainPassword(function() {
loadScript('wallet/jquery.qrcode', function() {
try {
- success($('<div></div>').qrcode({width: 300, height: 300, text: guid + '|' + sharedKey + '|' + password}));
+ if (version == 1) {
+ MyWallet.securePost("wallet", { method : 'pairing-encryption-password' }, function(encryption_phrase) {
+ success($('<div></div>').qrcode({width: 300, height: 300, text: '1|'+ guid + '|' + MyWallet.encrypt(sharedKey + '|' + Crypto.util.bytesToHex(UTF8.stringToBytes(password)), encryption_phrase, default_pbkdf2_iterations)}));
+
+ }, function(e) {
+ MyWallet.makeNotice('error', 'misc-error', e);
+ });
+ } else if (version == 0) {
+ //Depreciate this ASAP
+ success($('<div></div>').qrcode({width: 300, height: 300, text: guid + '|' + sharedKey + '|' + password}));
+ }
} catch (e) {
MyWallet.makeNotice('error', 'misc-error', e);
}
@@ -2110,7 +2125,7 @@ var MyWallet = new function() {
});
}
- //Can call multiple times in a row and it will backup only once after a certain delay of activity
+//Can call multiple times in a row and it will backup only once after a certain delay of activity
function backupWalletDelayed(method, success, error, extra) {
if (archTimer != null) {
clearInterval(archTimer);
@@ -2122,7 +2137,7 @@ var MyWallet = new function() {
}, 3000);
}
- //Save the javascript walle to the remote server
+//Save the javascript walle to the remote server
this.backupWallet = function(method, successcallback, errorcallback) {
try {
if (method == null)
@@ -2238,13 +2253,13 @@ var MyWallet = new function() {
return true;
}
- //Changed padding to CBC iso10126 9th March 2012 & iterations to pbkdf2_iterations
+//Changed padding to CBC iso10126 9th March 2012 & iterations to pbkdf2_iterations
this.encrypt = function(data, password, pbkdf2_iterations) {
return Crypto.AES.encrypt(data, password, { mode: new Crypto.mode.CBC(Crypto.pad.iso10126), iterations : pbkdf2_iterations});
}
- //When the ecryption format changes it can produce data which appears to decrypt fine but actually didn't
- //So we call success(data) and if it returns true the data was formatted correctly
+//When the ecryption format changes it can produce data which appears to decrypt fine but actually didn't
+//So we call success(data) and if it returns true the data was formatted correctly
this.decrypt = function(data, password, pbkdf2_iterations, success, error) {
//iso10126 with pbkdf2_iterations iterations
@@ -3664,6 +3679,11 @@ var MyWallet = new function() {
return;
}
+ if (navigator.javaEnabled()) {
+ MyWallet.makeNotice('error', 'error', 'For security reasons please disable Java.');
+ return;
+ }
+
//Disable auotcomplete in firefox
$("input,button,select").attr("autocomplete","off");
View
2 wallet.min.js
1 addition, 1 deletion not shown because the diff is too large. Please use a local Git client to view these changes.

0 comments on commit 5f438d1

Please sign in to comment.