secrez 1.1.0 → 1.1.2

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.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +414 -291
  3. package/bin/secrez.js +50 -47
  4. package/coverage.report +81 -0
  5. package/package.json +18 -20
  6. package/src/Command.js +78 -57
  7. package/src/PreCommand.js +74 -70
  8. package/src/Welcome.js +144 -134
  9. package/src/cliConfig.js +14 -14
  10. package/src/commands/Alias.js +123 -100
  11. package/src/commands/Bash.js +10 -12
  12. package/src/commands/Cat.js +117 -107
  13. package/src/commands/Cd.js +39 -42
  14. package/src/commands/Chat.js +75 -63
  15. package/src/commands/Conf.js +123 -99
  16. package/src/commands/Contacts.js +189 -171
  17. package/src/commands/Copy.js +132 -113
  18. package/src/commands/Courier.js +123 -105
  19. package/src/commands/Ds.js +88 -76
  20. package/src/commands/Edit.js +122 -103
  21. package/src/commands/Export.js +153 -114
  22. package/src/commands/Find.js +115 -110
  23. package/src/commands/Help.js +20 -23
  24. package/src/commands/Import.js +296 -225
  25. package/src/commands/Lcat.js +36 -39
  26. package/src/commands/Lcd.js +38 -39
  27. package/src/commands/Lls.js +58 -55
  28. package/src/commands/Lpwd.js +20 -24
  29. package/src/commands/Ls.js +107 -97
  30. package/src/commands/Mkdir.js +35 -38
  31. package/src/commands/Mv.js +147 -114
  32. package/src/commands/Paste.js +68 -65
  33. package/src/commands/Pwd.js +18 -23
  34. package/src/commands/Quit.js +22 -24
  35. package/src/commands/Rm.js +78 -70
  36. package/src/commands/Shell.js +31 -32
  37. package/src/commands/Ssh.js +77 -63
  38. package/src/commands/Tag.js +133 -112
  39. package/src/commands/Totp.js +166 -136
  40. package/src/commands/Touch.js +169 -56
  41. package/src/commands/Use.js +44 -41
  42. package/src/commands/Ver.js +16 -18
  43. package/src/commands/Whoami.js +34 -37
  44. package/src/commands/chat/Contacts.js +41 -44
  45. package/src/commands/chat/Help.js +20 -23
  46. package/src/commands/chat/Join.js +59 -55
  47. package/src/commands/chat/Leave.js +16 -22
  48. package/src/commands/chat/Quit.js +19 -24
  49. package/src/commands/chat/Send.js +58 -57
  50. package/src/commands/chat/Show.js +60 -51
  51. package/src/commands/chat/Whoami.js +18 -22
  52. package/src/commands/index.js +20 -22
  53. package/src/index.js +3 -3
  54. package/src/prompts/ChatPrompt.js +87 -82
  55. package/src/prompts/ChatPromptMock.js +11 -17
  56. package/src/prompts/CommandPrompt.js +146 -138
  57. package/src/prompts/Completion.js +64 -69
  58. package/src/prompts/MainPrompt.js +84 -77
  59. package/src/prompts/MainPromptMock.js +19 -30
  60. package/src/prompts/MultiEditorPrompt.js +21 -22
  61. package/src/prompts/SigintManager.js +21 -24
  62. package/src/utils/AliasManager.js +16 -18
  63. package/src/utils/ContactManager.js +15 -17
  64. package/src/utils/Fido2Client.js +59 -49
  65. package/src/utils/HelpProto.js +130 -117
  66. package/src/utils/Logger.js +48 -50
  67. package/.eslintignore +0 -0
  68. package/.eslintrc +0 -33
  69. package/.jshintrc +0 -3
