@zincapp/znvault-cli 2.23.0 → 2.24.0

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.
Files changed (61) hide show
  1. package/dist/commands/host/bootstrap-token.d.ts +6 -0
  2. package/dist/commands/host/bootstrap-token.d.ts.map +1 -0
  3. package/dist/commands/host/bootstrap-token.js +64 -0
  4. package/dist/commands/host/bootstrap-token.js.map +1 -0
  5. package/dist/commands/host/config.d.ts +6 -0
  6. package/dist/commands/host/config.d.ts.map +1 -0
  7. package/dist/commands/host/config.js +140 -0
  8. package/dist/commands/host/config.js.map +1 -0
  9. package/dist/commands/host/create.d.ts +6 -0
  10. package/dist/commands/host/create.d.ts.map +1 -0
  11. package/dist/commands/host/create.js +69 -0
  12. package/dist/commands/host/create.js.map +1 -0
  13. package/dist/commands/host/delete.d.ts +6 -0
  14. package/dist/commands/host/delete.d.ts.map +1 -0
  15. package/dist/commands/host/delete.js +59 -0
  16. package/dist/commands/host/delete.js.map +1 -0
  17. package/dist/commands/host/get.d.ts +10 -0
  18. package/dist/commands/host/get.d.ts.map +1 -0
  19. package/dist/commands/host/get.js +79 -0
  20. package/dist/commands/host/get.js.map +1 -0
  21. package/dist/commands/host/helpers.d.ts +33 -0
  22. package/dist/commands/host/helpers.d.ts.map +1 -0
  23. package/dist/commands/host/helpers.js +197 -0
  24. package/dist/commands/host/helpers.js.map +1 -0
  25. package/dist/commands/host/index.d.ts +7 -0
  26. package/dist/commands/host/index.d.ts.map +1 -0
  27. package/dist/commands/host/index.js +34 -0
  28. package/dist/commands/host/index.js.map +1 -0
  29. package/dist/commands/host/list.d.ts +10 -0
  30. package/dist/commands/host/list.d.ts.map +1 -0
  31. package/dist/commands/host/list.js +100 -0
  32. package/dist/commands/host/list.js.map +1 -0
  33. package/dist/commands/host/sync.d.ts +6 -0
  34. package/dist/commands/host/sync.d.ts.map +1 -0
  35. package/dist/commands/host/sync.js +61 -0
  36. package/dist/commands/host/sync.js.map +1 -0
  37. package/dist/commands/host/types.d.ts +197 -0
  38. package/dist/commands/host/types.d.ts.map +1 -0
  39. package/dist/commands/host/types.js +4 -0
  40. package/dist/commands/host/types.js.map +1 -0
  41. package/dist/commands/quarantine.d.ts +3 -0
  42. package/dist/commands/quarantine.d.ts.map +1 -0
  43. package/dist/commands/quarantine.js +400 -0
  44. package/dist/commands/quarantine.js.map +1 -0
  45. package/dist/index.js +4 -0
  46. package/dist/index.js.map +1 -1
  47. package/dist/lib/client/index.d.ts +18 -0
  48. package/dist/lib/client/index.d.ts.map +1 -1
  49. package/dist/lib/client/index.js +15 -0
  50. package/dist/lib/client/index.js.map +1 -1
  51. package/dist/lib/client/quarantine.d.ts +61 -0
  52. package/dist/lib/client/quarantine.d.ts.map +1 -0
  53. package/dist/lib/client/quarantine.js +97 -0
  54. package/dist/lib/client/quarantine.js.map +1 -0
  55. package/dist/lib/mode.d.ts +4 -0
  56. package/dist/lib/mode.d.ts.map +1 -1
  57. package/dist/lib/mode.js +9 -0
  58. package/dist/lib/mode.js.map +1 -1
  59. package/dist/types/index.d.ts +64 -0
  60. package/dist/types/index.d.ts.map +1 -1
  61. package/package.json +1 -1
