secrez 2.1.2 β 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -59
- package/coverage.report +7 -185
- package/package.json +1 -1
- package/src/commands/Copy.js +28 -15
- package/src/commands/Totp.js +14 -5
package/README.md
CHANGED
@@ -369,6 +369,11 @@ 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.4**
|
373
|
+
|
374
|
+
- uses clipboard only on macOS
|
375
|
+
- fixes `copy` return message when clipboard is not available
|
376
|
+
|
372
377
|
**2.1.2**
|
373
378
|
|
374
379
|
- disable `copy` command when in headless shells
|
@@ -848,65 +853,6 @@ Thank you for any contributions! π
|
|
848
853
|
## Test coverage
|
849
854
|
|
850
855
|
```
|
851
|
-
148 passing (16s)
|
852
|
-
1 pending
|
853
|
-
|
854
|
-
--------------------|---------|----------|---------|---------|--------------------------------------
|
855
|
-
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
856
|
-
--------------------|---------|----------|---------|---------|--------------------------------------
|
857
|
-
All files | 81.09 | 67.71 | 81.15 | 80.99 |
|
858
|
-
src | 57.84 | 53.62 | 52.63 | 58.41 |
|
859
|
-
Command.js | 79.66 | 78.72 | 76.92 | 81.03 | 32,55-62,73,80,119
|
860
|
-
PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
|
861
|
-
cliConfig.js | 100 | 100 | 100 | 100 |
|
862
|
-
src/commands | 83.73 | 69.2 | 90.64 | 83.61 |
|
863
|
-
Alias.js | 90.54 | 77.35 | 100 | 90.41 | 101,112,139,169,173,180,190
|
864
|
-
Bash.js | 75 | 0 | 66.66 | 75 | 18-19
|
865
|
-
Cat.js | 98.9 | 88.88 | 100 | 98.9 | 152
|
866
|
-
Cd.js | 96.42 | 86.66 | 100 | 96.42 | 44
|
867
|
-
Conf.js | 9.09 | 0 | 20 | 9.09 | 98-500
|
868
|
-
Contacts.js | 87.17 | 74.32 | 100 | 87.06 | ...5-141,145,165,172,184,237,250,260
|
869
|
-
Copy.js | 92.94 | 74.54 | 100 | 92.85 | 114,165,182,200,216-217
|
870
|
-
Ds.js | 92.53 | 82.05 | 100 | 92.42 | 99,108-113,125
|
871
|
-
Edit.js | 13.58 | 0 | 40 | 13.58 | 88-214
|
872
|
-
Export.js | 88.11 | 70.58 | 100 | 88.11 | ...0-175,185,197-201,206,218,227,230
|
873
|
-
Find.js | 93.58 | 86.66 | 100 | 93.42 | 101,164,200-203,209
|
874
|
-
Help.js | 100 | 80 | 100 | 100 | 29
|
875
|
-
Import.js | 93.2 | 85.48 | 100 | 93.13 | ...5,365,367,387,393,441,456-463,490
|
876
|
-
Lcat.js | 100 | 85.71 | 100 | 100 | 54
|
877
|
-
Lcd.js | 95.65 | 81.81 | 100 | 95.65 | 50
|
878
|
-
Lls.js | 95.45 | 72.72 | 100 | 95.45 | 97
|
879
|
-
Lpwd.js | 92.3 | 100 | 100 | 92.3 | 36
|
880
|
-
Ls.js | 91.3 | 75 | 100 | 90.76 | 103,114-116,130,181
|
881
|
-
Mkdir.js | 100 | 66.66 | 100 | 100 | 38-44
|
882
|
-
Mv.js | 88.04 | 73.21 | 100 | 87.77 | 93-99,133,155,165-172
|
883
|
-
Paste.js | 87.23 | 75 | 100 | 87.23 | 72,78,81,89,113,129
|
884
|
-
Pwd.js | 92.3 | 100 | 100 | 92.3 | 33
|
885
|
-
Quit.js | 90 | 50 | 100 | 90 | 27
|
886
|
-
Rm.js | 94 | 80.95 | 100 | 93.87 | 63,126,134
|
887
|
-
Shell.js | 88.23 | 60 | 100 | 88.23 | 38,55
|
888
|
-
Show.js | 72 | 45.45 | 57.14 | 73.46 | ...8,100,106-114,117,123-126,132,143
|
889
|
-
Ssh.js | 25 | 0 | 40 | 25 | 72-120
|
890
|
-
Tag.js | 98.03 | 92.3 | 100 | 98.01 | 122,171
|
891
|
-
Totp.js | 94.56 | 73.58 | 100 | 94.56 | 188-189,229,239,277
|
892
|
-
Touch.js | 95.91 | 81.48 | 100 | 95.83 | 152,202
|
893
|
-
Use.js | 96.77 | 89.47 | 100 | 96.77 | 68
|
894
|
-
Ver.js | 90 | 66.66 | 100 | 90 | 25
|
895
|
-
Whoami.js | 83.33 | 60 | 80 | 83.33 | 27,35,48
|
896
|
-
index.js | 87.5 | 50 | 100 | 86.95 | 15,22,31
|
897
|
-
src/prompts | 100 | 100 | 50 | 100 |
|
898
|
-
MainPromptMock.js | 100 | 100 | 50 | 100 |
|
899
|
-
src/utils | 70.04 | 63.28 | 56.25 | 69.67 |
|
900
|
-
AliasManager.js | 100 | 91.66 | 100 | 100 | 47
|
901
|
-
ContactManager.js | 73.33 | 60 | 85.71 | 73.33 | 12,34-36
|
902
|
-
Fido2Client.js | 15.38 | 0 | 11.11 | 15.38 | 14-108
|
903
|
-
HelpProto.js | 91.59 | 84.05 | 100 | 91.45 | 49,153-154,171-176,195
|
904
|
-
Logger.js | 63.63 | 56.25 | 36.84 | 62.79 | ...25,37-49,57,65-69,74,84,88,93,105
|
905
|
-
--------------------|---------|----------|---------|---------|--------------------------------------
|
906
|
-
|
907
|
-
> secrez@2.1.2 posttest /Users/francescosullo/Projects/Secrez/secrez/packages/secrez
|
908
|
-
> nyc check-coverage --statements 65 --branches 50 --functions 65 --lines 65
|
909
|
-
|
910
856
|
|
911
857
|
```
|
912
858
|
|
package/coverage.report
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> secrez@2.1.
|
2
|
+
> secrez@2.1.3 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,7 +29,7 @@
|
|
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 (
|
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
35
|
β should show the content of a Yaml file (1031ms)
|
@@ -51,197 +51,22 @@
|
|
51
51
|
|
52
52
|
#Copy
|
53
53
|
β should return the help
|
54
|
-
β should copy a file to the clipboard (488ms)
|
55
|
-
β should copy a string to the clipboard (271ms)
|
56
|
-
β should copy a card to the clipboard (1040ms)
|
57
|
-
β should return an error if the file does not exist or is a folder (60ms)
|
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
|
-
β should export a file to the current local folder
|
70
|
-
β should export a binary file to the current local folder
|
71
|
-
β should export an encrypted file to the current local folder
|
72
|
-
β should export a file and delete it after 1 second (1205ms)
|
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 (685ms)
|
75
|
-
β should export a cryptoenv file if a private_key exists in the entry
|
76
|
-
|
77
|
-
#Find
|
78
|
-
β should return the help
|
79
|
-
β should show find a string in the tree (1020ms)
|
80
|
-
β should find no result without parameters
|
81
|
-
β should skip binary files from search
|
82
|
-
|
83
|
-
#Help
|
84
|
-
β should return the help
|
85
|
-
β #execAsync and format
|
86
|
-
β should throw if wrong command
|
87
|
-
β -- to complete coverage
|
88
|
-
|
89
|
-
#Import
|
90
|
-
β should return the help
|
91
|
-
β should import a file in the current folder
|
92
|
-
β should import an encrypted file
|
93
|
-
β should import an encrypted file encrypted for myself
|
94
|
-
β should import an encrypted binary file and export it again verifying it is fine
|
95
|
-
β should import files recursively
|
96
|
-
β should read a folder and import the only text file
|
97
|
-
β should read a folder and import text and binary files
|
98
|
-
β should simulate the import of two files
|
99
|
-
β should move the imported file
|
100
|
-
β should import a backup from another software spanning the data among folders and files
|
101
|
-
β should import a backup from another software but saving the tags as tags
|
102
|
-
β should import a backup from another software using tags to prefix the paths
|
103
|
-
β should import using tags to prefix the paths, ignoring the tags
|
104
|
-
β should import from a LastPass-like csv setting the path from "grouping" and "name"
|
105
|
-
β should import from a json
|
106
|
-
β should throw importing a malformed backup
|
107
|
-
β should throw importing a CSV indicating wrong fields to generate the path
|
108
|
-
|
109
|
-
#Lcat
|
110
|
-
β should return the help
|
111
|
-
β cat a file
|
112
|
-
β return en error if trying to cat a binary file
|
113
|
-
|
114
|
-
#Lcd
|
115
|
-
β should return the help
|
116
|
-
β change to a folder
|
117
|
-
β return en error if changing to a file
|
118
|
-
|
119
|
-
#Lls
|
120
|
-
β should return the help
|
121
|
-
β should list a folder
|
122
|
-
β return en error if lls-ing a not existing path
|
123
|
-
β return a message if no files are found
|
124
|
-
|
125
|
-
#Lpwd
|
126
|
-
β should return the help
|
127
|
-
β change to a folder
|
128
|
-
|
129
|
-
#Ls
|
130
|
-
β should return the help
|
131
|
-
β should return all the datasets
|
132
|
-
β should list folders and files
|
133
|
-
β should list folders and files using wildcards
|
134
|
-
|
135
|
-
#Mkdir
|
136
|
-
β should return the help
|
137
|
-
β should create a folder
|
138
|
-
β should create a nested folder
|
139
|
-
β should throw if trying to create a child of a file
|
140
|
-
β should throw if wrong parameters
|
141
|
-
|
142
|
-
#Mv
|
143
|
-
β should return the help
|
144
|
-
β should rename a file (1014ms)
|
145
|
-
β should move a file to another folder
|
146
|
-
β should move many files to another folder
|
147
|
-
β should move a file to another subfolder
|
148
|
-
β should move and rename file to another folder
|
149
|
-
β should move file to another folder using wildcards
|
150
|
-
β should move file to another dataset using wildcards
|
151
|
-
β should move file managing duplicates
|
152
|
-
β should throw if parameters are missed or wrong
|
153
|
-
β should move files from and to other datasets (1033ms)
|
154
|
-
β should move the results of a find
|
155
|
-
|
156
|
-
#Paste
|
157
|
-
β should return the help
|
158
|
-
β should paste the clipboard content to a new file (52ms)
|
159
|
-
β should paste the clipboard content to an existent file (76ms)
|
160
|
-
β should paste a single field to a yml card (39ms)
|
161
|
-
|
162
|
-
#Pwd
|
163
|
-
β should return the help
|
164
|
-
β should show the working folder
|
165
|
-
|
166
|
-
#Quit
|
167
|
-
β should show the content of an external file via bash
|
168
|
-
|
169
|
-
#Rm
|
170
|
-
β should return the help
|
171
|
-
β should delete a file with one version
|
172
|
-
β should delete many files usign wildcards
|
173
|
-
β should return errors if wrong parameters
|
174
|
-
β should delete some versions of a file (1014ms)
|
175
|
-
|
176
|
-
#Shell
|
177
|
-
β should return the help
|
178
|
-
β should show the content of an external file via shell
|
179
|
-
|
180
|
-
#Show
|
181
|
-
β should return the help
|
182
|
-
β should show the field password of a card
|
183
|
-
|
184
|
-
#Tag
|
185
|
-
β should return the help
|
186
|
-
β should tag a file
|
187
|
-
β should remove a tag
|
188
|
-
β should list all the tags
|
189
|
-
β should show the file tagged as
|
190
|
-
β should show very long file tagged as
|
191
|
-
|
192
|
-
#Totp
|
193
|
-
β should return the help
|
194
|
-
β should totp a file to the clipboard (421ms)
|
195
|
-
β should read a totp secret from an image and add the totp field to the card (40ms)
|
196
|
-
β should read a totp secret from an image and return the secret
|
197
|
-
β should throw if bad image
|
198
|
-
β should throw if missing parameters
|
199
|
-
β should throw if the yaml is malformed
|
200
|
-
β should read a totp secret from the clipboard (215ms)
|
201
|
-
|
202
|
-
#Touch
|
203
|
-
β should return the help
|
204
|
-
β should create a file
|
205
|
-
β should create a file with content
|
206
|
-
β should throw if trying to create a child of a file
|
207
|
-
β should throw if wrong parameters
|
208
|
-
β should create a file and generate a wallet
|
209
|
-
New file "/folder2/file1" created.
|
210
|
-
β should generate 5 prefixed wallet (65ms)
|
211
|
-
New file "/folder2/file1" created.
|
212
|
-
β should generate a wallet with mnemonic and 2 keys
|
213
|
-
|
214
|
-
#Use
|
215
|
-
β should return the help
|
216
|
-
β should use a new dataset, creating it if does not exist
|
217
|
-
|
218
|
-
#Ver
|
219
|
-
β should show the current version
|
220
|
-
|
221
|
-
#Whoami
|
222
|
-
β should return the help
|
223
|
-
β should see who am I
|
224
|
-
|
225
|
-
|
226
|
-
148 passing (16s)
|
227
|
-
1 pending
|
228
|
-
|
229
54
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
230
55
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
231
56
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
232
|
-
All files |
|
57
|
+
All files | 77.54 | 63.7 | 79.71 | 77.44 |
|
233
58
|
src | 57.84 | 53.62 | 52.63 | 58.41 |
|
234
59
|
Command.js | 79.66 | 78.72 | 76.92 | 81.03 | 32,55-62,73,80,119
|
235
60
|
PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
|
236
61
|
cliConfig.js | 100 | 100 | 100 | 100 |
|
237
|
-
src/commands |
|
62
|
+
src/commands | 79.46 | 64.42 | 88.66 | 79.36 |
|
238
63
|
Alias.js | 90.54 | 77.35 | 100 | 90.41 | 101,112,139,169,173,180,190
|
239
64
|
Bash.js | 75 | 0 | 66.66 | 75 | 18-19
|
240
65
|
Cat.js | 98.9 | 88.88 | 100 | 98.9 | 152
|
241
66
|
Cd.js | 96.42 | 86.66 | 100 | 96.42 | 44
|
242
67
|
Conf.js | 9.09 | 0 | 20 | 9.09 | 98-500
|
243
68
|
Contacts.js | 87.17 | 74.32 | 100 | 87.06 | ...5-141,145,165,172,184,237,250,260
|
244
|
-
Copy.js |
|
69
|
+
Copy.js | 15.55 | 3.5 | 50 | 15.73 | 108-191,198-241,252-267
|
245
70
|
Ds.js | 92.53 | 82.05 | 100 | 92.42 | 99,108-113,125
|
246
71
|
Edit.js | 13.58 | 0 | 40 | 13.58 | 88-214
|
247
72
|
Export.js | 88.11 | 70.58 | 100 | 88.11 | ...0-175,185,197-201,206,218,227,230
|
@@ -263,7 +88,7 @@ All files | 81.09 | 67.71 | 81.15 | 80.99 |
|
|
263
88
|
Show.js | 72 | 45.45 | 57.14 | 73.46 | ...8,100,106-114,117,123-126,132,143
|
264
89
|
Ssh.js | 25 | 0 | 40 | 25 | 72-120
|
265
90
|
Tag.js | 98.03 | 92.3 | 100 | 98.01 | 122,171
|
266
|
-
Totp.js |
|
91
|
+
Totp.js | 84.21 | 56.36 | 100 | 84.21 | ...9,229,239,257-263,275-286,299-301
|
267
92
|
Touch.js | 95.91 | 81.48 | 100 | 95.83 | 152,202
|
268
93
|
Use.js | 96.77 | 89.47 | 100 | 96.77 | 68
|
269
94
|
Ver.js | 90 | 66.66 | 100 | 90 | 25
|
@@ -278,7 +103,4 @@ All files | 81.09 | 67.71 | 81.15 | 80.99 |
|
|
278
103
|
HelpProto.js | 91.59 | 84.05 | 100 | 91.45 | 49,153-154,171-176,195
|
279
104
|
Logger.js | 63.63 | 56.25 | 36.84 | 62.79 | ...25,37-49,57,65-69,74,84,88,93,105
|
280
105
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
281
|
-
|
282
|
-
> secrez@2.1.2 posttest /Users/francescosullo/Projects/Secrez/secrez/packages/secrez
|
283
|
-
> nyc check-coverage --statements 65 --branches 50 --functions 65 --lines 65
|
284
|
-
|
106
|
+
βELIFECYCLEβ Test failed. See above for more details.
|
package/package.json
CHANGED
package/src/commands/Copy.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
const path = require("path");
|
2
|
+
const os = require("os");
|
2
3
|
const clipboardy = require("clipboardy");
|
3
4
|
const { isYaml, yamlParse, TRUE, sleep, playMp3 } = require("@secrez/utils");
|
4
5
|
const { Node } = require("@secrez/fs");
|
@@ -193,12 +194,20 @@ class Copy extends require("../Command") {
|
|
193
194
|
}
|
194
195
|
|
195
196
|
isMacGuiSession() {
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
197
|
+
const platform = os.platform(); // 'darwin', 'linux', 'win32', etc.
|
198
|
+
|
199
|
+
if (platform === "darwin") {
|
200
|
+
// macOS only
|
201
|
+
try {
|
202
|
+
execSync("echo test | pbcopy", { stdio: "ignore" });
|
203
|
+
return true;
|
204
|
+
} catch {
|
205
|
+
return false;
|
206
|
+
}
|
201
207
|
}
|
208
|
+
|
209
|
+
// On Linux and Windows, pbcopy doesn't exist, so we assume false
|
210
|
+
return false;
|
202
211
|
}
|
203
212
|
|
204
213
|
async write(content, options, counter) {
|
@@ -240,17 +249,21 @@ class Copy extends require("../Command") {
|
|
240
249
|
if (options.help) {
|
241
250
|
return this.showHelp();
|
242
251
|
}
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
252
|
+
if (!this.isMacGuiSession()) {
|
253
|
+
this.Logger.red("Clipboard is not available in this shell");
|
254
|
+
} else {
|
255
|
+
try {
|
256
|
+
/* istanbul ignore if */
|
257
|
+
if (!this.clipboardyVerified) {
|
258
|
+
await clipboardy.read();
|
259
|
+
}
|
260
|
+
this.validate(options);
|
261
|
+
let name = await this.copy(options);
|
262
|
+
this.Logger.grey("Copied to clipboard:");
|
263
|
+
this.Logger.reset(name);
|
264
|
+
} catch (e) {
|
265
|
+
this.Logger.red(e.message);
|
247
266
|
}
|
248
|
-
this.validate(options);
|
249
|
-
let name = await this.copy(options);
|
250
|
-
this.Logger.grey("Copied to clipboard:");
|
251
|
-
this.Logger.reset(name);
|
252
|
-
} catch (e) {
|
253
|
-
this.Logger.red(e.message);
|
254
267
|
}
|
255
268
|
await this.prompt.run();
|
256
269
|
}
|
package/src/commands/Totp.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
const { authenticator } = require("otplib");
|
2
2
|
const path = require("path");
|
3
|
+
const os = require("os");
|
3
4
|
const fs = require("fs-extra");
|
4
5
|
const { execSync } = require("child_process");
|
5
6
|
const {
|
@@ -270,12 +271,20 @@ class Totp extends require("../Command") {
|
|
270
271
|
}
|
271
272
|
|
272
273
|
isMacGuiSession() {
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
274
|
+
const platform = os.platform(); // 'darwin', 'linux', 'win32', etc.
|
275
|
+
|
276
|
+
if (platform === "darwin") {
|
277
|
+
// macOS only
|
278
|
+
try {
|
279
|
+
execSync("echo test | pbcopy", { stdio: "ignore" });
|
280
|
+
return true;
|
281
|
+
} catch {
|
282
|
+
return false;
|
283
|
+
}
|
278
284
|
}
|
285
|
+
|
286
|
+
// On Linux and Windows, pbcopy doesn't exist, so we assume false
|
287
|
+
return false;
|
279
288
|
}
|
280
289
|
|
281
290
|
async exec(options = {}) {
|