favacli 0.0.6 → 0.0.7

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.
@@ -1,6 +1,7 @@
1
1
  import BaseCommand from '../../BaseCommand.mjs';
2
2
  declare class EntriesAddCommand extends BaseCommand {
3
3
  static paths: string[][];
4
+ static usage: import("clipanion").Usage;
4
5
  requireTwoFaLib: boolean;
5
6
  name: string;
6
7
  issuer: string;
@@ -12,6 +12,25 @@ class EntriesAddCommand extends BaseCommand {
12
12
  this.algorithm = Option.String('--algorithm', 'SHA-1');
13
13
  }
14
14
  static { this.paths = [['entries', 'add']]; }
15
+ static { this.usage = BaseCommand.Usage({
16
+ category: 'Entries',
17
+ description: 'Add a new TOTP entry to the vault',
18
+ details: `
19
+ This command adds a new time-based one-time password (TOTP) entry to your vault.
20
+
21
+ The secret must be provided in base32 format.
22
+ `,
23
+ examples: [
24
+ [
25
+ 'Add a basic TOTP entry',
26
+ 'entries add --name "My Account" --issuer "Example.com" --secret JBSWY3DPEHPK3PXP',
27
+ ],
28
+ [
29
+ 'Add a TOTP entry with custom period and digits',
30
+ 'entries add --name "Custom Account" --issuer "Example.com" --secret AAAAAAAA --period 60 --digits 8',
31
+ ],
32
+ ],
33
+ }); }
15
34
  async exec() {
16
35
  await this.twoFaLib.vault.addEntry({
17
36
  name: this.name,
@@ -1,6 +1,7 @@
1
1
  import BaseCommand from '../../BaseCommand.mjs';
2
2
  declare class EntriesListCommand extends BaseCommand {
3
3
  static paths: string[][];
4
+ static usage: import("clipanion").Usage;
4
5
  requireTwoFaLib: boolean;
5
6
  withTokens: boolean | undefined;
6
7
  exec(): Promise<0 | readonly import("type-fest").JsonValue[]>;
@@ -10,6 +10,19 @@ class EntriesListCommand extends BaseCommand {
10
10
  });
11
11
  }
12
12
  static { this.paths = [['entries', 'list']]; }
13
+ static { this.usage = BaseCommand.Usage({
14
+ category: 'Entries',
15
+ description: 'List all stored 2FA entries',
16
+ details: `
17
+ This command displays a table of all stored two-factor authentication entries.
18
+
19
+ When used with --withTokens, it will also show the current TOTP codes for each entry.
20
+ `,
21
+ examples: [
22
+ ['List all entries', 'entries list'],
23
+ ['List entries with current TOTP tokens', 'entries list --withTokens'],
24
+ ],
25
+ }); }
13
26
  async exec() {
14
27
  let entries;
15
28
  if (this.withTokens) {
@@ -2,6 +2,7 @@ import type { JsonArray } from 'type-fest';
2
2
  import BaseCommand from '../../BaseCommand.mjs';
3
3
  declare class EntriesSearchCommand extends BaseCommand {
4
4
  static paths: string[][];
5
+ static usage: import("clipanion").Usage;
5
6
  requireTwoFaLib: boolean;
6
7
  withTokens: boolean | undefined;
7
8
  query: string;
@@ -11,6 +11,23 @@ class EntriesSearchCommand extends BaseCommand {
11
11
  this.query = Option.String({ required: true });
12
12
  }
13
13
  static { this.paths = [['entries', 'search']]; }
14
+ static { this.usage = BaseCommand.Usage({
15
+ category: 'Entries',
16
+ description: 'Search for stored 2FA entries',
17
+ details: `
18
+ This command searches through all stored two-factor authentication entries.
19
+
20
+ The search query will match against entry names and issuers.
21
+ When used with --withTokens, it will also show the current TOTP codes for matching entries.
22
+ `,
23
+ examples: [
24
+ ['Search for entries containing "google"', 'entries search google'],
25
+ [
26
+ 'Search and show current TOTP tokens',
27
+ 'entries search google --withTokens',
28
+ ],
29
+ ],
30
+ }); }
14
31
  async exec() {
15
32
  let filteredEntries;
16
33
  if (this.withTokens) {
@@ -2,6 +2,7 @@ import BaseCommand from '../../BaseCommand.mjs';
2
2
  declare class ConnectCommand extends BaseCommand {
3
3
  static paths: string[][];
4
4
  requireTwoFaLib: boolean;
5
+ static usage: import("clipanion").Usage;
5
6
  exec(): Promise<{
6
7
  success: boolean;
7
8
  }>;
@@ -7,6 +7,16 @@ class ConnectCommand extends BaseCommand {
7
7
  this.requireTwoFaLib = true;
8
8
  }
9
9
  static { this.paths = [['sync', 'connect']]; }
10
+ static { this.usage = BaseCommand.Usage({
11
+ category: 'Sync',
12
+ description: 'Connect to an existing vault using a connection string',
13
+ details: `
14
+ This command allows you to connect to an existing vault by providing a connection string.
15
+
16
+ The connection string should be obtained from the device that hosts the vault you want to connect to.
17
+ `,
18
+ examples: [['Connect to an existing vault', 'sync connect']],
19
+ }); }
10
20
  async exec() {
11
21
  if (!this.twoFaLib.sync) {
12
22
  throw new Error('No server url set');
@@ -1,6 +1,7 @@
1
1
  import BaseCommand from '../../BaseCommand.mjs';
2
2
  declare class SetServerUrlCommand extends BaseCommand {
3
3
  static paths: string[][];
4
+ static usage: import("clipanion").Usage;
4
5
  requireTwoFaLib: boolean;
5
6
  serverUrl: string;
6
7
  exec(): Promise<{
@@ -7,6 +7,18 @@ class SetServerUrlCommand extends BaseCommand {
7
7
  this.serverUrl = Option.String({ required: true });
8
8
  }
9
9
  static { this.paths = [['sync', 'setServerUrl']]; }
10
+ static { this.usage = BaseCommand.Usage({
11
+ category: 'Sync',
12
+ description: 'Set the server URL for syncing',
13
+ details: `
14
+ This command sets the URL of the server that will be used for syncing.
15
+
16
+ The server URL must be provided as an argument.
17
+ `,
18
+ examples: [
19
+ ['Set sync server URL', 'sync setServerUrl https://example.com'],
20
+ ],
21
+ }); }
10
22
  async exec() {
11
23
  await this.twoFaLib.setSyncServerUrl(this.serverUrl);
12
24
  return { success: true };
@@ -2,6 +2,7 @@ import BaseCommand from '../../BaseCommand.mjs';
2
2
  declare class VaultCreateCommand extends BaseCommand {
3
3
  static paths: string[][];
4
4
  requireTwoFaLib: boolean;
5
+ static usage: import("clipanion").Usage;
5
6
  exec(): Promise<{
6
7
  success: boolean;
7
8
  }>;
@@ -12,6 +12,17 @@ class VaultCreateCommand extends BaseCommand {
12
12
  this.requireTwoFaLib = false;
13
13
  }
14
14
  static { this.paths = [['vault', 'create']]; }
15
+ static { this.usage = BaseCommand.Usage({
16
+ category: 'Vault',
17
+ description: 'Create a new encrypted vault',
18
+ details: `
19
+ This command creates a new encrypted vault file to store your 2FA entries.
20
+
21
+ You will be prompted to enter a passphrase that will be used to encrypt the vault.
22
+ The passphrase will be securely stored in your system's keychain.
23
+ `,
24
+ examples: [['Create a new vault', 'vault create']],
25
+ }); }
15
26
  async exec() {
16
27
  const passphrase = (await password({
17
28
  message: 'Enter your vault passphrase:',
package/build/main.mjs CHANGED
@@ -1,16 +1,21 @@
1
1
  #!/usr/bin/env node
2
- import { Cli } from 'clipanion';
2
+ import { Cli, Builtins } from 'clipanion';
3
3
  import VaultCreateCommand from './commands/vault/create.mjs';
4
4
  import EntriesAddCommand from './commands/entries/add.mjs';
5
5
  import EntriesListCommand from './commands/entries/list.mjs';
6
6
  import EntriesSearchCommand from './commands/entries/search.mjs';
7
7
  import SyncSetServerUrlCommand from './commands/sync/setServerUrl.mjs';
8
8
  import SyncConnect from './commands/sync/connect.mjs';
9
- const [node, app, ...args] = process.argv;
9
+ // check node version
10
+ const nodeRuntimeMajorVersion = parseInt(process.version.split('.')[0]);
11
+ if (nodeRuntimeMajorVersion < 20) {
12
+ throw new Error('Node.js version must be 20 or higher');
13
+ }
14
+ const [...args] = process.argv;
10
15
  const cli = new Cli({
11
- binaryLabel: `My Application`,
12
- binaryName: `${node} ${app}`,
13
- binaryVersion: `1.0.0`,
16
+ binaryLabel: 'FavaCli',
17
+ binaryName: `favacli`,
18
+ binaryVersion: '0.0.7',
14
19
  });
15
20
  cli.register(VaultCreateCommand);
16
21
  cli.register(EntriesAddCommand);
@@ -18,4 +23,9 @@ cli.register(EntriesListCommand);
18
23
  cli.register(EntriesSearchCommand);
19
24
  cli.register(SyncSetServerUrlCommand);
20
25
  cli.register(SyncConnect);
26
+ cli.register(Builtins.HelpCommand);
27
+ if (args[0].endsWith('node')) {
28
+ args.splice(0, 1);
29
+ args.splice(0, 1);
30
+ }
21
31
  void cli.runExit(args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "favacli",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "author": "",
@@ -25,5 +25,8 @@
25
25
  },
26
26
  "files": [
27
27
  "/build"
28
- ]
28
+ ],
29
+ "engines": {
30
+ "node": ">=20"
31
+ }
29
32
  }