secrez 2.0.0 → 2.1.1
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 +47 -34
- package/coverage.report +56 -52
- package/package.json +14 -15
- package/src/commands/Conf.js +24 -23
- package/src/commands/Copy.js +26 -8
- package/src/commands/Totp.js +28 -13
package/README.md
CHANGED
@@ -369,10 +369,19 @@ 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.1**
|
373
|
+
|
374
|
+
- manage missing clipboard when in headless shells
|
375
|
+
- fix bug in creating a `totp` when the target Yaml file is empty
|
376
|
+
|
377
|
+
**2.0.1**
|
378
|
+
|
379
|
+
- fix commands to change password and number of iterations
|
380
|
+
|
372
381
|
**2.0.0** (breaking changes)
|
373
382
|
|
374
383
|
- remove `@crypto/hub`, `@crypto/courier`, `@crypto/tunnel` and `@crypto/tls` since they are not maintained anymore
|
375
|
-
- add `show` command to show a card field as a QR code, for example to encode a private key and let a mobile wallet
|
384
|
+
- add `show` command to show a card field as a QR code, for example to encode a private key and let a mobile wallet scan it
|
376
385
|
|
377
386
|
**1.1.6**
|
378
387
|
|
@@ -835,62 +844,66 @@ Thank you for any contributions! 😉
|
|
835
844
|
## Test coverage
|
836
845
|
|
837
846
|
```
|
838
|
-
148 passing (
|
847
|
+
148 passing (16s)
|
839
848
|
1 pending
|
840
849
|
|
841
850
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
842
851
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
843
852
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
844
|
-
All files | 81.
|
845
|
-
src | 57.84 | 53.62 | 52.63 | 58.
|
853
|
+
All files | 81.09 | 67.66 | 81.15 | 80.99 |
|
854
|
+
src | 57.84 | 53.62 | 52.63 | 58.41 |
|
846
855
|
Command.js | 79.66 | 78.72 | 76.92 | 81.03 | 32,55-62,73,80,119
|
847
856
|
PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
|
848
857
|
cliConfig.js | 100 | 100 | 100 | 100 |
|
849
|
-
src/commands |
|
850
|
-
Alias.js | 90.54 | 77.
|
851
|
-
Bash.js | 75 | 0 | 66.
|
852
|
-
Cat.js | 98.9 | 88.
|
853
|
-
Cd.js | 96.
|
854
|
-
Conf.js |
|
855
|
-
Contacts.js | 87.
|
856
|
-
Copy.js | 94
|
857
|
-
Ds.js | 92.
|
858
|
+
src/commands | 83.73 | 69.14 | 90.64 | 83.61 |
|
859
|
+
Alias.js | 90.54 | 77.35 | 100 | 90.41 | 101,112,139,169,173,180,190
|
860
|
+
Bash.js | 75 | 0 | 66.66 | 75 | 18-19
|
861
|
+
Cat.js | 98.9 | 88.88 | 100 | 98.9 | 152
|
862
|
+
Cd.js | 96.42 | 86.66 | 100 | 96.42 | 44
|
863
|
+
Conf.js | 9.09 | 0 | 20 | 9.09 | 98-500
|
864
|
+
Contacts.js | 87.17 | 74.32 | 100 | 87.06 | ...5-141,145,165,172,184,237,250,260
|
865
|
+
Copy.js | 92.94 | 73.58 | 100 | 92.85 | 114,165,182,200,216-217
|
866
|
+
Ds.js | 92.53 | 82.05 | 100 | 92.42 | 99,108-113,125
|
858
867
|
Edit.js | 13.58 | 0 | 40 | 13.58 | 88-214
|
859
|
-
Export.js | 88.
|
860
|
-
Find.js | 93.
|
868
|
+
Export.js | 88.11 | 70.58 | 100 | 88.11 | ...0-175,185,197-201,206,218,227,230
|
869
|
+
Find.js | 93.58 | 86.66 | 100 | 93.42 | 101,164,200-203,209
|
861
870
|
Help.js | 100 | 80 | 100 | 100 | 29
|
862
|
-
Import.js | 93.2 | 85.48 | 100 | 93.
|
871
|
+
Import.js | 93.2 | 85.48 | 100 | 93.13 | ...5,365,367,387,393,441,456-463,490
|
863
872
|
Lcat.js | 100 | 85.71 | 100 | 100 | 54
|
864
|
-
Lcd.js | 95.65 | 81.
|
865
|
-
Lls.js | 95.45 | 72.
|
866
|
-
Lpwd.js |
|
867
|
-
Ls.js | 91.3 | 75 | 100 | 90.
|
868
|
-
Mkdir.js | 100 | 66.
|
869
|
-
Mv.js | 88.04 | 73.21 | 100 | 87.
|
873
|
+
Lcd.js | 95.65 | 81.81 | 100 | 95.65 | 50
|
874
|
+
Lls.js | 95.45 | 72.72 | 100 | 95.45 | 97
|
875
|
+
Lpwd.js | 92.3 | 100 | 100 | 92.3 | 36
|
876
|
+
Ls.js | 91.3 | 75 | 100 | 90.76 | 103,114-116,130,181
|
877
|
+
Mkdir.js | 100 | 66.66 | 100 | 100 | 38-44
|
878
|
+
Mv.js | 88.04 | 73.21 | 100 | 87.77 | 93-99,133,155,165-172
|
870
879
|
Paste.js | 87.23 | 75 | 100 | 87.23 | 72,78,81,89,113,129
|
871
|
-
Pwd.js |
|
880
|
+
Pwd.js | 92.3 | 100 | 100 | 92.3 | 33
|
872
881
|
Quit.js | 90 | 50 | 100 | 90 | 27
|
873
|
-
Rm.js | 94 | 80.95 | 100 | 93.
|
874
|
-
Shell.js | 88.
|
875
|
-
Show.js | 72 | 45.45 | 57.14 | 73.
|
882
|
+
Rm.js | 94 | 80.95 | 100 | 93.87 | 63,126,134
|
883
|
+
Shell.js | 88.23 | 60 | 100 | 88.23 | 38,55
|
884
|
+
Show.js | 72 | 45.45 | 57.14 | 73.46 | ...8,100,106-114,117,123-126,132,143
|
876
885
|
Ssh.js | 25 | 0 | 40 | 25 | 72-120
|
877
|
-
Tag.js | 98.
|
878
|
-
Totp.js |
|
879
|
-
Touch.js | 95.
|
886
|
+
Tag.js | 98.03 | 92.3 | 100 | 98.01 | 122,171
|
887
|
+
Totp.js | 94.56 | 73.58 | 100 | 94.56 | 188-189,229,239,277
|
888
|
+
Touch.js | 95.91 | 81.48 | 100 | 95.83 | 152,202
|
880
889
|
Use.js | 96.77 | 89.47 | 100 | 96.77 | 68
|
881
|
-
Ver.js | 90 | 66.
|
890
|
+
Ver.js | 90 | 66.66 | 100 | 90 | 25
|
882
891
|
Whoami.js | 83.33 | 60 | 80 | 83.33 | 27,35,48
|
883
|
-
index.js | 87.5 | 50 | 100 | 86.
|
892
|
+
index.js | 87.5 | 50 | 100 | 86.95 | 15,22,31
|
884
893
|
src/prompts | 100 | 100 | 50 | 100 |
|
885
894
|
MainPromptMock.js | 100 | 100 | 50 | 100 |
|
886
895
|
src/utils | 70.04 | 63.28 | 56.25 | 69.67 |
|
887
|
-
AliasManager.js | 100 | 91.
|
896
|
+
AliasManager.js | 100 | 91.66 | 100 | 100 | 47
|
888
897
|
ContactManager.js | 73.33 | 60 | 85.71 | 73.33 | 12,34-36
|
889
898
|
Fido2Client.js | 15.38 | 0 | 11.11 | 15.38 | 14-108
|
890
|
-
HelpProto.js |
|
891
|
-
Logger.js | 63.
|
899
|
+
HelpProto.js | 91.59 | 84.05 | 100 | 91.45 | 49,153-154,171-176,195
|
900
|
+
Logger.js | 63.63 | 56.25 | 36.84 | 62.79 | ...25,37-49,57,65-69,74,84,88,93,105
|
892
901
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
893
902
|
|
903
|
+
> secrez@2.1.1 posttest /Users/francescosullo/Projects/Secrez/secrez/packages/secrez
|
904
|
+
> nyc check-coverage --statements 65 --branches 50 --functions 65 --lines 65
|
905
|
+
|
906
|
+
|
894
907
|
```
|
895
908
|
|
896
909
|
## Copyright
|
package/coverage.report
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> secrez@2.
|
2
|
+
> secrez@2.1.1 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
|
|
@@ -32,7 +32,7 @@
|
|
32
32
|
✓ should show either one or all the versions of a file (1020ms)
|
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 (
|
35
|
+
✓ should show the content of a Yaml file (1030ms)
|
36
36
|
|
37
37
|
#Cd
|
38
38
|
✓ should return the help
|
@@ -51,9 +51,9 @@
|
|
51
51
|
|
52
52
|
#Copy
|
53
53
|
✓ should return the help
|
54
|
-
✓ should copy a file to the clipboard (
|
55
|
-
✓ should copy a string to the clipboard (
|
56
|
-
✓ should copy a card to the clipboard (
|
54
|
+
✓ should copy a file to the clipboard (405ms)
|
55
|
+
✓ should copy a string to the clipboard (254ms)
|
56
|
+
✓ should copy a card to the clipboard (937ms)
|
57
57
|
✓ should return an error if the file does not exist or is a folder
|
58
58
|
✓ should throw if copying to clipboard a binary files
|
59
59
|
|
@@ -69,14 +69,14 @@
|
|
69
69
|
✓ should export a file to the current local folder
|
70
70
|
✓ should export a binary file to the current local folder
|
71
71
|
✓ should export an encrypted file to the current local folder
|
72
|
-
✓ should export a file and delete it after 1 second (
|
72
|
+
✓ should export a file and delete it after 1 second (1203ms)
|
73
73
|
✓ should return an error if the file does not exist or is a folder
|
74
|
-
✓ should export a keystore json file if a private_key exists in the entry (
|
74
|
+
✓ should export a keystore json file if a private_key exists in the entry (718ms)
|
75
75
|
✓ should export a cryptoenv file if a private_key exists in the entry
|
76
76
|
|
77
77
|
#Find
|
78
78
|
✓ should return the help
|
79
|
-
✓ should show find a string in the tree (
|
79
|
+
✓ should show find a string in the tree (1017ms)
|
80
80
|
✓ should find no result without parameters
|
81
81
|
✓ should skip binary files from search
|
82
82
|
|
@@ -141,7 +141,7 @@
|
|
141
141
|
|
142
142
|
#Mv
|
143
143
|
✓ should return the help
|
144
|
-
✓ should rename a file (
|
144
|
+
✓ should rename a file (1013ms)
|
145
145
|
✓ should move a file to another folder
|
146
146
|
✓ should move many files to another folder
|
147
147
|
✓ should move a file to another subfolder
|
@@ -150,14 +150,14 @@
|
|
150
150
|
✓ should move file to another dataset using wildcards
|
151
151
|
✓ should move file managing duplicates
|
152
152
|
✓ should throw if parameters are missed or wrong
|
153
|
-
✓ should move files from and to other datasets (
|
153
|
+
✓ should move files from and to other datasets (1030ms)
|
154
154
|
✓ should move the results of a find
|
155
155
|
|
156
156
|
#Paste
|
157
157
|
✓ should return the help
|
158
|
-
✓ should paste the clipboard content to a new file (
|
159
|
-
✓ should paste the clipboard content to an existent file (
|
160
|
-
✓ should paste a single field to a yml card (
|
158
|
+
✓ should paste the clipboard content to a new file (52ms)
|
159
|
+
✓ should paste the clipboard content to an existent file (77ms)
|
160
|
+
✓ should paste a single field to a yml card (38ms)
|
161
161
|
|
162
162
|
#Pwd
|
163
163
|
✓ should return the help
|
@@ -171,7 +171,7 @@
|
|
171
171
|
✓ should delete a file with one version
|
172
172
|
✓ should delete many files usign wildcards
|
173
173
|
✓ should return errors if wrong parameters
|
174
|
-
✓ should delete some versions of a file (
|
174
|
+
✓ should delete some versions of a file (1010ms)
|
175
175
|
|
176
176
|
#Shell
|
177
177
|
✓ should return the help
|
@@ -191,13 +191,13 @@
|
|
191
191
|
|
192
192
|
#Totp
|
193
193
|
✓ should return the help
|
194
|
-
✓ should totp a file to the clipboard (
|
195
|
-
✓ should read a totp secret from an image and add the totp field to the card (
|
196
|
-
✓ should read a totp secret from an image and return the secret
|
194
|
+
✓ should totp a file to the clipboard (425ms)
|
195
|
+
✓ should read a totp secret from an image and add the totp field to the card (39ms)
|
196
|
+
✓ should read a totp secret from an image and return the secret
|
197
197
|
✓ should throw if bad image
|
198
198
|
✓ should throw if missing parameters
|
199
199
|
✓ should throw if the yaml is malformed
|
200
|
-
✓ should read a totp secret from the clipboard (
|
200
|
+
✓ should read a totp secret from the clipboard (115ms)
|
201
201
|
|
202
202
|
#Touch
|
203
203
|
✓ should return the help
|
@@ -207,7 +207,7 @@
|
|
207
207
|
✓ should throw if wrong parameters
|
208
208
|
✓ should create a file and generate a wallet
|
209
209
|
New file "/folder2/file1" created.
|
210
|
-
✓ should generate 5 prefixed wallet
|
210
|
+
✓ should generate 5 prefixed wallet (63ms)
|
211
211
|
New file "/folder2/file1" created.
|
212
212
|
✓ should generate a wallet with mnemonic and 2 keys
|
213
213
|
|
@@ -223,58 +223,62 @@ New file "/folder2/file1" created.
|
|
223
223
|
✓ should see who am I
|
224
224
|
|
225
225
|
|
226
|
-
148 passing (
|
226
|
+
148 passing (16s)
|
227
227
|
1 pending
|
228
228
|
|
229
229
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
230
230
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
231
231
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
232
|
-
All files | 81.
|
233
|
-
src | 57.84 | 53.62 | 52.63 | 58.
|
232
|
+
All files | 81.09 | 67.66 | 81.15 | 80.99 |
|
233
|
+
src | 57.84 | 53.62 | 52.63 | 58.41 |
|
234
234
|
Command.js | 79.66 | 78.72 | 76.92 | 81.03 | 32,55-62,73,80,119
|
235
235
|
PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
|
236
236
|
cliConfig.js | 100 | 100 | 100 | 100 |
|
237
|
-
src/commands |
|
238
|
-
Alias.js | 90.54 | 77.
|
239
|
-
Bash.js | 75 | 0 | 66.
|
240
|
-
Cat.js | 98.9 | 88.
|
241
|
-
Cd.js | 96.
|
242
|
-
Conf.js |
|
243
|
-
Contacts.js | 87.
|
244
|
-
Copy.js | 94
|
245
|
-
Ds.js | 92.
|
237
|
+
src/commands | 83.73 | 69.14 | 90.64 | 83.61 |
|
238
|
+
Alias.js | 90.54 | 77.35 | 100 | 90.41 | 101,112,139,169,173,180,190
|
239
|
+
Bash.js | 75 | 0 | 66.66 | 75 | 18-19
|
240
|
+
Cat.js | 98.9 | 88.88 | 100 | 98.9 | 152
|
241
|
+
Cd.js | 96.42 | 86.66 | 100 | 96.42 | 44
|
242
|
+
Conf.js | 9.09 | 0 | 20 | 9.09 | 98-500
|
243
|
+
Contacts.js | 87.17 | 74.32 | 100 | 87.06 | ...5-141,145,165,172,184,237,250,260
|
244
|
+
Copy.js | 92.94 | 73.58 | 100 | 92.85 | 114,165,182,200,216-217
|
245
|
+
Ds.js | 92.53 | 82.05 | 100 | 92.42 | 99,108-113,125
|
246
246
|
Edit.js | 13.58 | 0 | 40 | 13.58 | 88-214
|
247
|
-
Export.js | 88.
|
248
|
-
Find.js | 93.
|
247
|
+
Export.js | 88.11 | 70.58 | 100 | 88.11 | ...0-175,185,197-201,206,218,227,230
|
248
|
+
Find.js | 93.58 | 86.66 | 100 | 93.42 | 101,164,200-203,209
|
249
249
|
Help.js | 100 | 80 | 100 | 100 | 29
|
250
|
-
Import.js | 93.2 | 85.48 | 100 | 93.
|
250
|
+
Import.js | 93.2 | 85.48 | 100 | 93.13 | ...5,365,367,387,393,441,456-463,490
|
251
251
|
Lcat.js | 100 | 85.71 | 100 | 100 | 54
|
252
|
-
Lcd.js | 95.65 | 81.
|
253
|
-
Lls.js | 95.45 | 72.
|
254
|
-
Lpwd.js |
|
255
|
-
Ls.js | 91.3 | 75 | 100 | 90.
|
256
|
-
Mkdir.js | 100 | 66.
|
257
|
-
Mv.js | 88.04 | 73.21 | 100 | 87.
|
252
|
+
Lcd.js | 95.65 | 81.81 | 100 | 95.65 | 50
|
253
|
+
Lls.js | 95.45 | 72.72 | 100 | 95.45 | 97
|
254
|
+
Lpwd.js | 92.3 | 100 | 100 | 92.3 | 36
|
255
|
+
Ls.js | 91.3 | 75 | 100 | 90.76 | 103,114-116,130,181
|
256
|
+
Mkdir.js | 100 | 66.66 | 100 | 100 | 38-44
|
257
|
+
Mv.js | 88.04 | 73.21 | 100 | 87.77 | 93-99,133,155,165-172
|
258
258
|
Paste.js | 87.23 | 75 | 100 | 87.23 | 72,78,81,89,113,129
|
259
|
-
Pwd.js |
|
259
|
+
Pwd.js | 92.3 | 100 | 100 | 92.3 | 33
|
260
260
|
Quit.js | 90 | 50 | 100 | 90 | 27
|
261
|
-
Rm.js | 94 | 80.95 | 100 | 93.
|
262
|
-
Shell.js | 88.
|
263
|
-
Show.js | 72 | 45.45 | 57.14 | 73.
|
261
|
+
Rm.js | 94 | 80.95 | 100 | 93.87 | 63,126,134
|
262
|
+
Shell.js | 88.23 | 60 | 100 | 88.23 | 38,55
|
263
|
+
Show.js | 72 | 45.45 | 57.14 | 73.46 | ...8,100,106-114,117,123-126,132,143
|
264
264
|
Ssh.js | 25 | 0 | 40 | 25 | 72-120
|
265
|
-
Tag.js | 98.
|
266
|
-
Totp.js |
|
267
|
-
Touch.js | 95.
|
265
|
+
Tag.js | 98.03 | 92.3 | 100 | 98.01 | 122,171
|
266
|
+
Totp.js | 94.56 | 73.58 | 100 | 94.56 | 188-189,229,239,277
|
267
|
+
Touch.js | 95.91 | 81.48 | 100 | 95.83 | 152,202
|
268
268
|
Use.js | 96.77 | 89.47 | 100 | 96.77 | 68
|
269
|
-
Ver.js | 90 | 66.
|
269
|
+
Ver.js | 90 | 66.66 | 100 | 90 | 25
|
270
270
|
Whoami.js | 83.33 | 60 | 80 | 83.33 | 27,35,48
|
271
|
-
index.js | 87.5 | 50 | 100 | 86.
|
271
|
+
index.js | 87.5 | 50 | 100 | 86.95 | 15,22,31
|
272
272
|
src/prompts | 100 | 100 | 50 | 100 |
|
273
273
|
MainPromptMock.js | 100 | 100 | 50 | 100 |
|
274
274
|
src/utils | 70.04 | 63.28 | 56.25 | 69.67 |
|
275
|
-
AliasManager.js | 100 | 91.
|
275
|
+
AliasManager.js | 100 | 91.66 | 100 | 100 | 47
|
276
276
|
ContactManager.js | 73.33 | 60 | 85.71 | 73.33 | 12,34-36
|
277
277
|
Fido2Client.js | 15.38 | 0 | 11.11 | 15.38 | 14-108
|
278
|
-
HelpProto.js |
|
279
|
-
Logger.js | 63.
|
278
|
+
HelpProto.js | 91.59 | 84.05 | 100 | 91.45 | 49,153-154,171-176,195
|
279
|
+
Logger.js | 63.63 | 56.25 | 36.84 | 62.79 | ...25,37-49,57,65-69,74,84,88,93,105
|
280
280
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
281
|
+
|
282
|
+
> secrez@2.1.1 posttest /Users/francescosullo/Projects/Secrez/secrez/packages/secrez
|
283
|
+
> nyc check-coverage --statements 65 --branches 50 --functions 65 --lines 65
|
284
|
+
|
package/package.json
CHANGED
@@ -1,40 +1,39 @@
|
|
1
1
|
{
|
2
2
|
"name": "secrez",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.1.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"nyc": {
|
6
6
|
"include": "src",
|
7
7
|
"exclude": []
|
8
8
|
},
|
9
9
|
"dependencies": {
|
10
|
-
"@secrez/core": "~1.0.
|
11
|
-
"@secrez/crypto": "~1.0.
|
12
|
-
"@secrez/eth": "~0.0.
|
13
|
-
"@secrez/fs": "~1.0.
|
14
|
-
"@secrez/utils": "~1.0.
|
10
|
+
"@secrez/core": "~1.0.5",
|
11
|
+
"@secrez/crypto": "~1.0.4",
|
12
|
+
"@secrez/eth": "~0.0.4",
|
13
|
+
"@secrez/fs": "~1.0.5",
|
14
|
+
"@secrez/utils": "~1.0.4",
|
15
15
|
"case": "^1.6.3",
|
16
16
|
"chalk": "^3.0.0",
|
17
17
|
"clipboardy": "^2.3.0",
|
18
|
-
"command-line-args": "^5.
|
18
|
+
"command-line-args": "^5.2.1",
|
19
19
|
"external-editor": "^3.1.0",
|
20
20
|
"fs-extra": "^9.1.0",
|
21
21
|
"homedir": "^0.6.0",
|
22
|
-
"inquirer": "^7.
|
22
|
+
"inquirer": "^7.3.3",
|
23
23
|
"inquirer-command-prompt": "^0.1.0",
|
24
24
|
"jimp": "^0.13.0",
|
25
|
-
"lodash": "^4.17.
|
25
|
+
"lodash": "^4.17.21",
|
26
26
|
"otplib": "^12.0.1",
|
27
|
-
"qrcode": "^1.5.
|
27
|
+
"qrcode": "^1.5.4",
|
28
28
|
"qrcode-reader": "^1.0.4",
|
29
|
-
"superagent": "^5.3.1",
|
30
29
|
"tiny-cli-editor": "^0.1.1"
|
31
30
|
},
|
32
31
|
"devDependencies": {
|
33
|
-
"@secrez/test-helpers": "~2.0.
|
34
|
-
"chai": "^4.
|
32
|
+
"@secrez/test-helpers": "~2.0.1",
|
33
|
+
"chai": "^4.5.0",
|
35
34
|
"chalk": "^3.0.0",
|
36
|
-
"cross-env": "^7.0.
|
37
|
-
"mocha": "^7.
|
35
|
+
"cross-env": "^7.0.3",
|
36
|
+
"mocha": "^7.2.0",
|
38
37
|
"nyc": "^15.1.0",
|
39
38
|
"test-console": "^1.1.0"
|
40
39
|
},
|
package/src/commands/Conf.js
CHANGED
@@ -94,15 +94,15 @@ class Conf extends require("../Command") {
|
|
94
94
|
// }
|
95
95
|
// }
|
96
96
|
//
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
97
|
+
async getAllFactors() {
|
98
|
+
let allFactors = {};
|
99
|
+
const conf = this.secrez.getConf();
|
100
|
+
let keys = conf.data.keys || {};
|
101
|
+
for (let authenticator in keys) {
|
102
|
+
allFactors[authenticator] = keys[authenticator].type;
|
103
|
+
}
|
104
|
+
return allFactors;
|
105
|
+
}
|
106
106
|
//
|
107
107
|
// async verifyIfAlreadyRegistered() {
|
108
108
|
// let client = this.fido2Client
|
@@ -196,20 +196,21 @@ class Conf extends require("../Command") {
|
|
196
196
|
// await this.saveAndOverwrite(`main:/.RECOVERY_CODE_${authenticator}`, 'recovery code', recoveryCode, 'it')
|
197
197
|
// }
|
198
198
|
//
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
199
|
+
async saveAndOverwrite(p, spec, content, message) {
|
200
|
+
try {
|
201
|
+
await this.prompt.commands.rm.rm({
|
202
|
+
path: p,
|
203
|
+
});
|
204
|
+
} catch (e) {}
|
205
|
+
let node = await this.prompt.commands.touch.touch({
|
206
|
+
path: p,
|
207
|
+
content,
|
208
|
+
versionIfExists: true,
|
209
|
+
});
|
210
|
+
this.Logger.reset(
|
211
|
+
`For your convenience, ${message} has been saved in main:${node.getPath()}`
|
212
|
+
);
|
213
|
+
}
|
213
214
|
//
|
214
215
|
// async setFido2(options) {
|
215
216
|
// let client = this.fido2Client
|
package/src/commands/Copy.js
CHANGED
@@ -2,6 +2,7 @@ const path = require("path");
|
|
2
2
|
const clipboardy = require("clipboardy");
|
3
3
|
const { isYaml, yamlParse, TRUE, sleep, playMp3 } = require("@secrez/utils");
|
4
4
|
const { Node } = require("@secrez/fs");
|
5
|
+
const { execSync } = require("child_process");
|
5
6
|
|
6
7
|
class Copy extends require("../Command") {
|
7
8
|
setHelpAndCompletion() {
|
@@ -67,7 +68,9 @@ class Copy extends require("../Command") {
|
|
67
68
|
|
68
69
|
help() {
|
69
70
|
return {
|
70
|
-
description: [
|
71
|
+
description: [
|
72
|
+
"Copy a text file to the clipboard. It won't work in headless shells.",
|
73
|
+
],
|
71
74
|
examples: [
|
72
75
|
[
|
73
76
|
"copy ethKeys",
|
@@ -189,6 +192,15 @@ class Copy extends require("../Command") {
|
|
189
192
|
}
|
190
193
|
}
|
191
194
|
|
195
|
+
isMacGuiSession() {
|
196
|
+
try {
|
197
|
+
execSync("echo test | pbcopy", { stdio: "ignore" });
|
198
|
+
return true;
|
199
|
+
} catch {
|
200
|
+
return false;
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
192
204
|
async write(content, options, counter) {
|
193
205
|
let duration = options.duration
|
194
206
|
? options.duration.map((e) => 1000 * e)
|
@@ -201,19 +213,25 @@ class Copy extends require("../Command") {
|
|
201
213
|
let wait = i ? duration[1] : duration[0];
|
202
214
|
await this.writeAndWait(content[i], wait, counter);
|
203
215
|
if (this.counter === counter && !options.noBeep) {
|
204
|
-
|
216
|
+
try {
|
217
|
+
await playMp3(path.resolve(__dirname, "../../sounds/ding.mp3"));
|
218
|
+
} catch (e) {
|
219
|
+
// Ignore the error
|
220
|
+
}
|
205
221
|
}
|
206
222
|
}
|
207
223
|
}
|
208
224
|
}
|
209
225
|
|
210
226
|
async writeAndWait(content, wait, counter) {
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
await clipboardy.
|
227
|
+
if (this.isMacGuiSession()) {
|
228
|
+
let previousContent = await clipboardy.read();
|
229
|
+
if (this.counter === counter) {
|
230
|
+
await clipboardy.write(content);
|
231
|
+
await sleep(wait);
|
232
|
+
if (this.counter === counter && content === (await clipboardy.read())) {
|
233
|
+
await clipboardy.write(previousContent);
|
234
|
+
}
|
217
235
|
}
|
218
236
|
}
|
219
237
|
}
|
package/src/commands/Totp.js
CHANGED
@@ -77,7 +77,7 @@ class Totp extends require("../Command") {
|
|
77
77
|
examples: [
|
78
78
|
[
|
79
79
|
"totp coinbase.yml",
|
80
|
-
"prints a totp code and copies it to the clipboard for 5 seconds",
|
80
|
+
"prints a totp code and copies it to the clipboard for 5 seconds if not in a headless shell",
|
81
81
|
],
|
82
82
|
[
|
83
83
|
'totp coinbase.yml -s "9syh 34rd ge6s hey3 u874"',
|
@@ -225,10 +225,14 @@ class Totp extends require("../Command") {
|
|
225
225
|
let { content } = entry;
|
226
226
|
if (isYaml(p) && !options.allFile) {
|
227
227
|
let parsed;
|
228
|
-
|
229
|
-
parsed =
|
230
|
-
}
|
231
|
-
|
228
|
+
if (content === undefined) {
|
229
|
+
parsed = {};
|
230
|
+
} else {
|
231
|
+
try {
|
232
|
+
parsed = yamlParse(content);
|
233
|
+
} catch (e) {
|
234
|
+
throw new Error("The yml is malformed");
|
235
|
+
}
|
232
236
|
}
|
233
237
|
if (secret) {
|
234
238
|
if (parsed.totp && !options.force) {
|
@@ -249,11 +253,13 @@ class Totp extends require("../Command") {
|
|
249
253
|
if (totp) {
|
250
254
|
totp = totp.replace(/\s/g, "");
|
251
255
|
const token = authenticator.generate(totp);
|
252
|
-
this.
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
256
|
+
if (this.isMacGuiSession()) {
|
257
|
+
this.prompt.commands.copy.copy({
|
258
|
+
thisString: token,
|
259
|
+
duration: [options.duration || this.defaults.duration],
|
260
|
+
noBeep: options.noBeep,
|
261
|
+
});
|
262
|
+
}
|
257
263
|
return token;
|
258
264
|
}
|
259
265
|
}
|
@@ -263,6 +269,15 @@ class Totp extends require("../Command") {
|
|
263
269
|
throw new Error(err);
|
264
270
|
}
|
265
271
|
|
272
|
+
isMacGuiSession() {
|
273
|
+
try {
|
274
|
+
execSync("echo test | pbcopy", { stdio: "ignore" });
|
275
|
+
return true;
|
276
|
+
} catch {
|
277
|
+
return false;
|
278
|
+
}
|
279
|
+
}
|
280
|
+
|
266
281
|
async exec(options = {}) {
|
267
282
|
if (options.help) {
|
268
283
|
return this.showHelp();
|
@@ -273,10 +288,10 @@ class Totp extends require("../Command") {
|
|
273
288
|
if (options.fromImage || options.fromClipboard) {
|
274
289
|
this.Logger.grey(token);
|
275
290
|
} else {
|
276
|
-
this.Logger.grey("TOTP token: " + this.chalk.bold
|
277
|
-
if (!options.test) {
|
291
|
+
this.Logger.grey("TOTP token: " + this.chalk.bold(token));
|
292
|
+
if (!options.test && this.isMacGuiSession()) {
|
278
293
|
this.Logger.grey(
|
279
|
-
`It will stay in
|
294
|
+
`Copied to the clipboard. It will stay in it for ${
|
280
295
|
options.duration || this.defaults.duration
|
281
296
|
} seconds`
|
282
297
|
);
|