From 3d9d3c2d54d11d893348b5a2149786c5c20047b8 Mon Sep 17 00:00:00 2001 From: Jon Kuperman Date: Thu, 29 Sep 2016 23:25:28 -0700 Subject: [PATCH] ledger backup and recovery --- .../locales/en-US/preferences.properties | 18 +++ app/ledger.js | 12 +- js/about/preferences.js | 146 +++++++++++++++++- js/constants/settings.js | 4 +- less/about/preferences.less | 4 + less/button.less | 4 + 6 files changed, 185 insertions(+), 3 deletions(-) diff --git a/app/extensions/brave/locales/en-US/preferences.properties b/app/extensions/brave/locales/en-US/preferences.properties index 0b26dcad5ea..71d303e1907 100644 --- a/app/extensions/brave/locales/en-US/preferences.properties +++ b/app/extensions/brave/locales/en-US/preferences.properties @@ -59,6 +59,7 @@ bitcoinVisitAccount=Transfer BTC bitcoinBalance=Please transfer:  bitcoinWalletNotAvailable=Wallet information not available. :( usd=$ +cancel=Cancel done=Done off=off on=on @@ -71,6 +72,9 @@ add=Fund with debit/credit transferTime=Transfer may take up to 40 minutes addFundsTitle=Add funds… addFunds=Three ways to add funds to your Brave Wallet +copy=Copy +firstKey=Key 1 +secondKey=Key 2 copyToClipboard=Copy to clipboard smartphoneTitle=Use your smartphone app to transfer Bitcoin displayQRCode=Display QR code @@ -110,6 +114,20 @@ offerSearchSuggestions=Autocomplete search term as you type doNotTrackTitle=Do Not Track doNotTrack=Send a 'Do Not Track' header with browsing requests (requires browser restart) blockCanvasFingerprinting=Fingerprinting Protection (may break some websites) +advancedSettings=Advanced Settings... +advancedSettingsTitle=Advanced Settings for Brave Payments +ledgerRecoveryTitle=Recover your Brave wallet +ledgerRecoverySubtitle=Enter your recovery keys below +ledgerRecoveryContent=The balance of the recovered wallet will be transferred to your new Brave wallet. The old wallet will still exist as an empty wallet. +ledgerBackupTitle=Backup your Brave wallet +ledgerBackupContent=Below, you will find the anonymized recovery keys that are required if you ever lose access to this computer. We recommend that you print or save these keys and store them in a safe place, like your local safe deposit box, or under your mattress. It's really up to you! +minimumPageTimeSetting=Minimum page time before logging a visit +minimumVisitsSetting=Minimum visits for publisher relevancy +backupLedger=Backup your wallet +recoverLedger=Recover your wallet +recover=Recover +printKeys=Print keys +saveRecoveryFile=Save recovery file... advancedPrivacySettings=Advanced Privacy Settings: braveryDefaults=Bravery Defaults blockAttackSites=Block reported attack sites (not available yet) diff --git a/app/ledger.js b/app/ledger.js index 6e80de3e8ef..82d3f14c496 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -136,6 +136,10 @@ const doAction = (action) => { case settings.PAYMENTS_CONTRIBUTION_AMOUNT: setPaymentInfo(action.value) break + case settings.MINIMUM_VISIT_TIME: + break + case settings.MINIMUM_VISTS: + break default: break } @@ -869,6 +873,10 @@ var ledgerInfo = { buyURL: undefined, bravery: undefined, + // wallet credentials + paymentId: undefined, + passphrase: undefined, + hasBitcoinHandler: false, // geoIP/exchange information @@ -1107,6 +1115,9 @@ var getStateInfo = (state) => { var info = state.paymentInfo var then = underscore.now() - msecs.year + ledgerInfo.paymentId = state.properties.wallet.paymentId + ledgerInfo.passphrase = state.properties.wallet.keychains.passphrase + ledgerInfo.created = !!state.properties.wallet ledgerInfo.creating = !ledgerInfo.created @@ -1228,7 +1239,6 @@ var getPaymentInfo = () => { info = underscore.extend(info, underscore.pick(body, [ 'buyURL', 'buyURLExpires', 'balance', 'unconfirmed', 'satoshis' ])) info.address = client.getWalletAddress() - info.passphrase = client.getWalletPassphrase() if ((amount) && (currency)) { info = underscore.extend(info, { amount: amount, currency: currency }) if ((body.rates) && (body.rates[currency])) { diff --git a/js/about/preferences.js b/js/about/preferences.js index 9cd22297284..0eb693e62ca 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -721,6 +721,7 @@ class TabsTab extends ImmutableComponent { class PaymentsTab extends ImmutableComponent { constructor () { super() + this.printKeys = this.printKeys.bind(this) this.createWallet = this.createWallet.bind(this) } @@ -730,6 +731,23 @@ class PaymentsTab extends ImmutableComponent { } } + copyToClipboard (text) { + aboutActions.setClipboard(text) + } + + printKeys () { + const paymentId = this.props.ledgerData.get('paymentId') + const passphrase = this.props.ledgerData.get('passphrase') + + aboutActions.newFrame({ + location: `data:text/html,Brave Wallet Recovery keys + Date created: + Recovery Key 1: ${paymentId} + Recovery Key 2: ${passphrase} + Note: These keys are not stored on Brave servers. These keys are your only method of recovering your Brave wallet. Save these keys in a safe place, separate from your brave browser.` + }, true) + } + get enabled () { return getSetting(settings.PAYMENTS_ENABLED, this.props.settings) } @@ -839,6 +857,111 @@ class PaymentsTab extends ImmutableComponent { } + get advancedSettingsContent () { + return
+
+
+
+ + + + + +
+ + + + + +
+ {this.enabled + ? + : null} +
+
+ } + + get advancedSettingsFooter () { + return
+
+ } + + get ledgerBackupContent () { + const paymentId = this.props.ledgerData.get('paymentId') + const passphrase = this.props.ledgerData.get('passphrase') + + return
+
+ +
+
+
+
+

+ {paymentId} +

+
+
+
+
+
+

+ {passphrase} +

+
+
+
+ } + + get ledgerBackupFooter () { + return
+
+ } + + get ledgerRecoveryContent () { + return
+
+

+ + + +

Key 1

+ +

Key 2

+ +
+
+

+
+ } + + get ledgerRecoveryFooter () { + return
+
+ } + get nextReconcileDate () { const ledgerData = this.props.ledgerData if (!ledgerData.get('reconcileStamp')) { @@ -947,6 +1070,21 @@ class PaymentsTab extends ImmutableComponent { ? : null } + { + this.enabled && this.props.advancedSettingsOverlayVisible + ? + : null + } + { + this.enabled && this.props.ledgerBackupOverlayVisible + ? + : null + } + { + this.enabled && this.props.ledgerRecoveryOverlayVisible + ? + : null + }
Brave Payments @@ -957,7 +1095,7 @@ class PaymentsTab extends ImmutableComponent {
- {this.enabled ? : null} +
{ @@ -1361,6 +1499,9 @@ class AboutPreferences extends React.Component { bitcoinOverlayVisible: false, qrcodeOverlayVisible: false, paymentHistoryOverlayVisible: false, + advancedSettingsOverlayVisible: false, + ledgerBackupOverlayVisible: false, + ledgerRecoveryOverlayVisible: false, addFundsOverlayVisible: false, preferenceTab: hash.toUpperCase() in preferenceTabs ? hash : preferenceTabs.GENERAL, hintNumber: this.getNextHintNumber(), @@ -1491,6 +1632,9 @@ class AboutPreferences extends React.Component { bitcoinOverlayVisible={this.state.bitcoinOverlayVisible} qrcodeOverlayVisible={this.state.qrcodeOverlayVisible} paymentHistoryOverlayVisible={this.state.paymentHistoryOverlayVisible} + advancedSettingsOverlayVisible={this.state.advancedSettingsOverlayVisible} + ledgerBackupOverlayVisible={this.state.ledgerBackupOverlayVisible} + ledgerRecoveryOverlayVisible={this.state.ledgerRecoveryOverlayVisible} addFundsOverlayVisible={this.state.addFundsOverlayVisible} showOverlay={this.setOverlayVisible.bind(this, true)} hideOverlay={this.setOverlayVisible.bind(this, false)} /> diff --git a/js/constants/settings.js b/js/constants/settings.js index 7f489fa1574..d241f4d4b28 100644 --- a/js/constants/settings.js +++ b/js/constants/settings.js @@ -55,7 +55,9 @@ const settings = { HARDWARE_ACCELERATION_ENABLED: 'advanced.hardware-acceleration-enabled', PDFJS_ENABLED: 'advanced.pdfjs-enabled', DEFAULT_ZOOM_LEVEL: 'advanced.default-zoom-level', - SMOOTH_SCROLL_ENABLED: 'advanced.smooth-scroll-enabled' + SMOOTH_SCROLL_ENABLED: 'advanced.smooth-scroll-enabled', + MINIMUM_VISIT_TIME: 'advanced.minimum-visit-time', + MINIMUM_VISTS: 'advanced.minimum-visits' } module.exports = settings diff --git a/less/about/preferences.less b/less/about/preferences.less index ca9dabdcbd3..bbfea1d880c 100644 --- a/less/about/preferences.less +++ b/less/about/preferences.less @@ -897,6 +897,10 @@ div.nextPaymentSubmission { } } +.advancedSettingsFooter { + padding: 20px 100px; +} + #flashInfoIcon { padding: 5px 5px 5px 0; } diff --git a/less/button.less b/less/button.less index a788abe32be..7f48dc44f4a 100644 --- a/less/button.less +++ b/less/button.less @@ -118,6 +118,10 @@ span.browserButton, padding: 3px 35px; } + &.inlineButton { + display: inline; + } + &.secondaryButton { background-color: #eee; }