secrez 2.1.5 β†’ 2.1.7

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 CHANGED
@@ -369,6 +369,14 @@ Secrez is not intended to compete with password managers, so do not expect it to
369
369
 
370
370
  ## History
371
371
 
372
+ **2.1.7**
373
+
374
+ - add option `--no-export` to `export --crypto-env` to display the encrypted content in the console instead of writing it to a file
375
+
376
+ **2.1.6**
377
+
378
+ - export and encrypt, with option `--crypto-env`, the entire content of an item
379
+
372
380
  **2.1.5**
373
381
 
374
382
  - duplicate files using `touch <newfile> --from <file>` to copy the file from the source to the destination
@@ -857,7 +865,60 @@ Thank you for any contributions! πŸ˜‰
857
865
  ## Test coverage
858
866
 
859
867
  ```
860
-
868
+ 1 passing (549ms)
869
+
870
+ --------------------|---------|----------|---------|---------|--------------------------------------
871
+ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
872
+ --------------------|---------|----------|---------|---------|--------------------------------------
873
+ All files | 18.98 | 5.52 | 20.28 | 19.04 |
874
+ src | 30.39 | 14.49 | 21.05 | 30.69 |
875
+ Command.js | 32.2 | 21.27 | 30.76 | 32.75 | 22-35,40-97,102,108,119,122-130
876
+ PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
877
+ cliConfig.js | 100 | 100 | 100 | 100 |
878
+ src/commands | 18.27 | 4.93 | 22.16 | 18.35 |
879
+ Alias.js | 8.1 | 0 | 25 | 8.21 | 62-213
880
+ Bash.js | 62.5 | 0 | 33.33 | 62.5 | 11-19
881
+ Cat.js | 29.67 | 17.46 | 42.85 | 29.67 | 61-93,98,110,117-142,150-169,178-220
882
+ Cd.js | 17.85 | 0 | 25 | 17.85 | 28-73
883
+ Conf.js | 7.79 | 0 | 10 | 7.79 | 67-500
884
+ Contacts.js | 5.98 | 0 | 7.69 | 6.03 | 53-274
885
+ Copy.js | 10.98 | 0 | 12.5 | 11.11 | 71-268
886
+ Ds.js | 5.97 | 0 | 16.66 | 6.06 | 39-160
887
+ Edit.js | 12.34 | 0 | 20 | 12.34 | 61-214
888
+ Export.js | 50 | 26.92 | 50 | 50 | ...8,209,219-295,301,307-308,316-323
889
+ Find.js | 7.69 | 0 | 8.33 | 7.89 | 63-211
890
+ Help.js | 33.33 | 0 | 50 | 33.33 | 26-43
891
+ Import.js | 6.31 | 0 | 9.09 | 6.37 | 87-496
892
+ Lcat.js | 30 | 0 | 25 | 30 | 35-65
893
+ Lcd.js | 17.39 | 0 | 25 | 17.39 | 30-72
894
+ Lls.js | 40.9 | 9.09 | 50 | 40.9 | 49,68,74-99
895
+ Lpwd.js | 38.46 | 0 | 50 | 38.46 | 15,29-38
896
+ Ls.js | 5.79 | 0 | 10 | 6.15 | 46-183
897
+ Mkdir.js | 22.72 | 0 | 25 | 22.72 | 27-61
898
+ Mv.js | 6.52 | 0 | 16.66 | 6.66 | 46-240
899
+ Paste.js | 14.89 | 0 | 25 | 14.89 | 40-131
900
+ Pwd.js | 30.76 | 0 | 25 | 30.76 | 15-35
901
+ Quit.js | 50 | 0 | 33.33 | 50 | 19-40
902
+ Rm.js | 16 | 0 | 16.66 | 16.32 | 36-137
903
+ Shell.js | 29.41 | 0 | 25 | 29.41 | 25-57
904
+ Show.js | 16 | 0 | 14.28 | 16.32 | 45-145
905
+ Ssh.js | 22.22 | 0 | 20 | 22.22 | 49-120
906
+ Tag.js | 8.82 | 0 | 9.09 | 8.91 | 66-236
907
+ Totp.js | 14.58 | 0 | 9.09 | 14.58 | 76-312
908
+ Touch.js | 76 | 51.85 | 75 | 75.51 | 75,140,152-158,164,168,177,231-234
909
+ Use.js | 12.9 | 0 | 25 | 12.9 | 30-85
910
+ Ver.js | 50 | 0 | 33.33 | 50 | 17-28
911
+ Whoami.js | 27.77 | 0 | 20 | 27.77 | 20-50
912
+ index.js | 87.5 | 50 | 100 | 86.95 | 15,22,31
913
+ src/prompts | 100 | 100 | 33.33 | 100 |
914
+ MainPromptMock.js | 100 | 100 | 33.33 | 100 |
915
+ src/utils | 14.97 | 5.46 | 10.41 | 14.75 |
916
+ AliasManager.js | 5.88 | 0 | 0 | 5.88 | 3-48
917
+ ContactManager.js | 6.66 | 0 | 0 | 6.66 | 3-44
918
+ Fido2Client.js | 9.61 | 0 | 0 | 9.61 | 8-108
919
+ HelpProto.js | 4.2 | 0 | 16.66 | 4.27 | 11-200
920
+ Logger.js | 56.81 | 43.75 | 21.05 | 55.81 | ...16-29,37-57,65-69,74,84,88,93,105
921
+ --------------------|---------|----------|---------|---------|--------------------------------------
861
922
  ```
