certops 0.0.1 → 1.0.2
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/dist/client.js
CHANGED
|
@@ -2,11 +2,11 @@ import input from '@inquirer/input';
|
|
|
2
2
|
import { readConfig } from './config.js';
|
|
3
3
|
import { createApiClient } from './api.js';
|
|
4
4
|
export async function getConfiguredClient() {
|
|
5
|
-
let apiKey = process.env['
|
|
5
|
+
let apiKey = process.env['CERTOPS_API_KEY'];
|
|
6
6
|
if (!apiKey) {
|
|
7
7
|
if (!process.stdin.isTTY) {
|
|
8
|
-
process.stderr.write('Error:
|
|
9
|
-
process.stderr.write(' export
|
|
8
|
+
process.stderr.write('Error: CERTOPS_API_KEY is not set and no TTY is available for prompt.\n');
|
|
9
|
+
process.stderr.write(' export CERTOPS_API_KEY=\'sslpilot_...\'\n\n');
|
|
10
10
|
process.exit(1);
|
|
11
11
|
}
|
|
12
12
|
apiKey = await input({
|
|
@@ -47,7 +47,7 @@ export const checkCommand = new Command('check')
|
|
|
47
47
|
requireRoot();
|
|
48
48
|
const apiKey = await resolveApiKey();
|
|
49
49
|
if (!apiKey) {
|
|
50
|
-
process.stderr.write('\nError:
|
|
50
|
+
process.stderr.write('\nError: CERTOPS_API_KEY not found in environment or service unit.\n');
|
|
51
51
|
process.stderr.write(' Set the env var or run: sudo sp service install\n\n');
|
|
52
52
|
process.exit(1);
|
|
53
53
|
}
|
|
@@ -14,7 +14,7 @@ Wants=network-online.target
|
|
|
14
14
|
|
|
15
15
|
[Service]
|
|
16
16
|
Type=simple
|
|
17
|
-
Environment=
|
|
17
|
+
Environment=CERTOPS_API_KEY=${apiKey}
|
|
18
18
|
ExecStart=/usr/local/bin/certops service run
|
|
19
19
|
Restart=on-failure
|
|
20
20
|
RestartSec=30
|
|
@@ -48,7 +48,7 @@ export const installCommand = new Command('install')
|
|
|
48
48
|
console.log('\nSSL Pilot Service Setup\n');
|
|
49
49
|
const existing = await readConfig();
|
|
50
50
|
// API key — env takes precedence, otherwise prompt
|
|
51
|
-
const apiKey = process.env['
|
|
51
|
+
const apiKey = process.env['CERTOPS_API_KEY'] ?? await input({
|
|
52
52
|
message: 'SSL Pilot API key (sslpilot_...):',
|
|
53
53
|
validate: (v) => v.startsWith('sslpilot_') && v.length > 10
|
|
54
54
|
? true
|
|
@@ -8,12 +8,12 @@ function sleep(ms) {
|
|
|
8
8
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
9
9
|
}
|
|
10
10
|
export async function resolveApiKey() {
|
|
11
|
-
if (process.env['
|
|
12
|
-
return process.env['
|
|
11
|
+
if (process.env['CERTOPS_API_KEY'])
|
|
12
|
+
return process.env['CERTOPS_API_KEY'];
|
|
13
13
|
try {
|
|
14
14
|
const { execSync } = await import('child_process');
|
|
15
15
|
const out = execSync('systemctl show certops -p Environment --value', { encoding: 'utf8' });
|
|
16
|
-
const match = out.match(/
|
|
16
|
+
const match = out.match(/CERTOPS_API_KEY=(\S+)/);
|
|
17
17
|
return match?.[1] ?? null;
|
|
18
18
|
}
|
|
19
19
|
catch {
|