git ssb

2+

mixmix / ticktack



Tree: 98233c821a36cfebd65825ed3c2c4e9474f43e6e

Files: 98233c821a36cfebd65825ed3c2c4e9474f43e6e / backup / html / backup.js

2497 bytesRaw
1const nest = require('depnest')
2const { h, computed, Value, resolve } = require('mutant')
3const electron = require('electron')
4const { dialog } = require('electron').remote;
5const path = require('path')
6const fs = require('fs')
7
8exports.gives = nest({
9 'backup.html': ['exportIdentityButton', 'importIdentityButton']
10})
11
12exports.needs = nest({
13 'app.html.lightbox': 'first',
14 'keys.sync.id': 'first',
15 'translations.sync.strings': 'first',
16 'backup.async.exportIdentity': 'first'
17})
18
19exports.create = (api) => {
20 return nest('backup.html', { exportIdentityButton, importIdentityButton })
21
22 let feed = api.keys.sync.id()
23 let strings = api.translations.sync.strings()
24
25 function exportIdentityButton() {
26 let isOpen = Value(false)
27 let encryptionKeyRaw = Value('')
28
29 let encryptionKeyInput = h('textarea#encryptionKey', {
30 style: {
31 width: '90%'
32 },
33 placeholder: 'Please enter password to protect export file',
34 value: encryptionKeyRaw,
35 'ev-input': () => encryptionKeyRaw.set(encryptionKeyInput.value),
36 })
37
38 let exportDialog = h('div.dialog', {
39 style: {
40 'text-align': 'left'
41 }
42 },
43 [
44 h('div.message', [
45 h('h1', 'Export Identity'),
46 h('p', 'Please backup your private key file very carefully.'),
47 h('p', 'If your private key is hacked, all your private messages will be retrieved by third party, and your identity will be faked on the network')
48 ]),
49 h('div.form', [
50 encryptionKeyInput
51 ]),
52 h('div.actions', [
53 h('Button', { 'ev-click': () => isOpen.set(false) }, 'Cancel'),
54 h('Button -primary', {
55 'ev-click': () => {
56 dialog.showSaveDialog(
57 {
58 title: 'Export Identity',
59 butttonLabel: 'Export Identity',
60 defaultPath: 'ticktack-identity.backup',
61 },
62 (filename) => api.backup.async.exportIdentity(
63 resolve(encryptionKeyRaw), filename, () => isOpen.set(false)
64 )
65 )
66 }
67 }, 'Export Identity')
68 ])
69 ])
70
71 let lb = api.app.html.lightbox(exportDialog, isOpen)
72
73 return h('div.backupKeys', [
74 h('Button -backup', { 'ev-click': () => isOpen.set(true) }, 'Export Keys'),
75 lb
76 ])
77 }
78
79 function importIdentityButton() {
80 return h('div.backupKeys', [
81 h('Button -backup', 'Import Keys')
82 ])
83 }
84}
85

Built with git-ssb-web