@akaanakbaik/pterodactyl-gateway 1.0.0 → 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/README.md +288 -220
- package/add-promt.md +278 -135
- package/dist/gateway.js +12 -8
- package/dist/gateway.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/integrations.d.ts +56 -0
- package/dist/integrations.d.ts.map +1 -0
- package/dist/integrations.js +112 -0
- package/dist/integrations.js.map +1 -0
- package/package.json +36 -3
package/add-promt.md
CHANGED
|
@@ -1,22 +1,55 @@
|
|
|
1
1
|
# Add Prompt Integrasi Akadev Pterodactyl Gateway
|
|
2
2
|
|
|
3
|
-
Gunakan dokumen ini sebagai prompt tambahan saat meminta AI mengintegrasikan package `@akaanakbaik/pterodactyl-gateway` ke project Node.js, bot, dashboard, atau backend API.
|
|
3
|
+
Gunakan dokumen ini sebagai prompt tambahan saat meminta AI, coding agent, atau assistant developer mengintegrasikan package `@akaanakbaik/pterodactyl-gateway` ke project Node.js, TypeScript, bot, dashboard, website, atau backend API.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Tujuan prompt ini adalah menghasilkan integrasi yang aman, rapi, mudah dirawat, dan siap production.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Prompt utama siap pakai
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Tolong integrasikan package `@akaanakbaik/pterodactyl-gateway` versi `1.0.0` ke project saya dengan standar production.
|
|
10
10
|
|
|
11
|
-
Gunakan
|
|
11
|
+
Package ini adalah SDK TypeScript dan CLI untuk Pterodactyl Panel. Gunakan package ini untuk:
|
|
12
|
+
|
|
13
|
+
- cek koneksi panel;
|
|
14
|
+
- diagnosa konfigurasi;
|
|
15
|
+
- membuat user panel;
|
|
16
|
+
- membuat server panel;
|
|
17
|
+
- preview/dry-run payload create server;
|
|
18
|
+
- mengelola file server;
|
|
19
|
+
- mengubah startup variables;
|
|
20
|
+
- melihat resource server;
|
|
21
|
+
- mengelola backup;
|
|
22
|
+
- mengelola schedule;
|
|
23
|
+
- mengirim power signal;
|
|
24
|
+
- mengirim command aman;
|
|
25
|
+
- membuat integrasi bot WhatsApp, Telegram, Discord, API, dan website.
|
|
26
|
+
|
|
27
|
+
Gunakan env berikut dan jangan hardcode rahasia di source code:
|
|
12
28
|
|
|
13
29
|
```env
|
|
14
30
|
PTERO_DOMAIN=https://panel.example.com
|
|
15
31
|
PTERO_PTLA=isi_application_api_key
|
|
16
32
|
PTERO_PTLC=isi_client_api_key
|
|
33
|
+
PTERO_NODE_ID=1
|
|
34
|
+
PTERO_NEST_ID=5
|
|
35
|
+
PTERO_EGG_ID=18
|
|
17
36
|
```
|
|
18
37
|
|
|
19
|
-
|
|
38
|
+
Wajib gunakan error handling dengan `explainError()` agar error mudah dipahami user.
|
|
39
|
+
|
|
40
|
+
## Prinsip integrasi
|
|
41
|
+
|
|
42
|
+
- Semua rahasia wajib dari `.env` atau secret manager.
|
|
43
|
+
- Jangan log PTLA, PTLC, password, token bot, atau config profile.
|
|
44
|
+
- Semua create server wajib punya mode preview/dry-run sebelum eksekusi asli.
|
|
45
|
+
- Semua endpoint pembayaran/order wajib idempotent agar tidak membuat server dobel.
|
|
46
|
+
- Simpan `server.id`, `server.identifier`, `server.uuid`, `email`, `username`, dan status order ke database.
|
|
47
|
+
- Jangan menjalankan create server langsung dari frontend tanpa backend auth.
|
|
48
|
+
- Jangan membuka fitur delete user/server permanen tanpa guard tambahan.
|
|
49
|
+
- Jangan menambahkan kontrol node, location, atau allocation management di UI publik.
|
|
50
|
+
- Validasi input user: email, username, package/preset, dan nama server.
|
|
51
|
+
- Batasi akses fitur admin hanya untuk owner/admin.
|
|
52
|
+
- Gunakan queue untuk order massal.
|
|
20
53
|
|
|
21
54
|
## Install
|
|
22
55
|
|
|
@@ -24,128 +57,220 @@ Jangan hardcode API key atau password di source code.
|
|
|
24
57
|
npm i @akaanakbaik/pterodactyl-gateway
|
|
25
58
|
```
|
|
26
59
|
|
|
27
|
-
|
|
60
|
+
CLI global opsional:
|
|
28
61
|
|
|
29
62
|
```bash
|
|
30
63
|
npm i -g @akaanakbaik/pterodactyl-gateway
|
|
31
|
-
ptero-gateway
|
|
32
|
-
|
|
64
|
+
ptero-gateway doctor
|
|
65
|
+
ptero-gateway ids
|
|
66
|
+
ptero-gateway presets
|
|
67
|
+
ptero-gateway templates list
|
|
33
68
|
```
|
|
34
69
|
|
|
35
|
-
##
|
|
70
|
+
## Import utama
|
|
36
71
|
|
|
37
72
|
```ts
|
|
38
|
-
import {
|
|
73
|
+
import {
|
|
74
|
+
createPtero,
|
|
75
|
+
createIntegrationServerInput,
|
|
76
|
+
createIntegrationService,
|
|
77
|
+
explainError
|
|
78
|
+
} from "@akaanakbaik/pterodactyl-gateway";
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Koneksi SDK
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
const ptero = createPtero({
|
|
85
|
+
domain: process.env.PTERO_DOMAIN,
|
|
86
|
+
ptla: process.env.PTERO_PTLA,
|
|
87
|
+
ptlc: process.env.PTERO_PTLC
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
await ptero.doctor();
|
|
91
|
+
```
|
|
39
92
|
|
|
93
|
+
Atau jika env sudah pasti lengkap:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
40
96
|
const ptero = createPtero.fromEnv();
|
|
41
|
-
await ptero.connect();
|
|
42
97
|
```
|
|
43
98
|
|
|
44
|
-
|
|
99
|
+
## Helper integrasi yang disarankan
|
|
100
|
+
|
|
101
|
+
Pakai `createIntegrationService()` untuk bot dan website agar input server lebih konsisten.
|
|
45
102
|
|
|
46
103
|
```ts
|
|
47
|
-
const
|
|
104
|
+
const pterodactyl = createIntegrationService({
|
|
48
105
|
domain: process.env.PTERO_DOMAIN,
|
|
49
106
|
ptla: process.env.PTERO_PTLA,
|
|
50
107
|
ptlc: process.env.PTERO_PTLC
|
|
108
|
+
}, {
|
|
109
|
+
nodeId: Number(process.env.PTERO_NODE_ID),
|
|
110
|
+
nestId: Number(process.env.PTERO_NEST_ID),
|
|
111
|
+
eggId: Number(process.env.PTERO_EGG_ID),
|
|
112
|
+
preset: "standard",
|
|
113
|
+
autoCreateUser: true,
|
|
114
|
+
startOnCompletion: false
|
|
51
115
|
});
|
|
52
116
|
```
|
|
53
117
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
- `ptero.connect()` untuk cek koneksi.
|
|
57
|
-
- `ptero.doctor()` untuk diagnosa konfigurasi.
|
|
58
|
-
- `ptero.users.createSmart()` untuk membuat user.
|
|
59
|
-
- `ptero.users.getOrCreate()` untuk mengambil user atau membuat jika belum ada.
|
|
60
|
-
- `ptero.servers.previewCreate()` untuk melihat payload final sebelum create server.
|
|
61
|
-
- `ptero.servers.createSmart()` untuk create server dengan auto docker image, startup, environment, default allocation, dan additional allocation.
|
|
62
|
-
- `ptero.servers.createFromPreset()` untuk create server dari preset spek.
|
|
63
|
-
- `ptero.server(identifier).probe()` untuk cek endpoint client secara read-only.
|
|
64
|
-
- `ptero.server(identifier).resources()` untuk resource server.
|
|
65
|
-
- `ptero.server(identifier).start()`, `stop()`, `restart()`, `kill()` untuk power control.
|
|
66
|
-
- `ptero.server(identifier).command("npm start")` untuk kirim command.
|
|
67
|
-
- `ptero.server(identifier).files.*` untuk file manager.
|
|
68
|
-
- `ptero.server(identifier).startup.*` untuk startup variables.
|
|
69
|
-
- `ptero.server(identifier).network.*` untuk allocation/ports.
|
|
70
|
-
- `ptero.server(identifier).databases.*` untuk database manager.
|
|
71
|
-
- `ptero.server(identifier).backups.*` untuk backup manager.
|
|
72
|
-
- `ptero.server(identifier).schedules.*` untuk schedule manager.
|
|
73
|
-
- `ptero.raw.application` dan `ptero.raw.client` untuk endpoint yang belum tersedia wrapper.
|
|
74
|
-
|
|
75
|
-
## Fitur CLI penting
|
|
118
|
+
Jenis integrasi yang tersedia:
|
|
76
119
|
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
ptero-gateway connect
|
|
80
|
-
ptero-gateway ids
|
|
81
|
-
ptero-gateway ids --nest 5
|
|
82
|
-
ptero-gateway admin users
|
|
83
|
-
ptero-gateway admin servers
|
|
84
|
-
ptero-gateway servers
|
|
120
|
+
```ts
|
|
121
|
+
"whatsapp-bot" | "telegram-bot" | "discord-bot" | "nodejs-api" | "website" | "python-bot" | "blank"
|
|
85
122
|
```
|
|
86
123
|
|
|
87
|
-
|
|
124
|
+
## Flow create panel yang benar
|
|
88
125
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
126
|
+
1. Validasi user/order.
|
|
127
|
+
2. Cek pembayaran atau izin admin.
|
|
128
|
+
3. Bangun payload dengan integration helper.
|
|
129
|
+
4. Jalankan `dryRun` untuk debug saat development.
|
|
130
|
+
5. Eksekusi `create` hanya setelah order valid.
|
|
131
|
+
6. Simpan hasil server ke database.
|
|
132
|
+
7. Kirim pesan ke user tanpa membocorkan API key.
|
|
133
|
+
|
|
134
|
+
Contoh service reusable:
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
import { createIntegrationService, explainError } from "@akaanakbaik/pterodactyl-gateway";
|
|
138
|
+
|
|
139
|
+
export const pterodactyl = createIntegrationService({
|
|
140
|
+
domain: process.env.PTERO_DOMAIN,
|
|
141
|
+
ptla: process.env.PTERO_PTLA,
|
|
142
|
+
ptlc: process.env.PTERO_PTLC
|
|
143
|
+
}, {
|
|
144
|
+
nodeId: Number(process.env.PTERO_NODE_ID),
|
|
145
|
+
nestId: Number(process.env.PTERO_NEST_ID),
|
|
146
|
+
eggId: Number(process.env.PTERO_EGG_ID),
|
|
147
|
+
preset: "standard",
|
|
148
|
+
autoCreateUser: true
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
export async function createPanelForOrder(order) {
|
|
152
|
+
try {
|
|
153
|
+
const result = await pterodactyl.create({
|
|
154
|
+
kind: order.kind,
|
|
155
|
+
name: order.serverName,
|
|
156
|
+
email: order.email,
|
|
157
|
+
username: order.username,
|
|
158
|
+
password: "auto",
|
|
159
|
+
environment: order.environment ?? {}
|
|
160
|
+
});
|
|
161
|
+
return { ok: true, result };
|
|
162
|
+
} catch (error) {
|
|
163
|
+
return { ok: false, error: explainError(error) };
|
|
164
|
+
}
|
|
165
|
+
}
|
|
105
166
|
```
|
|
106
167
|
|
|
107
|
-
|
|
168
|
+
## Integrasi bot WhatsApp
|
|
108
169
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
--backups 0 \
|
|
124
|
-
--yes
|
|
170
|
+
Gunakan untuk bot Baileys, store panel via WhatsApp, atau automation order.
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
const result = await pterodactyl.create({
|
|
174
|
+
kind: "whatsapp-bot",
|
|
175
|
+
name: `wa-${user.id}`,
|
|
176
|
+
email: user.email,
|
|
177
|
+
username: `wa_${user.id}`,
|
|
178
|
+
password: "auto",
|
|
179
|
+
environment: {
|
|
180
|
+
OWNER_NUMBER: user.phone,
|
|
181
|
+
BOT_NAME: "AkaBot"
|
|
182
|
+
}
|
|
183
|
+
});
|
|
125
184
|
```
|
|
126
185
|
|
|
127
|
-
|
|
186
|
+
Instruksi untuk AI:
|
|
128
187
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
188
|
+
- Buat handler command/menu yang hanya bisa dipakai admin atau user yang sudah membayar.
|
|
189
|
+
- Tambahkan status proses: validating, dry-run, creating user, creating server, completed, failed.
|
|
190
|
+
- Simpan hasil server ke database.
|
|
191
|
+
- Jangan tampilkan token bot, API key, atau password di grup publik.
|
|
192
|
+
- Session WhatsApp harus disimpan di volume/server file, bukan memory sementara.
|
|
193
|
+
|
|
194
|
+
## Integrasi bot Telegram
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
const result = await pterodactyl.create({
|
|
198
|
+
kind: "telegram-bot",
|
|
199
|
+
name: `tg-${ctx.from.id}`,
|
|
200
|
+
email: `${ctx.from.id}@telegram.local`,
|
|
201
|
+
username: `tg_${ctx.from.id}`,
|
|
202
|
+
password: "auto"
|
|
203
|
+
});
|
|
138
204
|
```
|
|
139
205
|
|
|
140
|
-
|
|
206
|
+
Instruksi untuk AI:
|
|
141
207
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
208
|
+
- Gunakan Telegram ID sebagai identifier utama, bukan username.
|
|
209
|
+
- Gunakan inline keyboard untuk konfirmasi paket.
|
|
210
|
+
- Wajib cek transaksi sebelum create server.
|
|
211
|
+
- Tambahkan rate limit per Telegram ID.
|
|
212
|
+
- Kirim hasil lewat private chat jika berisi data sensitif.
|
|
213
|
+
|
|
214
|
+
## Integrasi bot Discord
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
const result = await pterodactyl.create({
|
|
218
|
+
kind: "discord-bot",
|
|
219
|
+
name: `dc-${interaction.user.id}`,
|
|
220
|
+
email: `${interaction.user.id}@discord.local`,
|
|
221
|
+
username: `dc_${interaction.user.id}`,
|
|
222
|
+
password: "auto"
|
|
223
|
+
});
|
|
146
224
|
```
|
|
147
225
|
|
|
148
|
-
|
|
226
|
+
Instruksi untuk AI:
|
|
227
|
+
|
|
228
|
+
- Gunakan ephemeral reply untuk data akun.
|
|
229
|
+
- Batasi command berdasarkan role.
|
|
230
|
+
- Jangan kirim credential di channel publik.
|
|
231
|
+
- Log audit ke channel admin tanpa password/API key.
|
|
232
|
+
|
|
233
|
+
## Integrasi website atau REST API
|
|
234
|
+
|
|
235
|
+
Pola aman untuk Express/Fastify/Next API:
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
app.post("/api/panel/preview", async (req, res) => {
|
|
239
|
+
const result = await pterodactyl.dryRun({
|
|
240
|
+
kind: "website",
|
|
241
|
+
name: req.body.name,
|
|
242
|
+
email: req.body.email,
|
|
243
|
+
username: req.body.username,
|
|
244
|
+
password: "auto"
|
|
245
|
+
});
|
|
246
|
+
res.json(result);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
app.post("/api/panel/create", async (req, res) => {
|
|
250
|
+
try {
|
|
251
|
+
const result = await pterodactyl.create({
|
|
252
|
+
kind: "website",
|
|
253
|
+
name: req.body.name,
|
|
254
|
+
email: req.body.email,
|
|
255
|
+
username: req.body.username,
|
|
256
|
+
password: "auto"
|
|
257
|
+
});
|
|
258
|
+
res.json({ ok: true, result });
|
|
259
|
+
} catch (error) {
|
|
260
|
+
res.status(400).json({ ok: false, error: explainError(error) });
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Instruksi untuk AI:
|
|
266
|
+
|
|
267
|
+
- Tambahkan middleware auth admin atau payment verification.
|
|
268
|
+
- Tambahkan schema validation.
|
|
269
|
+
- Tambahkan rate limit.
|
|
270
|
+
- Tambahkan idempotency key agar refresh tidak membuat server baru.
|
|
271
|
+
- Jangan expose PTLA/PTLC ke frontend.
|
|
272
|
+
|
|
273
|
+
## Create user manual
|
|
149
274
|
|
|
150
275
|
```ts
|
|
151
276
|
const user = await ptero.users.createSmart({
|
|
@@ -156,18 +281,18 @@ const user = await ptero.users.createSmart({
|
|
|
156
281
|
});
|
|
157
282
|
```
|
|
158
283
|
|
|
159
|
-
Jika `password` diisi `auto`, package membuat password
|
|
284
|
+
Jika `password` diisi `auto`, package membuat password dan mengembalikannya sekali pada response. Simpan dengan aman atau minta user reset password.
|
|
160
285
|
|
|
161
|
-
## Create server
|
|
286
|
+
## Create server manual
|
|
162
287
|
|
|
163
288
|
```ts
|
|
164
289
|
const server = await ptero.servers.createSmart({
|
|
165
290
|
name: "Bot WhatsApp Aka",
|
|
166
291
|
email: "user@example.com",
|
|
167
292
|
username: "aka_test",
|
|
168
|
-
password: "
|
|
293
|
+
password: "auto",
|
|
169
294
|
autoCreateUser: true,
|
|
170
|
-
description: "Server bot WhatsApp
|
|
295
|
+
description: "Server bot WhatsApp",
|
|
171
296
|
nodeId: 1,
|
|
172
297
|
nestId: 5,
|
|
173
298
|
eggId: 18,
|
|
@@ -197,63 +322,81 @@ const server = await ptero.servers.createSmart({
|
|
|
197
322
|
- `specs.allocations`
|
|
198
323
|
- `specs.backups`
|
|
199
324
|
|
|
200
|
-
## Field otomatis create server
|
|
201
|
-
|
|
202
|
-
- docker image dari egg
|
|
203
|
-
- startup command dari egg
|
|
204
|
-
- environment variables dari egg
|
|
205
|
-
- default allocation dari node
|
|
206
|
-
- additional allocations sesuai allocation limit
|
|
207
|
-
- swap default `0`
|
|
208
|
-
- block IO default `500`
|
|
209
|
-
- CPU pinning default kosong
|
|
210
|
-
- OOM disabled default `false`
|
|
211
|
-
|
|
212
325
|
## Preview dan dry-run
|
|
213
326
|
|
|
214
327
|
```ts
|
|
215
328
|
const preview = await ptero.servers.previewCreate(input);
|
|
216
329
|
console.log(preview.payload);
|
|
330
|
+
|
|
331
|
+
const dryRun = await ptero.servers.createSmart(input, { dryRun: true });
|
|
332
|
+
console.log(dryRun.payload);
|
|
217
333
|
```
|
|
218
334
|
|
|
335
|
+
## Kontrol server
|
|
336
|
+
|
|
219
337
|
```ts
|
|
220
|
-
const
|
|
221
|
-
|
|
338
|
+
const server = ptero.server("311d56b7");
|
|
339
|
+
|
|
340
|
+
await server.resources();
|
|
341
|
+
await server.files.list("/");
|
|
342
|
+
await server.files.read("/package.json");
|
|
343
|
+
await server.files.write("/tmp/test.txt", "halo");
|
|
344
|
+
await server.startup.variables();
|
|
345
|
+
await server.startup.set("CMD_RUN", "node index.js");
|
|
346
|
+
await server.backups.list();
|
|
347
|
+
await server.start();
|
|
348
|
+
await server.stop();
|
|
222
349
|
```
|
|
223
350
|
|
|
224
|
-
## Error handling
|
|
351
|
+
## Error handling wajib
|
|
225
352
|
|
|
226
353
|
```ts
|
|
227
354
|
import { explainError } from "@akaanakbaik/pterodactyl-gateway";
|
|
228
355
|
|
|
229
356
|
try {
|
|
230
|
-
await
|
|
357
|
+
await pterodactyl.create(input);
|
|
231
358
|
} catch (error) {
|
|
232
359
|
console.error(explainError(error));
|
|
233
360
|
}
|
|
234
361
|
```
|
|
235
362
|
|
|
236
|
-
##
|
|
363
|
+
## CLI penting saat debugging
|
|
237
364
|
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
365
|
+
```bash
|
|
366
|
+
ptero-gateway version
|
|
367
|
+
ptero-gateway self-check
|
|
368
|
+
ptero-gateway release-check
|
|
369
|
+
ptero-gateway doctor
|
|
370
|
+
ptero-gateway ids
|
|
371
|
+
ptero-gateway ids --nest 5
|
|
372
|
+
ptero-gateway presets
|
|
373
|
+
ptero-gateway templates list
|
|
374
|
+
ptero-gateway explain DOMAIN_REQUIRED
|
|
375
|
+
ptero-gateway explain DOCKER_IMAGE_NOT_FOUND
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## Checklist output AI yang diharapkan
|
|
379
|
+
|
|
380
|
+
Saat AI mengintegrasikan package ini, pastikan output akhirnya memiliki:
|
|
381
|
+
|
|
382
|
+
- file `.env.example` tanpa secret asli;
|
|
383
|
+
- service wrapper `pterodactyl.ts` atau `pterodactyl.js`;
|
|
384
|
+
- validasi input;
|
|
385
|
+
- dry-run endpoint/command;
|
|
386
|
+
- create endpoint/command dengan auth;
|
|
387
|
+
- error handling `explainError()`;
|
|
388
|
+
- audit log order;
|
|
389
|
+
- dokumentasi cara isi env;
|
|
390
|
+
- tidak ada PTLA/PTLC hardcoded;
|
|
391
|
+
- tidak ada command node/location/allocation management publik;
|
|
392
|
+
- tidak ada delete user/server permanen tanpa guard.
|
|
393
|
+
|
|
394
|
+
## Catatan versi
|
|
395
|
+
|
|
396
|
+
Gunakan versi utama `1.0.0` atau `latest`.
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
npm i @akaanakbaik/pterodactyl-gateway@1.0.0
|
|
245
400
|
```
|
|
246
401
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
- Simpan config rahasia di `.env`.
|
|
250
|
-
- Jangan log API key atau password.
|
|
251
|
-
- Gunakan `previewCreate()` atau `dryRun` sebelum create server final.
|
|
252
|
-
- Gunakan `explainError()` untuk pesan error yang mudah dipahami.
|
|
253
|
-
- Create server wajib memakai `nodeId`, `nestId`, dan `eggId` berupa angka.
|
|
254
|
-
- Jika ID node, nest, atau egg salah, arahkan user untuk cek `ptero-gateway ids` atau Admin Panel Pterodactyl.
|
|
255
|
-
- Jika allocation kosong, arahkan user menambah allocation di Admin Panel > Nodes > Allocations.
|
|
256
|
-
- Semua aksi yang mengubah server via CLI wajib memakai `--yes`.
|
|
257
|
-
- Write file via CLI default hanya boleh ke `/tmp`; untuk path lain wajib `--allow-any-path`.
|
|
258
|
-
- Jangan menjalankan command berisiko tanpa izin jelas dari user.
|
|
259
|
-
- Delete server/user permanen belum dibuka di v0.3.0 dan perlu guard tambahan.
|
|
402
|
+
Jika menemukan dokumentasi lama yang menyebut versi sebelum `1.0.0`, arahkan ke README terbaru dan gunakan `latest`.
|
package/dist/gateway.js
CHANGED
|
@@ -19,7 +19,7 @@ export class PteroGateway {
|
|
|
19
19
|
this.applicationKey = config.ptla ?? config.applicationKey;
|
|
20
20
|
this.clientKey = config.ptlc ?? config.clientKey;
|
|
21
21
|
this.timeout = config.timeout ?? 15000;
|
|
22
|
-
this.userAgent = config.userAgent ?? "AkadevPterodactylGateway/0.
|
|
22
|
+
this.userAgent = config.userAgent ?? "AkadevPterodactylGateway/1.0.0";
|
|
23
23
|
this.safeMode = config.safeMode ?? true;
|
|
24
24
|
this.presets = config.presets ?? {};
|
|
25
25
|
this.http = new HttpCore({
|
|
@@ -355,8 +355,8 @@ export class PteroServerHandle {
|
|
|
355
355
|
return this.power("kill");
|
|
356
356
|
}
|
|
357
357
|
command(command, options) {
|
|
358
|
-
if (!options?.allowDangerous && isDangerousCommand(command))
|
|
359
|
-
throw new PteroError({ code: "DANGEROUS_COMMAND_BLOCKED", message: "Command terlihat berbahaya dan diblokir oleh safe mode.", hint: "Gunakan allowDangerous: true hanya jika benar-benar paham risikonya." });
|
|
358
|
+
if (this.gateway.safeMode && !options?.allowDangerous && isDangerousCommand(command))
|
|
359
|
+
throw new PteroError({ code: "DANGEROUS_COMMAND_BLOCKED", message: "Command terlihat berbahaya dan diblokir oleh safe mode.", hint: "Gunakan allowDangerous: true atau safeMode: false hanya jika benar-benar paham risikonya." });
|
|
360
360
|
return this.gateway.raw.client.post(`/servers/${this.identifier}/command`, { command });
|
|
361
361
|
}
|
|
362
362
|
}
|
|
@@ -407,10 +407,14 @@ function mapTaskInput(input) {
|
|
|
407
407
|
return output;
|
|
408
408
|
}
|
|
409
409
|
function isDangerousCommand(command) {
|
|
410
|
-
const value = command.toLowerCase();
|
|
411
|
-
const
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
410
|
+
const value = command.toLowerCase().trim();
|
|
411
|
+
const patterns = [
|
|
412
|
+
/(^|[;&|`$()\s])rm\s+-[a-z]*r[a-z]*f[a-z]*\s+(\/|\/\*|~|~\/|\.\.)(\s|$)/,
|
|
413
|
+
/(^|[;&|`$()\s])mkfs(\.|\s|$)/,
|
|
414
|
+
/(^|[;&|`$()\s])dd\s+.*\bof=\/(dev|boot|etc|usr|var|home|root)\b/,
|
|
415
|
+
/(^|[;&|`$()\s])(shutdown|poweroff|halt|reboot)(\s|$)/,
|
|
416
|
+
/:\s*\(\s*\)\s*\{\s*:\s*\|\s*:\s*&\s*}\s*;/
|
|
417
|
+
];
|
|
418
|
+
return patterns.some(pattern => pattern.test(value));
|
|
415
419
|
}
|
|
416
420
|
//# sourceMappingURL=gateway.js.map
|