@zincapp/zn-vault-agent 1.3.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.
- package/README.md +701 -0
- package/deploy/logrotate.d/zn-vault-agent +14 -0
- package/deploy/systemd/zn-vault-agent.service +75 -0
- package/dist/commands/certs.d.ts +3 -0
- package/dist/commands/certs.d.ts.map +1 -0
- package/dist/commands/certs.js +369 -0
- package/dist/commands/certs.js.map +1 -0
- package/dist/commands/exec.d.ts +3 -0
- package/dist/commands/exec.d.ts.map +1 -0
- package/dist/commands/exec.js +193 -0
- package/dist/commands/exec.js.map +1 -0
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +234 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/secrets.d.ts +3 -0
- package/dist/commands/secrets.d.ts.map +1 -0
- package/dist/commands/secrets.js +445 -0
- package/dist/commands/secrets.js.map +1 -0
- package/dist/commands/setup.d.ts +9 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +346 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/start.d.ts +3 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +113 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +85 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/sync.d.ts +3 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +126 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api.d.ts +104 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +338 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/config.d.ts +164 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +299 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/deployer.d.ts +22 -0
- package/dist/lib/deployer.d.ts.map +1 -0
- package/dist/lib/deployer.js +407 -0
- package/dist/lib/deployer.js.map +1 -0
- package/dist/lib/health.d.ts +68 -0
- package/dist/lib/health.d.ts.map +1 -0
- package/dist/lib/health.js +216 -0
- package/dist/lib/health.js.map +1 -0
- package/dist/lib/logger.d.ts +38 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +161 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/metrics.d.ts +50 -0
- package/dist/lib/metrics.d.ts.map +1 -0
- package/dist/lib/metrics.js +273 -0
- package/dist/lib/metrics.js.map +1 -0
- package/dist/lib/secret-deployer.d.ts +22 -0
- package/dist/lib/secret-deployer.d.ts.map +1 -0
- package/dist/lib/secret-deployer.js +201 -0
- package/dist/lib/secret-deployer.js.map +1 -0
- package/dist/lib/validation.d.ts +25 -0
- package/dist/lib/validation.d.ts.map +1 -0
- package/dist/lib/validation.js +257 -0
- package/dist/lib/validation.js.map +1 -0
- package/dist/lib/websocket.d.ts +74 -0
- package/dist/lib/websocket.d.ts.map +1 -0
- package/dist/lib/websocket.js +441 -0
- package/dist/lib/websocket.js.map +1 -0
- package/dist/services/api-key-renewal.d.ts +13 -0
- package/dist/services/api-key-renewal.d.ts.map +1 -0
- package/dist/services/api-key-renewal.js +204 -0
- package/dist/services/api-key-renewal.js.map +1 -0
- package/dist/services/npm-auto-update.d.ts +60 -0
- package/dist/services/npm-auto-update.d.ts.map +1 -0
- package/dist/services/npm-auto-update.js +245 -0
- package/dist/services/npm-auto-update.js.map +1 -0
- package/dist/types/update.d.ts +19 -0
- package/dist/types/update.d.ts.map +1 -0
- package/dist/types/update.js +7 -0
- package/dist/types/update.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import ora from 'ora';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { isConfigured, getTargets } from '../lib/config.js';
|
|
4
|
+
import { deployCertificate } from '../lib/deployer.js';
|
|
5
|
+
export function registerSyncCommand(program) {
|
|
6
|
+
program
|
|
7
|
+
.command('sync')
|
|
8
|
+
.description('Sync certificates to configured targets')
|
|
9
|
+
.option('-f, --force', 'Force sync even if certificate unchanged')
|
|
10
|
+
.option('-t, --target <name>', 'Sync specific target only')
|
|
11
|
+
.option('--dry-run', 'Show what would be done without making changes')
|
|
12
|
+
.addHelpText('after', `
|
|
13
|
+
Examples:
|
|
14
|
+
# Sync all configured certificates
|
|
15
|
+
zn-vault-agent sync
|
|
16
|
+
|
|
17
|
+
# Force sync (even if unchanged)
|
|
18
|
+
zn-vault-agent sync --force
|
|
19
|
+
|
|
20
|
+
# Sync only a specific target
|
|
21
|
+
zn-vault-agent sync --target haproxy-frontend
|
|
22
|
+
|
|
23
|
+
# Preview what would be synced
|
|
24
|
+
zn-vault-agent sync --dry-run
|
|
25
|
+
`)
|
|
26
|
+
.action(async (options) => {
|
|
27
|
+
if (!isConfigured()) {
|
|
28
|
+
console.error(chalk.red('Not configured. Run: zn-vault-agent login'));
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
const targets = getTargets();
|
|
32
|
+
if (targets.length === 0) {
|
|
33
|
+
console.log('No certificate targets configured.');
|
|
34
|
+
console.log('Run ' + chalk.cyan('zn-vault-agent add') + ' to add one.');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// Filter to specific target if requested
|
|
38
|
+
const targetsToSync = options.target
|
|
39
|
+
? targets.filter(t => t.name === options.target || t.certId === options.target)
|
|
40
|
+
: targets;
|
|
41
|
+
if (options.target && targetsToSync.length === 0) {
|
|
42
|
+
console.error(chalk.red(`Target "${options.target}" not found`));
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
if (options.dryRun) {
|
|
46
|
+
console.log();
|
|
47
|
+
console.log(chalk.bold('Dry run - would sync:'));
|
|
48
|
+
console.log();
|
|
49
|
+
for (const target of targetsToSync) {
|
|
50
|
+
console.log(` ${chalk.cyan(target.name)}`);
|
|
51
|
+
console.log(` Certificate: ${target.certId.substring(0, 8)}...`);
|
|
52
|
+
console.log(` Outputs:`);
|
|
53
|
+
for (const [type, path] of Object.entries(target.outputs)) {
|
|
54
|
+
if (path)
|
|
55
|
+
console.log(` ${type}: ${path}`);
|
|
56
|
+
}
|
|
57
|
+
if (target.reloadCmd) {
|
|
58
|
+
console.log(` Reload: ${target.reloadCmd}`);
|
|
59
|
+
}
|
|
60
|
+
console.log();
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
console.log();
|
|
65
|
+
console.log(chalk.bold('Syncing Certificates'));
|
|
66
|
+
console.log();
|
|
67
|
+
let successCount = 0;
|
|
68
|
+
let failCount = 0;
|
|
69
|
+
let unchangedCount = 0;
|
|
70
|
+
for (const target of targetsToSync) {
|
|
71
|
+
const spinner = ora(`Syncing ${target.name}...`).start();
|
|
72
|
+
try {
|
|
73
|
+
const result = await deployCertificate(target, options.force);
|
|
74
|
+
if (result.success) {
|
|
75
|
+
if (result.message === 'Certificate unchanged') {
|
|
76
|
+
spinner.info(`${target.name}: unchanged`);
|
|
77
|
+
unchangedCount++;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
spinner.succeed(`${target.name}: ${result.message}`);
|
|
81
|
+
successCount++;
|
|
82
|
+
// Show details
|
|
83
|
+
if (result.filesWritten && result.filesWritten.length > 0) {
|
|
84
|
+
for (const file of result.filesWritten) {
|
|
85
|
+
console.log(` ${chalk.gray('→')} ${file}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (result.reloadOutput) {
|
|
89
|
+
console.log(` ${chalk.gray('reload:')} ${result.reloadOutput.trim()}`);
|
|
90
|
+
}
|
|
91
|
+
if (result.healthCheckPassed !== undefined) {
|
|
92
|
+
const status = result.healthCheckPassed
|
|
93
|
+
? chalk.green('passed')
|
|
94
|
+
: chalk.red('failed');
|
|
95
|
+
console.log(` ${chalk.gray('health:')} ${status}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
spinner.fail(`${target.name}: ${result.message}`);
|
|
101
|
+
failCount++;
|
|
102
|
+
if (result.rolledBack) {
|
|
103
|
+
console.log(` ${chalk.yellow('→ Rolled back to previous certificate')}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
spinner.fail(`${target.name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
109
|
+
failCount++;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
console.log();
|
|
113
|
+
console.log(chalk.bold('Summary:'));
|
|
114
|
+
if (successCount > 0)
|
|
115
|
+
console.log(` ${chalk.green('✓')} ${successCount} updated`);
|
|
116
|
+
if (unchangedCount > 0)
|
|
117
|
+
console.log(` ${chalk.gray('○')} ${unchangedCount} unchanged`);
|
|
118
|
+
if (failCount > 0)
|
|
119
|
+
console.log(` ${chalk.red('✗')} ${failCount} failed`);
|
|
120
|
+
console.log();
|
|
121
|
+
if (failCount > 0) {
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAyB,MAAM,oBAAoB,CAAC;AAE9E,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WA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AC1E,OAAO,CAAC,GAAG,EAAE,CAAC;QAEd,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { registerLoginCommand } from './commands/login.js';
|
|
4
|
+
import { registerCertsCommands } from './commands/certs.js';
|
|
5
|
+
import { registerSecretsCommands } from './commands/secrets.js';
|
|
6
|
+
import { registerSyncCommand } from './commands/sync.js';
|
|
7
|
+
import { registerStartCommand } from './commands/start.js';
|
|
8
|
+
import { registerStatusCommand } from './commands/status.js';
|
|
9
|
+
import { registerExecCommand } from './commands/exec.js';
|
|
10
|
+
import { registerSetupCommand } from './commands/setup.js';
|
|
11
|
+
const version = typeof __VERSION__ !== 'undefined' ? __VERSION__ : '0.0.0-dev';
|
|
12
|
+
const program = new Command();
|
|
13
|
+
program
|
|
14
|
+
.name('zn-vault-agent')
|
|
15
|
+
.description('ZN-Vault Agent - Sync certificates and secrets from vault')
|
|
16
|
+
.version(version);
|
|
17
|
+
// Register commands
|
|
18
|
+
registerLoginCommand(program);
|
|
19
|
+
registerCertsCommands(program);
|
|
20
|
+
registerSecretsCommands(program);
|
|
21
|
+
registerSyncCommand(program);
|
|
22
|
+
registerStartCommand(program);
|
|
23
|
+
registerStatusCommand(program);
|
|
24
|
+
registerExecCommand(program);
|
|
25
|
+
registerSetupCommand(program);
|
|
26
|
+
// Parse arguments
|
|
27
|
+
program.parse();
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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|
2
|
+
accessToken: string;
|
|
3
|
+
refreshToken: string;
|
|
4
|
+
expiresIn: number;
|
|
5
|
+
user: {
|
|
6
|
+
id: string;
|
|
7
|
+
username: string;
|
|
8
|
+
role: string;
|
|
9
|
+
tenantId: string | null;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface CertificateMetadata {
|
|
13
|
+
id: string;
|
|
14
|
+
tenantId: string;
|
|
15
|
+
clientId: string;
|
|
16
|
+
kind: string;
|
|
17
|
+
alias: string;
|
|
18
|
+
certificateType: 'PEM' | 'P12' | 'DER';
|
|
19
|
+
fingerprintSha256: string;
|
|
20
|
+
subjectCn: string;
|
|
21
|
+
issuerCn: string;
|
|
22
|
+
notBefore: string;
|
|
23
|
+
notAfter: string;
|
|
24
|
+
status: string;
|
|
25
|
+
version: number;
|
|
26
|
+
daysUntilExpiry: number;
|
|
27
|
+
}
|
|
28
|
+
export interface DecryptedCertificate {
|
|
29
|
+
id: string;
|
|
30
|
+
certificateData: string;
|
|
31
|
+
certificateType: 'PEM' | 'P12' | 'DER';
|
|
32
|
+
fingerprintSha256: string;
|
|
33
|
+
}
|
|
34
|
+
export interface SecretMetadata {
|
|
35
|
+
id: string;
|
|
36
|
+
alias: string;
|
|
37
|
+
tenantId: string;
|
|
38
|
+
type: string;
|
|
39
|
+
version: number;
|
|
40
|
+
createdAt: string;
|
|
41
|
+
updatedAt: string;
|
|
42
|
+
expiresAt?: string;
|
|
43
|
+
tags?: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface DecryptedSecret {
|
|
46
|
+
id: string;
|
|
47
|
+
alias: string;
|
|
48
|
+
type: string;
|
|
49
|
+
version: number;
|
|
50
|
+
data: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Login and get access token
|
|
54
|
+
*/
|
|
55
|
+
export declare function login(username: string, password: string): Promise<LoginResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* List certificates
|
|
58
|
+
*/
|
|
59
|
+
export declare function listCertificates(): Promise<{
|
|
60
|
+
items: CertificateMetadata[];
|
|
61
|
+
total: number;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Get certificate metadata
|
|
65
|
+
*/
|
|
66
|
+
export declare function getCertificate(certId: string): Promise<CertificateMetadata>;
|
|
67
|
+
/**
|
|
68
|
+
* Decrypt certificate (get actual cert data)
|
|
69
|
+
*/
|
|
70
|
+
export declare function decryptCertificate(certId: string, purpose: string): Promise<DecryptedCertificate>;
|
|
71
|
+
/**
|
|
72
|
+
* Acknowledge certificate delivery (for tracking)
|
|
73
|
+
*/
|
|
74
|
+
export declare function ackDelivery(certId: string, hostname: string, version: number): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* List secrets
|
|
77
|
+
*/
|
|
78
|
+
export declare function listSecrets(): Promise<{
|
|
79
|
+
items: SecretMetadata[];
|
|
80
|
+
total: number;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Get secret by ID or alias
|
|
84
|
+
* @param secretId - UUID or alias (e.g., "alias:db/credentials")
|
|
85
|
+
*/
|
|
86
|
+
export declare function getSecret(secretId: string): Promise<DecryptedSecret>;
|
|
87
|
+
/**
|
|
88
|
+
* Get secret metadata only (without decrypting)
|
|
89
|
+
*/
|
|
90
|
+
export declare function getSecretMetadata(secretId: string): Promise<SecretMetadata>;
|
|
91
|
+
/**
|
|
92
|
+
* Check vault connectivity
|
|
93
|
+
*/
|
|
94
|
+
export declare function checkHealth(): Promise<boolean>;
|
|
95
|
+
/**
|
|
96
|
+
* Clear cached token
|
|
97
|
+
*/
|
|
98
|
+
export declare function clearToken(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Check if we have a valid cached token
|
|
101
|
+
*/
|
|
102
|
+
export declare function hasValidToken(): boolean;
|
|
103
|
+
export {};
|
|
104
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../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,IAAI,OAAO,CAAC,OAAO,CAAC,CAcpD;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAIjC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC"}
|
package/dist/lib/api.js
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
// Path: src/lib/api.ts
|
|
2
|
+
// Vault API client with retry logic and observability
|
|
3
|
+
import https from 'node:https';
|
|
4
|
+
import http from 'node:http';
|
|
5
|
+
import { loadConfig } from './config.js';
|
|
6
|
+
import { apiLogger as log } from './logger.js';
|
|
7
|
+
import { metrics } from './metrics.js';
|
|
8
|
+
import { setVaultReachable } from './health.js';
|
|
9
|
+
// Token cache
|
|
10
|
+
let cachedToken = null;
|
|
11
|
+
let tokenExpiry = 0;
|
|
12
|
+
// Retry configuration
|
|
13
|
+
const MAX_RETRIES = 3;
|
|
14
|
+
const INITIAL_RETRY_DELAY = 1000; // 1 second
|
|
15
|
+
const MAX_RETRY_DELAY = 10000; // 10 seconds
|
|
16
|
+
/**
|
|
17
|
+
* Check if an error is retryable
|
|
18
|
+
*/
|
|
19
|
+
function isRetryableError(statusCode, error) {
|
|
20
|
+
// Network errors are retryable
|
|
21
|
+
if (error.message.includes('ECONNREFUSED') ||
|
|
22
|
+
error.message.includes('ENOTFOUND') ||
|
|
23
|
+
error.message.includes('ETIMEDOUT') ||
|
|
24
|
+
error.message.includes('timeout') ||
|
|
25
|
+
error.message.includes('socket hang up')) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
// 5xx errors are retryable
|
|
29
|
+
if (statusCode && statusCode >= 500 && statusCode < 600) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
// 429 Too Many Requests is retryable
|
|
33
|
+
if (statusCode === 429) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Calculate retry delay with exponential backoff and jitter
|
|
40
|
+
*/
|
|
41
|
+
function getRetryDelay(attempt) {
|
|
42
|
+
const baseDelay = INITIAL_RETRY_DELAY * Math.pow(2, attempt);
|
|
43
|
+
const jitter = Math.random() * 1000;
|
|
44
|
+
return Math.min(baseDelay + jitter, MAX_RETRY_DELAY);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Sleep for specified milliseconds
|
|
48
|
+
*/
|
|
49
|
+
function sleep(ms) {
|
|
50
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Make HTTP request to vault API with retry logic
|
|
54
|
+
*/
|
|
55
|
+
async function request(options) {
|
|
56
|
+
const config = loadConfig();
|
|
57
|
+
const startTime = Date.now();
|
|
58
|
+
if (!config.vaultUrl) {
|
|
59
|
+
throw new Error('Vault URL not configured. Run: zn-vault-agent login');
|
|
60
|
+
}
|
|
61
|
+
const url = new URL(config.vaultUrl);
|
|
62
|
+
url.pathname = options.path;
|
|
63
|
+
const headers = {
|
|
64
|
+
'Content-Type': 'application/json',
|
|
65
|
+
'Accept': 'application/json',
|
|
66
|
+
};
|
|
67
|
+
// Add authentication
|
|
68
|
+
if (options.token && options.token !== 'skip') {
|
|
69
|
+
headers['Authorization'] = `Bearer ${options.token}`;
|
|
70
|
+
}
|
|
71
|
+
else if (options.token !== 'skip') {
|
|
72
|
+
if (config.auth.apiKey) {
|
|
73
|
+
headers['X-API-Key'] = config.auth.apiKey;
|
|
74
|
+
}
|
|
75
|
+
else if (cachedToken && Date.now() < tokenExpiry) {
|
|
76
|
+
headers['Authorization'] = `Bearer ${cachedToken}`;
|
|
77
|
+
}
|
|
78
|
+
else if (config.auth.username && config.auth.password) {
|
|
79
|
+
// Need to login first
|
|
80
|
+
log.debug('Token expired or missing, logging in');
|
|
81
|
+
await login(config.auth.username, config.auth.password);
|
|
82
|
+
if (cachedToken) {
|
|
83
|
+
headers['Authorization'] = `Bearer ${cachedToken}`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const requestOptions = {
|
|
88
|
+
hostname: url.hostname,
|
|
89
|
+
port: url.port || (url.protocol === 'https:' ? 443 : 80),
|
|
90
|
+
path: url.pathname + url.search,
|
|
91
|
+
method: options.method,
|
|
92
|
+
headers,
|
|
93
|
+
timeout: 30000,
|
|
94
|
+
rejectUnauthorized: !config.insecure,
|
|
95
|
+
};
|
|
96
|
+
let lastError = null;
|
|
97
|
+
let lastStatusCode;
|
|
98
|
+
const maxAttempts = options.noRetry ? 1 : MAX_RETRIES;
|
|
99
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
100
|
+
if (attempt > 0) {
|
|
101
|
+
const delay = getRetryDelay(attempt - 1);
|
|
102
|
+
log.debug({ attempt, delay, path: options.path }, 'Retrying request');
|
|
103
|
+
await sleep(delay);
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const result = await executeRequest(requestOptions, options.body, url.protocol === 'https:');
|
|
107
|
+
const duration = Date.now() - startTime;
|
|
108
|
+
// Record metrics
|
|
109
|
+
metrics.apiRequest(options.method, result.statusCode, duration);
|
|
110
|
+
setVaultReachable(true);
|
|
111
|
+
if (result.statusCode >= 400) {
|
|
112
|
+
const error = result.data;
|
|
113
|
+
const errorMessage = error?.message || `Request failed with status ${result.statusCode}`;
|
|
114
|
+
lastStatusCode = result.statusCode;
|
|
115
|
+
lastError = new Error(errorMessage);
|
|
116
|
+
// Don't retry auth errors
|
|
117
|
+
if (result.statusCode === 401 || result.statusCode === 403) {
|
|
118
|
+
log.warn({ path: options.path, status: result.statusCode }, 'Authentication failed');
|
|
119
|
+
throw lastError;
|
|
120
|
+
}
|
|
121
|
+
// Check if retryable
|
|
122
|
+
if (!isRetryableError(result.statusCode, lastError)) {
|
|
123
|
+
log.warn({ path: options.path, status: result.statusCode, error: errorMessage }, 'Request failed');
|
|
124
|
+
throw lastError;
|
|
125
|
+
}
|
|
126
|
+
log.debug({ attempt, status: result.statusCode }, 'Retryable error');
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
log.debug({ path: options.path, status: result.statusCode, duration }, 'Request completed');
|
|
130
|
+
return result.data;
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
134
|
+
lastError = error;
|
|
135
|
+
const duration = Date.now() - startTime;
|
|
136
|
+
metrics.apiRequest(options.method, 0, duration);
|
|
137
|
+
// Network error - vault may be unreachable
|
|
138
|
+
if (error.message.includes('ECONNREFUSED') || error.message.includes('ENOTFOUND')) {
|
|
139
|
+
setVaultReachable(false);
|
|
140
|
+
}
|
|
141
|
+
if (!isRetryableError(undefined, error)) {
|
|
142
|
+
log.error({ path: options.path, err: error }, 'Non-retryable error');
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
log.debug({ attempt, err: error.message }, 'Retryable network error');
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// All retries exhausted
|
|
149
|
+
log.error({ path: options.path, attempts: maxAttempts, lastStatus: lastStatusCode }, 'Request failed after retries');
|
|
150
|
+
throw lastError || new Error('Request failed after retries');
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Execute a single HTTP request
|
|
154
|
+
*/
|
|
155
|
+
function executeRequest(requestOptions, body, useHttps) {
|
|
156
|
+
return new Promise((resolve, reject) => {
|
|
157
|
+
const protocol = useHttps ? https : http;
|
|
158
|
+
const req = protocol.request(requestOptions, (res) => {
|
|
159
|
+
let data = '';
|
|
160
|
+
res.on('data', (chunk) => (data += chunk));
|
|
161
|
+
res.on('end', () => {
|
|
162
|
+
try {
|
|
163
|
+
const parsed = data ? JSON.parse(data) : {};
|
|
164
|
+
resolve({ statusCode: res.statusCode || 0, data: parsed });
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
resolve({ statusCode: res.statusCode || 0, data: data });
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
req.on('error', reject);
|
|
172
|
+
req.on('timeout', () => {
|
|
173
|
+
req.destroy();
|
|
174
|
+
reject(new Error('Request timeout'));
|
|
175
|
+
});
|
|
176
|
+
if (body) {
|
|
177
|
+
req.write(JSON.stringify(body));
|
|
178
|
+
}
|
|
179
|
+
req.end();
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Login and get access token
|
|
184
|
+
*/
|
|
185
|
+
export async function login(username, password) {
|
|
186
|
+
log.info({ username }, 'Logging in to vault');
|
|
187
|
+
const response = await request({
|
|
188
|
+
method: 'POST',
|
|
189
|
+
path: '/auth/login',
|
|
190
|
+
body: { username, password },
|
|
191
|
+
token: 'skip', // Don't try to auto-auth
|
|
192
|
+
noRetry: true, // Don't retry login (could lock account)
|
|
193
|
+
});
|
|
194
|
+
// Cache the token
|
|
195
|
+
cachedToken = response.accessToken;
|
|
196
|
+
tokenExpiry = Date.now() + (response.expiresIn * 1000) - 60000; // 1 min buffer
|
|
197
|
+
log.info({ username, expiresIn: response.expiresIn }, 'Login successful');
|
|
198
|
+
setVaultReachable(true);
|
|
199
|
+
return response;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* List certificates
|
|
203
|
+
*/
|
|
204
|
+
export async function listCertificates() {
|
|
205
|
+
log.debug('Listing certificates');
|
|
206
|
+
return request({
|
|
207
|
+
method: 'GET',
|
|
208
|
+
path: '/v1/certificates',
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Get certificate metadata
|
|
213
|
+
*/
|
|
214
|
+
export async function getCertificate(certId) {
|
|
215
|
+
log.debug({ certId }, 'Getting certificate metadata');
|
|
216
|
+
return request({
|
|
217
|
+
method: 'GET',
|
|
218
|
+
path: `/v1/certificates/${certId}`,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Decrypt certificate (get actual cert data)
|
|
223
|
+
*/
|
|
224
|
+
export async function decryptCertificate(certId, purpose) {
|
|
225
|
+
log.debug({ certId, purpose }, 'Decrypting certificate');
|
|
226
|
+
return request({
|
|
227
|
+
method: 'POST',
|
|
228
|
+
path: `/v1/certificates/${certId}/decrypt`,
|
|
229
|
+
body: { purpose },
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Acknowledge certificate delivery (for tracking)
|
|
234
|
+
*/
|
|
235
|
+
export async function ackDelivery(certId, hostname, version) {
|
|
236
|
+
try {
|
|
237
|
+
await request({
|
|
238
|
+
method: 'POST',
|
|
239
|
+
path: `/v1/certificates/${certId}/ack`,
|
|
240
|
+
body: { hostname, version, timestamp: new Date().toISOString() },
|
|
241
|
+
noRetry: true, // ACK is best-effort
|
|
242
|
+
});
|
|
243
|
+
log.debug({ certId, hostname, version }, 'Delivery acknowledged');
|
|
244
|
+
}
|
|
245
|
+
catch (err) {
|
|
246
|
+
// ACK is best-effort, don't fail if endpoint doesn't exist yet
|
|
247
|
+
log.debug({ certId, err }, 'Failed to acknowledge delivery (best-effort)');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* List secrets
|
|
252
|
+
*/
|
|
253
|
+
export async function listSecrets() {
|
|
254
|
+
log.debug('Listing secrets');
|
|
255
|
+
const response = await request({
|
|
256
|
+
method: 'GET',
|
|
257
|
+
path: '/v1/secrets',
|
|
258
|
+
});
|
|
259
|
+
// API returns array directly, normalize to { items, total }
|
|
260
|
+
const items = Array.isArray(response) ? response : [];
|
|
261
|
+
return { items, total: items.length };
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Get secret by ID or alias
|
|
265
|
+
* @param secretId - UUID or alias (e.g., "alias:db/credentials")
|
|
266
|
+
*/
|
|
267
|
+
export async function getSecret(secretId) {
|
|
268
|
+
log.debug({ secretId }, 'Getting secret');
|
|
269
|
+
let id = secretId;
|
|
270
|
+
// Handle alias format - resolve to UUID first
|
|
271
|
+
if (secretId.startsWith('alias:')) {
|
|
272
|
+
const aliasPath = secretId.substring(6); // Remove "alias:" prefix
|
|
273
|
+
const metadata = await request({
|
|
274
|
+
method: 'GET',
|
|
275
|
+
path: `/v1/secrets/alias/${encodeURIComponent(aliasPath)}`,
|
|
276
|
+
});
|
|
277
|
+
id = metadata.id;
|
|
278
|
+
}
|
|
279
|
+
// Decrypt using UUID
|
|
280
|
+
return request({
|
|
281
|
+
method: 'POST',
|
|
282
|
+
path: `/v1/secrets/${id}/decrypt`,
|
|
283
|
+
body: {}, // Empty body required for POST
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Get secret metadata only (without decrypting)
|
|
288
|
+
*/
|
|
289
|
+
export async function getSecretMetadata(secretId) {
|
|
290
|
+
log.debug({ secretId }, 'Getting secret metadata');
|
|
291
|
+
// Handle alias format
|
|
292
|
+
if (secretId.startsWith('alias:')) {
|
|
293
|
+
const aliasPath = secretId.substring(6); // Remove "alias:" prefix
|
|
294
|
+
return request({
|
|
295
|
+
method: 'GET',
|
|
296
|
+
path: `/v1/secrets/alias/${encodeURIComponent(aliasPath)}`,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
// Use UUID metadata endpoint
|
|
300
|
+
return request({
|
|
301
|
+
method: 'GET',
|
|
302
|
+
path: `/v1/secrets/${secretId}/meta`,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Check vault connectivity
|
|
307
|
+
*/
|
|
308
|
+
export async function checkHealth() {
|
|
309
|
+
try {
|
|
310
|
+
await request({
|
|
311
|
+
method: 'GET',
|
|
312
|
+
path: '/v1/health',
|
|
313
|
+
token: 'skip',
|
|
314
|
+
noRetry: true,
|
|
315
|
+
});
|
|
316
|
+
setVaultReachable(true);
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
setVaultReachable(false);
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Clear cached token
|
|
326
|
+
*/
|
|
327
|
+
export function clearToken() {
|
|
328
|
+
cachedToken = null;
|
|
329
|
+
tokenExpiry = 0;
|
|
330
|
+
log.debug('Token cache cleared');
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Check if we have a valid cached token
|
|
334
|
+
*/
|
|
335
|
+
export function hasValidToken() {
|
|
336
|
+
return cachedToken !== null && Date.now() < tokenExpiry;
|
|
337
|
+
}
|
|
338
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,sDAAsD;AAEtD,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAyEhD,cAAc;AACd,IAAI,WAAW,GAAkB,IAAI,CAAC;AACtC,IAAI,WAAW,GAAW,CAAC,CAAC;AAE5B,sBAAsB;AACtB,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,mBAAmB,GAAG,IAAI,CAAC,CAAC,WAAW;AAC7C,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,aAAa;AAE5C;;GAEG;AACH,SAAS,gBAAgB,CAAC,UAA8B,EAAE,KAAY;IACpE,+BAA+B;IAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;QACtC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;QACnC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;QACnC,KAAK,CAAC,O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