favacli 0.0.10 → 0.0.12
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/build/BaseListOutputCommand.d.mts +7 -3
- package/build/commands/sync/setServerUrl.d.mts +1 -0
- package/build/commands/sync/setServerUrl.mjs +5 -2
- package/build/commands/vault/delete.d.mts +1 -0
- package/build/commands/vault/delete.mjs +13 -7
- package/build/formatters/alfred.mjs +7 -5
- package/build/main.mjs +1 -1
- package/package.json +2 -2
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { EntryMeta, EntryMetaWithToken } from 'favalib';
|
|
2
2
|
import BaseCommand from './BaseCommand.mjs';
|
|
3
3
|
import formatters from './formatters/index.mjs';
|
|
4
|
-
import {
|
|
5
|
-
export type Formatter = (entries: (EntryMeta | EntryMetaWithToken)[]) =>
|
|
4
|
+
import { Jsonifiable } from 'type-fest';
|
|
5
|
+
export type Formatter = (entries: (EntryMeta | EntryMetaWithToken)[]) => Jsonifiable;
|
|
6
6
|
declare abstract class BaseListOutputCommand extends BaseCommand {
|
|
7
7
|
abstract getList(): EntryMeta[] | EntryMetaWithToken[];
|
|
8
8
|
format: (typeof formatters)[0]["name"] | undefined;
|
|
9
|
-
exec(): Promise<
|
|
9
|
+
exec(): Promise<string | number | boolean | {
|
|
10
|
+
[x: string]: Jsonifiable | undefined;
|
|
11
|
+
} | {
|
|
12
|
+
toJSON: () => Jsonifiable;
|
|
13
|
+
} | import("type-fest/source/jsonifiable.js").JsonifiableArray | null>;
|
|
10
14
|
}
|
|
11
15
|
export default BaseListOutputCommand;
|
|
@@ -5,6 +5,9 @@ class SetServerUrlCommand extends BaseCommand {
|
|
|
5
5
|
super(...arguments);
|
|
6
6
|
this.requireTwoFaLib = true;
|
|
7
7
|
this.serverUrl = Option.String({ required: true });
|
|
8
|
+
this.force = Option.Boolean('--force', {
|
|
9
|
+
description: 'Set serverUrl even if connection fails',
|
|
10
|
+
});
|
|
8
11
|
}
|
|
9
12
|
static { this.paths = [['sync', 'setServerUrl']]; }
|
|
10
13
|
static { this.usage = BaseCommand.Usage({
|
|
@@ -12,7 +15,7 @@ class SetServerUrlCommand extends BaseCommand {
|
|
|
12
15
|
description: 'Set the server URL for syncing',
|
|
13
16
|
details: `
|
|
14
17
|
This command sets the URL of the server that will be used for syncing.
|
|
15
|
-
|
|
18
|
+
|
|
16
19
|
The server URL must be provided as an argument.
|
|
17
20
|
`,
|
|
18
21
|
examples: [
|
|
@@ -20,7 +23,7 @@ class SetServerUrlCommand extends BaseCommand {
|
|
|
20
23
|
],
|
|
21
24
|
}); }
|
|
22
25
|
async exec() {
|
|
23
|
-
await this.twoFaLib.setSyncServerUrl(this.serverUrl);
|
|
26
|
+
await this.twoFaLib.setSyncServerUrl(this.serverUrl, this.force);
|
|
24
27
|
return { success: true };
|
|
25
28
|
}
|
|
26
29
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
|
+
import { Option } from 'clipanion';
|
|
2
3
|
import { confirm } from '@inquirer/prompts';
|
|
3
4
|
import BaseCommand from '../../BaseCommand.mjs';
|
|
4
5
|
class VaultDeleteCommand extends BaseCommand {
|
|
5
6
|
constructor() {
|
|
6
7
|
super(...arguments);
|
|
7
8
|
this.requireTwoFaLib = false;
|
|
9
|
+
this.force = Option.Boolean('--force', {
|
|
10
|
+
description: 'Delete the vault without confirmation',
|
|
11
|
+
});
|
|
8
12
|
}
|
|
9
13
|
static { this.paths = [['vault', 'delete']]; }
|
|
10
14
|
static { this.usage = BaseCommand.Usage({
|
|
@@ -17,13 +21,15 @@ class VaultDeleteCommand extends BaseCommand {
|
|
|
17
21
|
examples: [['Delete the current vault', 'vault delete']],
|
|
18
22
|
}); }
|
|
19
23
|
async exec() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
if (!this.force) {
|
|
25
|
+
const shouldDelete = await confirm({
|
|
26
|
+
message: 'Are you sure you want to delete the vault? This action cannot be undone.',
|
|
27
|
+
default: false,
|
|
28
|
+
});
|
|
29
|
+
if (!shouldDelete) {
|
|
30
|
+
this.output('Vault deletion cancelled.\n');
|
|
31
|
+
return { success: false, cancelled: true };
|
|
32
|
+
}
|
|
27
33
|
}
|
|
28
34
|
await fs.rm(this.settings.vaultLocation);
|
|
29
35
|
this.output('Vault deleted successfully.\n');
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
const alfredFormatter = (entries) =>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const alfredFormatter = (entries) => ({
|
|
2
|
+
items: entries.map((entry) => ({
|
|
3
|
+
title: entry.issuer,
|
|
4
|
+
subtitle: entry.name,
|
|
5
|
+
arg: entry.token?.otp,
|
|
6
|
+
})),
|
|
7
|
+
});
|
|
6
8
|
export default { name: 'alfred', formatter: alfredFormatter };
|
package/build/main.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "favacli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
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.
|
|
13
|
+
"favalib": "^0.0.3",
|
|
14
14
|
"keytar": "^7.9.0",
|
|
15
15
|
"node-loader": "^2.0.0",
|
|
16
16
|
"ts-loader": "^9.5.1",
|