secrez 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/secrez.js CHANGED
@@ -31,6 +31,11 @@ const optionDefinitions = [
31
31
  alias: "s",
32
32
  type: Boolean,
33
33
  },
34
+ {
35
+ name: "timeout",
36
+ alias: "t",
37
+ type: Number,
38
+ },
34
39
  {
35
40
  name: "localDir",
36
41
  alias: "l",
@@ -100,12 +105,13 @@ Options:
100
105
  -s, --save-iterations Saves the number of iterations in env.json (which
101
106
  is git-ignored). Do it only if you computer is very safe.
102
107
  -l, --localDir The local (out of the enctrypted fs) working dir. "~" by default.
103
-
108
+ -t, --timeout The timeout in seconds before the screen is cleared. By default it is 180 seconds.
109
+
104
110
  Examples:
105
111
  $ secrez
106
112
  $ secrez -c /var/my-secrets -i 787099 -l ~/Desktop
107
113
  $ secrez -si 1213672
108
- $ secrez -c ~/.secrez-archive
114
+ $ secrez -c ~/.secrez-archive -t 60
109
115
 
110
116
  `
111
117
  );
package/coverage.report CHANGED
@@ -1,81 +1,329 @@
1
1
 
2
- > secrez@1.1.2 test /Users/francescosullo/Projects/Personal/secrez/packages/secrez
2
+ > secrez@1.1.4 test /Users/francescosullo/Projects/Secrez/secrez/packages/secrez
3
3
  > cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/*.test.js test/**/*.test.js test/**/**/*.js --exit
4
4
 
5
5
 
6
6
 
7
+ #Command
8
+ #constructor
9
+ ✓ should instantiate a Command object
10
+ #getFileList
11
+ ✓ should get the current internal folder dir
12
+ ✓ should get the current external folder dir
13
+ #help & #setHelpAndCompletion
14
+ ✓ should do nothing
15
+ #validate
16
+ ✓ should validate the options
17
+
18
+ #Fido2Client
19
+ #configuration
20
+ ✓ should verify that all the scripts exist
21
+
22
+ #Alias
23
+ ✓ should return the help
24
+ ✓ create aliases and lists them
25
+ - should chain two commands
26
+ ✓ rename and delete aliases
27
+ ✓ should throw if there are errors
28
+
29
+ #Cat
30
+ ✓ should return the help
31
+ ✓ should show the content of a file
32
+ ✓ should show either one or all the versions of a file (1021ms)
33
+ ✓ should throw if entry is not a file or file does not exist
34
+ ✓ should throw if trying to cat a binary file
35
+ ✓ should show the content of a Yaml file (1023ms)
36
+
37
+ #Cd
38
+ ✓ should return the help
39
+ ✓ change to a folder
40
+ ✓ return en error if changing to a file
41
+
42
+ #Chat
43
+ ✓ should return the help
44
+ ✓ should run the chat if the courier is ready (164ms)
45
+
46
+ #Contacts
47
+ ✓ should return the help
48
+ ✓ create a contacts
49
+ ✓ create contacts and get their public keys
50
+ ✓ should list contacts
51
+ ✓ should update a contact
52
+ ✓ should rename a contacts
53
+ ✓ should remove a contacts
54
+ ✓ should throw if there are errors
55
+
56
+ #Copy
57
+ ✓ should return the help
58
+ ✓ should copy a file to the clipboard (376ms)
59
+ ✓ should copy a string to the clipboard (246ms)
60
+ ✓ should copy a card to the clipboard (855ms)
61
+ ✓ should return an error if the file does not exist or is a folder
62
+ ✓ should throw if copying to clipboard a binary files
63
+
64
+ #Courier
65
+ ✓ should return the help
66
+ ✓ should check if it is ready
67
+ ✓ should set up the courier (140ms)
68
+ ✓ should set up the courier and get the default message when is already set up (144ms)
69
+
70
+ #Ds
71
+ ✓ should return the help
72
+ ✓ should list all datasets
73
+ ✓ should create a new dataset
74
+ ✓ should rename a dataset
75
+ ✓ should delete a dataset
76
+
77
+ #Export
78
+ ✓ should return the help
79
+ ✓ should export a file to the current local folder
80
+ ✓ should export a binary file to the current local folder
81
+ ✓ should export an encrypted file to the current local folder
82
+ ✓ should export a file and delete it after 1 second (1205ms)
83
+ ✓ should return an error if the file does not exist or is a folder
84
+ ✓ should export a keystore json file if a private_key exists in the entry (726ms)
85
+
86
+ #Find
87
+ ✓ should return the help
88
+ ✓ should show find a string in the tree (1031ms)
89
+ ✓ should find no result without parameters
90
+ ✓ should skip binary files from search
91
+
92
+ #Help
93
+ ✓ should return the help
94
+ ✓ #execAsync and format
95
+ ✓ should throw if wrong command
96
+ ✓ -- to complete coverage
97
+
98
+ #Import
99
+ ✓ should return the help
100
+ ✓ should import a file in the current folder
101
+ ✓ should import an encrypted file
102
+ ✓ should import an encrypted file encrypted for myself
103
+ ✓ should import an encrypted binary file and export it again verifying it is fine
104
+ ✓ should import files recursively
105
+ ✓ should read a folder and import the only text file
106
+ ✓ should read a folder and import text and binary files
107
+ ✓ should simulate the import of two files
108
+ ✓ should move the imported file
109
+ ✓ should import a backup from another software spanning the data among folders and files
110
+ ✓ should import a backup from another software but saving the tags as tags
111
+ ✓ should import a backup from another software using tags to prefix the paths
112
+ ✓ should import using tags to prefix the paths, ignoring the tags
113
+ ✓ should import from a LastPass-like csv setting the path from "grouping" and "name"
114
+ ✓ should import from a json
115
+ ✓ should throw importing a malformed backup
116
+ ✓ should throw importing a CSV indicating wrong fields to generate the path
117
+
118
+ #Lcat
119
+ ✓ should return the help
120
+ ✓ cat a file
121
+ ✓ return en error if trying to cat a binary file
122
+
123
+ #Lcd
124
+ ✓ should return the help
125
+ ✓ change to a folder
126
+ ✓ return en error if changing to a file
127
+
128
+ #Lls
129
+ ✓ should return the help
130
+ ✓ should list a folder
131
+ ✓ return en error if lls-ing a not existing path
132
+ ✓ return a message if no files are found
133
+
134
+ #Lpwd
135
+ ✓ should return the help
136
+ ✓ change to a folder
137
+
138
+ #Ls
139
+ ✓ should return the help
140
+ ✓ should return all the datasets
141
+ ✓ should list folders and files
142
+ ✓ should list folders and files using wildcards
143
+
144
+ #Mkdir
145
+ ✓ should return the help
146
+ ✓ should create a folder
147
+ ✓ should create a nested folder
148
+ ✓ should throw if trying to create a child of a file
149
+ ✓ should throw if wrong parameters
150
+
151
+ #Mv
152
+ ✓ should return the help
153
+ ✓ should rename a file (1009ms)
154
+ ✓ should move a file to another folder
155
+ ✓ should move many files to another folder
156
+ ✓ should move a file to another subfolder
157
+ ✓ should move and rename file to another folder
158
+ ✓ should move file to another folder using wildcards
159
+ ✓ should move file to another dataset using wildcards
160
+ ✓ should move file managing duplicates
161
+ ✓ should throw if parameters are missed or wrong
162
+ ✓ should move files from and to other datasets (1027ms)
163
+ ✓ should move the results of a find
164
+
165
+ #Paste
166
+ ✓ should return the help
167
+ ✓ should paste the clipboard content to a new file (51ms)
168
+ ✓ should paste the clipboard content to an existent file (71ms)
169
+ ✓ should paste a single field to a yml card (63ms)
170
+
171
+ #Pwd
172
+ ✓ should return the help
173
+ ✓ should show the working folder
174
+
175
+ #Quit
176
+ ✓ should show the content of an external file via bash
177
+
178
+ #Rm
179
+ ✓ should return the help
180
+ ✓ should delete a file with one version
181
+ ✓ should delete many files usign wildcards
182
+ ✓ should return errors if wrong parameters
183
+ ✓ should delete some versions of a file (1011ms)
184
+
185
+ #Shell
186
+ ✓ should return the help
187
+ ✓ should show the content of an external file via shell
188
+
189
+ #Tag
190
+ ✓ should return the help
191
+ ✓ should tag a file
192
+ ✓ should remove a tag
193
+ ✓ should list all the tags
194
+ ✓ should show the file tagged as
195
+ ✓ should show very long file tagged as
196
+
197
+ #Totp
198
+ ✓ should return the help
199
+ ✓ should totp a file to the clipboard (365ms)
200
+ ✓ should read a totp secret from an image and add the totp field to the card (50ms)
201
+ ✓ should read a totp secret from an image and return the secret
202
+ ✓ should throw if bad image
203
+ ✓ should throw if missing parameters
204
+ ✓ should throw if the yaml is malformed
205
+ ✓ should read a totp secret from the clipboard (87ms)
206
+
7
207
  #Touch
8
208
  ✓ should return the help
9
209
  ✓ should create a file
10
210
  ✓ should create a file with content
11
211
  ✓ should throw if trying to create a child of a file
12
212
  ✓ should throw if wrong parameters
13
- ✓ should create a file and generate a wallet (43ms)
213
+ ✓ should create a file and generate a wallet
14
214
  New file "/folder2/file1" created.
15
215
  ✓ should generate 5 prefixed wallet
16
216
  New file "/folder2/file1" created.
17
217
  ✓ should generate a wallet with mnemonic and 2 keys
18
218
 
219
+ #Use
220
+ ✓ should return the help
221
+ ✓ should use a new dataset, creating it if does not exist
222
+
223
+ #Ver
224
+ ✓ should show the current version
225
+
226
+ #Whoami
227
+ ✓ should return the help
228
+ ✓ should see who am I
229
+
230
+ #Help
231
+ ✓ should return the help
232
+
233
+ #Join
234
+ ✓ should return the help
235
+ ✓ should join a chat with user0x
236
+ ✓ should join a chat with user0x
237
+ ✓ should jump between chats
238
+ ✓ should return all the users
239
+ ✓ should throw if contact not found or multiple chat
240
+
241
+ #Leave
242
+ ✓ should return the help
243
+ ✓ should leave the room
244
+
245
+ #Quit
246
+ ✓ should return the help
247
+ ✓ should quit the chat, even if inside a room (51ms)
248
+
249
+ #Send
250
+ ✓ should return the help
251
+ ✓ should send a message to user0 (87ms)
252
+
253
+ #Show
254
+ ✓ should return the help
255
+ ✓ should show history messages (369ms)
256
+
19
257
 
20
- 8 passing (1s)
258
+ 166 passing (24s)
259
+ 1 pending
21
260
 
22
261
  -----------------------|---------|----------|---------|---------|-----------------------------------
23
262
  File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
24
263
  -----------------------|---------|----------|---------|---------|-----------------------------------
25
- All files | 19.31 | 6.31 | 17.43 | 19.32 |
26
- src | 33.03 | 15.07 | 25 | 33.33 |
27
- Command.js | 37.29 | 23.4 | 38.46 | 37.93 | 29-35,40-97,108,119,122-130
28
- PreCommand.js | 12.2 | 0 | 0 | 12.2 | 8-115
264
+ All files | 71.22 | 58.41 | 71.25 | 71.11 |
265
+ src | 59.63 | 54.79 | 55 | 60.19 |
266
+ Command.js | 79.66 | 78.72 | 76.92 | 81.03 | 32,55-62,73,80,119
267
+ PreCommand.js | 21.95 | 11.54 | 14.29 | 21.95 | 8-99,116
29
268
  cliConfig.js | 100 | 100 | 100 | 100 |
30
- src/commands | 15.44 | 2.67 | 19.63 | 15.5 |
31
- Alias.js | 8.11 | 0 | 25 | 8.22 | 62-213
32
- Bash.js | 62.5 | 0 | 33.33 | 62.5 | 11-19
33
- Cat.js | 12.09 | 0 | 14.29 | 12.09 | 61-220
34
- Cd.js | 17.86 | 0 | 25 | 17.86 | 28-73
269
+ src/commands | 81.53 | 67 | 89.95 | 81.4 |
270
+ Alias.js | 90.54 | 77.36 | 100 | 90.41 | 101,112,139,169,173,180,190
271
+ Bash.js | 75 | 0 | 66.67 | 75 | 18-19
272
+ Cat.js | 98.9 | 88.89 | 100 | 98.9 | 152
273
+ Cd.js | 96.43 | 86.67 | 100 | 96.43 | 44
35
274
  Chat.js | 19.51 | 0 | 16.67 | 19.51 | 23-144
36
- Conf.js | 8.96 | 0 | 12.5 | 8.96 | 67-499
37
- Contacts.js | 6 | 0 | 7.14 | 6.04 | 55-352
38
- Copy.js | 10.26 | 0 | 14.29 | 10.39 | 69-237
39
- Courier.js | 6.25 | 0 | 7.14 | 6.38 | 20-221
40
- Ds.js | 5.97 | 0 | 16.67 | 6.06 | 39-160
41
- Edit.js | 12.35 | 0 | 20 | 12.35 | 61-214
42
- Export.js | 12.99 | 0 | 16.67 | 12.99 | 68-232
43
- Find.js | 7.69 | 0 | 8.33 | 7.89 | 63-211
44
- Help.js | 73.33 | 40 | 75 | 73.33 | 26,36-40
45
- Import.js | 6.31 | 0 | 9.09 | 6.37 | 87-496
46
- Lcat.js | 30 | 0 | 25 | 30 | 35-65
47
- Lcd.js | 17.39 | 0 | 25 | 17.39 | 30-72
48
- Lls.js | 22.73 | 0 | 25 | 22.73 | 49-99
49
- Lpwd.js | 30.77 | 0 | 25 | 30.77 | 15-38
50
- Ls.js | 5.8 | 0 | 10 | 6.15 | 46-183
51
- Mkdir.js | 22.73 | 0 | 25 | 22.73 | 27-61
52
- Mv.js | 6.52 | 0 | 16.67 | 6.67 | 46-240
53
- Paste.js | 14.89 | 0 | 25 | 14.89 | 40-131
54
- Pwd.js | 30.77 | 0 | 25 | 30.77 | 15-35
55
- Quit.js | 50 | 0 | 33.33 | 50 | 19-40
56
- Rm.js | 16 | 0 | 16.67 | 16.33 | 36-137
57
- Shell.js | 29.41 | 0 | 25 | 29.41 | 25-57
58
- Ssh.js | 22.22 | 0 | 20 | 22.22 | 49-120
59
- Tag.js | 8.82 | 0 | 9.09 | 8.91 | 66-236
60
- Totp.js | 15.29 | 0 | 10 | 15.29 | 75-288
275
+ Conf.js | 10.45 | 0 | 25 | 10.45 | 134-499
276
+ Contacts.js | 74.67 | 65.98 | 92.86 | 74.5 | ...90-214,240,247,259,315,328,338
277
+ Copy.js | 94.87 | 74.51 | 100 | 94.81 | 111,162,179,204
278
+ Courier.js | 63.54 | 41.86 | 85.71 | 63.83 | ...37,152-171,188,200-203,215-221
279
+ Ds.js | 92.54 | 82.05 | 100 | 92.42 | 99,108-113,125
280
+ Edit.js | 13.58 | 0 | 40 | 13.58 | 88-214
281
+ Export.js | 87.63 | 67.74 | 100 | 87.63 | ...66,175,182-186,191,203,212,215
282
+ Find.js | 93.59 | 86.67 | 100 | 93.42 | 101,164,200-203,209
283
+ Help.js | 100 | 80 | 100 | 100 | 29
284
+ Import.js | 93.2 | 85.48 | 100 | 93.14 | ...65,367,387,393,441,456-463,490
285
+ Lcat.js | 100 | 85.71 | 100 | 100 | 54
286
+ Lcd.js | 95.65 | 81.82 | 100 | 95.65 | 50
287
+ Lls.js | 95.45 | 72.73 | 100 | 95.45 | 97
288
+ Lpwd.js | 92.31 | 100 | 100 | 92.31 | 36
289
+ Ls.js | 91.3 | 75 | 100 | 90.77 | 103,114-116,130,181
290
+ Mkdir.js | 100 | 66.67 | 100 | 100 | 38-44
291
+ Mv.js | 88.04 | 73.21 | 100 | 87.78 | 93-99,133,155,165-172
292
+ Paste.js | 87.23 | 75 | 100 | 87.23 | 72,78,81,89,113,129
293
+ Pwd.js | 92.31 | 100 | 100 | 92.31 | 33
294
+ Quit.js | 90 | 50 | 100 | 90 | 27
295
+ Rm.js | 94 | 80.95 | 100 | 93.88 | 63,126,134
296
+ Shell.js | 88.24 | 60 | 100 | 88.24 | 38,55
297
+ Ssh.js | 25 | 0 | 40 | 25 | 72-120
298
+ Tag.js | 98.04 | 92.31 | 100 | 98.02 | 122,171
299
+ Totp.js | 96.47 | 74.47 | 100 | 96.47 | 188-189,235
61
300
  Touch.js | 95.92 | 81.48 | 100 | 95.83 | 152,202
62
- Use.js | 12.9 | 0 | 25 | 12.9 | 30-85
63
- Ver.js | 50 | 0 | 33.33 | 50 | 17-28
64
- Whoami.js | 24.14 | 0 | 20 | 24.14 | 22-66
65
- chat.js | 19.51 | 0 | 16.67 | 19.51 | 23-144
66
- index.js | 87.5 | 50 | 100 | 86.96 | 15,22,31
67
- src/prompts | 14 | 0 | 4.76 | 14.12 |
68
- ChatPrompt.js | 6.17 | 0 | 0 | 6.17 | 8-163
69
- ChatPromptMock.js | 42.86 | 100 | 0 | 42.86 | 6-14
70
- CommandPrompt.js | 10.42 | 0 | 0 | 10.56 | 24-296
301
+ Use.js | 96.77 | 89.47 | 100 | 96.77 | 68
302
+ Ver.js | 90 | 66.67 | 100 | 90 | 25
303
+ Whoami.js | 93.1 | 63.64 | 80 | 93.1 | 29,64
304
+ chat.js | 85.37 | 53.85 | 100 | 85.37 | 105,117-130,136,142
305
+ index.js | 91.67 | 60 | 100 | 91.3 | 22,31
306
+ src/commands/chat | 79.44 | 63.29 | 92.31 | 79.33 |
307
+ Contacts.js | 80 | 42.86 | 80 | 80 | 54,65,69,81
308
+ Help.js | 86.67 | 60 | 100 | 86.67 | 37-38
309
+ Join.js | 95.65 | 82.61 | 100 | 95.56 | 43,110
310
+ Leave.js | 100 | 60 | 100 | 100 | 24,28
311
+ Quit.js | 100 | 75 | 100 | 100 | 24
312
+ Send.js | 67.65 | 46.67 | 100 | 67.65 | 37,41,44,77,86-95
313
+ Show.js | 68.75 | 70.59 | 100 | 68.75 | 74-78,87,102-108
314
+ Whoami.js | 42.86 | 0 | 60 | 42.86 | 22,30-39
315
+ src/prompts | 14.72 | 0 | 13.43 | 14.85 |
316
+ ChatPrompt.js | 6.1 | 0 | 0 | 6.1 | 8-164
317
+ ChatPromptMock.js | 100 | 100 | 66.67 | 100 |
318
+ CommandPrompt.js | 9.8 | 0 | 0 | 9.93 | 24-318
71
319
  Completion.js | 4.41 | 0 | 0 | 4.48 | 6-103
72
- MainPromptMock.js | 100 | 100 | 33.33 | 100 |
320
+ MainPromptMock.js | 100 | 100 | 66.67 | 100 |
73
321
  MultiEditorPrompt.js | 25 | 0 | 0 | 25 | 7-36
74
322
  SigintManager.js | 25 | 0 | 20 | 25 | 10-36
75
- src/utils | 51.63 | 40.63 | 20.83 | 51.03 |
76
- AliasManager.js | 5.88 | 0 | 0 | 5.88 | 3-48
77
- ContactManager.js | 7.14 | 0 | 0 | 7.14 | 3-44
78
- Fido2Client.js | 9.62 | 0 | 0 | 9.62 | 8-108
79
- HelpProto.js | 78.99 | 62.32 | 83.33 | 78.63 | 11-39,49,153-154,171-176,195
80
- Logger.js | 59.09 | 56.25 | 26.32 | 58.14 | ...29,37-57,65-69,74,84,88,93,105
323
+ src/utils | 69.92 | 63.28 | 56.25 | 69.55 |
324
+ AliasManager.js | 100 | 91.67 | 100 | 100 | 47
325
+ ContactManager.js | 71.43 | 60 | 85.71 | 71.43 | 12,35-37
326
+ Fido2Client.js | 15.38 | 0 | 11.11 | 15.38 | 14-108
327
+ HelpProto.js | 91.6 | 84.06 | 100 | 91.45 | 49,153-154,171-176,195
328
+ Logger.js | 63.64 | 56.25 | 36.84 | 62.79 | ...37-49,57,65-69,74,84,88,93,105
81
329
  -----------------------|---------|----------|---------|---------|-----------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "secrez",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "license": "MIT",
5
5
  "nyc": {
6
6
  "include": "src",
@@ -9,7 +9,7 @@
9
9
  "dependencies": {
10
10
  "@secrez/core": "~1.0.4",
11
11
  "@secrez/crypto": "~1.0.3",
12
- "@secrez/eth": "~0.0.2",
12
+ "@secrez/eth": "~0.0.3",
13
13
  "@secrez/fs": "~1.0.4",
14
14
  "@secrez/hub": "~0.2.2",
15
15
  "@secrez/utils": "~1.0.3",
package/src/PreCommand.js CHANGED
@@ -76,6 +76,7 @@ class PreCommand {
76
76
  name: "result",
77
77
  message: options.message,
78
78
  default: options.content,
79
+ choices: options.choices,
79
80
  validate: (val) => {
80
81
  if (val) {
81
82
  if (val === exitCode) {
@@ -3,8 +3,8 @@ const path = require("path");
3
3
  const chalk = require("chalk");
4
4
 
5
5
  const Crypto = require("@secrez/crypto");
6
- const { sleep } = require("@secrez/utils");
7
-
6
+ const { sleep, yamlParse } = require("@secrez/utils");
7
+ const { encryptPrivateKeyAsKeystoreJson } = require("@secrez/eth");
8
8
  const { Node, FileCipher } = require("@secrez/fs");
9
9
 
10
10
  class Export extends require("../Command") {
@@ -61,6 +61,11 @@ class Export extends require("../Command") {
61
61
  name: "include-me",
62
62
  type: Boolean,
63
63
  },
64
+ {
65
+ name: "keystore",
66
+ alias: "k",
67
+ type: Boolean,
68
+ },
64
69
  ];
65
70
  }
66
71
 
@@ -97,6 +102,10 @@ class Export extends require("../Command") {
97
102
  "export seed.json -e --include-me",
98
103
  "encrypts seed.json also using your key",
99
104
  ],
105
+ [
106
+ "export my-wallet.yml -k",
107
+ "it will export a private key from the entry to a keystore file. The fill will be named as the entry replacing the extension with '.keystore.json'. If in the entry there are more than one private_key, it will ask which one to export. If no '--password' is specified, it will ask for a password to encrypt the keystore file. The entry must be a valid card, with at least one 'private_key' field.",
108
+ ],
100
109
  ],
101
110
  };
102
111
  }
@@ -131,7 +140,43 @@ class Export extends require("../Command") {
131
140
  if (Node.isBinary(entry) && typeof content === "string") {
132
141
  content = Crypto.bs64.decode(content);
133
142
  }
134
- if (options.encrypt) {
143
+ if (options.keystore) {
144
+ let card;
145
+ try {
146
+ card = yamlParse(content);
147
+ } catch (e) {
148
+ throw new Error("The entry is not a valid card");
149
+ }
150
+ let pks = [];
151
+ for (let k in card) {
152
+ if (/private_key/.test(k)) {
153
+ pks.push(k);
154
+ }
155
+ }
156
+ if (!pks.length) {
157
+ throw new Error("The entry does not contain any private key");
158
+ }
159
+ let privateKey = card[pks[0]];
160
+ if (pks.length > 1) {
161
+ let pk = await this.useInput({
162
+ type: "list",
163
+ message: "Which private key do you want to export?",
164
+ choices: pks,
165
+ });
166
+ privateKey = card[pk];
167
+ }
168
+ let pwd =
169
+ options.password ||
170
+ (await this.useInput({
171
+ type: "password",
172
+ message: "Type the password to encrypt the keystore file",
173
+ }));
174
+ if (!pwd) {
175
+ throw new Error("Operation canceled");
176
+ }
177
+ content = await encryptPrivateKeyAsKeystoreJson(privateKey, pwd);
178
+ name = name.replace(/\.[^.]+$/, ".keystore.json");
179
+ } else if (options.encrypt) {
135
180
  const myPublicKey = this.secrez.getPublicKey();
136
181
  if (options.publicKeys) {
137
182
  if (
@@ -176,7 +221,8 @@ class Export extends require("../Command") {
176
221
  let fn = path.join(dir, name);
177
222
  await fs.writeFile(fn, content);
178
223
  if (options.duration) {
179
- this.deleteFromDisk(fn, options.duration);
224
+ // we do not wait for the deletion
225
+ this.deleteFromDisk(fn, options.duration).then();
180
226
  }
181
227
  return name;
182
228
  } else {
@@ -125,7 +125,7 @@ class Touch extends require("../Command") {
125
125
  if (i === 1) {
126
126
  wallet0 = wallet;
127
127
  } else {
128
- wallet0 = await getWalletFromMnemonic(
128
+ wallet0 = getWalletFromMnemonic(
129
129
  wallet.mnemonic.phrase,
130
130
  wallet.path,
131
131
  i - 1
@@ -42,6 +42,7 @@ class ChatPrompt extends require("./CommandPrompt") {
42
42
  }
43
43
 
44
44
  prePromptMessage(options = {}) {
45
+ this.resetTimeout();
45
46
  if (this.environment.room) {
46
47
  let nicks = this.nicks(this.environment.room[0].contact);
47
48
  return [
@@ -20,6 +20,28 @@ const sigintManager = require("./SigintManager");
20
20
  let thiz;
21
21
 
22
22
  class CommandPrompt {
23
+ constructor() {
24
+ this.timeoutId = null;
25
+ this.clearScreenTimeout = 180;
26
+ }
27
+
28
+ clearScreen() {
29
+ process.stdout.write("\u001b[2J\u001b[0;0H");
30
+ process.stdout.write(
31
+ `Screen cleared. Press any key to reactivate the terminal`
32
+ );
33
+ }
34
+
35
+ resetTimeout() {
36
+ const s = 180000;
37
+ if (this.timeoutId) {
38
+ clearTimeout(this.timeoutId);
39
+ }
40
+ this.timeoutId = setTimeout(() => {
41
+ this.clearScreen();
42
+ }, this.clearScreenTimeout * 1000);
43
+ }
44
+
23
45
  async getReady(options) {
24
46
  thiz = this;
25
47
  this.inquirer = inquirer;
@@ -27,6 +27,9 @@ class MainPrompt extends require("./CommandPrompt") {
27
27
  commands: new Commands(this, cliConfig).getCommands(),
28
28
  });
29
29
  this.cache = {};
30
+ if (options.timeout) {
31
+ this.clearScreenTimeout = options.timeout;
32
+ }
30
33
  }
31
34
 
32
35
  async preRun(options = {}) {
@@ -73,6 +76,7 @@ class MainPrompt extends require("./CommandPrompt") {
73
76
  }
74
77
 
75
78
  prePromptMessage(options = {}) {
79
+ this.resetTimeout();
76
80
  return chalk.reset(
77
81
  `Secrez ${
78
82
  this.internalFs.tree.name