@@ -1,214 +1,224 @@
1
- const _ = require('lodash')
2
- const {chalk} = require('../utils/Logger')
3
- const path = require('path')
4
- const {config} = require('@secrez/core')
5
- const Crypto = require('@secrez/crypto')
6
- const {Node} = require('@secrez/fs')
7
- const {isYaml, yamlParse} = require('@secrez/utils')
8
-
9
- class Cat extends require('../Command') {
1
+ const _ = require("lodash");
2
+ const { chalk } = require("../utils/Logger");
3
+ const path = require("path");
4
+ const { config } = require("@secrez/core");
5
+ const Crypto = require("@secrez/crypto");
6
+ const { Node } = require("@secrez/fs");
7
+ const { isYaml, yamlParse } = require("@secrez/utils");
10
8
 
9
+ class Cat extends require("../Command") {
11
10
  setHelpAndCompletion() {
12
11
  this.cliConfig.completion.cat = {
13
12
  _func: this.selfCompletion(this),
14
- _self: this
15
- }
16
- this.cliConfig.completion.help.cat = true
13
+ _self: this,
14
+ };
15
+ this.cliConfig.completion.help.cat = true;
17
16
  this.optionDefinitions = [
18
17
  {
19
- name: 'help',
20
- alias: 'h',
21
- type: Boolean
18
+ name: "help",
19
+ alias: "h",
20
+ type: Boolean,
22
21
  },
23
22
  {
24
- name: 'path',
25
- completionType: 'file',
26
- alias: 'p',
23
+ name: "path",
24
+ completionType: "file",
25
+ alias: "p",
27
26
  defaultOption: true,
28
- type: String
27
+ type: String,
29
28
  },
30
29
  {
31
- name: 'metadata',
32
- alias: 'm',
33
- type: Boolean
30
+ name: "metadata",
31
+ alias: "m",
32
+ type: Boolean,
34
33
  },
35
34
  {
36
- name: 'version',
37
- alias: 'v',
35
+ name: "version",
36
+ alias: "v",
38
37
  multiple: true,
39
- type: String
38
+ type: String,
40
39
  },
41
40
  {
42
- name: 'all',
43
- alias: 'a',
44
- type: Boolean
41
+ name: "all",
42
+ alias: "a",
43
+ type: Boolean,
45
44
  },
46
45
  {
47
- name: 'field',
48
- alias: 'f',
46
+ name: "field",
47
+ alias: "f",
49
48
  type: String,
50
- hint: 'Shows only the specified field if a Yaml file'
49
+ hint: "Shows only the specified field if a Yaml file",
51
50
  },
52
51
  {
53
- name: 'unformatted',
54
- alias: 'u',
52
+ name: "unformatted",
53
+ alias: "u",
55
54
  type: Boolean,
56
- hint: 'If a Yaml file, it does not format the output'
57
- }
58
- ]
55
+ hint: "If a Yaml file, it does not format the output",
56
+ },
57
+ ];
59
58
  }
60
59
 
61
60
  help() {
62
61
  return {
63
- description: ['Shows the content of a file.'],
62
+ description: ["Shows the content of a file."],
64
63
  examples: [
65
- 'cat ../passwords/Facebook',
66
- ['cat wallet -m', 'shows metadata: version and creation date'],
67
- ['cat etherWallet -v 2UYw', 'shows the version 2UYw of the secret, if exists'],
68
- ['cat etherWallet -a', 'lists all the versions'],
69
- ['cat etherWallet -v 17TR hUUv', 'shows two versions (-m is forced)'],
70
- ['cat wallet.yml -f private_key', 'shows only the field private_key of a yaml file'],
71
- ['cat some.yml -u', 'shows a Yaml file as is']
72
- ]
73
- }
64
+ "cat ../passwords/Facebook",
65
+ ["cat wallet -m", "shows metadata: version and creation date"],
66
+ [
67
+ "cat etherWallet -v 2UYw",
68
+ "shows the version 2UYw of the secret, if exists",
69
+ ],
70
+ ["cat etherWallet -a", "lists all the versions"],
71
+ ["cat etherWallet -v 17TR hUUv", "shows two versions (-m is forced)"],
72
+ [
73
+ "cat wallet.yml -f private_key",
74
+ "shows only the field private_key of a yaml file",
75
+ ],
76
+ ["cat some.yml -u", "shows a Yaml file as is"],
77
+ ],
78
+ };
74
79
  }