862
923
 
863
924
  ## Copyright
package/coverage.report CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- > secrez@2.1.3 test /Users/francescosullo/Projects/Secrez/secrez/packages/secrez
2
+ > secrez@2.1.7 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
 
@@ -29,10 +29,10 @@
29
29
  #Cat
30
30
  βœ“ should return the help
31
31
  βœ“ should show the content of a file
32
- βœ“ should show either one or all the versions of a file (1020ms)
32
+ βœ“ should show either one or all the versions of a file (1013ms)
33
33
  βœ“ should throw if entry is not a file or file does not exist
34
34
  βœ“ should throw if trying to cat a binary file
35
- βœ“ should show the content of a Yaml file (1031ms)
35
+ βœ“ should show the content of a Yaml file (1017ms)
36
36
 
37
37
  #Cd
38
38
  βœ“ should return the help
@@ -51,25 +51,223 @@
51
51
 
52
52
  #Copy
53
53
  βœ“ should return the help
54
+ βœ“ should copy a file to the clipboard (402ms)
55
+ βœ“ should copy a string to the clipboard (266ms)
56
+ βœ“ should copy a card to the clipboard (960ms)
57
+ βœ“ should return an error if the file does not exist or is a folder (48ms)
58
+ βœ“ should throw if copying to clipboard a binary files
59
+
60
+ #Ds
61
+ βœ“ should return the help
62
+ βœ“ should list all datasets
63
+ βœ“ should create a new dataset
64
+ βœ“ should rename a dataset
65
+ βœ“ should delete a dataset
66
+
67
+ #Export
68
+ βœ“ should return the help
69
+ 1) should export a file to the current local folder
70
+ βœ“ should export a file encrypted only for the user itself
71
+ βœ“ should export a binary file to the current local folder
72
+ βœ“ should export an encrypted file to the current local folder
73
+ βœ“ should export a file and delete it after 1 second (1205ms)
74
+ βœ“ should return an error if the file does not exist or is a folder
75
+ βœ“ should export a keystore json file if a private_key exists in the entry (922ms)
76
+ βœ“ should export a cryptoenv file if a private_key exists in the entry
77
+ βœ“ should export a cryptoenv file with entire content when no private_key fields exist and user confirms
78
+ βœ“ should throw error when no private_key fields exist and user declines
79
+ βœ“ should throw error when no private_key fields exist and keystore option is used
80
+ βœ“ should display encrypted content in console when using crypto-env with no-export
81
+
82
+ #Find
83
+ βœ“ should return the help
84
+ βœ“ should show find a string in the tree (1022ms)
85
+ βœ“ should find no result without parameters
86
+ βœ“ should skip binary files from search
87
+
88
+ #Help
89
+ βœ“ should return the help
90
+ βœ“ #execAsync and format
91
+ βœ“ should throw if wrong command
92
+ βœ“ -- to complete coverage
93
+
94
+ #Import
95
+ βœ“ should return the help
96
+ βœ“ should import a file in the current folder
97
+ βœ“ should import an encrypted file
98
+ βœ“ should import an encrypted file encrypted for myself
99
+ βœ“ should import an encrypted binary file and export it again verifying it is fine
100
+ βœ“ should import files recursively
101
+ βœ“ should read a folder and import the only text file
102
+ βœ“ should read a folder and import text and binary files
103
+ βœ“ should simulate the import of two files
104
+ βœ“ should move the imported file
105
+ βœ“ should import a backup from another software spanning the data among folders and files
106
+ βœ“ should import a backup from another software but saving the tags as tags
107
+ βœ“ should import a backup from another software using tags to prefix the paths
108
+ βœ“ should import using tags to prefix the paths, ignoring the tags
109
+ βœ“ should import from a LastPass-like csv setting the path from "grouping" and "name"
110
+ βœ“ should import from a json
111
+ βœ“ should throw importing a malformed backup
112
+ βœ“ should throw importing a CSV indicating wrong fields to generate the path
113
+
114
+ #Lcat
115
+ βœ“ should return the help
116
+ βœ“ cat a file
117
+ βœ“ return en error if trying to cat a binary file
118
+
119
+ #Lcd
120
+ βœ“ should return the help
121
+ βœ“ change to a folder
122
+ βœ“ return en error if changing to a file
123
+
124
+ #Lls
125
+ βœ“ should return the help
126
+ βœ“ should list a folder
127
+ βœ“ return en error if lls-ing a not existing path
128
+ βœ“ return a message if no files are found
129
+
130
+ #Lpwd
131
+ βœ“ should return the help
132
+ βœ“ change to a folder
133
+
134
+ #Ls
135
+ βœ“ should return the help
136
+ βœ“ should return all the datasets
137
+ βœ“ should list folders and files
138
+ βœ“ should list folders and files using wildcards
139
+
140
+ #Mkdir
141
+ βœ“ should return the help
142
+ βœ“ should create a folder
143
+ βœ“ should create a nested folder
144
+ βœ“ should throw if trying to create a child of a file
145
+ βœ“ should throw if wrong parameters
146
+
147
+ #Mv
148
+ βœ“ should return the help
149
+ βœ“ should rename a file (1010ms)
150
+ βœ“ should move a file to another folder
151
+ βœ“ should move many files to another folder
152
+ βœ“ should move a file to another subfolder
153
+ βœ“ should move and rename file to another folder
154
+ βœ“ should move file to another folder using wildcards
155
+ βœ“ should move file to another dataset using wildcards
156
+ βœ“ should move file managing duplicates
157
+ βœ“ should throw if parameters are missed or wrong
158
+ βœ“ should move files from and to other datasets (1014ms)
159
+ βœ“ should move the results of a find
160
+
161
+ #Paste
162
+ βœ“ should return the help
163
+ βœ“ should paste the clipboard content to a new file (61ms)
164
+ βœ“ should paste the clipboard content to an existent file (86ms)
165
+ βœ“ should paste a single field to a yml card
166
+
167
+ #Pwd
168
+ βœ“ should return the help
169
+ βœ“ should show the working folder
170
+
171
+ #Quit
172
+ βœ“ should show the content of an external file via bash
173
+
174
+ #Rm
175
+ βœ“ should return the help
176
+ βœ“ should delete a file with one version
177
+ βœ“ should delete many files usign wildcards
178
+ βœ“ should return errors if wrong parameters
179
+ βœ“ should delete some versions of a file (1009ms)
180
+
181
+ #Shell
182
+ βœ“ should return the help
183
+ βœ“ should show the content of an external file via shell
184
+
185
+ #Show
186
+ βœ“ should return the help
187
+ βœ“ should show the field password of a card
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 (394ms)
200
+ βœ“ should read a totp secret from an image and add the totp field to the card (44ms)
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 (242ms)
206
+
207
+ #Touch
208
+ βœ“ should return the help
209
+ βœ“ should create a file
210
+ βœ“ should create a file with content
211
+ βœ“ should duplicate a file
212
+ βœ“ should throw if trying to duplicate a non existing file
213
+ βœ“ should throw if trying to duplicate a folder
214
+ βœ“ should throw if trying to create a child of a file
215
+ βœ“ should throw if wrong parameters
216
+ βœ“ should create a file and generate a wallet
217
+ New file "/folder2/file1" created.
218
+ βœ“ should generate 5 prefixed wallet (65ms)
219
+ New file "/folder2/file1" created.
220
+ βœ“ should generate a wallet with mnemonic and 2 keys
221
+
222
+ #Use
223
+ βœ“ should return the help
224
+ βœ“ should use a new dataset, creating it if does not exist
225
+
226
+ #Ver
227
+ βœ“ should show the current version
228
+
229
+ #Whoami
230
+ βœ“ should return the help
231
+ βœ“ should see who am I
232
+
233
+
234
+ 155 passing (14s)
235
+ 1 pending
236
+ 1 failing
237
+
238
+ 1) #Export
239
+ should export a file to the current local folder:
240
+
241
+ AssertionError: expected 'file.2' to equal 'file'
242
+ + expected - actual
243
+
244
+ -file.2
245
+ +file
246
+
247
+ at assertConsole (/Users/francescosullo/Projects/Secrez/secrez/packages/test-helpers/src/index.js:121:16)
248
+ at Context.<anonymous> (test/commands/Export.test.js:94:5)
249
+
250
+
251
+
54
252
  --------------------|---------|----------|---------|---------|--------------------------------------
