@ebowwa/hetzner 0.2.2 → 0.3.1
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/bootstrap/index.js +1126 -0
- package/dist/bootstrap/index.js.map +15 -0
- package/dist/index.js +3540 -0
- package/dist/index.js.map +31 -0
- package/dist/onboarding/index.js +460 -0
- package/dist/onboarding/index.js.map +14 -0
- package/package.json +53 -16
- package/actions.js +0 -1084
- package/actions.ts +0 -1053
- package/auth.js +0 -39
- package/auth.ts +0 -37
- package/bootstrap/FIREWALL.md +0 -326
- package/bootstrap/KERNEL-HARDENING.md +0 -258
- package/bootstrap/SECURITY-INTEGRATION.md +0 -281
- package/bootstrap/TESTING.md +0 -301
- package/bootstrap/cloud-init.js +0 -323
- package/bootstrap/cloud-init.ts +0 -394
- package/bootstrap/firewall.js +0 -292
- package/bootstrap/firewall.ts +0 -342
- package/bootstrap/genesis.js +0 -424
- package/bootstrap/genesis.ts +0 -518
- package/bootstrap/index.js +0 -59
- package/bootstrap/index.ts +0 -71
- package/bootstrap/kernel-hardening.js +0 -270
- package/bootstrap/kernel-hardening.test.js +0 -182
- package/bootstrap/kernel-hardening.test.ts +0 -230
- package/bootstrap/kernel-hardening.ts +0 -272
- package/bootstrap/security-audit.js +0 -122
- package/bootstrap/security-audit.ts +0 -124
- package/bootstrap/ssh-hardening.js +0 -186
- package/bootstrap/ssh-hardening.ts +0 -192
- package/client.js +0 -234
- package/client.ts +0 -177
- package/config.js +0 -7
- package/config.ts +0 -5
- package/errors.js +0 -345
- package/errors.ts +0 -371
- package/index.js +0 -73
- package/index.ts +0 -59
- package/onboarding/doppler.ts +0 -116
- package/onboarding/git.ts +0 -133
- package/onboarding/index.ts +0 -18
- package/onboarding/onboarding.ts +0 -193
- package/onboarding/tailscale.ts +0 -159
- package/onboarding/types.ts +0 -115
- package/pricing.js +0 -387
- package/pricing.ts +0 -422
- package/schemas.js +0 -667
- package/schemas.ts +0 -765
- package/server-status.js +0 -122
- package/server-status.ts +0 -81
- package/servers.js +0 -667
- package/servers.ts +0 -568
- package/ssh-keys.js +0 -180
- package/ssh-keys.ts +0 -122
- package/ssh-setup.js +0 -253
- package/ssh-setup.ts +0 -218
- package/types.js +0 -99
- package/types.ts +0 -389
- package/volumes.js +0 -295
- package/volumes.ts +0 -229
package/server-status.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Fetch server status from Hetzner API by IP address
|
|
4
|
-
* Used for network error detection to determine if server is actually running
|
|
5
|
-
*/
|
|
6
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
16
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
17
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
18
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19
|
-
function step(op) {
|
|
20
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
21
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
22
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
23
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
24
|
-
switch (op[0]) {
|
|
25
|
-
case 0: case 1: t = op; break;
|
|
26
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
27
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
28
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
29
|
-
default:
|
|
30
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
31
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
32
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
33
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
34
|
-
if (t[2]) _.ops.pop();
|
|
35
|
-
_.trys.pop(); continue;
|
|
36
|
-
}
|
|
37
|
-
op = body.call(thisArg, _);
|
|
38
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
39
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.getServerStatusByIP = getServerStatusByIP;
|
|
44
|
-
exports.clearServerStatusCache = clearServerStatusCache;
|
|
45
|
-
exports.getServerStatusByIPWithDefault = getServerStatusByIPWithDefault;
|
|
46
|
-
var client_js_1 = require("./client.js");
|
|
47
|
-
/**
|
|
48
|
-
* Cache for server status lookups
|
|
49
|
-
* Key: IP address, Value: { status, timestamp }
|
|
50
|
-
*/
|
|
51
|
-
var statusCache = new Map();
|
|
52
|
-
var CACHE_TTL = 30 * 1000; // 30 seconds
|
|
53
|
-
/**
|
|
54
|
-
* Get server status by IP address
|
|
55
|
-
* @param ip - The server IP address
|
|
56
|
-
* @param client - HetznerClient instance
|
|
57
|
-
* @returns Server status ("running", "stopped", etc.) or null if not found
|
|
58
|
-
*/
|
|
59
|
-
function getServerStatusByIP(ip, client) {
|
|
60
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
-
var cached, hetznerClient, servers, server, status_1, error_1;
|
|
62
|
-
return __generator(this, function (_a) {
|
|
63
|
-
switch (_a.label) {
|
|
64
|
-
case 0:
|
|
65
|
-
cached = statusCache.get(ip);
|
|
66
|
-
if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
|
|
67
|
-
return [2 /*return*/, cached.status];
|
|
68
|
-
}
|
|
69
|
-
hetznerClient = client || new client_js_1.HetznerClient();
|
|
70
|
-
_a.label = 1;
|
|
71
|
-
case 1:
|
|
72
|
-
_a.trys.push([1, 3, , 4]);
|
|
73
|
-
return [4 /*yield*/, hetznerClient.listServers()];
|
|
74
|
-
case 2:
|
|
75
|
-
servers = _a.sent();
|
|
76
|
-
server = servers.find(function (s) { return s.public_net.ipv4.ip === ip; });
|
|
77
|
-
if (server) {
|
|
78
|
-
status_1 = server.status;
|
|
79
|
-
// Cache the result
|
|
80
|
-
statusCache.set(ip, { status: status_1, timestamp: Date.now() });
|
|
81
|
-
return [2 /*return*/, status_1];
|
|
82
|
-
}
|
|
83
|
-
// Server not found
|
|
84
|
-
return [2 /*return*/, null];
|
|
85
|
-
case 3:
|
|
86
|
-
error_1 = _a.sent();
|
|
87
|
-
// Log error but don't throw - we don't want to break SSH connection on API failure
|
|
88
|
-
console.warn("[NetworkError] Failed to fetch server status for ".concat(ip, ":"), error_1);
|
|
89
|
-
return [2 /*return*/, null];
|
|
90
|
-
case 4: return [2 /*return*/];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Clear the status cache
|
|
97
|
-
* Useful for testing or when you know server state has changed
|
|
98
|
-
*/
|
|
99
|
-
function clearServerStatusCache() {
|
|
100
|
-
statusCache.clear();
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Get server status by IP with a fallback default
|
|
104
|
-
* @param ip - The server IP address
|
|
105
|
-
* @param client - HetznerClient instance (optional)
|
|
106
|
-
* @param defaultStatus - Default status to return if lookup fails (default: "unknown")
|
|
107
|
-
* @returns Server status or defaultStatus if not found/error
|
|
108
|
-
*/
|
|
109
|
-
function getServerStatusByIPWithDefault(ip_1, client_1) {
|
|
110
|
-
return __awaiter(this, arguments, void 0, function (ip, client, defaultStatus) {
|
|
111
|
-
var status;
|
|
112
|
-
if (defaultStatus === void 0) { defaultStatus = "unknown"; }
|
|
113
|
-
return __generator(this, function (_a) {
|
|
114
|
-
switch (_a.label) {
|
|
115
|
-
case 0: return [4 /*yield*/, getServerStatusByIP(ip, client)];
|
|
116
|
-
case 1:
|
|
117
|
-
status = _a.sent();
|
|
118
|
-
return [2 /*return*/, status !== null && status !== void 0 ? status : defaultStatus];
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
}
|
package/server-status.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fetch server status from Hetzner API by IP address
|
|
3
|
-
* Used for network error detection to determine if server is actually running
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { HetznerClient } from "./client.js";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Cache for server status lookups
|
|
10
|
-
* Key: IP address, Value: { status, timestamp }
|
|
11
|
-
*/
|
|
12
|
-
const statusCache = new Map<string, { status: string; timestamp: number }>();
|
|
13
|
-
const CACHE_TTL = 30 * 1000; // 30 seconds
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Get server status by IP address
|
|
17
|
-
* @param ip - The server IP address
|
|
18
|
-
* @param client - HetznerClient instance
|
|
19
|
-
* @returns Server status ("running", "stopped", etc.) or null if not found
|
|
20
|
-
*/
|
|
21
|
-
export async function getServerStatusByIP(
|
|
22
|
-
ip: string,
|
|
23
|
-
client?: HetznerClient
|
|
24
|
-
): Promise<string | null> {
|
|
25
|
-
// Check cache first
|
|
26
|
-
const cached = statusCache.get(ip);
|
|
27
|
-
if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
|
|
28
|
-
return cached.status;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// If no client provided, create one (will use env vars)
|
|
32
|
-
const hetznerClient = client || new HetznerClient();
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
// List all servers and find matching IP
|
|
36
|
-
const servers = await hetznerClient.listServers();
|
|
37
|
-
|
|
38
|
-
// Find server with matching IPv4
|
|
39
|
-
const server = servers.find(
|
|
40
|
-
(s) => s.public_net.ipv4.ip === ip
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
if (server) {
|
|
44
|
-
const status = server.status;
|
|
45
|
-
// Cache the result
|
|
46
|
-
statusCache.set(ip, { status, timestamp: Date.now() });
|
|
47
|
-
return status;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Server not found
|
|
51
|
-
return null;
|
|
52
|
-
} catch (error) {
|
|
53
|
-
// Log error but don't throw - we don't want to break SSH connection on API failure
|
|
54
|
-
console.warn(`[NetworkError] Failed to fetch server status for ${ip}:`, error);
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Clear the status cache
|
|
61
|
-
* Useful for testing or when you know server state has changed
|
|
62
|
-
*/
|
|
63
|
-
export function clearServerStatusCache(): void {
|
|
64
|
-
statusCache.clear();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Get server status by IP with a fallback default
|
|
69
|
-
* @param ip - The server IP address
|
|
70
|
-
* @param client - HetznerClient instance (optional)
|
|
71
|
-
* @param defaultStatus - Default status to return if lookup fails (default: "unknown")
|
|
72
|
-
* @returns Server status or defaultStatus if not found/error
|
|
73
|
-
*/
|
|
74
|
-
export async function getServerStatusByIPWithDefault(
|
|
75
|
-
ip: string,
|
|
76
|
-
client?: HetznerClient,
|
|
77
|
-
defaultStatus: string = "unknown"
|
|
78
|
-
): Promise<string> {
|
|
79
|
-
const status = await getServerStatusByIP(ip, client);
|
|
80
|
-
return status ?? defaultStatus;
|
|
81
|
-
}
|