75
80
 
76
81
  formatTs(ts, name) {
77
- let tsHash = Node.hashVersion(ts)
78
- ts = Crypto.fromTsToDate(ts)
79
- let date = ts[0].split('Z')[0].split('T')
80
- let ret = `-- ${chalk.bold(tsHash)} -- ${date[0]} ${date[1].substring(0, 12)}${ts[1]}`
82
+ let tsHash = Node.hashVersion(ts);
83
+ ts = Crypto.fromTsToDate(ts);
84
+ let date = ts[0].split("Z")[0].split("T");
85
+ let ret = `-- ${chalk.bold(tsHash)} -- ${date[0]} ${date[1].substring(
86
+ 0,
87
+ 12
88
+ )}${ts[1]}`;
81
89
  if (name) {
82
- ret += ' (' + name + ')'
90
+ ret += " (" + name + ")";
83
91
  }
84
92
 
85
- return ret
93
+ return ret;
86
94
  }
87
95
 
88
96
  async cat(options, justContent) {
89
- if (typeof options === 'string') {
97
+ if (typeof options === "string") {
90
98
  options = {
91
- path: options
92
- }
99
+ path: options,
100
+ };
93
101
  }
94
- let data = await this.internalFs.getTreeIndexAndPath(options.path)
95
- options.path = data.path
96
- let tree = data.tree
97
- let p = tree.getNormalizedPath(options.path)
98
- let node = tree.root.getChildFromPath(p)
102
+ let data = await this.internalFs.getTreeIndexAndPath(options.path);
103
+ options.path = data.path;
104
+ let tree = data.tree;
105
+ let p = tree.getNormalizedPath(options.path);
106
+ let node = tree.root.getChildFromPath(p);
99
107
  if (node && Node.isFile(node)) {
100
- let result = []
108
+ let result = [];
101
109
  if (!isYaml(p)) {
102
- delete options.field
110
+ delete options.field;
103
111
  }
104
112
 
105
113
  const pushDetails = async (node, ts, field) => {
106
- let details = await tree.getEntryDetails(node, ts)
114
+ let details = await tree.getEntryDetails(node, ts);
107
115
  if (!justContent && !options.unformatted && isYaml(p)) {
108
- let fields
116
+ let fields;
109
117
  try {
110
- fields = yamlParse(details.content || '{}')
118
+ fields = yamlParse(details.content || "{}");
111
119
  } catch (e) {
112
120
  // wrong format
113
121
  }
114
122
 
115
- const format = field => {
116
- let val = fields[field]
123
+ const format = (field) => {
124
+ let val = fields[field];
117
125
  if (/\n/.test(val)) {
118
- val = '\n' + val
126
+ val = "\n" + val;
119
127
  }
120
- return [chalk.grey(field + ':'), val].join(' ')
121
- }
122
- if (typeof fields === 'object') {
128
+ return [chalk.grey(field + ":"), val].join(" ");
129
+ };
130
+ if (typeof fields === "object") {
123
131
  if (field) {
124
132
  if (fields[field]) {
125
- details.content = format(field)
133
+ details.content = format(field);
126
134
  } else {
127
- details.content = chalk.yellow('-- empty field')
135
+ details.content = chalk.yellow("-- empty field");
128
136
  }
129
137
  } else {
130
- let content = []
138
+ let content = [];
131
139
  for (let f in fields) {
132
- content.push(format(f))
140
+ content.push(format(f));
133
141
  }
134
- details.content = content.join('\n')
142
+ details.content = content.join("\n");
135
143
  }
136
144
  }
137
145
  }
138
- result.push(details)
139
- }
146
+ result.push(details);
147
+ };
140
148
 
141
149
  if (options.all || options.version) {
142
- let versions = node.getVersions()
150
+ let versions = node.getVersions();
143
151
  if (options.version && options.version.length > 1) {
144
- options.metadata = true
152
+ options.metadata = true;
145
153
  }
146
- let found = []
154
+ let found = [];
147
155
  for (let ts of versions) {
148
- let v = Node.hashVersion(ts)
156
+ let v = Node.hashVersion(ts);
149
157
  if (options.version) {
150
158
  if (!options.version.includes(v)) {
151
- continue
159
+ continue;
152
160
  }
153
161
  }
154
- await pushDetails(node, ts, options.field)
155
- found.push(v)
162
+ await pushDetails(node, ts, options.field);
163
+ found.push(v);
156
164
  }
157
165
  if (options.version && options.version.length > found.length) {
158
- options.notFound = []
166
+ options.notFound = [];
159
167
  for (let v of options.version) {
160
168
  if (!found.includes(v)) {
161
- options.notFound.push(v)
169
+ options.notFound.push(v);
162
170
  }
163
171
  }
164
172
  }
165
173
  } else {
166
- await pushDetails(node, options.ts, options.field)
174
+ await pushDetails(node, options.ts, options.field);
167
175
  }
168
- return result
176
+ return result;
169
177
  } else {
170
- throw new Error('Cat requires a valid file')
178
+ throw new Error("Cat requires a valid file");
171
179
  }
172
180
  }
