@zincapp/znvault-cli 2.1.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 +310 -0
- package/dist/commands/agent.d.ts +3 -0
- package/dist/commands/agent.d.ts.map +1 -0
- package/dist/commands/agent.js +660 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/apikey.d.ts +3 -0
- package/dist/commands/apikey.d.ts.map +1 -0
- package/dist/commands/apikey.js +767 -0
- package/dist/commands/apikey.js.map +1 -0
- package/dist/commands/audit.d.ts +3 -0
- package/dist/commands/audit.d.ts.map +1 -0
- package/dist/commands/audit.js +147 -0
- package/dist/commands/audit.js.map +1 -0
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +426 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/cert.d.ts +3 -0
- package/dist/commands/cert.d.ts.map +1 -0
- package/dist/commands/cert.js +398 -0
- package/dist/commands/cert.js.map +1 -0
- package/dist/commands/cluster.d.ts +3 -0
- package/dist/commands/cluster.d.ts.map +1 -0
- package/dist/commands/cluster.js +228 -0
- package/dist/commands/cluster.js.map +1 -0
- package/dist/commands/emergency.d.ts +3 -0
- package/dist/commands/emergency.d.ts.map +1 -0
- package/dist/commands/emergency.js +223 -0
- package/dist/commands/emergency.js.map +1 -0
- package/dist/commands/health.d.ts +3 -0
- package/dist/commands/health.d.ts.map +1 -0
- package/dist/commands/health.js +188 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/lockdown.d.ts +3 -0
- package/dist/commands/lockdown.d.ts.map +1 -0
- package/dist/commands/lockdown.js +232 -0
- package/dist/commands/lockdown.js.map +1 -0
- package/dist/commands/permissions.d.ts +3 -0
- package/dist/commands/permissions.d.ts.map +1 -0
- package/dist/commands/permissions.js +168 -0
- package/dist/commands/permissions.js.map +1 -0
- package/dist/commands/policy.d.ts +3 -0
- package/dist/commands/policy.d.ts.map +1 -0
- package/dist/commands/policy.js +660 -0
- package/dist/commands/policy.js.map +1 -0
- package/dist/commands/superadmin.d.ts +3 -0
- package/dist/commands/superadmin.d.ts.map +1 -0
- package/dist/commands/superadmin.js +203 -0
- package/dist/commands/superadmin.js.map +1 -0
- package/dist/commands/tenant.d.ts +3 -0
- package/dist/commands/tenant.d.ts.map +1 -0
- package/dist/commands/tenant.js +277 -0
- package/dist/commands/tenant.js.map +1 -0
- package/dist/commands/update.d.ts +9 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +359 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/user.d.ts +3 -0
- package/dist/commands/user.d.ts.map +1 -0
- package/dist/commands/user.js +363 -0
- package/dist/commands/user.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/client.d.ts +246 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/client.js +734 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/config.d.ts +130 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +342 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/db.d.ts +111 -0
- package/dist/lib/db.d.ts.map +1 -0
- package/dist/lib/db.js +698 -0
- package/dist/lib/db.js.map +1 -0
- package/dist/lib/local.d.ts +41 -0
- package/dist/lib/local.d.ts.map +1 -0
- package/dist/lib/local.js +236 -0
- package/dist/lib/local.js.map +1 -0
- package/dist/lib/mode.d.ts +210 -0
- package/dist/lib/mode.d.ts.map +1 -0
- package/dist/lib/mode.js +389 -0
- package/dist/lib/mode.js.map +1 -0
- package/dist/lib/output.d.ts +61 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/output.js +190 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/prompts.d.ts +32 -0
- package/dist/lib/prompts.d.ts.map +1 -0
- package/dist/lib/prompts.js +96 -0
- package/dist/lib/prompts.js.map +1 -0
- package/dist/services/auto-update-daemon.d.ts +48 -0
- package/dist/services/auto-update-daemon.d.ts.map +1 -0
- package/dist/services/auto-update-daemon.js +296 -0
- package/dist/services/auto-update-daemon.js.map +1 -0
- package/dist/services/signature-verifier.d.ts +38 -0
- package/dist/services/signature-verifier.d.ts.map +1 -0
- package/dist/services/signature-verifier.js +209 -0
- package/dist/services/signature-verifier.js.map +1 -0
- package/dist/services/update-checker.d.ts +39 -0
- package/dist/services/update-checker.d.ts.map +1 -0
- package/dist/services/update-checker.js +198 -0
- package/dist/services/update-checker.js.map +1 -0
- package/dist/services/update-installer.d.ts +54 -0
- package/dist/services/update-installer.d.ts.map +1 -0
- package/dist/services/update-installer.js +360 -0
- package/dist/services/update-installer.js.map +1 -0
- package/dist/types/index.d.ts +411 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/update.d.ts +137 -0
- package/dist/types/update.d.ts.map +1 -0
- package/dist/types/update.js +27 -0
- package/dist/types/update.js.map +1 -0
- package/dist/utils/platform.d.ts +35 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +115 -0
- package/dist/utils/platform.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Path: znvault-cli/src/utils/platform.ts
|
|
2
|
+
/**
|
|
3
|
+
* Platform Detection Utilities
|
|
4
|
+
*
|
|
5
|
+
* Detects the current platform and architecture for downloading
|
|
6
|
+
* the correct agent binary during updates.
|
|
7
|
+
*/
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
import * as os from 'os';
|
|
11
|
+
/**
|
|
12
|
+
* Detect the current platform for binary downloads
|
|
13
|
+
* Returns 'unsupported' for non-Linux platforms
|
|
14
|
+
*/
|
|
15
|
+
export function getPlatform() {
|
|
16
|
+
const platform = process.platform;
|
|
17
|
+
const arch = process.arch;
|
|
18
|
+
if (platform !== 'linux') {
|
|
19
|
+
return 'unsupported';
|
|
20
|
+
}
|
|
21
|
+
if (arch === 'x64') {
|
|
22
|
+
return 'linux_amd64';
|
|
23
|
+
}
|
|
24
|
+
if (arch === 'arm64') {
|
|
25
|
+
return 'linux_arm64';
|
|
26
|
+
}
|
|
27
|
+
return 'unsupported';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get human-readable platform name
|
|
31
|
+
*/
|
|
32
|
+
export function getPlatformName() {
|
|
33
|
+
const platform = getPlatform();
|
|
34
|
+
switch (platform) {
|
|
35
|
+
case 'linux_amd64':
|
|
36
|
+
return 'Linux (x86_64)';
|
|
37
|
+
case 'linux_arm64':
|
|
38
|
+
return 'Linux (ARM64)';
|
|
39
|
+
default:
|
|
40
|
+
return `${process.platform} (${process.arch}) - unsupported`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Standard installation paths to check
|
|
45
|
+
*/
|
|
46
|
+
const INSTALL_PATHS = [
|
|
47
|
+
'/opt/znvault/current/bin/znvault',
|
|
48
|
+
'/usr/local/bin/znvault',
|
|
49
|
+
'/usr/bin/znvault',
|
|
50
|
+
];
|
|
51
|
+
/**
|
|
52
|
+
* Get the installation path of the current znvault binary
|
|
53
|
+
*/
|
|
54
|
+
export function getInstallPath() {
|
|
55
|
+
// First, check if we're running from a known location
|
|
56
|
+
const execPath = process.execPath;
|
|
57
|
+
// If running via node, try to find the actual script location
|
|
58
|
+
if (execPath.includes('node')) {
|
|
59
|
+
// Check standard locations
|
|
60
|
+
for (const p of INSTALL_PATHS) {
|
|
61
|
+
if (fs.existsSync(p)) {
|
|
62
|
+
return p;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Default to /usr/local/bin for fresh installs
|
|
66
|
+
return '/usr/local/bin/znvault';
|
|
67
|
+
}
|
|
68
|
+
// Running as standalone binary, use current executable path
|
|
69
|
+
return execPath;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Check if the current process has write access to the install path
|
|
73
|
+
*/
|
|
74
|
+
export function canWriteToInstallPath(installPath) {
|
|
75
|
+
const targetPath = installPath || getInstallPath();
|
|
76
|
+
const targetDir = path.dirname(targetPath);
|
|
77
|
+
try {
|
|
78
|
+
// Check if directory exists and is writable
|
|
79
|
+
fs.accessSync(targetDir, fs.constants.W_OK);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Check if running as root (required for system-wide installs)
|
|
88
|
+
*/
|
|
89
|
+
export function isRoot() {
|
|
90
|
+
return process.getuid?.() === 0;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get temporary directory for downloads
|
|
94
|
+
*/
|
|
95
|
+
export function getTempDir() {
|
|
96
|
+
return os.tmpdir();
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get the home directory for config files
|
|
100
|
+
*/
|
|
101
|
+
export function getConfigDir() {
|
|
102
|
+
const home = os.homedir();
|
|
103
|
+
return path.join(home, '.znvault');
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Ensure config directory exists
|
|
107
|
+
*/
|
|
108
|
+
export function ensureConfigDir() {
|
|
109
|
+
const configDir = getConfigDir();
|
|
110
|
+
if (!fs.existsSync(configDir)) {
|
|
111
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
112
|
+
}
|
|
113
|
+
return configDir;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/utils/platform.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAE1C;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B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LI for ZN-Vault administration",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"znvault": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"build:prod": "tsc --sourceMap false",
|
|
16
|
+
"dev": "tsc --watch",
|
|
17
|
+
"clean": "rm -rf dist",
|
|
18
|
+
"test": "vitest",
|
|
19
|
+
"test:run": "vitest run",
|
|
20
|
+
"test:coverage": "vitest run --coverage",
|
|
21
|
+
"lint": "eslint src --ext .ts",
|
|
22
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
23
|
+
"typecheck": "tsc --noEmit"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"znvault",
|
|
27
|
+
"vault",
|
|
28
|
+
"secrets",
|
|
29
|
+
"cli",
|
|
30
|
+
"admin"
|
|
31
|
+
],
|
|
32
|
+
"author": "ZincApp",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@types/bcryptjs": "^2.4.6",
|
|
36
|
+
"@types/ws": "^8.18.1",
|
|
37
|
+
"bcryptjs": "^3.0.3",
|
|
38
|
+
"chalk": "^5.3.0",
|
|
39
|
+
"cli-table3": "^0.6.5",
|
|
40
|
+
"commander": "^12.1.0",
|
|
41
|
+
"conf": "^13.0.1",
|
|
42
|
+
"inquirer": "^13.1.0",
|
|
43
|
+
"openpgp": "^6.0.0",
|
|
44
|
+
"ora": "^8.1.1",
|
|
45
|
+
"pg": "^8.16.3",
|
|
46
|
+
"ws": "^8.18.3"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/inquirer": "^9.0.7",
|
|
50
|
+
"@types/node": "^20.17.10",
|
|
51
|
+
"@types/pg": "^8.16.0",
|
|
52
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
53
|
+
"typescript": "^5.7.2",
|
|
54
|
+
"vitest": "^4.0.16"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=20.0.0"
|
|
58
|
+
}
|
|
59
|
+
}
|