favacli 0.0.12 → 0.0.14

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.
@@ -23,14 +23,12 @@ class EntriesListCommand extends BaseListOutputCommand {
23
23
  ],
24
24
  }); }
25
25
  getList() {
26
- let entries;
27
26
  if (this.withTokens) {
28
- entries = this.twoFaLib.vault.listEntriesMetas(true);
27
+ return this.twoFaLib.vault.listEntriesMetas(true);
29
28
  }
30
29
  else {
31
- entries = this.twoFaLib.vault.listEntriesMetas(false);
30
+ return this.twoFaLib.vault.listEntriesMetas(false);
32
31
  }
33
- return entries;
34
32
  }
35
33
  }
36
34
  export default EntriesListCommand;
@@ -28,14 +28,12 @@ class EntriesSearchCommand extends BaseListOutputCommand {
28
28
  ],
29
29
  }); }
30
30
  getList() {
31
- let filteredEntries;
32
31
  if (this.withTokens) {
33
- filteredEntries = this.twoFaLib.vault.searchEntriesMetas(this.query, true);
32
+ return this.twoFaLib.vault.searchEntriesMetas(this.query, true);
34
33
  }
35
34
  else {
36
- filteredEntries = this.twoFaLib.vault.searchEntriesMetas(this.query, false);
35
+ return this.twoFaLib.vault.searchEntriesMetas(this.query, false);
37
36
  }
38
- return filteredEntries;
39
37
  }
40
38
  }
41
39
  export default EntriesSearchCommand;
package/build/main.mjs CHANGED
@@ -16,7 +16,7 @@ const [, , ...args] = process.argv;
16
16
  const cli = new Cli({
17
17
  binaryLabel: 'FavaCli',
18
18
  binaryName: `favacli`,
19
- binaryVersion: '0.0.12',
19
+ binaryVersion: '0.0.14',
20
20
  });
21
21
  cli.register(VaultCreateCommand);
22
22
  cli.register(VaultDeleteCommand);
@@ -7,8 +7,21 @@ const twoFaLibVaultCreationUtils = getTwoFaLibVaultCreationUtils(cryptoLib, 'cli
7
7
  const loadVault = async (vaultData, settings, verbose = false) => {
8
8
  const passphrase = (await keytar.getPassword('favacli', 'vault-passphrase'));
9
9
  const twoFaLib = await twoFaLibVaultCreationUtils.loadTwoFaLibFromLockedRepesentation(vaultData, passphrase);
10
- twoFaLib.addEventListener(TwoFaLibEvent.Changed, (ev) => {
11
- return fs.writeFile(settings.vaultLocation, ev.detail.newLockedRepresentationString);
10
+ twoFaLib.addEventListener(TwoFaLibEvent.Changed, async (ev) => {
11
+ const tempFile = `${settings.vaultLocation}.tmp`;
12
+ try {
13
+ // Write to temporary file first, so we don't have to worry about partial writes
14
+ await fs.writeFile(tempFile, ev.detail.newLockedRepresentationString);
15
+ // Atomically rename temp file to target file
16
+ await fs.rename(tempFile, settings.vaultLocation);
17
+ }
18
+ catch (error) {
19
+ // Clean up temp file if something went wrong
20
+ await fs.unlink(tempFile).catch((err) => {
21
+ console.error(err);
22
+ });
23
+ throw error;
24
+ }
12
25
  });
13
26
  twoFaLib.addEventListener(TwoFaLibEvent.Log, (ev) => {
14
27
  if (ev.detail.severity !== 'info' || verbose) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "favacli",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "author": "",
@@ -10,7 +10,7 @@
10
10
  "bufferutil": "^4.0.8",
11
11
  "clipanion": "^4.0.0-rc.4",
12
12
  "env-paths": "^3.0.0",
13
- "favalib": "^0.0.3",
13
+ "favalib": "^0.0.4",
14
14
  "keytar": "^7.9.0",
15
15
  "node-loader": "^2.0.0",
16
16
  "ts-loader": "^9.5.1",