173
181
 
174
182
  async exec(options = {}) {
175
183
  if (options.help) {
176
- return this.showHelp()
184
+ return this.showHelp();
177
185
  }
178
186
  try {
179
187
  this.validate(options, {
180
- path: true
181
- })
182
- let fn = path.basename(options.path)
183
- let data = await this.cat(options)
184
- let extra = options.all || options.metadata || options.versions
188
+ path: true,
189
+ });
190
+ let fn = path.basename(options.path);
191
+ let data = await this.cat(options);
192
+ let extra = options.all || options.metadata || options.versions;
185
193
  if (data) {
186
194
  for (let d of data) {
187
- let {content, ts, type, name} = d
195
+ let { content, ts, type, name } = d;
188
196
  if (extra) {
189
- this.Logger.yellow(`${this.formatTs(ts, fn === name ? undefined : name)}`)
197
+ this.Logger.yellow(
198
+ `${this.formatTs(ts, fn === name ? undefined : name)}`
199
+ );
190
200
  }
191
201
  if (type === config.types.TEXT) {
192
202
  if (_.trim(content)) {
193
- this.Logger.reset(_.trim(content))
203
+ this.Logger.reset(_.trim(content));
194
204
  } else {
195
- this.Logger.yellow('-- this version is empty')
205
+ this.Logger.yellow("-- this version is empty");
196
206
  }
197
207
  } else {
198
- this.Logger.yellow('-- this is a binary file')
208
+ this.Logger.yellow("-- this is a binary file");
199
209
  }
200
210
  }
201
211
  if (options.notFound && options.notFound.length) {
202
- this.Logger.yellow('Versions not found: ' + options.notFound.join(' '))
212
+ this.Logger.yellow(
213
+ "Versions not found: " + options.notFound.join(" ")
214
+ );
203
215
  }
204
216
  }
205
217
  } catch (e) {
206
- this.Logger.red(e.message)
218
+ this.Logger.red(e.message);
207
219
  }
208
- await this.prompt.run()
220
+ await this.prompt.run();
209
221
  }
210
222
  }
211
223
 
