secrez 1.1.2 → 1.1.3
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/README.md +161 -225
- package/coverage.report +299 -51
- package/package.json +2 -2
- package/src/PreCommand.js +1 -0
- package/src/commands/Export.js +50 -4
- package/src/commands/Touch.js +1 -1
package/README.md
CHANGED
@@ -31,91 +31,55 @@
|
|
31
31
|
|
32
32
|
</p>
|
33
33
|
|
34
|
-
Secrez is
|
35
|
-
|
36
|
-
- a CLI secret manager working as an encrypted file system;
|
37
|
-
- a decentralized surveillance-resistant end-to-end encrypted messaging system.
|
34
|
+
Secrez is a CLI secret manager that functions as an encrypted file system, as well as a decentralized, surveillance-resistant, end-to-end encrypted messaging system.
|
38
35
|
|
39
36
|
## Intro
|
40
37
|
|
41
|
-
At
|
42
|
-
|
43
|
-
The idea is to interact with encrypted virtual files as if they are just files in a standard file system.
|
38
|
+
At its core, Secrez is a command-line interface that manages an encrypted file system, with commands that work similarly to Unix commands like `cd`, `mkdir`, `ls`, `mv`, etc. The idea is to interact with encrypted virtual files as if they are just files in a standard file system.
|
44
39
|
|
45
40
|
## Why Secrez?
|
46
41
|
|
47
|
-
|
48
|
-
|
49
|
-
1. Online systems that save the data online (like LastPass)
|
50
|
-
2. Desktop tools who keep data in the computer (like KeyPass)
|
51
|
-
|
52
|
-
An Online Password Manager requires that you trust the remote server.
|
53
|
-
I founded Passpack in 2006, and I know very well how, at any moment, you can add a backdoor —— even only for a specific user —— and most likely nobody will notice it.
|
54
|
-
|
55
|
-
The second case, a desktop tool is intrinsically more secure, but it is hard to use on more than one computer.
|
56
|
-
The standard solution is to backup the database on Dropbox or Google Drive and —— before using it —— download it locally, which is prone to produce unfixable problems and cause data loss.
|
57
|
-
|
58
|
-
Secrez's goal is to be as safe as KeyPass but available everywhere, like Lastpass.
|
42
|
+
Secrez aims to provide a secure password management solution that is available everywhere. While online password managers like LastPass require you to trust a remote server, desktop tools like KeyPass are more secure but difficult to use on multiple computers. To address this, Secrez combines the security of KeyPass with the accessibility of LastPass.
|
59
43
|
|
60
|
-
To
|
44
|
+
To achieve its goal, Secrez uses several strategies. First, any secret is a local file. Second, any file, whether it's a tree version, a directory, a text file, or a binary file, is immutable. Finally, any change can be pulled/pushed to a remote private repository. You can either create a private repository on GitHub, BitBucket, etc. or set up your own self-hosted Git server.
|
61
45
|
|
62
|
-
|
63
|
-
- Any file — besides if it is a tree version, a directory, a text file, or a binary file — is immutable
|
64
|
-
- Any change can be pulled/pushed to a remote private repo
|
46
|
+
In addition to functioning as a password manager, Secrez also includes an optional decentralized, surveillance-resistant, end-to-end encrypted messaging system. This provides an extra layer of security for your communications, ensuring that your messages cannot be intercepted or read by anyone other than the intended recipient.
|
65
47
|
|
66
|
-
|
67
|
-
|
68
|
-
For now, this is a manual approach. In a future version, the git repo will be manageable from inside Secrez.
|
48
|
+
Overall, Secrez offers a powerful and secure solution for managing your passwords and secrets, all from the command line.
|
69
49
|
|
70
50
|
## The structure
|
71
51
|
|
72
|
-
Secrez simulates an operating system
|
73
|
-
|
74
|
-
Starting from version `0.6.0`, the data are organized in datasets. Think of them like separate disks, something like `/dev/disk1` and `/dev/disk2`.
|
75
|
-
|
76
|
-
By default, Secrez generates two datasets: `main` and `trash`. You can create more with, for example, `use -c archive`. The advantage of multiple datasets is mostly for people who have a lot of secrets to manage. If you have 2,000, if they are all in the primary dataset, the system will probably become quite slow. The solution is to move data to separate datasets (`archive`, `backup`, `twitter`, `cryptos`, etc.)
|
77
|
-
|
78
|
-
## Secrez never lose secrets
|
79
|
-
|
80
|
-
One of the primary goal of a secrets manager is that you will never lose any data.
|
81
|
-
|
82
|
-
However, since only the most recent index is read, some secrets could be in the folder and not been loaded.
|
52
|
+
Secrez simulates an operating system, allowing you to execute commands like ls and mv when you load the environment, similar to what you would normally do in a Unix terminal.
|
83
53
|
|
84
|
-
|
54
|
+
Starting from version 0.6.0, Secrez organizes data into datasets, which act like separate disks, such as /dev/disk1 and /dev/disk2. By default, Secrez generates two datasets: main and trash. You can create more using the use -c command, such as use -c archive.
|
55
|
+
One of the primary goals of a secrets manager is to ensure that no data is ever lost. However, in some cases, secrets may exist in a folder but not be loaded if only the most recent index is read.
|
85
56
|
|
86
|
-
When GitHub
|
57
|
+
Here's an example: Alice uses Secrez on both computer A and B, and the two data sets are aligned. Suddenly, GitHub goes down, and she makes some changes on both computers. When GitHub comes back online, she pushes the master branch on computer A, and everything goes fine. However, when she pulls on computer B and pushes, the data online become inconsistent because the most recent tree (from B) does not contain the new changes that were previously saved on A. This means that some secrets are in one index, while others are in the other.
|
87
58
|
|
88
|
-
|
89
|
-
Now, the data online are not consistent because the most recent tree (from B) does not contains the new changes saved previously on A, i.e., some secrets are in one index, some are in the other one.
|
59
|
+
No problem. When Alice restarts Secrez, the system finds the extra secrets, reads their positions from the previous indexes, and puts them back in the tree. Since files are immutable, the recovery strategy is not always obvious. Here's what happens in different cases:
|
90
60
|
|
91
|
-
|
61
|
+
If the recovered secret is in a folder that does not exist in the "official" index, the entire path is added using the encrypted data of the recovered secret.
|
62
|
+
If the secret is a file in a folder that already exists, the file is added as is, but the folders with existing paths are trashed.
|
63
|
+
If the secret is a file and a file with the same name already exists in the same position, the system checks the content of the file. If it is the same, the secret is ignored. If it's different, it is added as a version.
|
64
|
+
Any unused or rewritten secrets (as versions) are trashed (you can check them in the trash dataset). In any case, all the contents are kept.
|
92
65
|
|
93
|
-
|
66
|
+
To avoid repeating the same process on the other computer (which will generate files with different IDs and more deleted items), Alice should align the repo on computer A before doing anything there. But if she doesn't, nothing will be lost anyway.
|
94
67
|
|
95
|
-
|
96
|
-
2. The secret is a file in a folder that actually exists. The file is added as is, but the folders with existent paths are trashed.
|
97
|
-
3. The secret is a file but a file with the same name exists in the same position. The system checks the content of the file. If it is the same, the secret is ignored, if not it is added as a version.
|
98
|
-
|
99
|
-
Either any unused secret or secret that is rewritten (as a version) is trashed (you can check them in the `trash` dataset).
|
100
|
-
|
101
|
-
In any case, all the contents are kept.
|
102
|
-
|
103
|
-
To avoid to repeat the same process on the other computer (which will generate files with different IDs and more deleted items), Alice should align the repo on A before doing anything there. But, if she does not, nothing will be lost anyway.
|
68
|
+
Thus said, **it is a good practice to align the repo before doing anything. You never know.**
|
104
69
|
|
105
70
|
## The name convention
|
106
71
|
|
107
|
-
|
72
|
+
In Secrez, file names follow a specific convention:
|
108
73
|
|
109
74
|
```
|
110
75
|
1VAnGLojzCDWhfZRK8PCYK203WBzJkAA28FhKHdS7DM5SkJaTgYdGfN1MAjTdfUYSzvtDVsMJvGodoHWzMuK6zr
|
111
76
|
```
|
112
77
|
|
113
|
-
|
78
|
+
The first character, 1, indicates the type of file. The remaining characters represent an encrypted message with a nonce, in Base58 format. The encrypted part consists of an ID, timestamp, and the actual filename.
|
114
79
|
|
115
|
-
|
116
|
-
This implies that, at bootstrap, Secrez must read all the files' names and build a tree of the entire file system. This is done using particular files: trees. Only after reading all the data, Secrez is able to understand which is the tree and, if something is missed, add the missing secrets. Since everything is encrypted, there is no information deductible from the files on disk, except what you can deduct from the Git repo (mostly about versioning and timestamp). But the idea is to use a private repo, so this is a minor issue.
|
80
|
+
During initialization, Secrez reads all file names and builds a tree of the entire file system. This is done using special files called trees. Once all data has been read, Secrez can determine the tree and add any missing secrets. Since everything is encrypted, it is not possible to deduce information from the files on disk, except for versioning and timestamps, which can be obtained from the Git repo.
|
117
81
|
|
118
|
-
To mitigate this risk, you can create a new Git repo, save everything as the first commit, and delete the previously used repo. This
|
82
|
+
To mitigate this risk, you can create a new Git repo, save everything as the first commit, and delete the previously used repo. This will result in losing the repo's history, but it will also prevent someone from accessing information about timestamps and versions.
|
119
83
|
|
120
84
|
## The tree
|
121
85
|
|
@@ -123,26 +87,19 @@ Secrez manages trees as single immutable files. During a session, temporary file
|
|
123
87
|
|
124
88
|
## The cryptographic foundation
|
125
89
|
|
126
|
-
|
90
|
+
Secrez uses [NaCl](https://github.com/dchest/tweetnacl-js) as its primary cryptographic library. NaCl is a widely respected library that provides many algorithms for both synchronous and asynchronous encryption, and its design has been rigorously reviewed by experts in the field. By using NaCl, Secrez is able to provide strong security guarantees for its users.
|
127
91
|
|
128
92
|
## How to install it
|
129
93
|
|
130
|
-
|
94
|
+
Secrez requires at least Node 10. If you have installed a previous version, it may generate unclear errors and refuse to install or work properly. We recommend installing Node using nvm if possible. For more information, refer to [https://github.com/nvm-sh/nvm](https://github.com/nvm-sh/nvm).
|
131
95
|
|
132
|
-
|
133
|
-
|
134
|
-
```
|
135
|
-
npm install -g secrez
|
136
|
-
```
|
137
|
-
|
138
|
-
but, since this monorepo uses pnpm, it is even better if you use pnpm because the lock file will be used avoiding unespected conflicts among modules.
|
139
|
-
To install pnpm run
|
96
|
+
Since this monorepo uses [Pnpm](https://pnpm.io/), it is better to install secrez using pnpm because the lock file will be used to avoid unexpected conflicts among modules. To install pnpm, run:
|
140
97
|
|
141
98
|
```
|
142
99
|
npm i -g pnpm
|
143
100
|
```
|
144
101
|
|
145
|
-
and
|
102
|
+
and then run:
|
146
103
|
|
147
104
|
```
|
148
105
|
pnpm i -g secrez
|
@@ -150,76 +107,53 @@ pnpm i -g secrez
|
|
150
107
|
|
151
108
|
## How to use it
|
152
109
|
|
153
|
-
|
110
|
+
To get started with Secrez, simply run the command:
|
154
111
|
|
155
112
|
```
|
156
113
|
secrez
|
157
114
|
```
|
158
115
|
|
159
|
-
|
160
|
-
|
161
|
-
Since Secrez derives a master key from your password using `crypto.pbkdf2`, the number of iterations is a significant addition to the general security because the number of iterations is part of the salt used for the derivation. Even if you use a not-very-hard-to-guess password, if the attacker does not know the number of iterations, he has to try all the possible ones. Considering that 2,000,000 iterations require a second or so, customizable iterations increases enormously the overall security.
|
162
|
-
|
163
|
-
At first launch, you can also explicitly set up the number of iterations:
|
116
|
+
Upon first launch, Secrez will prompt you to enter a master password and the number of iterations. The number of iterations is used to derive a master key from your password, so the higher the number, the more secure your data will be. It's recommended to use between 500,000 and 1,000,000 iterations, but you can customize this based on your needs. For example, you can set the number of iterations explicitly by running:
|
164
117
|
|
165
118
|
```
|
166
119
|
secrez -i 1023896
|
167
120
|
```
|
168
121
|
|
169
|
-
|
170
|
-
|
171
|
-
```
|
172
|
-
secrez -si 876352
|
173
|
-
```
|
174
|
-
|
175
|
-
where the `-s` option saves the number locally in a git-ignored `env.json` file. This way you don't have to retype it all the time to launch Secrez (typing a wrong number of iterations, of course, will produce an error).
|
176
|
-
|
177
|
-
You can save locally the number of iterations adding the options `-s`, like:
|
122
|
+
You can also save the number of iterations locally by adding the -s option:
|
178
123
|
|
179
124
|
```
|
180
125
|
secrez -s
|
181
126
|
```
|
182
127
|
|
183
|
-
|
184
|
-
|
185
|
-
Other options at launch are:
|
186
|
-
|
187
|
-
- `-l` to set up the initial "external" folder on you computer
|
188
|
-
- `-c` to set up the container (i.e, the folder) where the encrypted data are located
|
189
|
-
|
190
|
-
By default, both folders are your homedir (`~`).
|
128
|
+
This will save the number of iterations in a git-ignored env.json file, so you don't have to enter it every time you launch Secrez. If you mistype the number of iterations, Secrez will produce an error.
|
191
129
|
|
192
|
-
|
130
|
+
In addition to the master password and number of iterations, you can also specify other options at launch, such as the initial "external" folder on your computer (-l option) and the container (i.e., the folder) where the encrypted data is located (-c option). By default, both folders are set to your home directory (~). For example, if you want to set up a separate encrypted database in a different folder, you can run:
|
193
131
|
|
194
132
|
```
|
195
133
|
secrez -c ~/data/secrez
|
196
134
|
```
|
197
135
|
|
136
|
+
If the number of iterations you chose makes the initial decryption too slow, you can change it inside the Secrez CLI with the conf command.
|
137
|
+
|
198
138
|
## The commands
|
199
139
|
|
140
|
+
Launching `help` you can list all available commands.
|
141
|
+
|
200
142
|
```
|
143
|
+
Available commands:
|
201
144
|
alias Create aliases of other commands.
|
145
|
+
bash << deprecated - use "shell" instead
|
202
146
|
cat Shows the content of a file.
|
203
147
|
cd Changes the working directory.
|
204
148
|
chat Enters the Secrez chat
|
205
|
-
|
206
|
-
help This help.
|
207
|
-
join Joins conversation.
|
208
|
-
leave Leaves a room
|
209
|
-
quit Quit the chat environment
|
210
|
-
send Sends either a room or the chat
|
211
|
-
show Show chat history in a room
|
212
|
-
whoami Show data that other users need to chat with you
|
213
|
-
conf Configure security data (2FA, password, number of iterations).
|
149
|
+
conf Shows current configuration and allow to change password and number of iterations).
|
214
150
|
contacts Manages your contacts
|
215
151
|
copy Copy a text file to the clipboard.
|
216
152
|
courier Configure the connection to a local courier
|
217
153
|
ds Manages datasets
|
218
154
|
edit Edits a file containing a secret.
|
219
|
-
exit << deprecated - use "quit" instead
|
220
155
|
export Export encrypted data to the OS in the current local folder
|
221
156
|
find Find a secret.
|
222
|
-
git Pushes to a repo and pulls from a repo.
|
223
157
|
help This help.
|
224
158
|
import Import files from the OS into the current folder
|
225
159
|
lcat Similar to a standard cat in the external fs.
|
@@ -233,7 +167,7 @@ secrez -c ~/data/secrez
|
|
233
167
|
pwd Shows the path of the working directory.
|
234
168
|
quit Quits Secrez.
|
235
169
|
rm Removes one or more files and folders.
|
236
|
-
shell Execute a
|
170
|
+
shell Execute a shell command in the current disk folder.
|
237
171
|
ssh Opens a new tab and run ssh to connect to a remote server via SSH
|
238
172
|
tag Tags a file and shows existent tags.
|
239
173
|
totp Generate a TOTP code if a totp field exists in the card.
|
@@ -246,45 +180,43 @@ secrez -c ~/data/secrez
|
|
246
180
|
|
247
181
|
## Some example
|
248
182
|
|
183
|
+
To display the content of an encrypted file called myPrivateKey, run the following command:
|
184
|
+
|
249
185
|
```
|
250
186
|
cat myPrivateKey
|
251
187
|
```
|
252
188
|
|
253
|
-
|
254
|
-
|
255
|
-
Adding options to the command, it is possible to either see a specific version or list all the versions.
|
256
|
-
|
257
|
-
The versioning is very important in Secrez because the primary way to backup and distribute the data is using Git. In this case, you want to avoid conflicts that can be not fixable because of the encryption. So, every time there is a change, an entirely new file is created, with metadata about its id and timestamp.
|
189
|
+
By default, the latest version of the file will be displayed. However, you can use additional options to view a specific version or list all versions.
|
258
190
|
|
259
|
-
The timestamp is used to assign a version to the file
|
191
|
+
Secrez uses versioning to ensure data integrity and avoid conflicts when backing up and distributing data through Git. Each time a file is modified, a new encrypted file is created with metadata about its ID and timestamp. The timestamp is used to assign a version to the file, which is a 4-letter hash of the timestamp.
|
260
192
|
|
261
|
-
Another example:
|
193
|
+
Another useful command is the import command. For example:
|
262
194
|
|
263
195
|
```
|
264
196
|
import ~/Desktop/myWallet.json -m
|
265
197
|
```
|
266
198
|
|
267
|
-
This command
|
199
|
+
This command will encrypt the file myWallet.json located on your Desktop, save it in the encrypted file system, and then delete the original file using the -m option.
|
268
200
|
|
269
|
-
This is
|
201
|
+
This is particularly useful if you have just downloaded a private key to access your crypto wallet and want to encrypt it as soon as possible. With Secrez, you can import the file and delete the cleartext version in one command.
|
270
202
|
|
271
|
-
## Aliases — where the fun
|
203
|
+
## Aliases — where the fun begins :-)
|
272
204
|
|
273
|
-
Suppose
|
205
|
+
Suppose you have a bank card and want to log in to your online account. You could copy the email and password to the clipboard to paste them in the browser. If you expect to be able to move from the terminal to the browser in 4 seconds, you could run the command:
|
274
206
|
|
275
207
|
```
|
276
208
|
copy bank.yml -f email password -d 4 2
|
277
209
|
```
|
278
210
|
|
279
|
-
This will copy the email field and give you 4 seconds to paste it in the browser. Then, it will emit a beep and you have 2 seconds to paste the password. It sounds quite useful, but it can be better.
|
211
|
+
This will copy the email field and give you 4 seconds to paste it in the browser. Then, it will emit a beep, and you have 2 seconds to paste the password. It sounds quite useful, but it can be even better.
|
280
212
|
|
281
|
-
If you use that login often, you could
|
213
|
+
If you use that login often, you could create an alias for it with:
|
282
214
|
|
283
215
|
```
|
284
|
-
alias b -c "copy bank.yml -f email password -d 4 2
|
216
|
+
alias b -c "copy bank.yml -f email password -d 4 2"
|
285
217
|
```
|
286
218
|
|
287
|
-
Next time, you can just type
|
219
|
+
Next time, you can just type:
|
288
220
|
|
289
221
|
```
|
290
222
|
b
|
@@ -292,13 +224,13 @@ b
|
|
292
224
|
|
293
225
|
It looks great, right? Well, it can be even better.
|
294
226
|
|
295
|
-
Let’s say
|
227
|
+
Let’s say you're using a 2FA app like Google Authenticator to connect to a website, for example, GitHub. Suppose you have a file called github.yml with a field called totp, which is the secret that GitHub gave you when you activated 2FA. You could execute:
|
296
228
|
|
297
229
|
```
|
298
230
|
totp github.yml
|
299
231
|
```
|
300
232
|
|
301
|
-
to generate a TOTP token for GitHub. The token will be shown and copied
|
233
|
+
to generate a TOTP token for GitHub. The token will be shown and copied to the clipboard. Now, you can create an alias like this:
|
302
234
|
|
303
235
|
```
|
304
236
|
alias G -c "copy github.yml -f username password -d 4 2 --wait && totp github.yml"
|
@@ -306,31 +238,28 @@ alias G -c "copy github.yml -f username password -d 4 2 --wait && totp github.ym
|
|
306
238
|
|
307
239
|
Can you guess what this will do?
|
308
240
|
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
You can also use parameters in aliases and create a macro like
|
241
|
+
It copies the username to the clipboard;
|
242
|
+
It waits 5 seconds, emits a beep, and copies the password;
|
243
|
+
It waits 3 seconds, emits a beep, and copies the TOTP token, keeping it in the clipboard.
|
244
|
+
You can also use parameters in aliases and create a macro like this:
|
314
245
|
|
315
246
|
```
|
316
247
|
alias M -c "copy $1 -f username password -d 4 2 --wait && totp $1"
|
317
248
|
```
|
318
249
|
|
319
|
-
and call it with
|
250
|
+
and call it with:
|
320
251
|
|
321
252
|
```
|
322
253
|
M github.yml
|
323
254
|
```
|
324
255
|
|
325
|
-
It
|
256
|
+
It's fantastic, isn't it?
|
326
257
|
|
327
|
-
_Btw, using a TOTP factor in Secrez is a bit of a contradiction
|
258
|
+
_Btw, using a TOTP factor in Secrez is a bit of a contradiction because you are converting a second factor (something that you have) into a first factor (something that you know). So, use this feature only when it makes sense._
|
328
259
|
|
329
260
|
## Importing from other password/secret managers
|
330
261
|
|
331
|
-
|
332
|
-
|
333
|
-
Suppose you have exported your password in a CSV file name export.csv like this:
|
262
|
+
Secrez supports importing backups from other software. Suppose you have exported your passwords in a CSV file named export.csv like this:
|
334
263
|
|
335
264
|
```
|
336
265
|
Path,Username,Password,Web Site,Notes
|
@@ -341,17 +270,17 @@ line
|
|
341
270
|
notes"
|
342
271
|
```
|
343
272
|
|
344
|
-
|
273
|
+
A field named path is necessary because Secrez needs to know where to place the new data. The path should be relative, allowing you to import it into your favorite folder.
|
345
274
|
|
346
|
-
|
275
|
+
To import the CSV file into the 1PasswordData folder, for example, you can run:
|
347
276
|
|
348
277
|
```
|
349
278
|
import export.csv -e 1PasswordData -t
|
350
279
|
```
|
351
280
|
|
352
|
-
The parameter
|
281
|
+
The parameter -e or --expand is necessary. If it's not provided, Secrez will import the file as a single file.
|
353
282
|
|
354
|
-
Internally, Secrez converts the CSV
|
283
|
+
Internally, Secrez converts the CSV file to a JSON file like this:
|
355
284
|
|
356
285
|
```
|
357
286
|
[
|
@@ -375,13 +304,13 @@ Internally, Secrez converts the CSV in a JSON file like this:
|
|
375
304
|
]
|
376
305
|
```
|
377
306
|
|
378
|
-
|
307
|
+
This means that you can also format your data as a JSON and import it directly using:
|
379
308
|
|
380
309
|
```
|
381
310
|
import export.json -e 1PasswordData
|
382
311
|
```
|
383
312
|
|
384
|
-
|
313
|
+
Each item in the JSON will generate a single YAML file. For example, the last element in the JSON will generate the file /1PasswordDate/somePath.yml with the following content:
|
385
314
|
|
386
315
|
```
|
387
316
|
password: s83832jedjdj
|
@@ -392,44 +321,43 @@ notes: |-
|
|
392
321
|
notes
|
393
322
|
```
|
394
323
|
|
395
|
-
When you edit the new file, Secrez
|
324
|
+
When you edit the new file, Secrez recognizes it as a card and asks you which field you want to edit (unless you explicitly specify it with, for example, -f password) and edits just that field.
|
396
325
|
|
397
|
-
At the end of the process, you can remove the original backup
|
398
|
-
You can also simulate the process to see which files will be created with the option `-s`.
|
326
|
+
At the end of the process, you can remove the original backup using the -m option. You can also simulate the process to see which files will be created using the -s option.
|
399
327
|
|
400
|
-
If
|
328
|
+
If the CSV file also contains a tags field, you can automatically tag any entries using the -t or --tags option. If you don't use this option, the tags will be saved in the YAML file like any other field.
|
401
329
|
|
402
330
|
### What if there is no path field?
|
403
331
|
|
404
|
-
Let's say
|
332
|
+
Let's say you want to import a CSV file exported by LastPass, which doesn't have a path field. In this case, you can use other fields, such as grouping and name, to build the path instead. Starting from version 0.8.8, you can do this by running:
|
405
333
|
|
406
334
|
```
|
407
335
|
import ~/Downloads/lastpass_export.csv -e lastpass -P grouping name
|
408
336
|
```
|
409
337
|
|
410
|
-
|
338
|
+
Or, if you want to put everything in the folder `lastpass` without generating any subfolders, you can run:
|
411
339
|
|
412
340
|
```
|
413
341
|
import ~/Downloads/lastpass_export.csv -e lastpass -P name -m
|
414
342
|
```
|
415
343
|
|
416
|
-
using only the
|
344
|
+
By using only the name field, any entries with a slash in the name will create a subfolder. The -m option will remove the CSV file from the operating system after importing.
|
417
345
|
|
418
|
-
In
|
346
|
+
In both examples, make sure that all entries in the LastPass CSV file have a name. If not, the import will fail because Secrez won't know how to name the file.
|
419
347
|
|
420
348
|
### Best practices
|
421
349
|
|
422
|
-
For security
|
350
|
+
For security reasons, it is better to export from your password manager and import into Secrez as quickly as possible, removing the exported file from your OS using -m.
|
423
351
|
|
424
|
-
|
352
|
+
However, if you need to edit the exported file to fix paths and names, it is more convenient to do it before importing the data, as it can take a lot more time to do so after the data is imported.
|
425
353
|
|
426
|
-
##
|
354
|
+
## FIDO2 second factor authentication?
|
427
355
|
|
428
|
-
|
356
|
+
It has been removed in version 0.11.0 due to potential critical issues with Python and the required libraries on MacOS (2FA may be restored if a pure Javascript library becomes available).
|
429
357
|
|
430
358
|
## (experimental) End-to-end encrypted communication with other accounts
|
431
359
|
|
432
|
-
Starting from version 0.8.0, Secrez allows to exchange encrypted messages with other users. To do
|
360
|
+
Starting from version 0.8.0, Secrez allows you to exchange encrypted messages with other users. To do so, you must set up a local Courier ([look here for more info](https://github.com/secrez/secrez/tree/master/packages/courier)).
|
433
361
|
|
434
362
|
## Blog posts
|
435
363
|
|
@@ -439,16 +367,16 @@ Starting from version 0.8.0, Secrez allows to exchange encrypted messages with o
|
|
439
367
|
|
440
368
|
## Some thoughts
|
441
369
|
|
442
|
-
Secrez
|
370
|
+
Secrez is not intended to compete with password managers, so do not expect it to have features like "form filling." The idea behind Secrez originated in 2017 when I was participating in many ICOs, and I had so many files to save, but any password manager I used was not very effective. Secrez is file-oriented and will likely remain so. However, it is open source, and someone is welcome to build a GUI or mobile app built on it.
|
443
371
|
|
444
|
-
##
|
372
|
+
## History
|
445
373
|
|
446
|
-
|
447
|
-
- Plugin architecture to allow others to add their own commands
|
374
|
+
**1.1.3**
|
448
375
|
|
449
|
-
|
376
|
+
- add new option `--keystore, -k` to `export`. If a file contains a private key field (i.e., a field with a name containing `private_key`), it can be exported in the keystore format. The file will have the same name with the extension replaced with `.keystore.json`.
|
377
|
+
- this README has been redacted by ChatGPT to make it more clear and concise.
|
450
378
|
|
451
|
-
**1.1.
|
379
|
+
**1.1.2**
|
452
380
|
|
453
381
|
- New options for `touch`:
|
454
382
|
- `--wait-for-content` to prompt the user to add the content, instead of expecting it as a parameter. The content will be trimmed at the first newline, if there is any.
|
@@ -456,6 +384,10 @@ Secrez does not want to compete with password managers. So, don't expect in the
|
|
456
384
|
- `--prefix` in combination with `--generate-wallet` specifies the prefix of the field, calling the fields, for example `my_private_key` and `my_address` if the prefix is `my`.
|
457
385
|
- `--amount` in combination with `--generate-wallet` specifies the amount of wallets to generate. The default is 1.
|
458
386
|
|
387
|
+
**1.1.1** (unpublished)
|
388
|
+
|
389
|
+
- using prettier for consistent formatting
|
390
|
+
|
459
391
|
**1.1.0**
|
460
392
|
|
461
393
|
- Remove `git`. If used carefully, the command was helpful, but still it is at risk of creating conflicts. After long thoughts, I disapproved my own proposal at: https://github.com/secrez/secrez/pull/163
|
@@ -824,64 +756,57 @@ npm run reset
|
|
824
756
|
|
825
757
|
#### Install OS requirements
|
826
758
|
|
827
|
-
To complete the tests, you must install some
|
759
|
+
To complete the tests, you must install some tools depending on your operating system.
|
828
760
|
|
829
|
-
The `copy` command does not work on Linux
|
761
|
+
The `copy` command does not work on Linux if `xsel` is not installed. So, if you are working on Ubuntu, install it with:
|
830
762
|
|
831
763
|
```
|
832
764
|
sudo apt install xsel
|
833
765
|
```
|
834
766
|
|
835
|
-
The `totp` command requires
|
767
|
+
The `totp` command requires `pngpaste` on macOS. You can install it with:
|
836
768
|
|
837
769
|
```
|
838
770
|
brew install pngpaste
|
839
771
|
```
|
840
772
|
|
841
|
-
|
842
|
-
|
843
|
-
```
|
844
|
-
pip install fido2
|
845
|
-
```
|
846
|
-
|
847
|
-
Notice that during the execution of Secrez, an error is generated if those tools have not been found. But, nothing happens, during testing. So, please, install them.
|
773
|
+
Please note that during the execution of Secrez, an error is generated if those tools have not been found. Please make sure to install them.
|
848
774
|
|
849
775
|
#### Testing
|
850
776
|
|
851
|
-
|
777
|
+
To run all the tests, navigate to the root directory of the project and run:
|
852
778
|
|
853
779
|
```
|
854
780
|
npm run test
|
855
781
|
```
|
856
782
|
|
857
|
-
|
858
|
-
You can also run
|
783
|
+
If you are inside a package directory, running this command will only execute the package-specific tests. You can also skip coverage by running:
|
859
784
|
|
860
785
|
```
|
861
786
|
npm run test-only
|
862
787
|
```
|
863
788
|
|
864
|
-
|
789
|
+
This is useful during development.
|
865
790
|
|
866
791
|
#### Debugging
|
867
792
|
|
868
|
-
To see if
|
793
|
+
To see if Secrez works properly, you can execute your version of Secrez by running the following command from inside the `packages/secrez` directory:
|
869
794
|
|
870
795
|
```
|
871
796
|
npm run dev
|
872
797
|
```
|
873
798
|
|
874
|
-
|
799
|
+
You will create a dev account to play with it.
|
875
800
|
|
876
801
|
#### Pull Requests
|
877
802
|
|
878
|
-
|
803
|
+
Before submitting a pull request, you should realign the versions. You can do this by running the following command from the root directory:
|
879
804
|
|
880
805
|
```
|
881
806
|
npm run patch-versions
|
882
807
|
```
|
883
808
|
|
884
|
-
Then, you can prepare the README inserting the coverage. To do
|
809
|
+
Then, you can prepare the README file by inserting the coverage. To do this, run:
|
885
810
|
|
886
811
|
```
|
887
812
|
npm run pre-push
|
@@ -889,73 +814,84 @@ npm run pre-push
|
|
889
814
|
|
890
815
|
Finally, you can push to GitHub.
|
891
816
|
|
892
|
-
|
817
|
+
Thank you for any contributions! 😉
|
893
818
|
|
894
819
|
## Test coverage
|
895
820
|
|
896
821
|
```
|
897
|
-
|
822
|
+
166 passing (25s)
|
823
|
+
1 pending
|
898
824
|
|
899
825
|
-----------------------|---------|----------|---------|---------|-----------------------------------
|
900
826
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
901
827
|
-----------------------|---------|----------|---------|---------|-----------------------------------
|
902
|
-
All files |
|
903
|
-
src |
|
904
|
-
Command.js |
|
905
|
-
PreCommand.js |
|
828
|
+
All files | 71.47 | 58.49 | 71.98 | 71.36 |
|
829
|
+
src | 59.63 | 54.79 | 55 | 60.19 |
|
830
|
+
Command.js | 79.66 | 78.72 | 76.92 | 81.03 | 32,55-62,73,80,119
|
831
|
+
PreCommand.js | 21.95 | 11.54 | 14.29 | 21.95 | 8-98,115
|
906
832
|
cliConfig.js | 100 | 100 | 100 | 100 |
|
907
|
-
src/commands |
|
908
|
-
Alias.js |
|
909
|
-
Bash.js |
|
910
|
-
Cat.js |
|
911
|
-
Cd.js |
|
833
|
+
src/commands | 81.53 | 67 | 89.95 | 81.4 |
|
834
|
+
Alias.js | 90.54 | 77.36 | 100 | 90.41 | 101,112,139,169,173,180,190
|
835
|
+
Bash.js | 75 | 0 | 66.67 | 75 | 18-19
|
836
|
+
Cat.js | 98.9 | 88.89 | 100 | 98.9 | 152
|
837
|
+
Cd.js | 96.43 | 86.67 | 100 | 96.43 | 44
|
912
838
|
Chat.js | 19.51 | 0 | 16.67 | 19.51 | 23-144
|
913
|
-
Conf.js |
|
914
|
-
Contacts.js |
|
915
|
-
Copy.js |
|
916
|
-
Courier.js |
|
917
|
-
Ds.js |
|
918
|
-
Edit.js |
|
919
|
-
Export.js |
|
920
|
-
Find.js |
|
921
|
-
Help.js |
|
922
|
-
Import.js |
|
923
|
-
Lcat.js |
|
924
|
-
Lcd.js |
|
925
|
-
Lls.js |
|
926
|
-
Lpwd.js |
|
927
|
-
Ls.js |
|
928
|
-
Mkdir.js |
|
929
|
-
Mv.js |
|
930
|
-
Paste.js |
|
931
|
-
Pwd.js |
|
932
|
-
Quit.js |
|
933
|
-
Rm.js |
|
934
|
-
Shell.js |
|
935
|
-
Ssh.js |
|
936
|
-
Tag.js |
|
937
|
-
Totp.js |
|
839
|
+
Conf.js | 10.45 | 0 | 25 | 10.45 | 134-499
|
840
|
+
Contacts.js | 74.67 | 65.98 | 92.86 | 74.5 | ...90-214,240,247,259,315,328,338
|
841
|
+
Copy.js | 94.87 | 74.51 | 100 | 94.81 | 111,162,179,204
|
842
|
+
Courier.js | 63.54 | 41.86 | 85.71 | 63.83 | ...37,152-171,188,200-203,215-221
|
843
|
+
Ds.js | 92.54 | 82.05 | 100 | 92.42 | 99,108-113,125
|
844
|
+
Edit.js | 13.58 | 0 | 40 | 13.58 | 88-214
|
845
|
+
Export.js | 87.63 | 67.74 | 100 | 87.63 | ...66,175,182-186,191,203,212,215
|
846
|
+
Find.js | 93.59 | 86.67 | 100 | 93.42 | 101,164,200-203,209
|
847
|
+
Help.js | 100 | 80 | 100 | 100 | 29
|
848
|
+
Import.js | 93.2 | 85.48 | 100 | 93.14 | ...65,367,387,393,441,456-463,490
|
849
|
+
Lcat.js | 100 | 85.71 | 100 | 100 | 54
|
850
|
+
Lcd.js | 95.65 | 81.82 | 100 | 95.65 | 50
|
851
|
+
Lls.js | 95.45 | 72.73 | 100 | 95.45 | 97
|
852
|
+
Lpwd.js | 92.31 | 100 | 100 | 92.31 | 36
|
853
|
+
Ls.js | 91.3 | 75 | 100 | 90.77 | 103,114-116,130,181
|
854
|
+
Mkdir.js | 100 | 66.67 | 100 | 100 | 38-44
|
855
|
+
Mv.js | 88.04 | 73.21 | 100 | 87.78 | 93-99,133,155,165-172
|
856
|
+
Paste.js | 87.23 | 75 | 100 | 87.23 | 72,78,81,89,113,129
|
857
|
+
Pwd.js | 92.31 | 100 | 100 | 92.31 | 33
|
858
|
+
Quit.js | 90 | 50 | 100 | 90 | 27
|
859
|
+
Rm.js | 94 | 80.95 | 100 | 93.88 | 63,126,134
|
860
|
+
Shell.js | 88.24 | 60 | 100 | 88.24 | 38,55
|
861
|
+
Ssh.js | 25 | 0 | 40 | 25 | 72-120
|
862
|
+
Tag.js | 98.04 | 92.31 | 100 | 98.02 | 122,171
|
863
|
+
Totp.js | 96.47 | 74.47 | 100 | 96.47 | 188-189,235
|
938
864
|
Touch.js | 95.92 | 81.48 | 100 | 95.83 | 152,202
|
939
|
-
Use.js |
|
940
|
-
Ver.js |
|
941
|
-
Whoami.js |
|
942
|
-
chat.js |
|
943
|
-
index.js |
|
944
|
-
src/
|
865
|
+
Use.js | 96.77 | 89.47 | 100 | 96.77 | 68
|
866
|
+
Ver.js | 90 | 66.67 | 100 | 90 | 25
|
867
|
+
Whoami.js | 93.1 | 63.64 | 80 | 93.1 | 29,64
|
868
|
+
chat.js | 85.37 | 53.85 | 100 | 85.37 | 105,117-130,136,142
|
869
|
+
index.js | 91.67 | 60 | 100 | 91.3 | 22,31
|
870
|
+
src/commands/chat | 79.44 | 63.29 | 92.31 | 79.33 |
|
871
|
+
Contacts.js | 80 | 42.86 | 80 | 80 | 54,65,69,81
|
872
|
+
Help.js | 86.67 | 60 | 100 | 86.67 | 37-38
|
873
|
+
Join.js | 95.65 | 82.61 | 100 | 95.56 | 43,110
|
874
|
+
Leave.js | 100 | 60 | 100 | 100 | 24,28
|
875
|
+
Quit.js | 100 | 75 | 100 | 100 | 24
|
876
|
+
Send.js | 67.65 | 46.67 | 100 | 67.65 | 37,41,44,77,86-95
|
877
|
+
Show.js | 68.75 | 70.59 | 100 | 68.75 | 74-78,87,102-108
|
878
|
+
Whoami.js | 42.86 | 0 | 60 | 42.86 | 22,30-39
|
879
|
+
src/prompts | 15.14 | 0 | 14.29 | 15.27 |
|
945
880
|
ChatPrompt.js | 6.17 | 0 | 0 | 6.17 | 8-163
|
946
|
-
ChatPromptMock.js |
|
881
|
+
ChatPromptMock.js | 100 | 100 | 66.67 | 100 |
|
947
882
|
CommandPrompt.js | 10.42 | 0 | 0 | 10.56 | 24-296
|
948
883
|
Completion.js | 4.41 | 0 | 0 | 4.48 | 6-103
|
949
|
-
MainPromptMock.js | 100 | 100 |
|
884
|
+
MainPromptMock.js | 100 | 100 | 66.67 | 100 |
|
950
885
|
MultiEditorPrompt.js | 25 | 0 | 0 | 25 | 7-36
|
951
886
|
SigintManager.js | 25 | 0 | 20 | 25 | 10-36
|
952
|
-
src/utils |
|
953
|
-
AliasManager.js |
|
954
|
-
ContactManager.js |
|
955
|
-
Fido2Client.js |
|
956
|
-
HelpProto.js |
|
957
|
-
Logger.js |
|
887
|
+
src/utils | 69.92 | 63.28 | 56.25 | 69.55 |
|
888
|
+
AliasManager.js | 100 | 91.67 | 100 | 100 | 47
|
889
|
+
ContactManager.js | 71.43 | 60 | 85.71 | 71.43 | 12,35-37
|
890
|
+
Fido2Client.js | 15.38 | 0 | 11.11 | 15.38 | 14-108
|
891
|
+
HelpProto.js | 91.6 | 84.06 | 100 | 91.45 | 49,153-154,171-176,195
|
892
|
+
Logger.js | 63.64 | 56.25 | 36.84 | 62.79 | ...37-49,57,65-69,74,84,88,93,105
|
958
893
|
-----------------------|---------|----------|---------|---------|-----------------------------------
|
894
|
+
|
959
895
|
```
|
960
896
|
|
961
897
|
## Copyright
|
package/coverage.report
CHANGED
@@ -1,81 +1,329 @@
|
|
1
1
|
|
2
|
-
> secrez@1.1.
|
2
|
+
> secrez@1.1.3 test /Users/francescosullo/Projects/Personal/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 (1022ms)
|
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 (1031ms)
|
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 (247ms)
|
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 (409ms)
|
59
|
+
✓ should copy a string to the clipboard (239ms)
|
60
|
+
✓ should copy a card to the clipboard (937ms)
|
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 (143ms)
|
68
|
+
✓ should set up the courier and get the default message when is already set up (143ms)
|
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 (1204ms)
|
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 (717ms)
|
85
|
+
|
86
|
+
#Find
|
87
|
+
✓ should return the help
|
88
|
+
✓ should show find a string in the tree (1028ms)
|
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 (1031ms)
|
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 (54ms)
|
168
|
+
✓ should paste the clipboard content to an existent file (77ms)
|
169
|
+
✓ should paste a single field to a yml card (41ms)
|
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 (1013ms)
|
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 (357ms)
|
200
|
+
✓ should read a totp secret from an image and add the totp field to the card (48ms)
|
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 (285ms)
|
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
|
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 (50ms)
|
248
|
+
|
249
|
+
#Send
|
250
|
+
✓ should return the help
|
251
|
+
✓ should send a message to user0 (120ms)
|
252
|
+
|
253
|
+
#Show
|
254
|
+
✓ should return the help
|
255
|
+
✓ should show history messages (395ms)
|
256
|
+
|
19
257
|
|
20
|
-
|
258
|
+
166 passing (25s)
|
259
|
+
1 pending
|
21
260
|
|
22
261
|
-----------------------|---------|----------|---------|---------|-----------------------------------
|
23
262
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
24
263
|
-----------------------|---------|----------|---------|---------|-----------------------------------
|
25
|
-
All files |
|
26
|
-
src |
|
27
|
-
Command.js |
|
28
|
-
PreCommand.js |
|
264
|
+
All files | 71.47 | 58.49 | 71.98 | 71.36 |
|
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-98,115
|
29
268
|
cliConfig.js | 100 | 100 | 100 | 100 |
|
30
|
-
src/commands |
|
31
|
-
Alias.js |
|
32
|
-
Bash.js |
|
33
|
-
Cat.js |
|
34
|
-
Cd.js |
|
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 |
|
37
|
-
Contacts.js |
|
38
|
-
Copy.js |
|
39
|
-
Courier.js |
|
40
|
-
Ds.js |
|
41
|
-
Edit.js |
|
42
|
-
Export.js |
|
43
|
-
Find.js |
|
44
|
-
Help.js |
|
45
|
-
Import.js |
|
46
|
-
Lcat.js |
|
47
|
-
Lcd.js |
|
48
|
-
Lls.js |
|
49
|
-
Lpwd.js |
|
50
|
-
Ls.js |
|
51
|
-
Mkdir.js |
|
52
|
-
Mv.js |
|
53
|
-
Paste.js |
|
54
|
-
Pwd.js |
|
55
|
-
Quit.js |
|
56
|
-
Rm.js |
|
57
|
-
Shell.js |
|
58
|
-
Ssh.js |
|
59
|
-
Tag.js |
|
60
|
-
Totp.js |
|
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 |
|
63
|
-
Ver.js |
|
64
|
-
Whoami.js |
|
65
|
-
chat.js |
|
66
|
-
index.js |
|
67
|
-
src/
|
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 | 15.14 | 0 | 14.29 | 15.27 |
|
68
316
|
ChatPrompt.js | 6.17 | 0 | 0 | 6.17 | 8-163
|
69
|
-
ChatPromptMock.js |
|
317
|
+
ChatPromptMock.js | 100 | 100 | 66.67 | 100 |
|
70
318
|
CommandPrompt.js | 10.42 | 0 | 0 | 10.56 | 24-296
|
71
319
|
Completion.js | 4.41 | 0 | 0 | 4.48 | 6-103
|
72
|
-
MainPromptMock.js | 100 | 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 |
|
76
|
-
AliasManager.js |
|
77
|
-
ContactManager.js |
|
78
|
-
Fido2Client.js |
|
79
|
-
HelpProto.js |
|
80
|
-
Logger.js |
|
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.
|
3
|
+
"version": "1.1.3",
|
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.
|
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
package/src/commands/Export.js
CHANGED
@@ -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.
|
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
|
-
|
224
|
+
// we do not wait for the deletion
|
225
|
+
this.deleteFromDisk(fn, options.duration).then();
|
180
226
|
}
|
181
227
|
return name;
|
182
228
|
} else {
|
package/src/commands/Touch.js
CHANGED