favacli 0.0.16 → 0.0.18

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,11 @@
1
+ import BaseCommand from '../../BaseCommand.mjs';
2
+ import type { PublicSyncDevice } from 'favalib';
3
+ declare class ListDevicesCommand extends BaseCommand {
4
+ static paths: string[][];
5
+ requireTwoFaLib: boolean;
6
+ static usage: import("clipanion").Usage;
7
+ exec(): Promise<{
8
+ devices: PublicSyncDevice[];
9
+ }>;
10
+ }
11
+ export default ListDevicesCommand;
@@ -0,0 +1,35 @@
1
+ import Table from 'tty-table';
2
+ import BaseCommand from '../../BaseCommand.mjs';
3
+ class ListDevicesCommand extends BaseCommand {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.requireTwoFaLib = true;
7
+ }
8
+ static { this.paths = [['sync', 'list-devices']]; }
9
+ static { this.usage = BaseCommand.Usage({
10
+ category: 'Sync',
11
+ description: 'List all devices synced to the vault',
12
+ details: `This command displays all devices that are currently synced to your vault, showing their status and last sync information.`,
13
+ examples: [['List all synced devices', 'sync list-devices']],
14
+ }); }
15
+ async exec() {
16
+ if (!this.twoFaLib.sync) {
17
+ throw new Error('No server url set');
18
+ }
19
+ const devices = this.twoFaLib.sync.getSyncDevices();
20
+ const headers = [
21
+ { value: 'deviceId', align: 'left', width: 38 },
22
+ { value: 'deviceType', align: 'left', width: 38 },
23
+ { value: 'deviceFriendlyName', align: 'left', width: 38 },
24
+ ];
25
+ const tableOptions = {
26
+ borderStyle: 'solid',
27
+ paddingLeft: 1,
28
+ paddingRight: 1,
29
+ headerAlign: 'left',
30
+ };
31
+ this.output(Table(headers, devices, [], tableOptions).render() + '\n');
32
+ return Promise.resolve({ devices });
33
+ }
34
+ }
35
+ export default ListDevicesCommand;
@@ -15,7 +15,7 @@ class ResilverCommand extends BaseCommand {
15
15
  if (!this.twoFaLib.sync) {
16
16
  throw new Error('No server url set');
17
17
  }
18
- this.twoFaLib.sync.requestResilver();
18
+ await this.twoFaLib.sync.requestResilver();
19
19
  // TODO: do this based on events
20
20
  await new Promise((resolve) => setTimeout(resolve, 5000));
21
21
  return { success: true };
@@ -0,0 +1,11 @@
1
+ import BaseCommand from '../../BaseCommand.mjs';
2
+ declare class SetFriendlyNameCommand extends BaseCommand {
3
+ static paths: string[][];
4
+ requireTwoFaLib: boolean;
5
+ static usage: import("clipanion").Usage;
6
+ name: string;
7
+ exec(): Promise<{
8
+ success: boolean;
9
+ }>;
10
+ }
11
+ export default SetFriendlyNameCommand;
@@ -0,0 +1,28 @@
1
+ import { Option } from 'clipanion';
2
+ import BaseCommand from '../../BaseCommand.mjs';
3
+ class SetFriendlyNameCommand extends BaseCommand {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.requireTwoFaLib = true;
7
+ this.name = Option.String('--name', { required: true });
8
+ }
9
+ static { this.paths = [['sync', 'set-friendly-name']]; }
10
+ static { this.usage = BaseCommand.Usage({
11
+ category: 'Sync',
12
+ description: 'Set friendly name for the current device',
13
+ details: `This command allows you to set the friendly name for the current device in your vault sync configuration.`,
14
+ examples: [
15
+ ['Set device name', 'sync set-friendly-name --name "My Laptop"'],
16
+ ['Set device name', 'sync set-friendly-name --name "Work Phone"'],
17
+ ],
18
+ }); }
19
+ async exec() {
20
+ if (!this.twoFaLib.sync) {
21
+ throw new Error('No server url set');
22
+ }
23
+ await this.twoFaLib.setDeviceFriendlyName(this.name);
24
+ this.output(`Device name set to: ${this.name}\n`);
25
+ return { success: true };
26
+ }
27
+ }
28
+ export default SetFriendlyNameCommand;
package/build/main.mjs CHANGED
@@ -8,6 +8,8 @@ import EntriesSearchCommand from './commands/entries/search.mjs';
8
8
  import SyncSetServerUrlCommand from './commands/sync/setServerUrl.mjs';
9
9
  import SyncConnect from './commands/sync/connect.mjs';
10
10
  import SyncResilver from './commands/sync/resilver.mjs';
11
+ import SyncListDevices from './commands/sync/listDevices.mjs';
12
+ import SyncSetFriendlyNameCommand from './commands/sync/setFriendlyName.mjs';
11
13
  import ExportTextCommand from './commands/export/text.mjs';
12
14
  // check node version
13
15
  const nodeRuntimeMajorVersion = parseInt(process.version.split('.')[0]);
@@ -18,7 +20,7 @@ const [, , ...args] = process.argv;
18
20
  const cli = new Cli({
19
21
  binaryLabel: 'FavaCli',
20
22
  binaryName: `favacli`,
21
- binaryVersion: '0.0.16',
23
+ binaryVersion: '0.0.18',
22
24
  });
23
25
  cli.register(VaultCreateCommand);
24
26
  cli.register(VaultDeleteCommand);
@@ -28,6 +30,8 @@ cli.register(EntriesSearchCommand);
28
30
  cli.register(SyncSetServerUrlCommand);
29
31
  cli.register(SyncConnect);
30
32
  cli.register(SyncResilver);
33
+ cli.register(SyncListDevices);
31
34
  cli.register(ExportTextCommand);
35
+ cli.register(SyncSetFriendlyNameCommand);
32
36
  cli.register(Builtins.HelpCommand);
33
37
  void cli.runExit(args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "favacli",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "author": "",
@@ -10,7 +10,7 @@
10
10
  "bufferutil": "^4.0.9",
11
11
  "clipanion": "^4.0.0-rc.4",
12
12
  "env-paths": "^3.0.0",
13
- "favalib": "^0.0.8",
13
+ "favalib": "^0.0.11",
14
14
  "keytar": "^7.9.0",
15
15
  "tty-table": "^4.2.3",
16
16
  "typanion": "^3.14.0"