212
- module.exports = Cat
213
-
214
-
224
+ module.exports = Cat;
@@ -1,80 +1,77 @@
1
- const {Node} = require('@secrez/fs')
2
-
3
- class Cd extends require('../Command') {
1
+ const { Node } = require("@secrez/fs");
4
2
 
3
+ class Cd extends require("../Command") {
5
4
  setHelpAndCompletion() {
6
5
  this.cliConfig.completion.cd = {
7
6
  _func: this.selfCompletion(this),
8
- _self: this
9
- }
10
- this.cliConfig.completion.help.cd = true
7
+ _self: this,
8
+ };
9
+ this.cliConfig.completion.help.cd = true;
11
10
  this.optionDefinitions = [
12
11
  {
13
- name: 'help',
14
- alias: 'h',
15
- type: Boolean
12
+ name: "help",
13
+ alias: "h",
14
+ type: Boolean,
16
15
  },
17
16
  {
18
- name: 'path',
19
- completionType: 'file',
20
- alias: 'p',
17
+ name: "path",
18
+ completionType: "file",
19
+ alias: "p",
21
20
  defaultOption: true,
22
21
  type: String,
23
- defaultValue: '/'
24
- }
25
- ]
22
+ defaultValue: "/",
23
+ },
24
+ ];
26
25
  }
27
26
 
28
27
  help() {
29
28
  return {
30
- description: ['Changes the working directory.'],
29
+ description: ["Changes the working directory."],
31
30
  examples: [
32
- 'cd coin',
33
- 'cd ../passwords',
34
- ['cd', 'moves to the root, like "cd /"'],
35
- ['cd ~', '~ is equivalent to /'],
36
- ]
37
- }
31
+ "cd coin",
32
+ "cd ../passwords",
33
+ ["cd", 'moves to the root, like "cd /"'],
34
+ ["cd ~", "~ is equivalent to /"],
35
+ ],
36
+ };
38
37
  }
39
38
 
40
39
  async cd(options) {
41
- let currentIndex = this.internalFs.treeIndex
42
- let startingPath = options.path
43
- let data = await this.internalFs.getTreeIndexAndPath(options.path)
40
+ let currentIndex = this.internalFs.treeIndex;
41
+ let startingPath = options.path;
42
+ let data = await this.internalFs.getTreeIndexAndPath(options.path);
44
43
  if (currentIndex !== data.index) {
45
- await this.internalFs.mountTree(data.index, true)
44
+ await this.internalFs.mountTree(data.index, true);
46
45
  }
47
- options.path = startingPath ? data.path : '/'
48
- let tree = data.tree
49
- let p = tree.getNormalizedPath(options.path)
46
+ options.path = startingPath ? data.path : "/";
47
+ let tree = data.tree;
48
+ let p = tree.getNormalizedPath(options.path);
50
49
  if (!p || /^(\/|~|~\/)$/.test(p)) {
51
- tree.workingNode = tree.root
52
- } else if (p === '.') {
50
+ tree.workingNode = tree.root;
51
+ } else if (p === ".") {
53
52
  // nothing
54
53
  } else {
55
- let node = tree.root.getChildFromPath(p)
54
+ let node = tree.root.getChildFromPath(p);
56
55
  if (Node.isDir(node)) {
57
- tree.workingNode = node
56
+ tree.workingNode = node;
58
57
  } else {
59
- throw new Error('You cannot cd to a file')
58
+ throw new Error("You cannot cd to a file");
60
59
  }
61
60
  }
62
61
  }
63
62
 
64
63
  async exec(options = {}) {
65
64
  if (options.help) {
66
- return this.showHelp()
65
+ return this.showHelp();
67
66
  }
68
67
  try {
69
- this.validate(options)
70
- await this.cd(options)
68
+ this.validate(options);
69
+ await this.cd(options);
71
70
  } catch (e) {
72
- this.Logger.red(e.message)
71
+ this.Logger.red(e.message);
73
72
  }
74
- await this.prompt.run()
73
+ await this.prompt.run();
75
74
  }
76
75
  }
77
76
 
