@grey-ts/types 1.4.0 → 2.0.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/dist/index.d.ts +265 -93
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -187,7 +187,7 @@ declare namespace GreyHack {
|
|
|
187
187
|
interface BaseComputer<FileType extends GreyHack.File | GreyHack.FtpFile> {
|
|
188
188
|
classID: "ftpComputer" | "computer";
|
|
189
189
|
/** Returns the hostname of the machine. */
|
|
190
|
-
getName
|
|
190
|
+
getName(): string;
|
|
191
191
|
/**
|
|
192
192
|
* Creates a folder at the path provided in the arguments.
|
|
193
193
|
*
|
|
@@ -197,7 +197,7 @@ declare namespace GreyHack {
|
|
|
197
197
|
*
|
|
198
198
|
* Using this method in an SSH encryption process will cause an error to be thrown, aborting further script execution.
|
|
199
199
|
*/
|
|
200
|
-
createFolder
|
|
200
|
+
createFolder(path: string, folderName?: string): string | true;
|
|
201
201
|
/**
|
|
202
202
|
* Returns a file located at the path provided in the argument.
|
|
203
203
|
*
|
|
@@ -206,8 +206,14 @@ declare namespace GreyHack {
|
|
|
206
206
|
* If the provided path cannot be resolved, meaning that no file or folder exists, this method will return null.
|
|
207
207
|
*
|
|
208
208
|
* Providing an empty string for the path will result in an error, interrupting the script execution.
|
|
209
|
+
* @example
|
|
210
|
+
* const computer = getShell().hostComputer;
|
|
211
|
+
* const passwd = computer.file("/etc/passwd");
|
|
212
|
+
* if (passwd) {
|
|
213
|
+
* print(`Content of passwd file\n${passwd.getContent()}`)
|
|
214
|
+
* }
|
|
209
215
|
*/
|
|
210
|
-
file
|
|
216
|
+
file(path: string): FileType | null;
|
|
211
217
|
}
|
|
212
218
|
interface FtpComputer extends BaseComputer<FtpFile> {
|
|
213
219
|
classID: "ftpComputer";
|
|
@@ -219,7 +225,7 @@ declare namespace GreyHack {
|
|
|
219
225
|
/** The public IP address of the computer */
|
|
220
226
|
publicIp: string;
|
|
221
227
|
/** Returns `WIFI` or `ETHERNET` depending on the connection type the computer is currently using */
|
|
222
|
-
activeNetCard
|
|
228
|
+
activeNetCard(): "WIFI" | "ETHERNET";
|
|
223
229
|
/**
|
|
224
230
|
* Changes the password of an existing user on the computer.
|
|
225
231
|
*
|
|
@@ -227,13 +233,13 @@ declare namespace GreyHack {
|
|
|
227
233
|
*
|
|
228
234
|
* If the provided username is empty, an error will be thrown, preventing any further script execution.
|
|
229
235
|
*/
|
|
230
|
-
changePassword
|
|
236
|
+
changePassword(username: string, password: string): boolean | string;
|
|
231
237
|
/**
|
|
232
238
|
* Closes a program associated with the provided PID.
|
|
233
239
|
*
|
|
234
240
|
* You can see the list of active programs by either using {@link showProcs} or typing ps into your terminal. To close a program, you need to either be the owner of the running process or root. If closing the program fails, this method will return a string containing details. On success, it will return true. If there is no process with the provided PID, this method will return false.
|
|
235
241
|
*/
|
|
236
|
-
closeProgram
|
|
242
|
+
closeProgram(pid: number): boolean | string;
|
|
237
243
|
/**
|
|
238
244
|
* Sets up a new IP address on the computer through the Ethernet connection.
|
|
239
245
|
*
|
|
@@ -241,7 +247,7 @@ declare namespace GreyHack {
|
|
|
241
247
|
*
|
|
242
248
|
* If the computer is not connected to the internet, an error will be thrown, preventing any further script execution.
|
|
243
249
|
*/
|
|
244
|
-
connectEthernet
|
|
250
|
+
connectEthernet(netDevice: netDevice, address: string, gateway: string): string | null;
|
|
245
251
|
/**
|
|
246
252
|
* Connects to the indicated Wi-Fi network.
|
|
247
253
|
*
|
|
@@ -249,25 +255,25 @@ declare namespace GreyHack {
|
|
|
249
255
|
*
|
|
250
256
|
* Wi-Fi networks can be found via {@link wifiNetworks} or by typing iwlist as a command in the terminal.
|
|
251
257
|
*/
|
|
252
|
-
connectWifi
|
|
258
|
+
connectWifi(netDevice: netDevice, bssid: string, essid: string, password: string): true | string;
|
|
253
259
|
/**
|
|
254
260
|
* Creates a new group associated with an existing user on the computer.
|
|
255
261
|
*
|
|
256
262
|
* Root access is necessary to successfully create a group. There are limitations when creating a group, such as a character limit of 15 and that the group name may only contain alphanumeric characters. If the group creation fails, this method will return a string containing the cause of failure. On success, it will return true. If the provided arguments are empty or the username exceeds 15 characters, an error will be thrown, interrupting further script execution.
|
|
257
263
|
*/
|
|
258
|
-
createGroup
|
|
264
|
+
createGroup(username: string, group: string): true | string;
|
|
259
265
|
/**
|
|
260
266
|
* Creates a user on the computer with the specified name and password.
|
|
261
267
|
*
|
|
262
268
|
* Root access is necessary to successfully create a user. Both the username and password cannot exceed more than 15 characters and must be alphanumeric. There cannot be more than 15 users created on the same computer. If the creation fails, this method will return a string containing the reason for the failure. On success, it will return true. If the provided username is empty or either of the values exceeds 15 characters, an error will be thrown, interrupting further script execution.
|
|
263
269
|
*/
|
|
264
|
-
createUser
|
|
270
|
+
createUser(username: string, password: string): true | string;
|
|
265
271
|
/**
|
|
266
272
|
* Deletes an existing group associated with an existing user on the computer.
|
|
267
273
|
*
|
|
268
274
|
* Root access is necessary to successfully delete a group. If the group deletion fails, this method will return a string containing the cause of failure. On success, it will return true. If either of the provided values is empty, an error will be thrown, preventing further script execution.
|
|
269
275
|
*/
|
|
270
|
-
deleteGroup
|
|
276
|
+
deleteGroup(username: string, group: string): true | string;
|
|
271
277
|
/**
|
|
272
278
|
* Deletes the indicated user from the computer.
|
|
273
279
|
*
|
|
@@ -278,25 +284,25 @@ declare namespace GreyHack {
|
|
|
278
284
|
* @param username the user to remove
|
|
279
285
|
* @param removeHome remove the user's home folder as well
|
|
280
286
|
*/
|
|
281
|
-
deleteUser
|
|
287
|
+
deleteUser(username: string, removeHome?: boolean): true | string;
|
|
282
288
|
/** Returns an array of ports on the computer that are active. */
|
|
283
|
-
getPorts
|
|
289
|
+
getPorts(): Port[];
|
|
284
290
|
/**
|
|
285
291
|
* Returns a string containing groups associated with an existing user on the computer.
|
|
286
292
|
*
|
|
287
293
|
* If the user does not exist, a string with an error message will be returned. If the provided username is empty, an error will be thrown, preventing further script execution.
|
|
288
294
|
*/
|
|
289
|
-
groups
|
|
295
|
+
groups(username: string): string;
|
|
290
296
|
/** Returns a boolean indicating if the computer has internet access */
|
|
291
|
-
isNetworkActive
|
|
297
|
+
isNetworkActive(): boolean;
|
|
292
298
|
/**
|
|
293
299
|
* Returns a string containing information about all network devices available on the computer.
|
|
294
300
|
*
|
|
295
301
|
* Each item includes details about the interface name, chipset, and whether monitoring support is enabled.
|
|
296
302
|
*/
|
|
297
|
-
networkDevices
|
|
303
|
+
networkDevices(): string;
|
|
298
304
|
/** Returns a string with the gateway IP address configured on the computer. */
|
|
299
|
-
networkGateway
|
|
305
|
+
networkGateway(): string;
|
|
300
306
|
/**
|
|
301
307
|
* Reboots the computer. By default, it reboots in standard mode.
|
|
302
308
|
*
|
|
@@ -306,35 +312,31 @@ declare namespace GreyHack {
|
|
|
306
312
|
*
|
|
307
313
|
* @param safeMode reboot the system in safe mode instead
|
|
308
314
|
*/
|
|
309
|
-
reboot
|
|
315
|
+
reboot(safeMode?: boolean): true | string;
|
|
310
316
|
/**
|
|
311
317
|
* Returns a string with an overview of all active processes on the computer, including information about the user, PID, CPU, memory, and command.
|
|
312
318
|
*
|
|
313
319
|
* Using this method in an SSH encryption process will cause an error to be thrown, preventing any further script execution.
|
|
314
320
|
*/
|
|
315
|
-
showProcs
|
|
321
|
+
showProcs(): string;
|
|
316
322
|
/**
|
|
317
323
|
* Creates an empty text file at the provided path.
|
|
318
324
|
*
|
|
319
325
|
* Certain limitations apply to file creation: the file name must be alphanumeric and below 128 characters. Creation will fail if there is already a file in place or if permissions are lacking. Additionally, there is a file limit of about 250 in each folder and 3125 files in the computer overall.
|
|
320
326
|
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
327
|
* Using this method in an SSH encryption process will cause an error to be thrown, preventing any further script execution.
|
|
324
328
|
*/
|
|
325
|
-
touch
|
|
329
|
+
touch(destFolder: string, fileName: string): true | string;
|
|
326
330
|
/**
|
|
327
|
-
* Returns
|
|
331
|
+
* Returns an array of the Wi-Fi networks that are available for the provided interface.
|
|
328
332
|
*
|
|
329
|
-
* Each item in the
|
|
333
|
+
* Each item in the array is a string containing information on the BSSID, PWR, and ESSID.
|
|
330
334
|
*
|
|
331
335
|
* If the active network card is not a Wi-Fi card, an error will be thrown, preventing any further script execution.
|
|
332
336
|
*
|
|
333
|
-
* @returns
|
|
334
|
-
* @returns string with details on failure
|
|
335
|
-
* @returns null if no matching netDevice can be found
|
|
337
|
+
* @returns null if no matching netDevice can be found, otherwise the available networks
|
|
336
338
|
*/
|
|
337
|
-
wifiNetworks
|
|
339
|
+
wifiNetworks(netDevice: netDevice): string[] | null;
|
|
338
340
|
}
|
|
339
341
|
}
|
|
340
342
|
declare namespace GreyHack {
|
|
@@ -347,13 +349,13 @@ declare namespace GreyHack {
|
|
|
347
349
|
*
|
|
348
350
|
* In case the current entity is a file instead of a folder this method will return null, so it is advisable to first use the isFolder function before calling this method. In case the current folder gets deleted this method will return null as well.
|
|
349
351
|
*/
|
|
350
|
-
getFiles
|
|
352
|
+
getFiles(): FtpFile[] | null;
|
|
351
353
|
/**
|
|
352
354
|
* Returns an array of folders inside this folder.
|
|
353
355
|
*
|
|
354
356
|
* In case the current entity is a file instead of a folder this method will return null, so it is advisable to first use the isFolder function before calling this method. In case the current folder gets deleted this method will return null as well.
|
|
355
357
|
*/
|
|
356
|
-
getFolders
|
|
358
|
+
getFolders(): FtpFile[] | null;
|
|
357
359
|
}
|
|
358
360
|
interface File extends BaseFile {
|
|
359
361
|
classID: "file";
|
|
@@ -366,13 +368,13 @@ declare namespace GreyHack {
|
|
|
366
368
|
*
|
|
367
369
|
* In case the current entity is a file instead of a folder this method will return null, so it is advisable to first use the isFolder function before calling this method. In case the current folder gets deleted this method will return null as well.
|
|
368
370
|
*/
|
|
369
|
-
getFiles
|
|
371
|
+
getFiles(): File[] | null;
|
|
370
372
|
/**
|
|
371
373
|
* Returns an array of folders inside this folder.
|
|
372
374
|
*
|
|
373
375
|
* In case the current entity is a file instead of a folder this method will return null, so it is advisable to first use the isFolder function before calling this method. In case the current folder gets deleted this method will return null as well.
|
|
374
376
|
*/
|
|
375
|
-
getFolders
|
|
377
|
+
getFolders(): File[] | null;
|
|
376
378
|
/**
|
|
377
379
|
* Modifies the file permissions.
|
|
378
380
|
*
|
|
@@ -382,7 +384,7 @@ declare namespace GreyHack {
|
|
|
382
384
|
*
|
|
383
385
|
* @param recursive set the permissions recursively to every file inside this folder
|
|
384
386
|
*/
|
|
385
|
-
chmod
|
|
387
|
+
chmod(perms: string, recursive?: boolean): string;
|
|
386
388
|
/**
|
|
387
389
|
* Returns a string representing the content of the file. To read a file, the user requires read access or being root.
|
|
388
390
|
*
|
|
@@ -390,7 +392,7 @@ declare namespace GreyHack {
|
|
|
390
392
|
*
|
|
391
393
|
* If this method is used within an SSH encryption process, an error will be thrown, preventing any further script execution.
|
|
392
394
|
*/
|
|
393
|
-
getContent
|
|
395
|
+
getContent(): string | null;
|
|
394
396
|
/**
|
|
395
397
|
* Saves text into a file. The content will not get appended to the file; therefore, existing content will be overridden.
|
|
396
398
|
*
|
|
@@ -398,7 +400,7 @@ declare namespace GreyHack {
|
|
|
398
400
|
*
|
|
399
401
|
* If this method is used within an SSH encryption process, an error will be thrown, preventing any further script execution. If the permissions are lacking, this method will return false. In case the file gets deleted this method will return null.
|
|
400
402
|
*/
|
|
401
|
-
setContent
|
|
403
|
+
setContent(content: string): string | boolean | null;
|
|
402
404
|
/**
|
|
403
405
|
* Change the group related to this file.
|
|
404
406
|
*
|
|
@@ -408,7 +410,7 @@ declare namespace GreyHack {
|
|
|
408
410
|
*
|
|
409
411
|
* @param recursive set the group recursively to every file inside this folder
|
|
410
412
|
*/
|
|
411
|
-
setGroup
|
|
413
|
+
setGroup(group: string, recursive?: boolean): string | null;
|
|
412
414
|
/**
|
|
413
415
|
* Change the owner of this file.
|
|
414
416
|
*
|
|
@@ -418,7 +420,7 @@ declare namespace GreyHack {
|
|
|
418
420
|
*
|
|
419
421
|
* @param recursive set the owner recursively to every file inside this folder
|
|
420
422
|
*/
|
|
421
|
-
setOwner
|
|
423
|
+
setOwner(owner: string, recursive?: boolean): string | null;
|
|
422
424
|
/**
|
|
423
425
|
* Creates a symlink to the specified path.
|
|
424
426
|
*
|
|
@@ -426,7 +428,7 @@ declare namespace GreyHack {
|
|
|
426
428
|
*
|
|
427
429
|
* If used within an SSH encryption process, if the new name exceeds 128 characters, or if the path is too long, an error will be thrown, interrupting script execution. If the current file is deleted, this method will return null.
|
|
428
430
|
*/
|
|
429
|
-
symlink
|
|
431
|
+
symlink(path: string, newName?: string): true | string | null;
|
|
430
432
|
}
|
|
431
433
|
interface BaseFile {
|
|
432
434
|
classID: "ftpFile" | "file";
|
|
@@ -455,7 +457,7 @@ declare namespace GreyHack {
|
|
|
455
457
|
*
|
|
456
458
|
* If this method is used within an SSH encryption process, the new name exceeds 128 characters, or the path is too long, an error will be thrown, causing an interruption of script execution. In case the current file gets deleted, this method will return null.
|
|
457
459
|
*/
|
|
458
|
-
copy
|
|
460
|
+
copy(destFolder?: string, newName?: string): string | boolean | null;
|
|
459
461
|
/**
|
|
460
462
|
* Delete the current file.
|
|
461
463
|
*
|
|
@@ -463,18 +465,18 @@ declare namespace GreyHack {
|
|
|
463
465
|
*
|
|
464
466
|
* Note that deleting a file will leave a log entry.
|
|
465
467
|
*/
|
|
466
|
-
delete
|
|
468
|
+
delete(): string;
|
|
467
469
|
/** Returns a boolean indicating if the user who launched the script has the requested permissions.
|
|
468
470
|
*
|
|
469
471
|
* In case the file gets deleted, this method will return null instead.
|
|
470
472
|
*/
|
|
471
|
-
hasPermission
|
|
473
|
+
hasPermission(perms: "r" | "w" | "x"): boolean | null;
|
|
472
474
|
/** Returns a boolean indicating if the file is a binary. Returns null if the file gets deleted */
|
|
473
|
-
isBinary
|
|
475
|
+
isBinary(): boolean | null;
|
|
474
476
|
/** Returns a boolean indicating if the file is a folder. Returns null if the file gets deleted */
|
|
475
|
-
isFolder
|
|
477
|
+
isFolder(): boolean | null;
|
|
476
478
|
/** Returns a boolean indicating if the file is a symlink. Returns null if the file gets deleted */
|
|
477
|
-
isSymlink
|
|
479
|
+
isSymlink(): boolean | null;
|
|
478
480
|
/**
|
|
479
481
|
* Moves the file to the provided path.
|
|
480
482
|
*
|
|
@@ -482,12 +484,12 @@ declare namespace GreyHack {
|
|
|
482
484
|
*
|
|
483
485
|
* If this method is used within an SSH encryption process, the new name exceeds 128 characters, or the path is too long, an error will be thrown, causing an interruption of script execution. In case the current file gets deleted, this method will return null.
|
|
484
486
|
*/
|
|
485
|
-
move
|
|
487
|
+
move(destFolder: string, newName?: string): string | boolean | null;
|
|
486
488
|
/**
|
|
487
489
|
* Returns a string containing the file path. If the file has been deleted, this method will still return the path it had prior to deletion.
|
|
488
490
|
* @param symLinkOriginalPath return the original path of the linked file instead
|
|
489
491
|
*/
|
|
490
|
-
path
|
|
492
|
+
path(symLinkOriginalPath?: boolean): string;
|
|
491
493
|
/**
|
|
492
494
|
* Rename the file with the name provided.
|
|
493
495
|
*
|
|
@@ -495,7 +497,7 @@ declare namespace GreyHack {
|
|
|
495
497
|
*
|
|
496
498
|
* If this method is used within an SSH encryption process, an error will be thrown, causing the script execution to be interrupted.
|
|
497
499
|
*/
|
|
498
|
-
rename
|
|
500
|
+
rename(name: string): string;
|
|
499
501
|
}
|
|
500
502
|
}
|
|
501
503
|
/** Provides access to global variables of this script */
|
|
@@ -761,12 +763,18 @@ declare namespace GreyHack {
|
|
|
761
763
|
* }
|
|
762
764
|
*/
|
|
763
765
|
function isType<T extends keyof GameTypeMap>(value: any, type: T): value is GameTypeMap[T];
|
|
764
|
-
/**
|
|
766
|
+
/**
|
|
767
|
+
* FOR TRANSPILER ONLY
|
|
765
768
|
*
|
|
766
769
|
* Includes the given source to this position. If the file was already transpiled then this does nothing
|
|
767
770
|
*
|
|
768
771
|
* Can be a folder if you want to include all the files inside
|
|
769
|
-
*
|
|
772
|
+
*
|
|
773
|
+
* @param file The absolute or relative path of the file
|
|
774
|
+
*
|
|
775
|
+
* @example
|
|
776
|
+
* include("./commands");
|
|
777
|
+
*/
|
|
770
778
|
function include(file: string): void;
|
|
771
779
|
type LibTypes = {
|
|
772
780
|
"aptclient.so": GreyHack.AptClient;
|
|
@@ -1064,7 +1072,25 @@ declare namespace GreyHack {
|
|
|
1064
1072
|
*
|
|
1065
1073
|
* So in case a password does not exist in the game world, the decryption will fail.
|
|
1066
1074
|
*
|
|
1067
|
-
* On failure, this method will return null. Using this method in an SSH encryption process will cause an error to be thrown, aborting further script execution.
|
|
1075
|
+
* On failure, this method will return null. Using this method in an SSH encryption process will cause an error to be thrown, aborting further script execution.
|
|
1076
|
+
* @example
|
|
1077
|
+
* const crypto = includeLib("/lib/crypto.so");
|
|
1078
|
+
* if (!isType(crypto, "cryptoLib")) exit("Failed to load crypto.so");
|
|
1079
|
+
*
|
|
1080
|
+
* const computer = getShell().hostComputer;
|
|
1081
|
+
* const passwdFile = computer.file("/etc/passwd");
|
|
1082
|
+
* if (!passwdFile) exit("Failed to get passwd file");
|
|
1083
|
+
*
|
|
1084
|
+
* const lines = passwdFile.getContent()!.split(char(10));
|
|
1085
|
+
* for (const line of lines) {
|
|
1086
|
+
* const parsed = line.split(":");
|
|
1087
|
+
* const username = parsed[0];
|
|
1088
|
+
* const passwordhash = parsed[1];
|
|
1089
|
+
*
|
|
1090
|
+
* const password = crypto.decipher(passwordhash);
|
|
1091
|
+
* print(`Password for user '${username}' is: ${password}`);
|
|
1092
|
+
* }
|
|
1093
|
+
*/
|
|
1068
1094
|
decipher(hash: string): string | null;
|
|
1069
1095
|
/** Decrypts the specified file using the provided key.
|
|
1070
1096
|
*
|
|
@@ -1205,23 +1231,44 @@ declare namespace GreyHack {
|
|
|
1205
1231
|
}
|
|
1206
1232
|
}
|
|
1207
1233
|
interface Math {
|
|
1234
|
+
/** Returns the value of pi to the precision of 6 */
|
|
1208
1235
|
readonly PI: number;
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1236
|
+
/** Returns the absolute value of number. */
|
|
1237
|
+
abs(value: number): number;
|
|
1238
|
+
/** Returns the inverse cosine (in radians) of a number. */
|
|
1239
|
+
acos(value: number): number;
|
|
1240
|
+
/** Returns the inverse sine (in radians) of a number. */
|
|
1241
|
+
asin(value: number): number;
|
|
1242
|
+
/** Returns the inverse tangent (in radians) of a number. */
|
|
1243
|
+
atan(y: number, x?: number | undefined): number;
|
|
1244
|
+
/** Returns number rounded up to the integer value of the provided number. */
|
|
1245
|
+
ceil(value: number): number;
|
|
1246
|
+
/** Returns number rounded down to the integer value of the provided number. */
|
|
1247
|
+
floor(value: number): number;
|
|
1248
|
+
/** Returns the cosine of a number in radians. */
|
|
1249
|
+
cos(value: number): number;
|
|
1250
|
+
/** Returns the sine of a number in radians. */
|
|
1251
|
+
sin(value: number): number;
|
|
1252
|
+
/** Returns the tangent of a number in radians. */
|
|
1253
|
+
tan(value: number): number;
|
|
1254
|
+
/** Returns the square root of a number. */
|
|
1255
|
+
sqrt(value: number): number;
|
|
1256
|
+
/** Returns 1 or -1 indicating the sign of the value passed or 0 if the value is 0 */
|
|
1257
|
+
sign(value: number): -1 | 0 | 1;
|
|
1258
|
+
/** Returns number rounded to the integer value of the provided number. */
|
|
1259
|
+
round(value: number, fixed?: number | undefined): number;
|
|
1260
|
+
/** Returns a random number between 0 and 1. Optionally a seed number can be provided. */
|
|
1261
|
+
random(seed?: number | undefined): number;
|
|
1262
|
+
/**
|
|
1263
|
+
* Returns the natural logarithm of a number.
|
|
1264
|
+
*
|
|
1265
|
+
* By default, the base is 10. Optionally the base can be changed.
|
|
1266
|
+
*/
|
|
1267
|
+
log(value: number, base?: number | undefined): number;
|
|
1268
|
+
/** Returns the smallest number of the given values */
|
|
1269
|
+
min(...values: number[]): number;
|
|
1270
|
+
/** Returns the largest number of the given values */
|
|
1271
|
+
max(...values: number[]): number;
|
|
1225
1272
|
}
|
|
1226
1273
|
declare var Math: Math;
|
|
1227
1274
|
declare namespace GreyHack {
|
|
@@ -1299,9 +1346,9 @@ declare namespace GreyHack {
|
|
|
1299
1346
|
/** Port number used by this port */
|
|
1300
1347
|
portNumber: number;
|
|
1301
1348
|
/** Returns a boolean, where true indicates that the specified port is closed and false indicates that the port is open. */
|
|
1302
|
-
isClosed
|
|
1349
|
+
isClosed(): boolean;
|
|
1303
1350
|
/** Returns a string containing the local IP address of the computer to which the port is pointing. */
|
|
1304
|
-
getLanIp
|
|
1351
|
+
getLanIp(): string;
|
|
1305
1352
|
}
|
|
1306
1353
|
interface Router {
|
|
1307
1354
|
classID: "router";
|
|
@@ -1365,7 +1412,7 @@ declare namespace GreyHack {
|
|
|
1365
1412
|
*
|
|
1366
1413
|
* In case any provided values deviate from the defined signature a runtime exception will be thrown.
|
|
1367
1414
|
*/
|
|
1368
|
-
build
|
|
1415
|
+
build(sourcePath: string, binaryPath: string, allowImport?: boolean): string;
|
|
1369
1416
|
/**
|
|
1370
1417
|
* Returns a shell if the connection attempt to the provided IP was successful.
|
|
1371
1418
|
*
|
|
@@ -1373,7 +1420,7 @@ declare namespace GreyHack {
|
|
|
1373
1420
|
*
|
|
1374
1421
|
* In case of failure, a string is returned containing details. If this method is run in an SSH encryption process, or if the computer is not connected to the internet, a runtime exception will be thrown.
|
|
1375
1422
|
*/
|
|
1376
|
-
connectService
|
|
1423
|
+
connectService(ip: string, port: number, user: string, password: string, service?: "ssh" | "ftp"): Shell | FtpShell | string | null;
|
|
1377
1424
|
/**
|
|
1378
1425
|
* Launches the binary located at the provided path.
|
|
1379
1426
|
*
|
|
@@ -1385,13 +1432,13 @@ declare namespace GreyHack {
|
|
|
1385
1432
|
*
|
|
1386
1433
|
* There is a cooldown of 2 seconds between launches to prevent abuse. If you attempt to launch a script during this cooldown period, the method will return false.
|
|
1387
1434
|
*/
|
|
1388
|
-
launch
|
|
1435
|
+
launch(program: string, params?: string): string | boolean;
|
|
1389
1436
|
/**
|
|
1390
1437
|
* Pings an IP address.
|
|
1391
1438
|
*
|
|
1392
1439
|
* Return a boolean indicating if the remote address could be reached. Firewalls do not block ping requests. Passing an invalid ip will cause the method to return a string with an error message.
|
|
1393
1440
|
*/
|
|
1394
|
-
ping
|
|
1441
|
+
ping(ip: string): string | boolean;
|
|
1395
1442
|
/**
|
|
1396
1443
|
* Send a file to the computer related to the provided shell.
|
|
1397
1444
|
*
|
|
@@ -1401,7 +1448,7 @@ declare namespace GreyHack {
|
|
|
1401
1448
|
*
|
|
1402
1449
|
* In case of failure, this method will return a string with the cause. Otherwise, true will be returned. In case the string for sourceFile or destinationFolder is empty, an error will be thrown, preventing further script execution. Utilizing this method in an SSH encryption process will trigger an error, halting further script execution.
|
|
1403
1450
|
*/
|
|
1404
|
-
scp
|
|
1451
|
+
scp(file: string, folder: string, remoteShell: Shell, isUpload?: boolean): boolean | string;
|
|
1405
1452
|
/**
|
|
1406
1453
|
* Launches an active terminal.
|
|
1407
1454
|
*
|
|
@@ -1409,9 +1456,13 @@ declare namespace GreyHack {
|
|
|
1409
1456
|
*
|
|
1410
1457
|
* Using this method within an SSH encryption process will cause an error to be thrown, preventing further script execution.
|
|
1411
1458
|
*/
|
|
1412
|
-
startTerminal
|
|
1459
|
+
startTerminal(): never;
|
|
1413
1460
|
}
|
|
1414
1461
|
}
|
|
1462
|
+
declare const console: {
|
|
1463
|
+
readonly log: typeof GreyHack.print;
|
|
1464
|
+
readonly clear: typeof GreyHack.clearScreen;
|
|
1465
|
+
};
|
|
1415
1466
|
interface RegExp {
|
|
1416
1467
|
}
|
|
1417
1468
|
interface CallableFunction {
|
|
@@ -1423,6 +1474,7 @@ interface IArguments {
|
|
|
1423
1474
|
interface Boolean {
|
|
1424
1475
|
}
|
|
1425
1476
|
interface String {
|
|
1477
|
+
/** Returns the length of the string */
|
|
1426
1478
|
readonly length: number;
|
|
1427
1479
|
/** Returns the Unicode code of the first character of the string */
|
|
1428
1480
|
code(): number;
|
|
@@ -1430,17 +1482,69 @@ interface String {
|
|
|
1430
1482
|
indexOf(value: string, offset?: number): number | null;
|
|
1431
1483
|
indexes(): number[];
|
|
1432
1484
|
insert(index: number, value: string): string;
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1485
|
+
/**
|
|
1486
|
+
* Uses regular expression to check if a string matches a certain pattern.
|
|
1487
|
+
*
|
|
1488
|
+
* If the pattern is empty, the provided {@link https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options|regexOptions} are invalid, or if the regular expression times out, an error will be thrown, preventing further script execution.
|
|
1489
|
+
*/
|
|
1490
|
+
isMatch(pattern: string | RegExp, regexOptions?: string): boolean;
|
|
1491
|
+
/** Returns the last occurrence of a substring in the string. */
|
|
1492
|
+
lastIndexOf(searchString: string): number;
|
|
1493
|
+
/** Converts all the alphabetic characters in a string to lowercase. */
|
|
1494
|
+
toLowerCase(): string;
|
|
1495
|
+
/** Converts all the alphabetic characters in a string to uppercase. */
|
|
1496
|
+
toUpperCase(): string;
|
|
1497
|
+
/**
|
|
1498
|
+
* Returns an object with all search results for the provided regular expression.
|
|
1499
|
+
*
|
|
1500
|
+
* Each key contains the index and the value contains the matching string.
|
|
1501
|
+
*
|
|
1502
|
+
* If the pattern is empty, the provided {@link https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options|regexOptions} are invalid, or if the regular expression times out, an error will be thrown, preventing further script execution.
|
|
1503
|
+
*/
|
|
1436
1504
|
matches(pattern: string | RegExp, regexOptions?: string): Record<number, string>;
|
|
1505
|
+
/**
|
|
1506
|
+
* Returns a new string with the provided value removed
|
|
1507
|
+
* @example
|
|
1508
|
+
* const myString = "I will not eat an ice cream!";
|
|
1509
|
+
* const newString = myString.remove("not ");
|
|
1510
|
+
* print(newString); // Prints "I will eat an ice cream!"
|
|
1511
|
+
*/
|
|
1437
1512
|
remove(value: string): string;
|
|
1513
|
+
/**
|
|
1514
|
+
* Returns a string with the replaced content by using regular expressions.
|
|
1515
|
+
*
|
|
1516
|
+
* If the pattern is empty, the provided {@link https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options|regexOptions} are invalid or if the regular expression times out, an error will be thrown, preventing further script execution.
|
|
1517
|
+
*
|
|
1518
|
+
* @example
|
|
1519
|
+
* const myString = "I am now online";
|
|
1520
|
+
* const newString = myString.replace("online", "offline");
|
|
1521
|
+
* print(newString); // Prints "I am now offline"
|
|
1522
|
+
*/
|
|
1438
1523
|
replace(pattern: string | RegExp, newValue: string, regexOptions?: string): string;
|
|
1524
|
+
/**
|
|
1525
|
+
* Returns an array where each item is a segment of the string, separated by the provided separator string.
|
|
1526
|
+
*
|
|
1527
|
+
* This method uses regular expressions for matching, so remember to escape special characters such as dots.
|
|
1528
|
+
*
|
|
1529
|
+
* In case the pattern is empty, the provided {@link https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options|regexOptions} are invalid, or the regular expression times out, an error will be thrown, preventing further script execution.
|
|
1530
|
+
*
|
|
1531
|
+
* @example
|
|
1532
|
+
* const csvString = "cat,turtle,dog,mouse";
|
|
1533
|
+
* const animals = csvString.split(",");
|
|
1534
|
+
* print(animals); // Prints ["cat", "turtle", "dog", "mouse"]
|
|
1535
|
+
*/
|
|
1439
1536
|
split(pattern: string | RegExp, regexOptions?: string): string[];
|
|
1537
|
+
/**
|
|
1538
|
+
* Returns a number which is parsed from the string as an integer.
|
|
1539
|
+
*
|
|
1540
|
+
* In case the string is not numeric it will return the original string.
|
|
1541
|
+
*/
|
|
1440
1542
|
toInt(): string | number;
|
|
1543
|
+
/** Removes the leading and trailing white space and line terminator characters from a string. */
|
|
1441
1544
|
trim(): string;
|
|
1442
|
-
|
|
1545
|
+
/** Returns a number which is parsed from the string. In case the string is not numeric it will return a zero. */
|
|
1443
1546
|
val(): number;
|
|
1547
|
+
/** Returns an array where each item is a string representing all available characters in the string. Could be compared to using {@link String.split|split} but with empty separator. */
|
|
1444
1548
|
values(): string[];
|
|
1445
1549
|
/** Returns true if this string starts with the searchString. Otherwise returns false. */
|
|
1446
1550
|
startsWith(searchString: string, position?: number): boolean;
|
|
@@ -1458,45 +1562,87 @@ interface String {
|
|
|
1458
1562
|
* @param end The index to the end of the specified portion of string. The substring includes the characters up to, but not including, the character indicated by end. If this value is not specified, the substring continues to the end of string.
|
|
1459
1563
|
*/
|
|
1460
1564
|
slice(start?: number, end?: number): string;
|
|
1565
|
+
/** Returns a string representation of a string. */
|
|
1566
|
+
toString(): string;
|
|
1461
1567
|
readonly [index: number]: string;
|
|
1462
1568
|
}
|
|
1463
1569
|
interface Number {
|
|
1570
|
+
/** Returns a string representation of a number. */
|
|
1571
|
+
toString(): string;
|
|
1464
1572
|
}
|
|
1465
1573
|
type PropertyKey = number | string | symbol;
|
|
1466
1574
|
interface Object {
|
|
1467
|
-
/** Returns
|
|
1468
|
-
|
|
1469
|
-
hasIndex(key: PropertyKey): boolean;
|
|
1470
|
-
indexOf(value: any): any;
|
|
1471
|
-
indexes<T extends PropertyKey>(): T[];
|
|
1472
|
-
pop(): any;
|
|
1473
|
-
pull(): any;
|
|
1474
|
-
push(key: PropertyKey): any;
|
|
1475
|
-
remove(key: PropertyKey): boolean;
|
|
1476
|
-
replace(oldValue: any, newValue: any, maxCount?: number): any;
|
|
1477
|
-
shuffle(): null;
|
|
1478
|
-
sum(): number;
|
|
1479
|
-
values(): any[];
|
|
1575
|
+
/** Returns a string representation of an object. */
|
|
1576
|
+
toString(): string;
|
|
1480
1577
|
}
|
|
1481
1578
|
interface ObjectConstructor {
|
|
1482
1579
|
new (value?: any): Object;
|
|
1483
1580
|
readonly prototype: Object;
|
|
1581
|
+
/** Determines whether an object has a property with the specified name. */
|
|
1484
1582
|
hasOwn<T extends PropertyKey, U = object>(o: U, key: T): o is (T extends keyof U ? U : U & {
|
|
1485
1583
|
[K in T]: unknown;
|
|
1486
1584
|
});
|
|
1585
|
+
/**
|
|
1586
|
+
* Returns a key of the object that has a value equal to the given value
|
|
1587
|
+
* @example
|
|
1588
|
+
* const myObject = { test: 123, other: 222 };
|
|
1589
|
+
* const key = Object.indexOf(myObject, 222);
|
|
1590
|
+
* print(key); // Prints "other"
|
|
1591
|
+
*/
|
|
1592
|
+
indexOf<T extends Record<any, any>>(o: T, value: T[keyof T]): keyof T | null;
|
|
1487
1593
|
/** Copy the properties of the source to the target */
|
|
1488
1594
|
assign<T extends {}, U>(target: T, source: U): T & U;
|
|
1489
1595
|
assign<T extends {}, U, V>(target: T, source: U, source2: V): T & U & V;
|
|
1490
1596
|
assign<T extends {}, U, V, W>(target: T, source: U, source2: V, source3: W): T & U & V & W;
|
|
1491
1597
|
assign(target: object, ...sources: any[]): any;
|
|
1598
|
+
/** Returns the number of items inside the object */
|
|
1599
|
+
size<T extends Record<any, any>>(o: T): number;
|
|
1600
|
+
/** Returns an array of keys of the object */
|
|
1492
1601
|
keys<T extends Record<any, any>>(o: T): (Exclude<keyof T, symbol>)[];
|
|
1602
|
+
/** Returns an array of values of the object */
|
|
1603
|
+
values<T extends Record<any, any>>(o: T): (T[keyof T])[];
|
|
1604
|
+
/** Returns sum of all values inside the given object. Any non-numeric values will be considered a zero. */
|
|
1605
|
+
sum(o: Record<any, any>): number;
|
|
1606
|
+
/** Shuffles all **values** in the object. This operation will mutate the map. */
|
|
1607
|
+
shuffle(o: Record<any, any>): null;
|
|
1608
|
+
/**
|
|
1609
|
+
* Replaces each value of the object matching `oldValue` with `newValue`.
|
|
1610
|
+
*
|
|
1611
|
+
* This method will mutate the object
|
|
1612
|
+
* @example
|
|
1613
|
+
* const myObject = { status: "online" };
|
|
1614
|
+
* Object.replace(myObject, "online", "offline");
|
|
1615
|
+
* print(myObject); // Prints { "status": "offline" };
|
|
1616
|
+
*/
|
|
1617
|
+
replace<T extends Record<any, any>>(o: T, oldValue: T[keyof T], newValue: T[keyof T], maxCount?: number): T;
|
|
1618
|
+
/**
|
|
1619
|
+
* Removes a key-value pair from the object. This method mutates the object.
|
|
1620
|
+
*
|
|
1621
|
+
* @returns a boolean indicating success
|
|
1622
|
+
*/
|
|
1623
|
+
remove<T extends Record<any, any>>(o: T, key: keyof T): boolean;
|
|
1624
|
+
/**
|
|
1625
|
+
* Removes the first item of the object and returns it's key
|
|
1626
|
+
*
|
|
1627
|
+
* This method mutates the object.
|
|
1628
|
+
*/
|
|
1629
|
+
shift<T extends Record<any, any>>(o: T): keyof T | null;
|
|
1493
1630
|
}
|
|
1494
1631
|
interface Array<T> {
|
|
1495
1632
|
readonly length: number;
|
|
1633
|
+
/** Returns a boolean indicating if the provided index exists in the array */
|
|
1496
1634
|
hasIndex(index: number): boolean;
|
|
1635
|
+
/** Returns the index of the first occurrence of a value in an array, or null if it is not present. */
|
|
1497
1636
|
indexOf(value: T, offset?: number): number | null;
|
|
1637
|
+
/** Returns an array containing the indexes of the array */
|
|
1498
1638
|
indexes(): number[];
|
|
1639
|
+
/** Inserts a value into the array at the provided index. This method mutates the array and returns a reference to the same array. */
|
|
1499
1640
|
insert(index: number, value: T): T[];
|
|
1641
|
+
/**
|
|
1642
|
+
* Returns a concatenated string containing all stringified values inside the list. These values will be separated via the provided separator.
|
|
1643
|
+
*
|
|
1644
|
+
* In case the list exceeds `16777215L` items or the delimiter exceeds 128 characters, this method will throw an error, interrupting further script execution.
|
|
1645
|
+
*/
|
|
1500
1646
|
join(delimiter: string): string;
|
|
1501
1647
|
/** Removes the first element from an array and returns it. If the array is empty, null is returned. */
|
|
1502
1648
|
shift(): T | null;
|
|
@@ -1506,11 +1652,33 @@ interface Array<T> {
|
|
|
1506
1652
|
pop(): T | null;
|
|
1507
1653
|
/** Appends new elements to the end of an array, and returns the new length of the array. */
|
|
1508
1654
|
push(...items: T[]): number;
|
|
1655
|
+
/**
|
|
1656
|
+
* Removes an item from the list with the provided index. Due to the removal the list will get mutated.
|
|
1657
|
+
*/
|
|
1509
1658
|
remove(index: number): null;
|
|
1659
|
+
/**
|
|
1660
|
+
* Changes every value of the array that matches `oldValue` into `newValue`
|
|
1661
|
+
*
|
|
1662
|
+
* This method mutates the array and returns a reference to the same array.
|
|
1663
|
+
*/
|
|
1510
1664
|
replace(oldValue: T, newValue: T, maxCount?: number): T[];
|
|
1511
|
-
|
|
1665
|
+
/** Reverses the elements in an array in place. This method mutates the array and returns a reference to the same array. */
|
|
1666
|
+
reverse(): T;
|
|
1667
|
+
/** Shuffles all values in the array. This method mutates the array. */
|
|
1512
1668
|
shuffle(): null;
|
|
1513
|
-
|
|
1669
|
+
/**
|
|
1670
|
+
* Sorts the values of an array alphanumerically.
|
|
1671
|
+
*
|
|
1672
|
+
* This operation mutates the original array. Optionally, a key can be provided, which is used if the items are objects or arrays. Finally, this method returns the updated array.
|
|
1673
|
+
* @example
|
|
1674
|
+
* const myArray = [{ key: 123 }, { key: 5 }, { key: 17 }];
|
|
1675
|
+
* myArray.sort("key");
|
|
1676
|
+
*
|
|
1677
|
+
* const numbers = [1,2,3,4,5];
|
|
1678
|
+
* numbers.sort()
|
|
1679
|
+
*/
|
|
1680
|
+
sort(key?: PropertyKey | null, ascending?: boolean): T[];
|
|
1681
|
+
/** Returns a sum of all values inside the array. Any non-numeric values will be considered a zero. */
|
|
1514
1682
|
sum(): number;
|
|
1515
1683
|
values(): T[];
|
|
1516
1684
|
/** Combines two or more arrays. This method returns a new array without modifying any existing arrays.
|
|
@@ -1534,9 +1702,13 @@ interface Array<T> {
|
|
|
1534
1702
|
* @param end The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array.
|
|
1535
1703
|
* */
|
|
1536
1704
|
slice(start?: number, end?: number): T[];
|
|
1705
|
+
/** Returns a string representation of an array. */
|
|
1706
|
+
toString(): string;
|
|
1537
1707
|
[n: number]: T;
|
|
1538
1708
|
}
|
|
1539
1709
|
interface Function {
|
|
1710
|
+
/** Returns a string representation of a function. */
|
|
1711
|
+
toString(): string;
|
|
1540
1712
|
}
|
|
1541
1713
|
declare var String: {
|
|
1542
1714
|
new (value?: any): String;
|