55
253
  File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
56
254
  --------------------|---------|----------|---------|---------|--------------------------------------
57
- All files | 77.54 | 63.7 | 79.71 | 77.44 |
255
+ All files | 81.06 | 67.92 | 81.15 | 80.95 |
58
256
  src | 57.84 | 53.62 | 52.63 | 58.41 |
59
257
  Command.js | 79.66 | 78.72 | 76.92 | 81.03 | 32,55-62,73,80,119
60
258
  PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
61
259
  cliConfig.js | 100 | 100 | 100 | 100 |
62
- src/commands | 79.46 | 64.42 | 88.66 | 79.36 |
260
+ src/commands | 83.81 | 69.51 | 90.64 | 83.7 |
63
261
  Alias.js | 90.54 | 77.35 | 100 | 90.41 | 101,112,139,169,173,180,190
64
262
  Bash.js | 75 | 0 | 66.66 | 75 | 18-19
65
263
  Cat.js | 98.9 | 88.88 | 100 | 98.9 | 152
66
264
  Cd.js | 96.42 | 86.66 | 100 | 96.42 | 44
67
265
  Conf.js | 9.09 | 0 | 20 | 9.09 | 98-500
68
266
  Contacts.js | 87.17 | 74.32 | 100 | 87.06 | ...5-141,145,165,172,184,237,250,260