78
- module.exports = Cd
79
-
80
-
77
+ module.exports = Cd;
@@ -1,106 +1,120 @@
1
- const path = require('path')
2
- const chalk = require('chalk')
3
- const {ConfigUtils} = require('@secrez/core')
4
- const ChatPrompt = require('../prompts/ChatPrompt')
5
-
6
- class Chat extends require('../Command') {
1
+ const path = require("path");
2
+ const chalk = require("chalk");
3
+ const { ConfigUtils } = require("@secrez/core");
4
+ const ChatPrompt = require("../prompts/ChatPrompt");
7
5
 
6
+ class Chat extends require("../Command") {
8
7
  setHelpAndCompletion() {
9
8
  this.cliConfig.completion.chat = {
10
9
  _func: this.selfCompletion(this),
11
- _self: this
12
- }
13
- this.cliConfig.completion.help.chat = true
10
+ _self: this,
11
+ };
12
+ this.cliConfig.completion.help.chat = true;
14
13
  this.optionDefinitions = [
15
14
  {
16
- name: 'help',
17
- alias: 'h',
18
- type: Boolean
19
- }
20
- ]
15
+ name: "help",
16
+ alias: "h",
17
+ type: Boolean,
18
+ },
19
+ ];
21
20
  }
22
21
 
23
22
  help() {
24
23
  return {
25
- description: ['Enters the Secrez chat'],
26
- examples: [
27
- 'chat'
28
- ]
29
- }
24
+ description: ["Enters the Secrez chat"],
25
+ examples: ["chat"],
26
+ };
30
27
  }
31
28
 
32
29
  async uploadUsersPublicKeysToCourier(options) {
33
- const {port, caCrt} = options.env.courier
34
- let contacts = await this.prompt.commands.contacts.contacts({list: true, asIs: true})
35
- this.contactsByPublicKey = {}
30
+ const { port, caCrt } = options.env.courier;
31
+ let contacts = await this.prompt.commands.contacts.contacts({
32
+ list: true,
33
+ asIs: true,
34
+ });
35
+ this.contactsByPublicKey = {};
36
36
  for (let contact of contacts) {
37
- this.contactsByPublicKey[contact[1].publicKey] = contact[0]
38
- await this.callCourier({
39
- action: {
40
- name: 'add',
41
- publicKey: contact[1].publicKey,
42
- url: contact[1].url
43
- }
44
- }, port, caCrt, '/admin')
37
+ this.contactsByPublicKey[contact[1].publicKey] = contact[0];
38
+ await this.callCourier(
39
+ {
40
+ action: {
41
+ name: "add",
42
+ publicKey: contact[1].publicKey,
43
+ url: contact[1].url,
44
+ },
45
+ },
46
+ port,
47
+ caCrt,
48
+ "/admin"
49
+ );
45
50
  }
46
51
  }
47
52
 
48
53
  async readHistoryMessages(options = {}) {
49
54
  /* istanbul ignore if */
50
55
  if (!options.asIs) {
51
- this.chatPrompt.skip = true
56
+ this.chatPrompt.skip = true;
52
57
  }
53
- const {minTimestamp, maxTimestamp, from, to} = options
58
+ const { minTimestamp, maxTimestamp, from, to } = options;
54
59
  /* istanbul ignore if */
55
60
  if (!options.asIs) {
56
- this.Logger.bold(from || to ? `Messages${from ? ` from ${from}` : ''}${to ? ` to ${to}` : ''}:` : 'All message history:')
61
+ this.Logger.bold(
62
+ from || to
63
+ ? `Messages${from ? ` from ${from}` : ""}${to ? ` to ${to}` : ""}:`
64
+ : "All message history:"
65
+ );
57
66
  }
58
67
  let newMessages = await this.prompt.commands.courier.getSomeMessages({
59
68
  payload: {
60
69
  minTimestamp,
61
70
  maxTimestamp,
62
71
  from: this.room[0].publicKey,
63
- limit: 1000
64
- }
65
- })
72
+ limit: 1000,
73
+ },
74
+ });
66
75
  /* istanbul ignore if */
