secrez 2.1.4 → 2.1.6
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 +8 -0
- package/coverage.report +208 -11
- package/package.json +1 -1
- package/src/commands/Export.js +30 -14
- package/src/commands/Touch.js +31 -2
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.6**
|
373
|
+
|
374
|
+
- export and encrypt, with option `--crypto-env`, the entire content of an item
|
375
|
+
|
376
|
+
**2.1.5**
|
377
|
+
|
378
|
+
- duplicate files using `touch <newfile> --from <file>` to copy the file from the source to the destination
|
379
|
+
|
372
380
|
**2.1.4**
|
373
381
|
|
374
382
|
- uses clipboard only on macOS
|
package/coverage.report
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> secrez@2.1.
|
2
|
+
> secrez@2.1.6 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 (
|
32
|
+
✓ should show either one or all the versions of a file (1012ms)
|
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 (1018ms)
|
36
36
|
|
37
37
|
#Cd
|
38
38
|
✓ should return the help
|
@@ -51,25 +51,222 @@
|
|
51
51
|
|
52
52
|
#Copy
|
53
53
|
✓ should return the help
|
54
|
+
✓ should copy a file to the clipboard (416ms)
|
55
|
+
✓ should copy a string to the clipboard (321ms)
|
56
|
+
✓ should copy a card to the clipboard (943ms)
|
57
|
+
✓ should return an error if the file does not exist or is a folder (50ms)
|
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 (1204ms)
|
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 (753ms)
|
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
|
+
|
81
|
+
#Find
|
82
|
+
✓ should return the help
|
83
|
+
✓ should show find a string in the tree (1033ms)
|
84
|
+
✓ should find no result without parameters
|
85
|
+
✓ should skip binary files from search
|
86
|
+
|
87
|
+
#Help
|
88
|
+
✓ should return the help
|
89
|
+
✓ #execAsync and format
|
90
|
+
✓ should throw if wrong command
|
91
|
+
✓ -- to complete coverage
|
92
|
+
|
93
|
+
#Import
|
94
|
+
✓ should return the help
|
95
|
+
✓ should import a file in the current folder
|
96
|
+
✓ should import an encrypted file
|
97
|
+
✓ should import an encrypted file encrypted for myself
|
98
|
+
✓ should import an encrypted binary file and export it again verifying it is fine
|
99
|
+
✓ should import files recursively
|
100
|
+
✓ should read a folder and import the only text file
|
101
|
+
✓ should read a folder and import text and binary files
|
102
|
+
✓ should simulate the import of two files
|
103
|
+
✓ should move the imported file
|
104
|
+
✓ should import a backup from another software spanning the data among folders and files
|
105
|
+
✓ should import a backup from another software but saving the tags as tags
|
106
|
+
✓ should import a backup from another software using tags to prefix the paths
|
107
|
+
✓ should import using tags to prefix the paths, ignoring the tags
|
108
|
+
✓ should import from a LastPass-like csv setting the path from "grouping" and "name"
|
109
|
+
✓ should import from a json
|
110
|
+
✓ should throw importing a malformed backup
|
111
|
+
✓ should throw importing a CSV indicating wrong fields to generate the path
|
112
|
+
|
113
|
+
#Lcat
|
114
|
+
✓ should return the help
|
115
|
+
✓ cat a file
|
116
|
+
✓ return en error if trying to cat a binary file
|
117
|
+
|
118
|
+
#Lcd
|
119
|
+
✓ should return the help
|
120
|
+
✓ change to a folder
|
121
|
+
✓ return en error if changing to a file
|
122
|
+
|
123
|
+
#Lls
|
124
|
+
✓ should return the help
|
125
|
+
✓ should list a folder
|
126
|
+
✓ return en error if lls-ing a not existing path
|
127
|
+
✓ return a message if no files are found
|
128
|
+
|
129
|
+
#Lpwd
|
130
|
+
✓ should return the help
|
131
|
+
✓ change to a folder
|
132
|
+
|
133
|
+
#Ls
|
134
|
+
✓ should return the help
|
135
|
+
✓ should return all the datasets
|
136
|
+
✓ should list folders and files
|
137
|
+
✓ should list folders and files using wildcards
|
138
|
+
|
139
|
+
#Mkdir
|
140
|
+
✓ should return the help
|
141
|
+
✓ should create a folder
|
142
|
+
✓ should create a nested folder
|
143
|
+
✓ should throw if trying to create a child of a file
|
144
|
+
✓ should throw if wrong parameters
|
145
|
+
|
146
|
+
#Mv
|
147
|
+
✓ should return the help
|
148
|
+
✓ should rename a file (1011ms)
|
149
|
+
✓ should move a file to another folder
|
150
|
+
✓ should move many files to another folder
|
151
|
+
✓ should move a file to another subfolder
|
152
|
+
✓ should move and rename file to another folder
|
153
|
+
✓ should move file to another folder using wildcards
|
154
|
+
✓ should move file to another dataset using wildcards
|
155
|
+
✓ should move file managing duplicates
|
156
|
+
✓ should throw if parameters are missed or wrong
|
157
|
+
✓ should move files from and to other datasets (1018ms)
|
158
|
+
✓ should move the results of a find
|
159
|
+
|
160
|
+
#Paste
|
161
|
+
✓ should return the help
|
162
|
+
✓ should paste the clipboard content to a new file (46ms)
|
163
|
+
✓ should paste the clipboard content to an existent file (79ms)
|
164
|
+
✓ should paste a single field to a yml card (38ms)
|
165
|
+
|
166
|
+
#Pwd
|
167
|
+
✓ should return the help
|
168
|
+
✓ should show the working folder
|
169
|
+
|
170
|
+
#Quit
|
171
|
+
✓ should show the content of an external file via bash
|
172
|
+
|
173
|
+
#Rm
|
174
|
+
✓ should return the help
|
175
|
+
✓ should delete a file with one version
|
176
|
+
✓ should delete many files usign wildcards
|
177
|
+
✓ should return errors if wrong parameters
|
178
|
+
✓ should delete some versions of a file (1010ms)
|
179
|
+
|
180
|
+
#Shell
|
181
|
+
✓ should return the help
|
182
|
+
✓ should show the content of an external file via shell
|
183
|
+
|
184
|
+
#Show
|
185
|
+
✓ should return the help
|
186
|
+
✓ should show the field password of a card
|
187
|
+
|
188
|
+
#Tag
|
189
|
+
✓ should return the help
|
190
|
+
✓ should tag a file
|
191
|
+
✓ should remove a tag
|
192
|
+
✓ should list all the tags
|
193
|
+
✓ should show the file tagged as
|
194
|
+
✓ should show very long file tagged as
|
195
|
+
|
196
|
+
#Totp
|
197
|
+
✓ should return the help
|
198
|
+
✓ should totp a file to the clipboard (395ms)
|
199
|
+
✓ should read a totp secret from an image and add the totp field to the card (46ms)
|
200
|
+
✓ should read a totp secret from an image and return the secret
|
201
|
+
✓ should throw if bad image
|
202
|
+
✓ should throw if missing parameters
|
203
|
+
✓ should throw if the yaml is malformed
|
204
|
+
✓ should read a totp secret from the clipboard (269ms)
|
205
|
+
|
206
|
+
#Touch
|
207
|
+
✓ should return the help
|
208
|
+
✓ should create a file
|
209
|
+
✓ should create a file with content
|
210
|
+
✓ should duplicate a file
|
211
|
+
✓ should throw if trying to duplicate a non existing file
|
212
|
+
✓ should throw if trying to duplicate a folder
|
213
|
+
✓ should throw if trying to create a child of a file
|
214
|
+
✓ should throw if wrong parameters
|
215
|
+
✓ should create a file and generate a wallet
|
216
|
+
New file "/folder2/file1" created.
|
217
|
+
✓ should generate 5 prefixed wallet (65ms)
|
218
|
+
New file "/folder2/file1" created.
|
219
|
+
✓ should generate a wallet with mnemonic and 2 keys
|
220
|
+
|
221
|
+
#Use
|
222
|
+
✓ should return the help
|
223
|
+
✓ should use a new dataset, creating it if does not exist
|
224
|
+
|
225
|
+
#Ver
|
226
|
+
✓ should show the current version
|
227
|
+
|
228
|
+
#Whoami
|
229
|
+
✓ should return the help
|
230
|
+
✓ should see who am I
|
231
|
+
|
232
|
+
|
233
|
+
154 passing (16s)
|
234
|
+
1 pending
|
235
|
+
1 failing
|
236
|
+
|
237
|
+
1) #Export
|
238
|
+
should export a file to the current local folder:
|
239
|
+
|
240
|
+
AssertionError: expected 'file.2' to equal 'file'
|
241
|
+
+ expected - actual
|
242
|
+
|
243
|
+
-file.2
|
244
|
+
+file
|
245
|
+
|
246
|
+
at assertConsole (/Users/francescosullo/Projects/Secrez/secrez/packages/test-helpers/src/index.js:121:16)
|
247
|
+
at Context.<anonymous> (test/commands/Export.test.js:94:5)
|
248
|
+
|
249
|
+
|
250
|
+
|
54
251
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
55
252
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
56
253
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
57
|
-
All files |
|
254
|
+
All files | 81.01 | 67.81 | 81.15 | 80.91 |
|
58
255
|
src | 57.84 | 53.62 | 52.63 | 58.41 |
|
59
256
|
Command.js | 79.66 | 78.72 | 76.92 | 81.03 | 32,55-62,73,80,119
|
60
257
|
PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
|
61
258
|
cliConfig.js | 100 | 100 | 100 | 100 |
|
62
|
-
src/commands |
|
259
|
+
src/commands | 83.77 | 69.39 | 90.64 | 83.66 |
|
63
260
|
Alias.js | 90.54 | 77.35 | 100 | 90.41 | 101,112,139,169,173,180,190
|
64
261
|
Bash.js | 75 | 0 | 66.66 | 75 | 18-19
|
65
262
|
Cat.js | 98.9 | 88.88 | 100 | 98.9 | 152
|
66
263
|
Cd.js | 96.42 | 86.66 | 100 | 96.42 | 44
|
67
264
|
Conf.js | 9.09 | 0 | 20 | 9.09 | 98-500
|
68
265
|
Contacts.js | 87.17 | 74.32 | 100 | 87.06 | ...5-141,145,165,172,184,237,250,260
|
69
|
-
Copy.js |
|
266
|
+
Copy.js | 91.2 | 71.92 | 100 | 91.11 | 115,166,183,205-210,225-226,253
|
70
267
|
Ds.js | 92.53 | 82.05 | 100 | 92.42 | 99,108-113,125
|
71
268
|
Edit.js | 13.58 | 0 | 40 | 13.58 | 88-214
|
72
|
-
Export.js |
|
269
|
+
Export.js | 89.71 | 75.67 | 100 | 89.71 | ...5-190,201,213-217,222,234,243,246
|
73
270
|
Find.js | 93.58 | 86.66 | 100 | 93.42 | 101,164,200-203,209
|
74
271
|
Help.js | 100 | 80 | 100 | 100 | 29
|
75
272
|
Import.js | 93.2 | 85.48 | 100 | 93.13 | ...5,365,367,387,393,441,456-463,490
|
@@ -88,19 +285,19 @@ All files | 77.54 | 63.7 | 79.71 | 77.44 |
|
|
88
285
|
Show.js | 72 | 45.45 | 57.14 | 73.46 | ...8,100,106-114,117,123-126,132,143
|
89
286
|
Ssh.js | 25 | 0 | 40 | 25 | 72-120
|
90
287
|
Tag.js | 98.03 | 92.3 | 100 | 98.01 | 122,171
|
91
|
-
Totp.js |
|
92
|
-
Touch.js |
|
288
|
+
Totp.js | 93.75 | 72.72 | 100 | 93.75 | 189-190,230,240,282-287
|
289
|
+
Touch.js | 96 | 81.48 | 100 | 95.91 | 164,231
|
93
290
|
Use.js | 96.77 | 89.47 | 100 | 96.77 | 68
|
94
291
|
Ver.js | 90 | 66.66 | 100 | 90 | 25
|
95
292
|
Whoami.js | 83.33 | 60 | 80 | 83.33 | 27,35,48
|
96
293
|
index.js | 87.5 | 50 | 100 | 86.95 | 15,22,31
|
97
294
|
src/prompts | 100 | 100 | 50 | 100 |
|
98
295
|
MainPromptMock.js | 100 | 100 | 50 | 100 |
|
99
|
-
src/utils |
|
296
|
+
src/utils | 68.82 | 62.5 | 56.25 | 68.44 |
|
100
297
|
AliasManager.js | 100 | 91.66 | 100 | 100 | 47
|
101
298
|
ContactManager.js | 73.33 | 60 | 85.71 | 73.33 | 12,34-36
|
102
299
|
Fido2Client.js | 15.38 | 0 | 11.11 | 15.38 | 14-108
|
103
|
-
HelpProto.js |
|
300
|
+
HelpProto.js | 89.07 | 82.6 | 100 | 88.88 | 49,135-137,153-154,171-176,195
|
104
301
|
Logger.js | 63.63 | 56.25 | 36.84 | 62.79 | ...25,37-49,57,65-69,74,84,88,93,105
|
105
302
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
106
303
|
ELIFECYCLE Test failed. See above for more details.
|
package/package.json
CHANGED
package/src/commands/Export.js
CHANGED
@@ -162,19 +162,35 @@ class Export extends require("../Command") {
|
|
162
162
|
pks.push(k);
|
163
163
|
}
|
164
164
|
}
|
165
|
+
let shouldEncryptAll = false;
|
165
166
|
if (!pks.length) {
|
166
|
-
|
167
|
+
if (options.cryptoEnv) {
|
168
|
+
shouldEncryptAll = await this.useInput({
|
169
|
+
type: "confirm",
|
170
|
+
message:
|
171
|
+
"No private_key fields found. Would you like to encrypt the entire content instead?",
|
172
|
+
default: false,
|
173
|
+
});
|
174
|
+
}
|
175
|
+
if (!shouldEncryptAll) {
|
176
|
+
throw new Error("The entry does not contain any private key");
|
177
|
+
}
|
167
178
|
}
|
168
|
-
let privateKey
|
169
|
-
if (
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
179
|
+
let privateKey;
|
180
|
+
if (shouldEncryptAll) {
|
181
|
+
privateKey = content;
|
182
|
+
} else {
|
183
|
+
privateKey = card[pks[0]];
|
184
|
+
if (pks.length > 1) {
|
185
|
+
let pk = await this.useInput({
|
186
|
+
type: "list",
|
187
|
+
message: "Which private key do you want to export?",
|
188
|
+
choices: pks,
|
189
|
+
});
|
190
|
+
privateKey = card[pk];
|
191
|
+
}
|
176
192
|
}
|
177
|
-
let fileType = options.
|
193
|
+
let fileType = options.cryptoEnv ? "crypto-env" : "keystore";
|
178
194
|
let pwd =
|
179
195
|
options.password ||
|
180
196
|
(await this.useInput({
|
@@ -184,12 +200,12 @@ class Export extends require("../Command") {
|
|
184
200
|
if (!pwd) {
|
185
201
|
throw new Error("Operation canceled");
|
186
202
|
}
|
187
|
-
if (options.
|
188
|
-
content = await encryptPrivateKeyAsKeystoreJson(privateKey, pwd);
|
189
|
-
name = name.replace(/\.[^.]+$/, ".keystore.json");
|
190
|
-
} else {
|
203
|
+
if (options.cryptoEnv) {
|
191
204
|
content = await Crypto.encrypt(privateKey, Crypto.SHA3(pwd));
|
192
205
|
name = name.replace(/\.[^.]+$/, ".crypto.env");
|
206
|
+
} else {
|
207
|
+
content = await encryptPrivateKeyAsKeystoreJson(privateKey, pwd);
|
208
|
+
name = name.replace(/\.[^.]+$/, ".keystore.json");
|
193
209
|
}
|
194
210
|
} else if (options.encrypt) {
|
195
211
|
const myPublicKey = this.secrez.getPublicKey();
|
package/src/commands/Touch.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
const { config, Entry } = require("@secrez/core");
|
2
2
|
const { yamlStringify } = require("@secrez/utils");
|
3
3
|
const { newWallet, getWalletFromMnemonic } = require("@secrez/eth");
|
4
|
+
const { Node } = require("@secrez/fs");
|
4
5
|
|
5
6
|
class Touch extends require("../Command") {
|
6
7
|
setHelpAndCompletion() {
|
@@ -62,6 +63,11 @@ class Touch extends require("../Command") {
|
|
62
63
|
alias: "v",
|
63
64
|
type: Boolean,
|
64
65
|
},
|
66
|
+
{
|
67
|
+
name: "from",
|
68
|
+
type: String,
|
69
|
+
completionType: "file",
|
70
|
+
},
|
65
71
|
];
|
66
72
|
}
|
67
73
|
|
@@ -77,8 +83,10 @@ class Touch extends require("../Command") {
|
|
77
83
|
"touch somefile",
|
78
84
|
"If the the file exists, it create 'somefile.2', 'somefile.3', etc.",
|
79
85
|
],
|
80
|
-
|
81
|
-
|
86
|
+
[
|
87
|
+
'touch -p afile --content "Password: 1432874565"',
|
88
|
+
"Save the specified content in 'afile'.",
|
89
|
+
],
|
82
90
|
[
|
83
91
|
"touch sample.txt -w",
|
84
92
|
"Prompt the user to type the content of the file. The text cannot contain newlines. It will cut at the first one, if so. If '-w' and '-c' are both present, '-c' will be ignored.",
|
@@ -107,6 +115,10 @@ class Touch extends require("../Command") {
|
|
107
115
|
"touch new-wallets.yaml -gi",
|
108
116
|
"Includes the mnemonic. In this case, it will also add the fields 'mnemonic' (mnemonic phrase) and 'derived_path' (path used to generate the keys). ",
|
109
117
|
],
|
118
|
+
[
|
119
|
+
"touch wallet2.yml --from wallet.yaml",
|
120
|
+
"Creates the new file 'wallet2.yml' duplicating 'wallet.yml'.",
|
121
|
+
],
|
110
122
|
],
|
111
123
|
};
|
112
124
|
}
|
@@ -193,6 +205,23 @@ class Touch extends require("../Command") {
|
|
193
205
|
} else {
|
194
206
|
throw new Error("Command canceled");
|
195
207
|
}
|
208
|
+
} else if (options.from) {
|
209
|
+
let data = await this.internalFs.getTreeIndexAndPath(options.from);
|
210
|
+
let tree = data.tree;
|
211
|
+
let p = tree.getNormalizedPath(data.path);
|
212
|
+
let node;
|
213
|
+
try {
|
214
|
+
node = tree.root.getChildFromPath(p);
|
215
|
+
} catch (e) {
|
216
|
+
throw new Error(`File "${options.from}" not found.`);
|
217
|
+
}
|
218
|
+
if (Node.isFile(node)) {
|
219
|
+
console.log("is file");
|
220
|
+
let details = await tree.getEntryDetails(node);
|
221
|
+
options.content = details.content;
|
222
|
+
} else {
|
223
|
+
throw new Error(`"${options.from}" is not a file.`);
|
224
|
+
}
|
196
225
|
}
|
197
226
|
}
|
198
227
|
let newFile = await this.touch(options);
|