69
- Copy.js | 15.55 | 3.5 | 50 | 15.73 | 108-191,198-241,252-267
267
+ Copy.js | 91.2 | 71.92 | 100 | 91.11 | 115,166,183,205-210,225-226,253
70
268
  Ds.js | 92.53 | 82.05 | 100 | 92.42 | 99,108-113,125
71
269
  Edit.js | 13.58 | 0 | 40 | 13.58 | 88-214
72
- Export.js | 88.11 | 70.58 | 100 | 88.11 | ...0-175,185,197-201,206,218,227,230
270
+ Export.js | 90.17 | 76.92 | 100 | 90.17 | ...3-198,209,227-231,236,248,257,260
73
271
  Find.js | 93.58 | 86.66 | 100 | 93.42 | 101,164,200-203,209
74
272
  Help.js | 100 | 80 | 100 | 100 | 29
75
273
  Import.js | 93.2 | 85.48 | 100 | 93.13 | ...5,365,367,387,393,441,456-463,490
@@ -88,19 +286,19 @@ All files | 77.54 | 63.7 | 79.71 | 77.44 |
88
286
  Show.js | 72 | 45.45 | 57.14 | 73.46 | ...8,100,106-114,117,123-126,132,143
89
287
  Ssh.js | 25 | 0 | 40 | 25 | 72-120
90
288
  Tag.js | 98.03 | 92.3 | 100 | 98.01 | 122,171
91
- Totp.js | 84.21 | 56.36 | 100 | 84.21 | ...9,229,239,257-263,275-286,299-301
92
- Touch.js | 95.91 | 81.48 | 100 | 95.83 | 152,202
289
+ Totp.js | 93.75 | 72.72 | 100 | 93.75 | 189-190,230,240,282-287
290
+ Touch.js | 96 | 81.48 | 100 | 95.91 | 164,231
93
291
  Use.js | 96.77 | 89.47 | 100 | 96.77 | 68
94
292
  Ver.js | 90 | 66.66 | 100 | 90 | 25
95
293
  Whoami.js | 83.33 | 60 | 80 | 83.33 | 27,35,48
96
294
  index.js | 87.5 | 50 | 100 | 86.95 | 15,22,31
97
295
  src/prompts | 100 | 100 | 50 | 100 |
98
296
  MainPromptMock.js | 100 | 100 | 50 | 100 |
99
- src/utils | 70.04 | 63.28 | 56.25 | 69.67 |
297
+ src/utils | 68.82 | 62.5 | 56.25 | 68.44 |
100
298
  AliasManager.js | 100 | 91.66 | 100 | 100 | 47
101
299
  ContactManager.js | 73.33 | 60 | 85.71 | 73.33 | 12,34-36
102
300
  Fido2Client.js | 15.38 | 0 | 11.11 | 15.38 | 14-108
