git ssb

2+

mixmix / ticktack



Tree: 992639a1213cadc35e523df588f878128718bc5b

Files: 992639a1213cadc35e523df588f878128718bc5b / backup / html / backup.js

1926 bytesRaw
1const nest = require('depnest')
2const { h, computed, Value } = require('mutant')
3const electron = require('electron')
4const path = require('path')
5const fs = require('fs')
6
7exports.gives = nest({
8 'backup.html': ['exportIdentityButton', 'importIdentityButton']
9})
10
11exports.needs = nest({
12 'app.html.lightbox': 'first',
13 'keys.sync.id': 'first',
14 'translations.sync.strings': 'first'
15})
16
17exports.create = (api) => {
18 return nest('backup.html', { exportIdentityButton, importIdentityButton })
19
20 let feed = api.keys.sync.id()
21 let strings = api.translations.sync.strings()
22
23 function exportIdentityButton() {
24 let isOpen = Value(false)
25 let encryptionKeyRaw = Value('')
26 let msg = "Your identity is represented by an ed25519 key pair. Please backup your private key file very carefully. 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"
27 let encryptionKeyInput = h('textarea#encryptionKey', {
28 style: {
29 width: '90%'
30 },
31 placeholder: 'Please enter password to protect export file',
32 value: encryptionKeyRaw,
33 'ev-input': () => encryptionKeyRaw.set(encryptionKeyInput.value),
34 })
35
36 let dialog = h('div.dialog', [
37 h('div.message', [
38 h('p', msg),
39 ]),
40 h('div.form', [
41 encryptionKeyInput
42 ]),
43 h('div.actions', [
44 h('Button', { 'ev-click': () => isOpen.set(false) }, 'Cancel'),
45 h('Button -primary', { 'ev-click': () => exportKey(resolve(encryptionKeyRaw), () => isOpen.set(false)) }, 'Export Keys')
46 ])
47 ])
48
49 let lb = api.app.html.lightbox(dialog, isOpen)
50
51 return h('div.backupKeys', [
52 h('Button -backup', { 'ev-click': () => isOpen.set(true) }, 'Export Keys'),
53 lb
54 ])
55 }
56
57 function importIdentityButton() {
58 return h('div.backupKeys', [
59 h('Button -backup', 'Import Keys')
60 ])
61 }
62}
63

Built with git-ssb-web