favacli 0.0.23 → 0.0.24
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.
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import BaseCommand from '../../BaseCommand.mjs';
|
|
2
|
+
declare class EntriesGetTokenByIdCommand extends BaseCommand {
|
|
3
|
+
static paths: string[][];
|
|
4
|
+
static usage: import("clipanion").Usage;
|
|
5
|
+
requireFavaLib: boolean;
|
|
6
|
+
id: string;
|
|
7
|
+
exec(): Promise<string | null>;
|
|
8
|
+
}
|
|
9
|
+
export default EntriesGetTokenByIdCommand;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Option } from 'clipanion';
|
|
2
|
+
import { EntryNotFoundError } from 'favalib';
|
|
3
|
+
import BaseCommand from '../../BaseCommand.mjs';
|
|
4
|
+
class EntriesGetTokenByIdCommand extends BaseCommand {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.requireFavaLib = true;
|
|
8
|
+
this.id = Option.String({ required: true });
|
|
9
|
+
}
|
|
10
|
+
static { this.paths = [['entries', 'get-token-by-id']]; }
|
|
11
|
+
static { this.usage = BaseCommand.Usage({
|
|
12
|
+
category: 'Entries',
|
|
13
|
+
description: 'Get the current TOTP token for an entry by its id',
|
|
14
|
+
details: `
|
|
15
|
+
This command generates and prints the current TOTP code for a single
|
|
16
|
+
entry, identified by its id.
|
|
17
|
+
`,
|
|
18
|
+
examples: [
|
|
19
|
+
['Get the current token for an entry', 'entries get-token-by-id <id>'],
|
|
20
|
+
],
|
|
21
|
+
}); }
|
|
22
|
+
async exec() {
|
|
23
|
+
const id = this.id;
|
|
24
|
+
try {
|
|
25
|
+
const token = await this.favaLib.vault.generateTokenForEntry(id);
|
|
26
|
+
this.output(`${token.otp}\n`);
|
|
27
|
+
return token.otp;
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
if (err instanceof EntryNotFoundError) {
|
|
31
|
+
this.output(`No entry found with id ${this.id}\n`);
|
|
32
|
+
this.errors.push({ timestamp: Date.now(), message: err.message });
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export default EntriesGetTokenByIdCommand;
|
package/build/main.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import VaultRestorePasswordCommand from './commands/vault/restorePassword.mjs';
|
|
|
6
6
|
import EntriesAddCommand from './commands/entries/add.mjs';
|
|
7
7
|
import EntriesListCommand from './commands/entries/list.mjs';
|
|
8
8
|
import EntriesSearchCommand from './commands/entries/search.mjs';
|
|
9
|
+
import EntriesGetTokenByIdCommand from './commands/entries/getTokenById.mjs';
|
|
9
10
|
import SyncSetServerUrlCommand from './commands/sync/setServerUrl.mjs';
|
|
10
11
|
import SyncConnect from './commands/sync/connect.mjs';
|
|
11
12
|
import SyncResilver from './commands/sync/resilver.mjs';
|
|
@@ -23,7 +24,7 @@ const [, , ...args] = process.argv;
|
|
|
23
24
|
const cli = new Cli({
|
|
24
25
|
binaryLabel: 'FavaCli',
|
|
25
26
|
binaryName: `favacli`,
|
|
26
|
-
binaryVersion: '0.0.
|
|
27
|
+
binaryVersion: '0.0.24',
|
|
27
28
|
});
|
|
28
29
|
cli.register(VaultCreateCommand);
|
|
29
30
|
cli.register(VaultDeleteCommand);
|
|
@@ -31,6 +32,7 @@ cli.register(VaultRestorePasswordCommand);
|
|
|
31
32
|
cli.register(EntriesAddCommand);
|
|
32
33
|
cli.register(EntriesListCommand);
|
|
33
34
|
cli.register(EntriesSearchCommand);
|
|
35
|
+
cli.register(EntriesGetTokenByIdCommand);
|
|
34
36
|
cli.register(SyncSetServerUrlCommand);
|
|
35
37
|
cli.register(SyncConnect);
|
|
36
38
|
cli.register(SyncResilver);
|