103
- HelpProto.js | 91.59 | 84.05 | 100 | 91.45 | 49,153-154,171-176,195
301
+ HelpProto.js | 89.07 | 82.6 | 100 | 88.88 | 49,135-137,153-154,171-176,195
104
302
  Logger.js | 63.63 | 56.25 | 36.84 | 62.79 | ...25,37-49,57,65-69,74,84,88,93,105
105
303
  --------------------|---------|----------|---------|---------|--------------------------------------
106
304
   ELIFECYCLE  Test failed. See above for more details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "secrez",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "license": "MIT",
5
5
  "nyc": {
6
6
  "include": "src",
@@ -71,6 +71,10 @@ class Export extends require("../Command") {
71
71
  alias: "C",
72
72
  type: Boolean,
73
73
  },
74
+ {
75
+ name: "no-export",
76
+ type: Boolean,
77
+ },
74
78
  ];
75
79
  }
76
80
 
@@ -115,6 +119,10 @@ class Export extends require("../Command") {
115
119
  "export my-wallet.yml --crypto-env",
116
120
  "it works like with keystore files, but it will export to file with .crypto.env extension ready to be used with @secrez/cryptoenv. Notice that the option -k has priority over -C.",
117
121
  ],
122
+ [
123
+ "export my-wallet.yml --crypto-env --no-export",
124
+ "encrypts the private key but displays it in console instead of exporting to file.",
125
+ ],
118
126
  ],
119
127
  };
120
128
  }
@@ -162,19 +170,35 @@ class Export extends require("../Command") {
162
170
  pks.push(k);
163
171
  }
164
172
  }
173
+ let shouldEncryptAll = false;
165
174
  if (!pks.length) {
166
- throw new Error("The entry does not contain any private key");
175
+ if (options.cryptoEnv) {
176
+ shouldEncryptAll = await this.useInput({
177
+ type: "confirm",
178
+ message:
179
+ "No private_key fields found. Would you like to encrypt the entire content instead?",
180
+ default: false,
181
+ });
182
+ }
183
+ if (!shouldEncryptAll) {
184
+ throw new Error("The entry does not contain any private key");
185
+ }
167
186
  }
168
- let privateKey = card[pks[0]];
169
- if (pks.length > 1) {
170
- let pk = await this.useInput({
171
- type: "list",
172
- message: "Which private key do you want to export?",
173
- choices: pks,
174
- });
175
- privateKey = card[pk];
187
+ let privateKey;
188
+ if (shouldEncryptAll) {
189
+ privateKey = content;
190
+ } else {
191
+ privateKey = card[pks[0]];
192
+ if (pks.length > 1) {
193
+ let pk = await this.useInput({
194
+ type: "list",
195
+ message: "Which private key do you want to export?",
196
+ choices: pks,
197
+ });
198
+ privateKey = card[pk];
199
+ }
176
200
  }
177
- let fileType = options.keystore ? "keystore" : "crypto-env";
201
+ let fileType = options.cryptoEnv ? "crypto-env" : "keystore";
178
202
  let pwd =
179
203
  options.password ||
180
204
  (await this.useInput({
@@ -184,12 +208,18 @@ class Export extends require("../Command") {
184
208
  if (!pwd) {
185
209
  throw new Error("Operation canceled");
186
210
  }
187
- if (options.keystore) {
188
- content = await encryptPrivateKeyAsKeystoreJson(privateKey, pwd);
189
- name = name.replace(/\.[^.]+$/, ".keystore.json");
190
- } else {
211
+ if (options.cryptoEnv) {
191
212
  content = await Crypto.encrypt(privateKey, Crypto.SHA3(pwd));
213
+ if (options.noExport) {
214
+ // Display encrypted content in console instead of exporting
215
+ this.Logger.grey("Encrypted content:");
216
+ this.Logger.reset(content);
217
+ return null; // Return null to indicate no file was created
218
+ }
192
219
  name = name.replace(/\.[^.]+$/, ".crypto.env");
220
+ } else {
221
+ content = await encryptPrivateKeyAsKeystoreJson(privateKey, pwd);
222
+ name = name.replace(/\.[^.]+$/, ".keystore.json");
193
223
  }
194
224
  } else if (options.encrypt) {
195
225
  const myPublicKey = this.secrez.getPublicKey();
@@ -273,8 +303,10 @@ class Export extends require("../Command") {
273
303
  try {
274
304
  this.validate(options);
275
305
  let name = await this.export(options);
276
- this.Logger.grey("Exported file:");
277
- this.Logger.reset(name);
306
+ if (name) {
307
+ this.Logger.grey("Exported file:");
308
+ this.Logger.reset(name);
309
+ }
278
310
  if (
279
311
  options.encrypt &&
280
312
  !options.password &&