@@ -0,0 +1,197 @@
1
+ // Path: src/commands/host/helpers.ts
2
+ // Helper functions for host management commands
3
+ /**
4
+ * ANSI color codes
5
+ */
6
+ const COLORS = {
7
+ green: '\x1b[32m',
8
+ red: '\x1b[31m',
9
+ yellow: '\x1b[33m',
10
+ cyan: '\x1b[36m',
11
+ gray: '\x1b[90m',
12
+ reset: '\x1b[0m',
13
+ };
14
+ /**
15
+ * Format host status with color
16
+ */
17
+ export function formatStatus(status) {
18
+ switch (status) {
19
+ case 'active':
20
+ return `${COLORS.green}active${COLORS.reset}`;
21
+ case 'disabled':
22
+ return `${COLORS.red}disabled${COLORS.reset}`;
23
+ case 'pending':
24
+ return `${COLORS.yellow}pending${COLORS.reset}`;
25
+ default:
26
+ return status;
27
+ }
28
+ }
29
+ /**
30
+ * Format relative time (e.g., "5m ago", "2h ago", "3d ago")
31
+ */
32
+ export function formatRelativeTime(dateString) {
33
+ if (!dateString)
34
+ return '-';
35
+ const date = new Date(dateString);
36
+ const now = new Date();
37
+ const diffMs = now.getTime() - date.getTime();
38
+ const diffSecs = Math.floor(diffMs / 1000);
39
+ const diffMins = Math.floor(diffSecs / 60);
40
+ const diffHours = Math.floor(diffMins / 60);
41
+ const diffDays = Math.floor(diffHours / 24);
42
+ if (diffSecs < 60)
43
+ return 'just now';
44
+ if (diffMins < 60)
45
+ return `${diffMins}m ago`;
46
+ if (diffHours < 24)
47
+ return `${diffHours}h ago`;
48
+ if (diffDays < 30)
49
+ return `${diffDays}d ago`;
50
+ return date.toLocaleDateString();
51
+ }
52
+ /**
53
+ * Format config summary for display
54
+ */
55
+ export function formatConfigSummary(config) {
56
+ const parts = [];
57
+ const certCount = config.targets?.length ?? 0;
58
+ const secretCount = config.secretTargets?.length ?? 0;
59
+ const pluginCount = config.plugins?.filter((p) => p.enabled !== false).length ?? 0;
60
+ if (certCount > 0)
61
+ parts.push(`${certCount} cert(s)`);
62
+ if (secretCount > 0)
63
+ parts.push(`${secretCount} secret(s)`);
64
+ if (pluginCount > 0)
65
+ parts.push(`${pluginCount} plugin(s)`);
66
+ if (config.exec)
67
+ parts.push('exec mode');
68
+ return parts.length > 0 ? parts.join(', ') : 'empty';
69
+ }
70
+ /**
71
+ * Validate hostname format
72
+ */
73
+ export function validateHostname(hostname) {
74
+ if (!hostname || hostname.length === 0) {
75
+ return { valid: false, error: 'Hostname is required' };
76
+ }
77
+ // Basic hostname validation (RFC 1123)
78
+ const hostnameRegex = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
79
+ if (!hostnameRegex.test(hostname)) {
80
+ return { valid: false, error: 'Invalid hostname format (must be valid DNS name)' };
81
+ }
82
+ if (hostname.length > 253) {
83
+ return { valid: false, error: 'Hostname too long (max 253 characters)' };
84
+ }
85
+ return { valid: true };
86
+ }
87
+ /**
88
+ * Parse duration string to ISO date (e.g., "1h", "24h", "7d")
89
+ */
90
+ export function parseDuration(duration) {
91
+ const match = duration.match(/^(\d+)([hmd])$/);
92
+ if (!match) {
93
+ throw new Error(`Invalid duration format: ${duration}. Use format like '1h', '24h', '7d'`);
94
+ }
95
+ const value = parseInt(match[1], 10);
96
+ const unit = match[2];
97
+ const now = new Date();
98
+ switch (unit) {
99
+ case 'h':
100
+ now.setHours(now.getHours() + value);
101
+ break;
102
+ case 'd':
103
+ now.setDate(now.getDate() + value);
104
+ break;
105
+ case 'm':
106
+ now.setMinutes(now.getMinutes() + value);
107
+ break;
108
+ default:
109
+ throw new Error(`Invalid duration unit: ${unit}`);
110
+ }
111
+ return now;
112
+ }
113
+ /**
114
+ * Pretty print config as YAML-like format
115
+ */
116
+ export function formatConfigYaml(config, indent = 0) {
117
+ const lines = [];
118
+ const prefix = ' '.repeat(indent);
119
+ if (config.targets && config.targets.length > 0) {
120
+ lines.push(`${prefix}targets:`);
121
+ for (const target of config.targets) {
122
+ lines.push(`${prefix} - certId: ${target.certId}`);
123
+ lines.push(`${prefix} name: ${target.name}`);
124
+ if (target.outputs.combined) {
125
+ lines.push(`${prefix} combined: ${target.outputs.combined}`);
126
+ }
127
+ if (target.outputs.cert) {
128
+ lines.push(`${prefix} cert: ${target.outputs.cert}`);
129
+ }
130
+ if (target.outputs.key) {
131
+ lines.push(`${prefix} key: ${target.outputs.key}`);
132
+ }
133
+ }
134
+ }
135
+ if (config.secretTargets && config.secretTargets.length > 0) {
136
+ lines.push(`${prefix}secretTargets:`);
137
+ for (const target of config.secretTargets) {
138
+ lines.push(`${prefix} - secretId: ${target.secretId}`);
139
+ lines.push(`${prefix} name: ${target.name}`);
140
+ lines.push(`${prefix} format: ${target.format}`);
141
+ if (target.output) {
142
+ lines.push(`${prefix} output: ${target.output}`);
143
+ }
144
+ }
145
+ }
146
+ if (config.plugins && config.plugins.length > 0) {
147
+ lines.push(`${prefix}plugins:`);
148
+ for (const plugin of config.plugins) {
149
+ const name = plugin.package ?? plugin.path ?? 'unknown';
150
+ const enabled = plugin.enabled !== false ? 'enabled' : 'disabled';
151
+ lines.push(`${prefix} - ${name} (${enabled})`);
152
+ }
153
+ }
154
+ if (config.exec) {
155
+ lines.push(`${prefix}exec:`);
156
+ lines.push(`${prefix} command: ${config.exec.command.join(' ')}`);
157
+ if (config.exec.secrets.length > 0) {
158
+ lines.push(`${prefix} secrets: ${config.exec.secrets.length} mapping(s)`);
159
+ }
160
+ }
161
+ if (config.globalReloadCmd) {
162
+ lines.push(`${prefix}globalReloadCmd: ${config.globalReloadCmd}`);
163
+ }
164
+ if (config.pollInterval) {
165
+ lines.push(`${prefix}pollInterval: ${config.pollInterval}s`);
166
+ }
167
+ return lines.length > 0 ? lines.join('\n') : `${prefix}(empty config)`;
168
+ }
169
+ /**
170
+ * Print host details in a formatted way
171
+ */
172
+ export function printHostDetails(host) {
173
+ console.log();
174
+ console.log(`${COLORS.cyan}Host: ${host.hostname}${COLORS.reset}`);
175
+ console.log('─'.repeat(50));
176
+ console.log(` ID: ${host.id}`);
177
+ console.log(` Status: ${formatStatus(host.status)}`);
178
+ console.log(` Tenant: ${host.tenantId}`);
179
+ console.log(` Version: ${host.version}`);
180
+ if (host.description) {
181
+ console.log(` Description: ${host.description}`);
182
+ }
183
+ if (host.managedKeyName) {
184
+ console.log(` Managed Key: ${host.managedKeyName}`);
185
+ }
186
+ console.log(` Created: ${formatRelativeTime(host.createdAt)} by ${host.createdBy}`);
187
+ console.log(` Updated: ${formatRelativeTime(host.updatedAt)}${host.updatedBy ? ` by ${host.updatedBy}` : ''}`);
188
+ console.log(` Last Pull: ${formatRelativeTime(host.lastPulledAt)}`);
189
+ if (host.lastPulledByAgentId) {
190
+ console.log(` Pulled By: ${host.lastPulledByAgentId.substring(0, 8)}...`);
191
+ }
192
+ console.log();
193
+ console.log(`${COLORS.gray}Configuration:${COLORS.reset}`);
194
+ console.log(formatConfigYaml(host.config, 1));
195
+ console.log();
196
+ }
197
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/commands/host/helpers.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,gDAAgD;AAIhD;;GAEG;AACH,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,UAAU;IACjB,GAAG,EAAE,UAAU;IACf,MAAM,EAAE,UAAU;IAClB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,SAAS;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAkB;IAC7C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,GAAG,MAAM,CAAC,KAAK,SAAS,MAAM,CAAC,KAAK,EAAE,CAAC;QAChD,KAAK,UAAU;YACb,OAAO,GAAG,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,KAAK,EAAE,CAAC;QAChD,KAAK,SAAS;YACZ,OAAO,GAAG,MAAM,CAAC,MAAM,UAAU,MAAM,CAAC,KAAK,EAAE,CAAC;QAClD;YACE,OAAO,MAAM,CAAC;IAClB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAA8B;IAC/D,IAAI,CAAC,UAAU;QAAE,OAAO,GAAG,CAAC;IAE5B,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;IAClC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC;IAC3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/E,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,iBAAiB,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * Register all host management commands
4
+ */
5
+ export declare function registerHostCommands(program: Command): void;
6
+ export * from './types.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/host/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASzC;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsB3D;AAGD,cAAc,YAAY,CAAC"}
@@ -0,0 +1,34 @@
1
+ // Path: src/commands/host/index.ts
2
+ // Host management commands for unified agent deployment
3
+ import { registerListCommand, registerStatsCommand } from './list.js';
4
+ import { registerCreateCommand } from './create.js';
5
+ import { registerGetCommand, registerOutdatedAgentsCommand } from './get.js';
6
+ import { registerConfigCommand } from './config.js';
7
+ import { registerDeleteCommand } from './delete.js';
8
+ import { registerBootstrapTokenCommand } from './bootstrap-token.js';
9
+ import { registerSyncCommand } from './sync.js';
10
+ /**
11
+ * Register all host management commands
12
+ */
13
+ export function registerHostCommands(program) {
14
+ const hostCmd = program
15
+ .command('host')
16
+ .alias('hosts')
17
+ .description('Manage host configurations for unified agent deployment');
18
+ // List and stats
19
+ registerListCommand(hostCmd);
20
+ registerStatsCommand(hostCmd);
21
+ // CRUD operations
22
+ registerCreateCommand(hostCmd);
23
+ registerGetCommand(hostCmd);
24
+ registerConfigCommand(hostCmd);
25
+ registerDeleteCommand(hostCmd);
26
+ // Bootstrap and sync
27
+ registerBootstrapTokenCommand(hostCmd);
28
+ registerSyncCommand(hostCmd);
29
+ // Utility commands
30
+ registerOutdatedAgentsCommand(hostCmd);
31
+ }
32
+ // Re-export types
33
+ export * from './types.js';
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/host/index.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,wDAAwD;AAGxD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,MAAM,OAAO,GAAG,OAAO;SACpB,OAAO,CAAC,MAAM,CAAC;SACf,KAAK,CAAC,OAAO,CAAC;SACd,WAAW,CAAC,yDAAyD,CAAC,CAAC;IAE1E,iBAAiB;IACjB,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC7B,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAE9B,kBAAkB;IAClB,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC/B,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC5B,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC/B,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAE/B,qBAAqB;IACrB,6BAA6B,CAAC,OAAO,CAAC,CAAC;IACvC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAE7B,mBAAmB;IACnB,6BAA6B,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,kBAAkB;AAClB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * Register the list command
4
+ */
5
+ export declare function registerListCommand(parentCmd: Command): void;
6
+ /**
7
+ * Register the stats command
8
+ */
9
+ export declare function registerStatsCommand(parentCmd: Command): void;
10
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/host/list.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CA6D5D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAkC7D"}
@@ -0,0 +1,100 @@
1
+ // Path: src/commands/host/list.ts
2
+ // List host configurations
3
+ import ora from 'ora';
4
+ import * as mode from '../../lib/mode.js';
5
+ import * as output from '../../lib/output.js';
6
+ import { formatStatus, formatRelativeTime, formatConfigSummary } from './helpers.js';
7
+ /**
8
+ * Register the list command
9
+ */
10
+ export function registerListCommand(parentCmd) {
11
+ parentCmd
12
+ .command('list')
13
+ .alias('ls')
14
+ .description('List all host configurations')
15
+ .option('--status <status>', 'Filter by status (active, disabled, pending)')
16
+ .option('-t, --tenant <tenantId>', 'Filter by tenant (superadmin only)')
17
+ .option('--json', 'Output as JSON')
18
+ .option('--page <number>', 'Page number', '1')
19
+ .option('--page-size <number>', 'Items per page', '50')
20
+ .action(async (options) => {
21
+ const spinner = ora('Fetching host configurations...').start();
22
+ try {
23
+ const params = new URLSearchParams();
24
+ if (options.status)
25
+ params.set('status', options.status);
26
+ if (options.tenant)
27
+ params.set('tenantId', options.tenant);
28
+ params.set('page', String(options.page ?? 1));
29
+ params.set('pageSize', String(options.pageSize ?? 50));
30
+ const query = params.toString();
31
+ const response = await mode.apiGet(`/v1/hosts${query ? `?${query}` : ''}`);
32
+ spinner.stop();
33
+ if (options.json) {
34
+ output.json(response);
35
+ return;
36
+ }
37
+ if (response.items.length === 0) {
38
+ console.log('No host configurations found.');
39
+ console.log();
40
+ console.log('Create one with: znvault host create <hostname>');
41
+ return;
42
+ }
43
+ console.log(`Found ${response.pagination.totalItems} host(s) (page ${response.pagination.page}/${response.pagination.totalPages})`);
44
+ console.log();
45
+ output.table(['Hostname', 'Status', 'Version', 'Config', 'Last Pull', 'Managed Key'], response.items.map((host) => [
46
+ host.hostname,
47
+ formatStatus(host.status),
48
+ String(host.version),
49
+ formatConfigSummary(host.config),
50
+ formatRelativeTime(host.lastPulledAt),
51
+ host.managedKeyName ?? '-',
52
+ ]));
53
+ }
54
+ catch (err) {
55
+ spinner.fail('Failed to list hosts');
56
+ output.error(err instanceof Error ? err.message : String(err));
57
+ process.exit(1);
58
+ }
59
+ finally {
60
+ await mode.closeLocalClient();
61
+ }
62
+ });
63
+ }
64
+ /**
65
+ * Register the stats command
66
+ */
67
+ export function registerStatsCommand(parentCmd) {
68
+ parentCmd
69
+ .command('stats')
70
+ .description('Show host configuration statistics')
71
+ .option('--json', 'Output as JSON')
72
+ .action(async (options) => {
73
+ const spinner = ora('Fetching statistics...').start();
74
+ try {
75
+ const response = await mode.apiGet('/v1/hosts/stats');
76
+ spinner.stop();
77
+ if (options.json) {
78
+ output.json(response);
79
+ return;
80
+ }
81
+ console.log('Host Configuration Statistics');
82
+ console.log('─'.repeat(35));
83
+ console.log(` Total hosts: ${response.total}`);
84
+ console.log(` Active: ${response.byStatus.active ?? 0}`);
85
+ console.log(` Disabled: ${response.byStatus.disabled ?? 0}`);
86
+ console.log(` Pending: ${response.byStatus.pending ?? 0}`);
87
+ console.log(` Recently pulled: ${response.recentlyPulled}`);
88
+ console.log(` Avg version: ${response.averageVersion.toFixed(1)}`);
89
+ }
90
+ catch (err) {
91
+ spinner.fail('Failed to get statistics');
92
+ output.error(err instanceof Error ? err.message : String(err));
93
+ process.exit(1);
94
+ }
95
+ finally {
96
+ await mode.closeLocalClient();
97
+ }
98
+ });
99
+ }
100
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/host/list.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,2BAA2B;AAG3B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAErF;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAkB;IACpD,SAAS;SACN,OAAO,CAAC,MAAM,CAAC;SACf,KAAK,CAAC,IAAI,CAAC;SACX,WAAW,CAAC,8BAA8B,CAAC;SAC3C,MAAM,CAAC,mBAAmB,EAAE,8CAA8C,CAAC;SAC3E,MAAM,CAAC,yBAAyB,EAAE,oCAAoC,CAAC;SACvE,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,iBAAiB,EAAE,aAAa,EAAE,GAAG,CAAC;SAC7C,MAAM,CAAC,sBAAsB,EAAE,gBAAgB,EAAE,IAAI,CAAC;SACtD,MAAM,CAAC,KAAK,EAAE,OAAoB,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,GAAG,CAAC,iCAAiC,CAAC,CAAC,KAAK,EAAE,CAAC;QAE/D,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;YACrC,IAAI,OAAO,CAAC,MAAM;gBAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YACzD,IAAI,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CAAC;YAED,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,uBAAuB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;YACrD,OAAO,CAAC,GAAG,CAAC,uBAAuB,QAAQ,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,CAAC;YACpE,OAAO,CAAC,GAAG,CAAC,uBAAuB,QAAQ,CAAC,QAAQ,CAAC,QAAQ,IAAI,CAAC,EAAE,CAAC,CAAC;YACtE,OAAO,CAAC,GAAG,CAAC,uBAAuB,QAAQ,CAAC,QAAQ,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC;YACrE,OAAO,CAAC,GAAG,CAAC,uBAAuB,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC;YAC9D,OAAO,CAAC,GAAG,CAAC,uBAAuB,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC3E,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YACzC,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;gBAAS,CAAC;YACT,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAChC,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * Register the sync command
4
+ */
5
+ export declare function registerSyncCommand(parentCmd: Command): void;
6
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/commands/host/sync.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CA0D5D"}
@@ -0,0 +1,61 @@
1
+ // Path: src/commands/host/sync.ts
2
+ // Push configuration updates to connected agents
3
+ import ora from 'ora';
4
+ import * as mode from '../../lib/mode.js';
5
+ import * as output from '../../lib/output.js';
6
+ /**
7
+ * Register the sync command
8
+ */
9
+ export function registerSyncCommand(parentCmd) {
10
+ parentCmd
11
+ .command('sync <hostname>')
12
+ .alias('push')
13
+ .description('Push configuration update to connected agents')
14
+ .option('-f, --force', 'Force sync even if no config changes detected')
15
+ .option('--json', 'Output as JSON')
16
+ .action(async (hostname, options) => {
17
+ const spinner = ora('Pushing configuration to agents...').start();
18
+ try {
19
+ const response = await mode.apiPost(`/v1/hosts/${encodeURIComponent(hostname)}/sync`, { force: options.force ?? false });
20
+ spinner.stop();
21
+ if (options.json) {
22
+ output.json(response);
23
+ return;
24
+ }
25
+ if (response.linkedAgents === 0) {
26
+ console.log(`Host: ${response.hostname} (version ${response.version})`);
27
+ console.log();
28
+ console.log('No agents linked to this host configuration.');
29
+ console.log('Agents will pull the config when they connect.');
30
+ return;
31
+ }
32
+ if (response.notifiedAgents === 0) {
33
+ console.log(`Host: ${response.hostname} (version ${response.version})`);
34
+ console.log();
35
+ console.log(`${response.linkedAgents} agent(s) linked, but none are currently connected.`);
36
+ console.log('Offline agents will pull the new config on next connection.');
37
+ return;
38
+ }
39
+ console.log(`Host: ${response.hostname} (version ${response.version})`);
40
+ console.log();
41
+ console.log(`Notified ${response.notifiedAgents}/${response.linkedAgents} agent(s)`);
42
+ console.log();
43
+ if (response.notifiedAgents < response.linkedAgents) {
44
+ const offline = response.linkedAgents - response.notifiedAgents;
45
+ console.log(`Note: ${offline} agent(s) are offline and will sync on next connection.`);
46
+ }
47
+ else {
48
+ console.log('All linked agents have been notified to pull the new configuration.');
49
+ }
50
+ }
51
+ catch (err) {
52
+ spinner.fail('Failed to sync configuration');
53
+ output.error(err instanceof Error ? err.message : String(err));
54
+ process.exit(1);
55
+ }
56
+ finally {
57
+ await mode.closeLocalClient();
58
+ }
59
+ });
60
+ }
61
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/host/sync.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,iDAAiD;AAGjD,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAG9C;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAkB;IACpD,SAAS;SACN,OAAO,CAAC,iBAAiB,CAAC;SAC1B,KAAK,CAAC,MAAM,CAAC;SACb,WAAW,CAAC,+CAA+C,CAAC;SAC5D,MAAM,CAAC,aAAa,EAAE,+CAA+C,CAAC;SACtE,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,KAAK,EAAE,QAAgB,EAAE,OAAoB,EAAE,EAAE;QACvD,MAAM,OAAO,GAAG,GAAG,CAAC,oCAAoC,CAAC,CAAC,KAAK,EAAE,CAAC;QAElE,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CACjC,aAAa,kBAAkB,CAAC,QAAQ,CAAC,OAAO,EAChD,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK,EAAE,CAClC,CAAC;YAEF,OAAO,CAAC,IAAI,EAAE,CAAC;YAEf,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACtB,OAAO;YACT,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CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;YAC7C,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;gBAAS,CAAC;YACT,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAChC,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Host configuration status
3
+ */
4
+ export type HostStatus = 'active' | 'disabled' | 'pending';
5
+ /**
6
+ * Host configuration from vault server
7
+ */
8
+ export interface HostConfig {
9
+ id: string;
10
+ tenantId: string;
11
+ hostname: string;
12
+ description?: string;
13
+ config: {
14
+ targets?: CertTarget[];
15
+ secretTargets?: SecretTarget[];
16
+ plugins?: PluginConfig[];
17
+ exec?: ExecConfig;
18
+ globalReloadCmd?: string;
19
+ pollInterval?: number;
20
+ verbose?: boolean;
21
+ insecure?: boolean;
22
+ };
23
+ version: number;
24
+ managedKeyName?: string;
25
+ status: HostStatus;
26
+ lastPulledAt?: string;
27
+ lastPulledByAgentId?: string;
28
+ createdAt: string;
29
+ updatedAt: string;
30
+ createdBy: string;
31
+ updatedBy?: string;
32
+ }
33
+ /**
34
+ * Certificate target configuration
35
+ */
36
+ export interface CertTarget {
37
+ certId: string;
38
+ name: string;
39
+ outputs: {
40
+ combined?: string;
41
+ cert?: string;
42
+ key?: string;
43
+ chain?: string;
44
+ fullchain?: string;
45
+ };
46
+ owner?: string;
47
+ mode?: string;
48
+ reloadCmd?: string;
49
+ healthCheckCmd?: string;
50
+ }
51
+ /**
52
+ * Secret target configuration
53
+ */
54
+ export interface SecretTarget {
55
+ secretId: string;
56
+ name: string;
57
+ format: 'env' | 'json' | 'yaml' | 'raw' | 'template' | 'none';
58
+ output?: string;
59
+ key?: string;
60
+ templatePath?: string;
61
+ envPrefix?: string;
62
+ owner?: string;
63
+ mode?: string;
64
+ reloadCmd?: string;
65
+ }
66
+ /**
67
+ * Plugin configuration
68
+ */
69
+ export interface PluginConfig {
70
+ package?: string;
71
+ path?: string;
72
+ enabled?: boolean;
73
+ config?: Record<string, unknown>;
74
+ autoUpdate?: {
75
+ enabled?: boolean;
76
+ channel?: string;
77
+ };
78
+ }
79
+ /**
80
+ * Exec mode configuration
81
+ */
82
+ export interface ExecConfig {
83
+ command: string[];
84
+ secrets: ExecSecret[];
85
+ inheritEnv?: boolean;
86
+ restartOnChange?: boolean;
87
+ restartDelayMs?: number;
88
+ maxRestarts?: number;
89
+ restartWindowMs?: number;
90
+ envFile?: string;
91
+ }
92
+ /**
93
+ * Exec secret mapping
94
+ */
95
+ export interface ExecSecret {
96
+ env: string;
97
+ secret?: string;
98
+ literal?: string;
99
+ apiKey?: string;
100
+ outputToFile?: boolean;
101
+ }
102
+ /**
103
+ * Host list response
104
+ */
105
+ export interface HostListResponse {
106
+ items: HostConfig[];
107
+ pagination: {
108
+ page: number;
109
+ pageSize: number;
110
+ totalItems: number;
111
+ totalPages: number;
112
+ };
113
+ }
114
+ /**
115
+ * Host stats response
116
+ */
117
+ export interface HostStatsResponse {
118
+ total: number;
119
+ byStatus: Record<HostStatus, number>;
120
+ recentlyPulled: number;
121
+ averageVersion: number;
122
+ }
123
+ /**
124
+ * Host config response (for agents)
125
+ */
126
+ export interface HostAgentConfigResponse {
127
+ version: number;
128
+ tenantId: string;
129
+ config: HostConfig['config'];
130
+ managedKeyName: string | null;
131
+ vaultUrl: string;
132
+ }
133
+ /**
134
+ * Bootstrap token response
135
+ */
136
+ export interface BootstrapTokenResponse {
137
+ token: string;
138
+ expiresAt: string;
139
+ bootstrapUrl: string;
140
+ hostConfigId: string;
141
+ hostname: string;
142
+ }
143
+ /**
144
+ * Sync response
145
+ */
146
+ export interface SyncResponse {
147
+ success: boolean;
148
+ hostname: string;
149
+ version: number;
150
+ linkedAgents: number;
151
+ notifiedAgents: number;
152
+ }
153
+ /**
154
+ * Outdated agents response
155
+ */
156
+ export interface OutdatedAgentsResponse {
157
+ hostname: string;
158
+ currentVersion: number;
159
+ agents: Array<{
160
+ agentId: string;
161
+ configVersion: number | null;
162
+ versionsBehind: number;
163
+ }>;
164
+ }
165
+ export interface ListOptions {
166
+ status?: string;
167
+ tenant?: string;
168
+ json?: boolean;
169
+ page?: number;
170
+ pageSize?: number;
171
+ }
172
+ export interface CreateOptions {
173
+ managedKey?: string;
174
+ description?: string;
175
+ configFile?: string;
176
+ json?: boolean;
177
+ }
178
+ export interface GetOptions {
179
+ json?: boolean;
180
+ }
181
+ export interface ConfigOptions {
182
+ edit?: boolean;
183
+ import?: string;
184
+ json?: boolean;
185
+ }
186
+ export interface DeleteOptions {
187
+ yes?: boolean;
188
+ }
189
+ export interface BootstrapTokenOptions {
190
+ expires?: string;
191
+ json?: boolean;
192
+ }
193
+ export interface SyncOptions {
194
+ force?: boolean;
195
+ json?: boolean;
196
+ }
197
+ //# sourceMappingURL=types.d.ts.map