67
76
  if (!options.asIs) {
68
- let len = newMessages.length
77
+ let len = newMessages.length;
69
78
  if (len) {
70
79
  this.chatPrompt.onMessages(newMessages, {
71
80
  fromHistory: true,
72
81
  verbose: options.verbose,
73
- lastLine: options.asIs ? undefined : chalk.grey(`${len} message${len > 1 ? 's' : ''} found.`)
74
- })
82
+ lastLine: options.asIs
83
+ ? undefined
84
+ : chalk.grey(`${len} message${len > 1 ? "s" : ""} found.`),
85
+ });
75
86
  } else {
76
- this.Logger.yellow('None found')
87
+ this.Logger.yellow("None found");
77
88
  }
78
- this.chatPrompt.skip = false
89
+ this.chatPrompt.skip = false;
79
90
  } else {
80
- return newMessages
91
+ return newMessages;
81
92
  }
82
93
  }
83
94
 
84
95
  async chat(options) {
85
- const env = options.env = await ConfigUtils.getEnv(this.secrez.config)
96
+ const env = (options.env = await ConfigUtils.getEnv(this.secrez.config));
86
97
  if (env.courier) {
87
- this.courier = await this.prompt.commands.courier
88
- await this.courier.preInit(options)
98
+ this.courier = await this.prompt.commands.courier;
99
+ await this.courier.preInit(options);
89
100
  if (options.ready) {
90
- await this.uploadUsersPublicKeysToCourier(options)
91
- if (process.env.NODE_ENV === 'test') {
92
- this.chatPrompt = options.chatPrompt
101
+ await this.uploadUsersPublicKeysToCourier(options);
102
+ if (process.env.NODE_ENV === "test") {
103
+ this.chatPrompt = options.chatPrompt;
93
104
  } else {
94
- this.chatPrompt = new ChatPrompt
105
+ this.chatPrompt = new ChatPrompt();
95
106
  }
96
107
  await this.chatPrompt.init({
97
- historyPath: path.join(this.secrez.config.localDataPath, 'chatHistory'),
108
+ historyPath: path.join(
109
+ this.secrez.config.localDataPath,
110
+ "chatHistory"
111
+ ),
98
112
  environment: this,
99
- secrez: this.secrez
100
- })
101
- await this.chatPrompt.run(options)
113
+ secrez: this.secrez,
114
+ });
115
+ await this.chatPrompt.run(options);
102
116
  } else {
103
- throw new Error('The configured courier is not responding.')
117
+ throw new Error("The configured courier is not responding.");
104
118
  }
105
119
  } else {
106
120
  this.Logger.grey(`Chat requires a courier listening locally.
@@ -112,25 +126,23 @@ and launch it as
112
126
 
113
127
  secrez-courier
114
128
 
115
- It will show the port where it is listening to. Copy it and come back to Secrez. Then run "courier" to configure the connection w/ the courier.`)
116
- throw new Error('Courier not found.')
129
+ It will show the port where it is listening to. Copy it and come back to Secrez. Then run "courier" to configure the connection w/ the courier.`);
130
+ throw new Error("Courier not found.");
117
131
  }
118
132
  }
119
133
 
120
134
  async exec(options = {}) {
121
135
  if (options.help) {
122
- return this.showHelp()
136
+ return this.showHelp();
123
137
  }
124
138
  try {
125
- await this.chat(options)
139
+ await this.chat(options);
126
140
  } catch (e) {
127
141
  // console.log(e)
128
- this.Logger.red(e.message)
142
+ this.Logger.red(e.message);
129
143
  }
130
- await this.prompt.run()
144
+ await this.prompt.run();
131
145
  }
132
146
  }
133
147
 
134
- module.exports = Chat
135
-
136
-
148
+ module.exports = Chat;