@grey-ts/types 1.3.0 → 1.5.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.
Files changed (2) hide show
  1. package/dist/index.d.ts +1225 -105
  2. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -1,51 +1,218 @@
1
1
  declare namespace GreyHack {
2
2
  interface Coin {
3
3
  classID: "coin";
4
- createSubWallet(walletID: string, pin: string, subwalletUser: string, subwalletPassword: string): string | true | null;
4
+ /**
5
+ * Registers a new account in the coin that can be used to manage services such as stores.
6
+ *
7
+ * It is necessary to provide the PIN of the owner's wallet that wants to register.
8
+ *
9
+ * In case of success, the method will return true. In case of an error, a string with the details is returned.
10
+ */
11
+ createSubWallet(walletID: string, pin: string, subwalletUser: string, subwalletPassword: string): string | true;
12
+ /** Returns the configured address that will be shown to users who do not have the currency, indicating where they have to register.
13
+ *
14
+ * In case of an error, it returns a string with details.
15
+ */
5
16
  getAddress(): string;
17
+ /**
18
+ * Returns a number representing the defined interval in which each user receives a coin reward when mining.
19
+ *
20
+ * In case of failure, the method will return a string with details.
21
+ */
6
22
  getCycleMining(): number | string;
23
+ /**
24
+ * Returns a number representing the amount of coins that have been mined so far.
25
+ *
26
+ * In case of an error, it returns a string with details.
27
+ */
7
28
  getMinedCoins(): number | string;
29
+ /**
30
+ * Returns a number representing the amount of coins that will be received as a reward after each mining cycle.
31
+ *
32
+ * In case of failure, the method will return a string with details.
33
+ */
8
34
  getReward(): number | string;
9
- getSubwallet(subwalletUser: string): SubWallet | string | null;
35
+ /**
36
+ * Returns a {@link SubWallet} on success.
37
+ *
38
+ * In case of error, it returns a string with the details.
39
+ */
40
+ getSubwallet(subwalletUser: string): SubWallet | string;
41
+ /**
42
+ * Returns an array where each item is a {@link SubWallet}, including all the accounts registered in the cryptocurrency.
43
+ *
44
+ * In case of error, it returns a string with the details.
45
+ */
10
46
  getSubwallets(): SubWallet[] | string;
47
+ /** Resets the password of the coin. It returns true if resetting was successful; otherwise, it will return a string. */
11
48
  resetPassword(newPassword: string): true | string;
12
- setAddress(address: string): true | string | null;
13
- setCycleMining(rateHours: number): true | string | null;
14
- setReward(coinAmount: number): true | string | null;
15
- transaction(subwalletFrom: string, subwalletTo: string, amount: number): true | string | null;
49
+ /**
50
+ * Configures a valid address that will be shown to users who do not have the currency, indicating where to register.
51
+ *
52
+ * In case of an error, it returns a string with the details. In case of success, true will be returned.
53
+ */
54
+ setAddress(address: string): true | string;
55
+ /**
56
+ * Defines the interval (in-game hours) in which each user receives a coin reward when mining.
57
+ *
58
+ * The interval cannot be lower than 1 and not higher than 2160.
59
+ *
60
+ * On success, it will return true. In case of failure, the method will return a string with details.
61
+ */
62
+ setCycleMining(rateHours: number): true | string;
63
+ /**
64
+ * Assigns the reward that miners will receive after each mining cycle. The reward value has to be above one.
65
+ *
66
+ * On success, it will return true. In case of failure, the method will return a string with details.
67
+ */
68
+ setReward(coinAmount: number): true | string;
69
+ /**
70
+ * Facilitates a transaction of the currency between the indicated subwallets.
71
+ *
72
+ * In case of an error, a string with the details is returned. In case of success, true will be returned.
73
+ */
74
+ transaction(subwalletFrom: string, subwalletTo: string, amount: number): true | string;
16
75
  }
17
76
  interface SubWallet {
18
77
  classID: "subwallet";
19
- walletUsername(): string;
78
+ /** Returns a boolean indicating if the credentials are correct. For some cases, this method will return a string with an error message. */
20
79
  checkPassword(password: string): true | string;
80
+ /** Returns a string with the name of the wallet to which this subwallet belongs. */
81
+ walletUsername(): string;
82
+ /** Deletes the account registered in the cryptocurrency.
83
+ *
84
+ * Returns a boolean indicating if the deletion was successful. In case of certain failures, this method may return a string with details.
85
+ */
21
86
  delete(): boolean | string;
87
+ /** Returns a number of coins of a given currency. In case of error, a string with the details is returned. */
22
88
  getBalance(): number | string;
89
+ /** Returns a string with the information stored by the coin creator. */
23
90
  getInfo(): string;
91
+ /** Returns a string with the username associated with this subwallet. On failure, this method returns a string with an error message. */
24
92
  getUser(): string;
93
+ /**
94
+ * Returns a list with the information of the last transaction.
95
+ *
96
+ * Index 0 is a string with the other subWallet. Index 1 is an integer with the amount. Index 2 is a number indicating the direction of the transaction (0 for Deposit, 1 for Withdrawal). Index 3 is a string indicating the date of the transaction.
97
+ *
98
+ * On failure, this method will either return false or a string with an error message.
99
+ */
25
100
  lastTransaction(): [string, number, 0 | 1, string] | false | string;
101
+ /**
102
+ * Starts the process of mining the cryptocurrency. The process leaves the terminal busy until a coin is mined.
103
+ *
104
+ * On success, this method will return true. On failure, this method will return a string with details.
105
+ */
26
106
  mining(): true | string;
107
+ /**
108
+ * Stores optional information in the Subwallet for any use.
109
+ *
110
+ * Upon success, true will be returned. In case of failure, a string with details will be returned.
111
+ */
27
112
  setInfo(info: string): true | string;
28
113
  }
29
114
  interface Wallet {
30
115
  classID: "wallet";
116
+ /**
117
+ * Publishes a purchase offer indicating the number of coins you wish to buy and the price ($) per unit you are willing to pay.
118
+ *
119
+ * The purchase will be finalized if there is any sale offer with a price less than or equal to the one proposed in the purchase.
120
+ *
121
+ * If there is no eligible offer to sell at that time, the offer to buy will remain publicly visible until a new offer to sell satisfies the requirements.
122
+ *
123
+ * If the publication has been successful, true is returned. In case of error, a string with the details is returned.
124
+ */
31
125
  buyCoin(coinName: string, coinAmount: number, unitPrice: number, subwalletUser: string): true | string;
32
- cancelPendingTrade(coinName: string): string | null;
33
- getBalance(coinName: string): number | string | null;
34
- getGlobalOffers(coinName: string): string | Record<string, [string, number, number]> | null;
35
- getPendingTrade(coinName: string): string | Record<string, [string, number, number]> | null;
126
+ /**
127
+ * Cancel any pending offer of a certain coin.
128
+ *
129
+ * On success, an empty string will be returned. On failure, a string with an error message will be returned.
130
+ */
131
+ cancelPendingTrade(coinName: string): string;
132
+ /** Returns a number of coins of a given currency. In case of error, a string with the details is returned. */
133
+ getBalance(coinName: string): number | string;
134
+ /**
135
+ * Returns a record with all the offers made by any player of a given currency.
136
+ *
137
+ * The key of the record represents the WalletID of the player who has made the offer, and the value of the record is an array where index 0 represents the type of offer with a string (Buy/Sell), index 1 represents the amount to sell or buy, and index 2 represents the price per unit.
138
+ *
139
+ * In case of failure, this method returns a string with details.
140
+ */
141
+ getGlobalOffers(coinName: string): string | Record<"Buy" | "Sell", [string, number, number]>;
142
+ /**
143
+ * Returns an array with the pending sale or purchase offer of this wallet for a certain currency.
144
+ *
145
+ * Index 0 of the array represents the type of offer with a string (Buy/Sell), index 1 represents the quantity to be sold or bought, and index 2 represents the price per unit.
146
+ *
147
+ * On failure, this method will return a string with details.
148
+ */
149
+ getPendingTrade(coinName: string): ["Buy" | "Sell", number, number] | string;
150
+ /** Returns a string with a PIN that refreshes every few minutes. This PIN is used to obtain an account in cryptocurrency services. */
36
151
  getPin(): string;
152
+ /**
153
+ * Returns a list where each item is a string with the names of the coins available in the wallet.
154
+ *
155
+ * On failure this method returns a string with an error message.
156
+ */
37
157
  listCoins(): string[] | string;
158
+ /**
159
+ * Returns a list where each item is a string containing the names of all the currencies that exist.
160
+ *
161
+ * In case of failure, this method returns a string with details.
162
+ */
38
163
  listGlobalCoins(): string[] | string;
39
- resetPassword(newPassword: string): true | string | null;
164
+ /**
165
+ * Change the password of the wallet. Only the account owner can perform this action.
166
+ *
167
+ * If the process is completed successfully, true will be returned. In case of an error, a string with details will be returned.
168
+ */
169
+ resetPassword(newPassword: string): true | string;
170
+ /**
171
+ * Publishes a sale offer indicating the amount of coins you want to sell and the price ($) per unit you want to assign.
172
+ *
173
+ * The sale will be finalized if there is any purchase offer with a price greater than or equal to that proposed in the sale. If there is no existing offer to buy that matches the requirements at that time, the offer to sell will remain publicly visible until a new offer to buy satisfies the requirements.
174
+ *
175
+ * If the publication has been successful, true is returned. In case of error, a string with the details is returned.
176
+ */
40
177
  sellCoin(coinName: string, coinAmount: number, unitPrice: number, subwalletUser: string): true | string;
41
- showNodes(coinName: string): string | number | null;
178
+ /**
179
+ * Returns a number representing the count of devices mining a specific coin for the same wallet.
180
+ *
181
+ * In case of an error, a string with details is returned.
182
+ */
183
+ showNodes(coinName: string): string | number;
42
184
  }
43
185
  }
44
186
  declare namespace GreyHack {
45
187
  interface BaseComputer<FileType extends GreyHack.File | GreyHack.FtpFile> {
46
188
  classID: "ftpComputer" | "computer";
189
+ /** Returns the hostname of the machine. */
47
190
  getName: () => string;
48
- createFolder: (path: string, folderName?: string) => string | boolean;
191
+ /**
192
+ * Creates a folder at the path provided in the arguments.
193
+ *
194
+ * There are certain limitations to creating a folder: the folder name has to be alphanumeric and below 128 characters. Creation will fail if there is already a folder in place or if there are lacking permissions. Additionally, there is a folder limit of about 250 in each folder and 3125 folders in the computer overall.
195
+ *
196
+ * In case the folder creation fails, the method will return a string with details. In case of success, it will return true.
197
+ *
198
+ * Using this method in an SSH encryption process will cause an error to be thrown, aborting further script execution.
199
+ */
200
+ createFolder: (path: string, folderName?: string) => string | true;
201
+ /**
202
+ * Returns a file located at the path provided in the argument.
203
+ *
204
+ * The path can be either relative or absolute. It's important to note that any file object can represent a folder as well.
205
+ *
206
+ * If the provided path cannot be resolved, meaning that no file or folder exists, this method will return null.
207
+ *
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
+ * }
215
+ */
49
216
  file: (path: string) => FileType | null;
50
217
  }
51
218
  interface FtpComputer extends BaseComputer<FtpFile> {
@@ -53,95 +220,383 @@ declare namespace GreyHack {
53
220
  }
54
221
  interface Computer extends BaseComputer<File> {
55
222
  classID: "computer";
223
+ /** The local IP address of the computer */
56
224
  localIp: string;
225
+ /** The public IP address of the computer */
57
226
  publicIp: string;
58
- activeNetCard: () => string;
59
- changePassword: (username: string, password: string) => boolean | string | null;
60
- closeProgram: (pid: number) => boolean | string | null;
227
+ /** Returns `WIFI` or `ETHERNET` depending on the connection type the computer is currently using */
228
+ activeNetCard: () => "WIFI" | "ETHERNET";
229
+ /**
230
+ * Changes the password of an existing user on the computer.
231
+ *
232
+ * Root access is necessary to successfully change the password. Passwords can only include alphanumeric characters and cannot exceed 15 characters. If the password change fails, this method will return a string containing information on why it failed. If the change succeeds, it will return true.
233
+ *
234
+ * If the provided username is empty, an error will be thrown, preventing any further script execution.
235
+ */
236
+ changePassword: (username: string, password: string) => boolean | string;
237
+ /**
238
+ * Closes a program associated with the provided PID.
239
+ *
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.
241
+ */
242
+ closeProgram: (pid: number) => boolean | string;
243
+ /**
244
+ * Sets up a new IP address on the computer through the Ethernet connection.
245
+ *
246
+ * It's not possible to set up a new IP address while being logged in as a guest. On failure, this method will either return a string with details or null. On success, it will return an empty string.
247
+ *
248
+ * If the computer is not connected to the internet, an error will be thrown, preventing any further script execution.
249
+ */
61
250
  connectEthernet: (netDevice: netDevice, address: string, gateway: string) => string | null;
62
- connectWifi: (netDevice: netDevice, bssid: string, essid: string, password: string) => boolean | string | null;
63
- createGroup: (username: string, group: string) => boolean | string | null;
64
- createUser: (username: string, password: string) => boolean | string | null;
65
- deleteGroup: (username: string, group: string) => boolean | string | null;
66
- deleteUser: (username: string, removeHome?: boolean) => boolean | string | null;
251
+ /**
252
+ * Connects to the indicated Wi-Fi network.
253
+ *
254
+ * It's not possible to connect to a new Wi-Fi while being logged in as a guest. If connecting to a new Wi-Fi fails, this method will return a string containing details. On success, it will return true.
255
+ *
256
+ * Wi-Fi networks can be found via {@link wifiNetworks} or by typing iwlist as a command in the terminal.
257
+ */
258
+ connectWifi: (netDevice: netDevice, bssid: string, essid: string, password: string) => true | string;
259
+ /**
260
+ * Creates a new group associated with an existing user on the computer.
261
+ *
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.
263
+ */
264
+ createGroup: (username: string, group: string) => true | string;
265
+ /**
266
+ * Creates a user on the computer with the specified name and password.
267
+ *
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.
269
+ */
270
+ createUser: (username: string, password: string) => true | string;
271
+ /**
272
+ * Deletes an existing group associated with an existing user on the computer.
273
+ *
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.
275
+ */
276
+ deleteGroup: (username: string, group: string) => true | string;
277
+ /**
278
+ * Deletes the indicated user from the computer.
279
+ *
280
+ * Root access is necessary to successfully delete a user. Keep in mind that you cannot delete the root user.
281
+ *
282
+ * If the deletion fails, this method will return a string containing the cause of failure. On success, it will return true. If the provided username is empty, an error will be thrown, interrupting further script execution.
283
+ *
284
+ * @param username the user to remove
285
+ * @param removeHome remove the user's home folder as well
286
+ */
287
+ deleteUser: (username: string, removeHome?: boolean) => true | string;
288
+ /** Returns an array of ports on the computer that are active. */
67
289
  getPorts: () => Port[];
68
- groups: (username: string) => string | null;
290
+ /**
291
+ * Returns a string containing groups associated with an existing user on the computer.
292
+ *
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.
294
+ */
295
+ groups: (username: string) => string;
296
+ /** Returns a boolean indicating if the computer has internet access */
69
297
  isNetworkActive: () => boolean;
298
+ /**
299
+ * Returns a string containing information about all network devices available on the computer.
300
+ *
301
+ * Each item includes details about the interface name, chipset, and whether monitoring support is enabled.
302
+ */
70
303
  networkDevices: () => string;
304
+ /** Returns a string with the gateway IP address configured on the computer. */
71
305
  networkGateway: () => string;
72
- reboot: (safeMode?: boolean) => boolean | string | null;
306
+ /**
307
+ * Reboots the computer. By default, it reboots in standard mode.
308
+ *
309
+ * On success, the method returns true. If the reboot fails, a descriptive error message is returned as a string.
310
+ *
311
+ * Calling this method in an SSH encryption process will trigger an error, halting further script execution.
312
+ *
313
+ * @param safeMode reboot the system in safe mode instead
314
+ */
315
+ reboot: (safeMode?: boolean) => true | string;
316
+ /**
317
+ * Returns a string with an overview of all active processes on the computer, including information about the user, PID, CPU, memory, and command.
318
+ *
319
+ * Using this method in an SSH encryption process will cause an error to be thrown, preventing any further script execution.
320
+ */
73
321
  showProcs: () => string;
74
- touch: (destFolder: string, fileName: string) => boolean | string;
322
+ /**
323
+ * Creates an empty text file at the provided path.
324
+ *
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.
326
+ *
327
+ * Using this method in an SSH encryption process will cause an error to be thrown, preventing any further script execution.
328
+ */
329
+ touch: (destFolder: string, fileName: string) => true | string;
330
+ /**
331
+ * Returns an array of the Wi-Fi networks that are available for the provided interface.
332
+ *
333
+ * Each item in the array is a string containing information on the BSSID, PWR, and ESSID.
334
+ *
335
+ * If the active network card is not a Wi-Fi card, an error will be thrown, preventing any further script execution.
336
+ *
337
+ * @returns null if no matching netDevice can be found, otherwise the available networks
338
+ */
75
339
  wifiNetworks: (netDevice: netDevice) => string[] | null;
76
- getName: () => string;
77
- createFolder: (path: string, folderName?: string) => string | boolean;
78
340
  }
79
341
  }
80
342
  declare namespace GreyHack {
81
343
  interface FtpFile extends BaseFile {
82
344
  classID: "ftpFile";
345
+ /** The parent folder of the current file or folder */
83
346
  parent: FtpFile | null;
347
+ /**
348
+ * Returns an array of files inside this folder.
349
+ *
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.
351
+ */
84
352
  getFiles: () => FtpFile[] | null;
353
+ /**
354
+ * Returns an array of folders inside this folder.
355
+ *
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.
357
+ */
85
358
  getFolders: () => FtpFile[] | null;
86
359
  }
87
360
  interface File extends BaseFile {
88
361
  classID: "file";
362
+ /** The parent folder of the current file or folder */
89
363
  parent: File | null;
364
+ /** Indicates if the file is a binary and can be imported by other scripts */
90
365
  allowImport: boolean;
366
+ /**
367
+ * Returns an array of files inside this folder.
368
+ *
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.
370
+ */
91
371
  getFiles: () => File[] | null;
372
+ /**
373
+ * Returns an array of folders inside this folder.
374
+ *
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.
376
+ */
92
377
  getFolders: () => File[] | null;
378
+ /**
379
+ * Modifies the file permissions.
380
+ *
381
+ * The format for applying permissions is as follows: `[references][operator][modes]`. The references type is defined through three possible types: user `u`, group `g`, and other `o`. The operator is used to define if permissions get added "+" or removed "-". There are three different modes that can be modified: read `r`, write `w`, and execute `x`. So, for example, `o-wrx` would remove all possible permissions for others. To add all permissions for others again, `o+wrx` would be used.
382
+ *
383
+ * In case the modification fails, this method will return a string containing information about the reason. Otherwise, an empty string is returned.
384
+ *
385
+ * @param recursive set the permissions recursively to every file inside this folder
386
+ */
93
387
  chmod: (perms: string, recursive?: boolean) => string;
388
+ /**
389
+ * Returns a string representing the content of the file. To read a file, the user requires read access or being root.
390
+ *
391
+ * Note that you cannot read a binary file. In case of failure, null will be returned.
392
+ *
393
+ * If this method is used within an SSH encryption process, an error will be thrown, preventing any further script execution.
394
+ */
94
395
  getContent: () => string | null;
396
+ /**
397
+ * Saves text into a file. The content will not get appended to the file; therefore, existing content will be overridden.
398
+ *
399
+ * To set new content, the user requires write permissions or being root. Keep in mind that text files cannot exceed the character limit of 160,000. In case setting the content was successful, true will be returned. Otherwise, a string with details will be returned.
400
+ *
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.
402
+ */
95
403
  setContent: (content: string) => string | boolean | null;
404
+ /**
405
+ * Change the group related to this file.
406
+ *
407
+ * The group name cannot exceed 15 characters. Additionally either write permissions or being root is required. In case of failure, a string with details. On success, an empty string gets returned. In case the current file gets deleted, this method will return null.
408
+ *
409
+ * If the passed group value is empty, the group value is longer than 15 characters, or the passed recursive value deviates from its original type, an error will be thrown, preventing further script execution.
410
+ *
411
+ * @param recursive set the group recursively to every file inside this folder
412
+ */
96
413
  setGroup: (group: string, recursive?: boolean) => string | null;
414
+ /**
415
+ * Change the owner of this file.
416
+ *
417
+ * The owner's name cannot exceed 15 characters. Additionally either write permissions or being root is required. In case of failure a string gets returned containing the cause. Otherwise an empty string gets returned. In case the current file gets deleted, this method will return null.
418
+ *
419
+ * If the passed owner value is empty, the owner value is longer than 15 characters, or the passed recursive value deviates from its original type, an error will be thrown, interrupting further script execution.
420
+ *
421
+ * @param recursive set the owner recursively to every file inside this folder
422
+ */
97
423
  setOwner: (owner: string, recursive?: boolean) => string | null;
98
- symlink: (path: string, newName?: string) => string | boolean | null;
424
+ /**
425
+ * Creates a symlink to the specified path.
426
+ *
427
+ * Symlinks can only be created if the user has write permissions or is root. The new filename must be alphanumeric and under 128 characters. Upon success, this method returns true. On failure, it returns a string with details.
428
+ *
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.
430
+ */
431
+ symlink: (path: string, newName?: string) => true | string | null;
99
432
  }
100
433
  interface BaseFile {
101
434
  classID: "ftpFile" | "file";
435
+ /** The name of the file. Is null if the file gets deleted before accessing this */
102
436
  name: string | null;
103
- group: string;
437
+ /** The name of the group this file belongs to. Is null if the file gets deleted before accessing this */
438
+ group: string | null;
439
+ /** The name of the file owner. Is null if the file gets deleted before accessing this */
104
440
  owner: string | null;
441
+ /**
442
+ * The permissions of the file. Is null if the file gets deleted before accessing this
443
+ *
444
+ * The format for this permissions string is as follows: `[fileType][wrx](u)[wrx](g)[wrx](o)`. The file type is either `d` in case it's a directory or `-`. The user type gets defined through three possible types: user `u`, group `g`, and other `o`. There are three different permission types: read `r`, write `w`, and execute `x`. An example of a string returned by this method would be `-rwxr-xr-x`.
445
+ */
105
446
  permissions: string | null;
447
+ /**
448
+ * The size of the file in bytes. Is null if the file gets deleted before accessing this
449
+ *
450
+ * There is no correlation between file size and actual file content. Instead, the file size is depending on the name of the file
451
+ */
106
452
  size: string | null;
453
+ /**
454
+ * Copies the file to the provided path.
455
+ *
456
+ * Files can only be copied if the user has read and write permissions or is root. The new filename has to be below 128 characters and alphanumeric. After success, this method will return true. Otherwise, it will return a string containing information about the reason for failure.
457
+ *
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.
459
+ */
107
460
  copy: (destFolder?: string, newName?: string) => string | boolean | null;
461
+ /**
462
+ * Delete the current file.
463
+ *
464
+ * To delete files, write permissions are required or being root. In case of failure, a string with details will be returned. Otherwise, an empty string gets returned.
465
+ *
466
+ * Note that deleting a file will leave a log entry.
467
+ */
108
468
  delete: () => string;
469
+ /** Returns a boolean indicating if the user who launched the script has the requested permissions.
470
+ *
471
+ * In case the file gets deleted, this method will return null instead.
472
+ */
109
473
  hasPermission: (perms: "r" | "w" | "x") => boolean | null;
474
+ /** Returns a boolean indicating if the file is a binary. Returns null if the file gets deleted */
110
475
  isBinary: () => boolean | null;
476
+ /** Returns a boolean indicating if the file is a folder. Returns null if the file gets deleted */
111
477
  isFolder: () => boolean | null;
478
+ /** Returns a boolean indicating if the file is a symlink. Returns null if the file gets deleted */
112
479
  isSymlink: () => boolean | null;
480
+ /**
481
+ * Moves the file to the provided path.
482
+ *
483
+ * Files can only be moved if the user has read and write permissions or is root. The new filename has to be below 128 characters and alphanumeric. After success, this method will return true. Otherwise, this method will return a string with details.
484
+ *
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.
486
+ */
113
487
  move: (destFolder: string, newName?: string) => string | boolean | null;
488
+ /**
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.
490
+ * @param symLinkOriginalPath return the original path of the linked file instead
491
+ */
114
492
  path: (symLinkOriginalPath?: boolean) => string;
115
- rename: (name: string) => string | boolean;
493
+ /**
494
+ * Rename the file with the name provided.
495
+ *
496
+ * Files can only be renamed if the user has write permissions or is root. The new filename has to be below 128 characters and alphanumeric. On failure, this method will return a string with details. Otherwise, this method will return an empty string.
497
+ *
498
+ * If this method is used within an SSH encryption process, an error will be thrown, causing the script execution to be interrupted.
499
+ */
500
+ rename: (name: string) => string;
116
501
  }
117
502
  }
503
+ /** Provides access to global variables of this script */
118
504
  declare var globals: any;
119
505
  /** The parameters given to this script on launch */
120
506
  declare var params: string[];
121
507
  declare namespace GreyHack {
122
- function abs(value: number): number;
123
- function acos(value: number): number;
508
+ /** Returns a string with the name of the user who is executing the current script. */
124
509
  function activeUser(): string;
125
- function asin(value: number): number;
126
- function atan(y: number, x?: number): number;
510
+ /** Performs a bitwise AND for the provided values. Warning: If either operand is >= `0x80000000`, it'll always return 0. */
127
511
  function bitAnd(a: number, b: number): number;
512
+ /** Performs a bitwise OR for the provided values. Warning: If either operand is >= `0x80000000`, it'll always return 0. */
128
513
  function bitOr(a: number, b: number): number;
514
+ /** Performs a bitwise XOR for the provided values. Warning: If either operand is >= `0x80000000`, it'll always return 0. */
129
515
  function bitXor(a: number, b: number): number;
130
- function bitwise(operator: "~" | "&" | "|" | "^" | "<<" | ">>" | ">>>", a: number, b?: number): number;
516
+ /**
517
+ * Returns a number by performing bitwise operations.
518
+ *
519
+ * Warning: If either operand is >= `0x80000000`, it'll always returns 0.
520
+ */
521
+ function bitwise(operator: "~", a: number): number;
522
+ function bitwise(operator: "&" | "|" | "^" | "<<" | ">>" | ">>>", a: number, b: number): number;
523
+ /**
524
+ * Changes the current working directory of the active shell to the specified path.
525
+ *
526
+ * On success, an empty string is returned. If the operation fails, a descriptive error message is returned as a string.
527
+ *
528
+ * If this method is invoked during an SSH encryption process, a runtime error is thrown and further script execution is halted.
529
+ */
131
530
  function cd(path: string): string;
132
- function ceil(value: number): number;
531
+ /**
532
+ * Returns the UTF-16 character string related to the provided unicode number.
533
+ *
534
+ * The provided number needs to be between 0 and 65535. Any number which is outside this range will cause the script to throw a runtime error.
535
+ *
536
+ * Beware when passing non-ASCII values to intrinsics as they will likely get re-encoded as UTF-8. For example, `md5(char(255))` will actually return the hash of the two-byte sequence `0xC3 0xBF`.
537
+ */
133
538
  function char(code: number): string;
539
+ /**
540
+ * Removes any text existing in a Terminal prior to this point.
541
+ *
542
+ * Utilizing this method in an SSH encryption process will trigger an error, halting further script execution.
543
+ */
134
544
  function clearScreen(): null;
545
+ /** Returns the Unicode number of the first character of the string. In case an empty string is provided the script execution will crash. */
135
546
  function code(char: string): number;
547
+ /**
548
+ * Returns a string value of a translation. Translations include commands, documentation and other game-related things.
549
+ *
550
+ * Checkout {@link https://github.com/LoadingHome/Grey-Texts/blob/main/EnglishLang.json|Grey-Texts} for an overview of all available keys.
551
+ *
552
+ * If the provided command name is empty this method will throw an error causing the script to stop.
553
+ */
136
554
  function commandInfo(commandName: string): string;
137
- function cos(value: number): number;
555
+ /**
556
+ * Returns a string containing the current date and time. Ingame time passes 15 times as fast as real-time - 4 seconds per in-game minute.
557
+ *
558
+ * The initial time after every wipe will be the 1st of January 2000 at 6:00 AM. Additionally, the game time will not proceed while the server is offline.
559
+ *
560
+ * Output schema: `[day]/[month]/[year] - [hours]:[minutes]`
561
+ *
562
+ * Example output: `27/Jan/2000 - 08:19`
563
+ */
138
564
  function currentDate(): string;
565
+ /** Returns a string with the current active working directory. The working directory can be changed via the `cd` command. */
139
566
  function currentPath(): string;
567
+ /**
568
+ * Stops execution of the currently running script.
569
+ *
570
+ * Optionally a message can be provided which will be shown in the Terminal. There is also the possibility of styling output by using {@link https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/manual/index.html|TextMeshPro rich-text tags}.
571
+ */
140
572
  function exit(message?: string): never;
141
- function floor(value: number): number;
573
+ /**
574
+ * Returns a string which is the formatted version of the provided text.
575
+ *
576
+ * Keep in mind that {@link https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/manual/index.html|TextMeshPro rich-text tags} might screw up the output. When using tags consider applying these after formatting.
577
+ */
142
578
  function formatColumns(columns: string): string;
579
+ /**
580
+ * Returns the absolute path of the given path string.
581
+ *
582
+ * If the path is already absolute, it is returned unchanged. Otherwise, it is resolved against the current working path by default, or against the provided base path if specified.
583
+ *
584
+ * If the path exceeds 1024 characters, the base path exceeds 64 characters, a runtime exception is thrown.
585
+ */
143
586
  function getAbsPath(path: string, basePath?: string): string;
587
+ /**
588
+ * Returns {@link CtfEvent} if there is one available.
589
+ *
590
+ * In case of failure this method will return a string with details.
591
+ */
144
592
  function getCtf(user: string, password: string, eventName: string): CtfEvent | string;
593
+ /**
594
+ * Returns an object which is shared throughout script execution.
595
+ *
596
+ * Can be helpful if it desired to pass or receive values when using {@link Shell.launch}.
597
+ *
598
+ * Using this method in a SSH encryption process will cause an error to be thrown preventing further script execution.
599
+ */
145
600
  function getCustomObject<T = object>(): T & Record<string, any>;
146
601
  /** Returns by default the {@link Router router} to which the executing computer is connected to.
147
602
  *
@@ -171,38 +626,132 @@ declare namespace GreyHack {
171
626
  * if (switch) print("This device is a switch!");
172
627
  */
173
628
  function getSwitch(ip: string): Router | null;
629
+ /**
630
+ * Returns numeric hash for the provided data.
631
+ *
632
+ * Using this method within a SSH encryption process will cause an error to be thrown causing the script execution to stop.
633
+ */
174
634
  function hash(value: any): number;
635
+ /** Returns a string with the home folder path of the user who is executing the current script. */
175
636
  function homeDir(): string;
637
+ /** Enables to import code from different sources into one file. */
176
638
  function importCode(path: string): null;
639
+ /**
640
+ * Enables the inclusion of library binaries, which can be used inside your script.
641
+ *
642
+ * If successful, an object related to the provided library will be returned; otherwise, null is returned.
643
+ *
644
+ * This function is exclusively for importing library binaries. If you want to import custom scripts or binaries into your project, use {@link importCode} instead. That is only for files ingame. For files in your editor, use {@link include}
645
+ *
646
+ * Leaving the path empty will cause an error to be thrown, interrupting further script execution.
647
+ */
177
648
  function includeLib(path: string): LibTypes[keyof LibTypes] | null;
649
+ /** Returns a boolean indicating if the given IP is a valid LAN address */
178
650
  function isLanIp(ip: string): boolean;
651
+ /** Returns a boolean indicating if the given IP is valid */
179
652
  function isValidIp(ip: string): boolean;
653
+ /** Returns a string containing the path of the script that was initially executed, meaning that even when using {@link Shell.launch}, it will still return the path of the initially executed script. */
180
654
  function launchPath(): string;
181
- function log(value: number, base?: number): number;
182
- function mailLogin(user: string, pass: string): MetaMail | string | null;
655
+ /**
656
+ * Returns a {@link MetaMail} entity if the login was successful.
657
+ *
658
+ * On failure a string with details gets returned.
659
+ *
660
+ * Utilizing this method in an SSH encryption process will trigger an error, halting further script execution.
661
+ */
662
+ function mailLogin(user: string, pass: string): MetaMail | string;
663
+ /**
664
+ * Returns the MD5 hash string of the provided string.
665
+ *
666
+ * Using this method within an SSH encryption process will cause an error to be thrown, stopping any further script execution.
667
+ */
183
668
  function md5(value: string): string;
669
+ /**
670
+ * Returns the IP address for the provided web address.
671
+ *
672
+ * In case the web address cannot be found a string gets returned containing the following message: `Not found`.
673
+ *
674
+ * If the provided web address is empty this method will throw an error preventing further script execution.
675
+ */
184
676
  function nslookup(webAddress: string): string;
677
+ /**
678
+ * Returns a string which is the parent path of the provided path.
679
+ *
680
+ * The path provided needs to be properly formatted. If the path is empty, this method will throw an error interrupting further script execution.
681
+ */
185
682
  function parentPath(path: string): string;
186
- function pi(): number;
683
+ /**
684
+ * Print a message on the Terminal.
685
+ *
686
+ * There is also the possibility of styling output by using {@link https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/manual/index.html|TextMeshPro rich-text tags}.
687
+ *
688
+ * @param replaceText Clear the terminal before printing. This can be useful for creating a loading bar for example.
689
+ */
187
690
  function print(value: any, replaceText?: boolean): null;
691
+ /** Returns a string containing the path of the script that is currently executing. It will update when using {@link Shell.launch|launch}, which makes it different from {@link launchPath}. */
188
692
  function programPath(): string;
693
+ /**
694
+ * Generates an array where each item is a number. By default, if only one argument is provided, the list starts at the given value and decrements by one for each item.
695
+ *
696
+ * You can optionally define a start and end value, as well as customize the incremental value. However, if the incremental value is zero, or if the list exceeds `16777215L` items, the function will throw a runtime error.
697
+ */
189
698
  function range(start: number, end?: number, increment?: number): number[];
699
+ /**
700
+ * Resets the password of your CTF account.
701
+ *
702
+ * Returns true if resetting was successful; otherwise, it will return a string containing the reason for failure.
703
+ */
190
704
  function resetCtfPassword(newPassword: string): true | string;
191
- function rnd(seed?: number): number;
192
- function round(value: number, fixed?: number): number;
193
- function sign(value: number): number;
194
- function sin(value: number): number;
705
+ /**
706
+ * Returns a sliced version of the passed object.
707
+ *
708
+ * The returned object will contain all elements related to the provided start and end index. If no start or end index is provided this method will essentially return a shallow copy of the passed object.
709
+ */
195
710
  function slice<T extends Array<any> | string>(value: T, startIndex?: number, endIndex?: number): T extends string ? string : T;
196
- function sqrt(value: number): number;
711
+ /** Returns the string value of provided data. */
197
712
  function str(value: any): string;
198
- function tan(value: number): number;
713
+ /** Returns a number of seconds representing the elapsed time since the script started. */
199
714
  function time(): number;
715
+ /**
716
+ * Returns a string containing the bank account number of the player who is executing the script.
717
+ *
718
+ * If the user does not have a bank this method will return null.
719
+ */
200
720
  function userBankNumber(): string | null;
721
+ /**
722
+ * Pauses script execution to receive input from the user.
723
+ *
724
+ * The prompt message can include {@link https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/manual/index.html|TextMeshPro rich-text tags} for styling. Input is submitted by pressing Enter.
725
+ *
726
+ * Using this function during an SSH encryption process will throw a runtime error and halt further script execution.
727
+ *
728
+ * @param message A message to display on the terminal
729
+ * @param isPassword hide what's being typed
730
+ * @param anyKey capture a single key press and return
731
+ * @param addToHistory saves the input to the input history, allowing it to be recalled with the arrow keys
732
+ */
201
733
  function userInput(message?: string, isPassword?: boolean, anyKey?: boolean, addToHistory?: boolean): string;
734
+ /**
735
+ * Returns a string containing the email address of the player who is executing the script.
736
+ *
737
+ * If the user does not have an email address this method will return null.
738
+ */
202
739
  function userMailAddress(): string | null;
203
- function wait(seconds: number): null;
740
+ /**
741
+ * Pauses the script execution. Optionally, the duration can be provided via the time argument. By default, the duration will be 1 second.
742
+ *
743
+ * The duration cannot be below 0.01 or above 300; otherwise, this method will throw a runtime exception.
744
+ */
745
+ function wait(seconds?: number): null;
746
+ /**
747
+ * Returns a string containing the administrator information behind an IP address provided.
748
+ *
749
+ * In case of failure the returned string will contain an error message instead. If the provided ip is empty this method will throw an error causing the script to stop.
750
+ */
204
751
  function whois(ip: string): string;
752
+ /** Waits for the next tick. */
205
753
  function yield(): null;
754
+ /** Returns the type of the object */
206
755
  function getType(value: any): keyof GameTypeMap;
207
756
  /** Checks if the given object is of a specific type
208
757
  * @example
@@ -214,12 +763,18 @@ declare namespace GreyHack {
214
763
  * }
215
764
  */
216
765
  function isType<T extends keyof GameTypeMap>(value: any, type: T): value is GameTypeMap[T];
217
- /** FOR TRANSPILER ONLY
766
+ /**
767
+ * FOR TRANSPILER ONLY
218
768
  *
219
769
  * Includes the given source to this position. If the file was already transpiled then this does nothing
220
770
  *
221
771
  * Can be a folder if you want to include all the files inside
222
- * @param file The absolute or relative path of the file */
772
+ *
773
+ * @param file The absolute or relative path of the file
774
+ *
775
+ * @example
776
+ * include("./commands");
777
+ */
223
778
  function include(file: string): void;
224
779
  type LibTypes = {
225
780
  "aptclient.so": GreyHack.AptClient;
@@ -320,159 +875,587 @@ type GameTypeMap = ClassIDMap & OtherTypeMap;
320
875
  declare namespace GreyHack {
321
876
  interface Service {
322
877
  classID: "service";
878
+ /**
879
+ * Installs the necessary files for the correct functioning of the service and starts it.
880
+ *
881
+ * If the installation is completed successfully, it returns true. In case of an error, it returns a string with details.
882
+ */
323
883
  installService(): true | string;
884
+ /**
885
+ * Starts the service and opens its associated port on the local machine.
886
+ *
887
+ * The service requires a port forwarded to the router to be accessible from the outside.
888
+ *
889
+ * If the service starts correctly, it returns true. In case of an error, it returns a string with details.
890
+ */
324
891
  startService(): true | string;
325
- stopService(): true | string;
892
+ /**
893
+ * Stops the service and closes its associated port on the local machine.
894
+ *
895
+ * If the service is stopped successfully, it returns true.
896
+ *
897
+ * If an error occurs during the process, it returns a string with details. In some cases, the returned value might be false, indicating that the service removal failed.
898
+ */
899
+ stopService(): boolean | string;
326
900
  }
327
901
  interface Metaxploit {
328
902
  classID: "MetaxploitLib";
903
+ /**
904
+ * Returns a {@link MetaLib} object for the provided path to the library binary. Keep in mind that this can only be used on library files.
905
+ *
906
+ * On failure, this method will return null. If the provided path is empty, this method will throw a runtime exception, preventing further script execution.
907
+ */
329
908
  load(path: string): MetaLib | null;
909
+ /**
910
+ * Returns a {@link NetSession} object for the provided IP address and port.
911
+ *
912
+ * Note that if the port is set to zero, it will return a {@link NetSession} related to the kernel router.
913
+ *
914
+ * The main purpose of this method is to gain a {@link NetSession} and then use {@link NetSession.dumpLib} to receive a {@link MetaLib} object to exploit vulnerabilities.
915
+ *
916
+ * In case of failure, this method will return null. If this method is used within an SSH encryption process or with disabled internet, or if an invalid target IP is provided, this method will throw a runtime exception. */
330
917
  netUse(ip: string, port: number): NetSession | null;
918
+ /**
919
+ * Launches a process on the victim's computer, silently attempting to continuously connect in the background to the specified address and port.
920
+ *
921
+ * For the reverse shell to run successfully, the rshell service must be installed, and the port forward must be configured correctly on the machine where the server is waiting for the victim's connection.
922
+ *
923
+ * If the launch was successful, true will be returned. In case of failure, a string with details will be returned.
924
+ */
331
925
  rshellClient(ip: string, port: number, processName?: string): true | string;
926
+ /** This method returns an array of {@link Shell} objects that have been reverse shell connected to this computer.
927
+ *
928
+ * To manage the connections received, the rshell service must be installed on the machine that receives the victims' connections.
929
+ *
930
+ * In case of failure a string will be returned with details. */
332
931
  rshellServer(): Shell[] | string;
932
+ /** Returns an array where each item is a string representing a memory area which has vulnerabilities related to the provided library.
933
+ *
934
+ * These memory areas can be used to make further scans via {@link Metaxploit.scanAddress}.
935
+ *
936
+ * In case of failure, this method returns null instead.
937
+ *
938
+ * An example of a memory area would be `0x7BFC1EAA`.
939
+ *
940
+ * Using this method within a SSH encryption process will throw a runtime exception. */
333
941
  scan(metaLib: MetaLib): string[] | null;
942
+ /**
943
+ * Returns a string containing information about each vulnerability in the provided library and memory area.
944
+ *
945
+ * In case the scanning fails this method will return null.
946
+ *
947
+ * Using this method within a SSH encryption process will throw a runtime exception.
948
+ */
334
949
  scanAddress(metaLib: MetaLib, memoryAddress: string): string | null;
950
+ /**
951
+ * The terminal listens to the network packets of any connection that passes through the computer.
952
+ *
953
+ * When any connection information gets captured, it will print a string with the obtained data.
954
+ *
955
+ * In case saving of encryption source is enabled it will download the source code of the script responsible for encryption.
956
+ *
957
+ * In case the operation fails this method will return null.
958
+ *
959
+ * Using this method within a SSH encryption process will throw a runtime exception.
960
+ */
335
961
  sniffer(saveEncSource?: boolean): string | null;
336
962
  }
337
963
  interface MetaLib {
338
964
  classID: "MetaLib";
965
+ /** The name of the library. An example of a name would be `init.so`. */
339
966
  libName: string;
967
+ /** Version number of the library. An example of a version number would be `1.0.0`. */
340
968
  version: string;
341
- debugTools(user: string, password: string): string | DebugLibrary | null;
342
- isPatched(getDate?: boolean): boolean | string | null;
969
+ /**
970
+ * Returns a library in debug mode as a {@link DebugLibrary} object.
971
+ *
972
+ * A valid Neurobox engineer's username and password are required to access this mode.
973
+ *
974
+ * If successful, the {@link DebugLibrary} object is returned; in case of an error, a string with details is provided. */
975
+ debugTools(user: string, password: string): DebugLibrary | string;
976
+ /**
977
+ * Returns by default a boolean indicating whether the library has been patched.
978
+ *
979
+ * True indicates that the library has been patched, while false indicates that it has not.
980
+ *
981
+ * If the getdate parameter is set to true, the function will return a string containing the date of the last patch. The data format is as follows: `dd/MM/yyyy`.
982
+ *
983
+ * Additionally if there is any error the return value will be a string.
984
+ */
985
+ isPatched(getDate?: boolean): boolean | string;
986
+ /**
987
+ * Exploits vulnerabilities in target systems by executing various attack vectors against libraries located in the `/lib` folder.
988
+ *
989
+ * The function requires a memory address, vulnerability identifier, and optional arguments that are mandatory for password changes (new password) and computer exploits (LAN IP address).
990
+ *
991
+ * The system validates that the target library exists and is properly located in the `/lib` directory before proceeding otherwise it will return null.
992
+ *
993
+ * If the network where the library is located is disabled, the function returns a string indicating the network status.
994
+ *
995
+ * The exploit will fail and return null if the target is behind a firewall or if any of the specific vulnerability requirements aren't met, such as insufficient registered users, missing required libraries with correct versions, inadequate port forwards, absence of required user types like active guests or root users, or invalid file paths.
996
+ *
997
+ * If the target vulnerability is identified as a zero-day exploit, the system will load the appropriate zero-day vulnerability before execution.
998
+ *
999
+ * During execution, if a super admin intercepts the exploit attempt, user privileges are automatically lowered to guest level.
1000
+ *
1001
+ * Shell exploits, once all requirements are met, always return a shell object.
1002
+ *
1003
+ * Random folder exploits return a file object if the specified path exists or null if the folder cannot be found.
1004
+ *
1005
+ * Password change exploits return true for successful password modification or false for failure due to guest user restrictions, invalid alphanumeric format, or exceeding the 15-character limit.
1006
+ *
1007
+ * Settings override exploits work only on smart appliances like fridges or microwaves and return true for success or false for failure.
1008
+ *
1009
+ * Traffic light exploits require targets on the police station's network and return true for success or false for failure.
1010
+ *
1011
+ * Firewall exploits need router targets and return true for success or false for failure.
1012
+ *
1013
+ * Computer exploits return a computer object when successful or false if the LAN IP is invalid, the computer doesn't exist, or no non-root user is available.
1014
+ *
1015
+ * Using {@link isType} or {@link getType} to verify return value types is essential before processing results due to the variety of possible return types.
1016
+ */
343
1017
  overflow(memoryAddress: string, unsecZone: string, optArgs?: string): Shell | Computer | File | string | boolean | null;
344
1018
  }
345
1019
  interface DebugLibrary {
346
1020
  classID: "debugLibrary";
347
- applyPatch(path: string): string | null;
348
- payload<T extends string | undefined>(memZone: string, filePath?: T): string | null | (T extends string ? [Partial<Computer>, Partial<File>, MetaLib] : [Partial<Computer>]);
1021
+ /** Applies a patch containing corrected code to the specified text file at the provided path.
1022
+ *
1023
+ * Returns a string with the result of the operation. */
1024
+ applyPatch(path: string): string;
1025
+ /** Returns a list containing a single partial computer object if zero-day vulnerabilities are detected within the specified memory zone.
1026
+ *
1027
+ * If a file path is provided, a partial file object associated with this path will also be included in the array.
1028
+ *
1029
+ * Additionally, if this file is a library, its corresponding metaLib object is added to the returned array.
1030
+ *
1031
+ * In case of an error, a string with details is returned. */
1032
+ payload(memZone: string): string | [Partial<Computer>];
1033
+ payload(memZone: string, filePath: string): string | [Partial<Computer>, Partial<File>] | [Partial<Computer>, Partial<File>, MetaLib];
1034
+ /** Scans the library in debug mode to identify potential code errors that may lead to vulnerabilities.
1035
+ *
1036
+ * If issues are detected, the relevant code snippets are printed. In case of an error, a string containing the error message is returned. */
349
1037
  scan(): string;
350
- unitTesting(errorLines: number[]): string | null;
1038
+ /** Conducts automated tests on the specified lines of code.
1039
+ *
1040
+ * If potential vulnerabilities are detected due to errors in these lines, this method will print partial objects that could be obtained by exploiting the vulnerability, along with the affected memory zone and detailed vulnerability information.
1041
+ *
1042
+ * In case of failure, this function returns a string with an error message. */
1043
+ unitTesting(errorLines: number[]): string;
351
1044
  }
352
1045
  interface Crypto {
353
1046
  classID: "cryptoLib";
1047
+ /** Returns a string containing the password based on the file which was generated via aireplay.
1048
+ *
1049
+ * In case of failure, it will return null instead. If the provided path is empty, an error will be thrown, interrupting the script execution. */
354
1050
  aircrack(path: string): string | null;
1051
+ /** Used to inject frames on wireless interfaces.
1052
+ *
1053
+ * Once the command with `Control+C` is stopped, it will save the captured information in a text file called `file.cap` in the path where the terminal is currently located.
1054
+ *
1055
+ * Alternatively, a maximum of captured acks can be specified for the command to stop automatically, saving the `file.cap` file as described above.
1056
+ *
1057
+ * To figure out how many ACKs are required, you can use the following formula: `300000 / (Power + 15)`.
1058
+ *
1059
+ * If there is an error, a string will be returned with the message indicating the problem. On success, it will return null, it is advised though to verify that the capture file actually exists.
1060
+ *
1061
+ * In case any of the provided values deviate from the signature types or bssid/essid is empty, an error will be thrown preventing any further script execution. */
355
1062
  aireplay(bssid: string, essid: string, maxAcks?: number): string | null;
1063
+ /** Enables or disables the monitor mode of a network device.
1064
+ *
1065
+ * Monitor mode can only be enabled on Wifi cards.
1066
+ *
1067
+ * If it wasn't possible to enable or disable the monitor mode, this method will return either false or a string with details. In case of success, it will return true. */
356
1068
  airmon(option: "start" | "stop", device: netDevice): boolean | string;
1069
+ /** Returns a decrypted password via the provided password MD5 hash.
1070
+ *
1071
+ * Keep in mind that this method is not decrypting a password but rather checking for existing passwords within the game world with a matching MD5 hash.
1072
+ *
1073
+ * So in case a password does not exist in the game world, the decryption will fail.
1074
+ *
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
+ */
357
1094
  decipher(hash: string): string | null;
358
- decrypt(filePath: string, password: string): true | string | null;
359
- encrypt(filePath: string, password: string): true | string | null;
360
- isEncrypted(filePath: string): boolean | string | null;
361
- smtpUserList(ip: string, port: number): string[] | string | null;
1095
+ /** Decrypts the specified file using the provided key.
1096
+ *
1097
+ * On success, the method returns true. If decryption fails, a descriptive error message is returned as a string. */
1098
+ decrypt(filePath: string, password: string): true | string;
1099
+ /** Encrypts the specified file using the provided key.
1100
+ *
1101
+ * On success, the method returns true. If encryption fails, a descriptive error message is returned as a string. */
1102
+ encrypt(filePath: string, password: string): true | string;
1103
+ /** Checks whether the specified file is encrypted.
1104
+ *
1105
+ * Returns true if the file is encrypted, or zero if it is not. If the check fails (e.g., due to a missing or unreadable file), a descriptive error message is returned as a string. */
1106
+ isEncrypted(filePath: string): boolean | string;
1107
+ /** Returns an array of the existing users on the computer where the SMTP service is running.
1108
+ *
1109
+ * If these users also have an email account registered on the SMTP server, it will be indicated in the array.
1110
+ *
1111
+ * SMTP services are usually running on port 25. In case of failure, this method will return a string containing the cause. */
1112
+ smtpUserList(ip: string, port: number): string[] | string;
362
1113
  }
363
1114
  interface BlockChain {
364
1115
  classID: "blockchainLib";
365
- amountMined(coinName: string): number | string | null;
366
- coinPrice(coinName: string): number | string | null;
367
- createWallet(user: string, password: string): Wallet | string | null;
368
- deleteCoin(coinName: string, user: string, password: string): true | string | null;
369
- getCoin(coinName: string, user: string, password: string): Coin | string | null;
370
- getCoinName(user: string, password: string): string | null;
371
- loginWallet(user: string, password: string): Wallet | string | null;
1116
+ /** Returns a number representing the total amount of mined coins.
1117
+ *
1118
+ * In case of an error, it will return a string with the details.
1119
+ * @example
1120
+ * const blockChain = includeLib("/lib/blockchain.so");
1121
+ * if (!isType(blockChain, "blockchainLib"))
1122
+ * exit("Failed to get blockchain.so");
1123
+ *
1124
+ * const mined = blockChain.amountMined("bitcoin");
1125
+ * if (isType(mined, "string"))
1126
+ * exit(`Coudn't get the amount of mined coin: ${mined}`);
1127
+ *
1128
+ * print(`There are ${mined} coins mined for this coin`);
1129
+ */
1130
+ amountMined(coinName: string): number | string;
1131
+ /** Returns a number representing the current unit value of the cryptocurrency.
1132
+ *
1133
+ * In case of an error, a string with the error details will be returned. */
1134
+ coinPrice(coinName: string): number | string;
1135
+ /** Creates a wallet and returns a wallet object on success, which can be used to manage cryptocurrencies.
1136
+ *
1137
+ * In case of an error, it will return a string with the details. */
1138
+ createWallet(user: string, password: string): Wallet | string;
1139
+ /** Removes a cryptocurrency from the world. The credentials used in the creation of the cryptocurrency are required.
1140
+ *
1141
+ * On success, it will return a true.
1142
+ *
1143
+ * On failure, it will return a string containing details. */
1144
+ deleteCoin(coinName: string, user: string, password: string): true | string;
1145
+ /** Returns a coin object used to manage the currency.
1146
+ *
1147
+ * In case of an error, it will return a string with the details. */
1148
+ getCoin(coinName: string, user: string, password: string): Coin | string;
1149
+ /** Returns a string with the name of the coin owned by the player.
1150
+ *
1151
+ * In case of an error, it returns a string with details. */
1152
+ getCoinName(user: string, password: string): string;
1153
+ /** Returns a wallet object on success. In case of an error, it will return a string indicating the reason. */
1154
+ loginWallet(user: string, password: string): Wallet | string;
1155
+ /** Returns an object with the latest changes in the value of a specific cryptocurrency.
1156
+ *
1157
+ * The key of the object is an index represented by a number. The value is an array, where index 0 is the historical price of the coin and index 1 is the date when the price change occurred.
1158
+ *
1159
+ * If no coin exists with this name, the method will return null. */
372
1160
  showHistory(coinName: string): Record<number, [number, string]> | string | null;
373
1161
  }
374
1162
  interface AptClient {
375
1163
  classID: "aptClientLib";
376
- addRepo(repositoryAddress: string, port?: number): string | null;
377
- checkUpgrade(filePath: string): boolean | string | null;
378
- delRepo(repositoryAddress: string): string | null;
379
- install(package: string, installPath?: string): true | string | null;
380
- search(package: string): string | null;
381
- show(repositoryAddress: string): string | null;
1164
+ /** Inserts a repository address into the `/etc/apt/sources.txt` file.
1165
+ *
1166
+ * On success, it will return an empty string. In case of failure, it will return a string with an error message.
1167
+ */
1168
+ addRepo(repositoryAddress: string, port?: number): string;
1169
+ /** Checks if there is a newer version of the program or library in the repository.
1170
+ *
1171
+ * On success, it will return a boolean, with false indicating that there is no new version, while true indicates that there is a new version available.
1172
+ *
1173
+ * In case of failure, it will return a string containing an error message. */
1174
+ checkUpgrade(filePath: string): boolean | string;
1175
+ /** Deletes a repository address from the `/etc/apt/sources.txt` file.
1176
+ *
1177
+ * On success, it will return an empty string. In case of failure, it will return a string with an error message. */
1178
+ delRepo(repositoryAddress: string): string;
1179
+ /** Installs a program or library from a remote repository listed in `/etc/apt/sources.txt`.
1180
+ *
1181
+ * If no path is specified, the program installs in `/lib` if it is a library or in `/bin` otherwise.
1182
+ *
1183
+ * On success, this method will return true. In case of failure, it will return a string containing an error message. */
1184
+ install(package: string, installPath?: string): true | string;
1185
+ /** Search specifically looks for a package in any of the repositories listed in `/etc/apt/sources.txt`.
1186
+ *
1187
+ * On success, it will return a string containing all packages that partially match the provided search value.
1188
+ *
1189
+ * On failure, it will return a string with various error messages. */
1190
+ search(package: string): string;
1191
+ /** Show displays all the packages available in a repository. The repository must be listed in the `/etc/apt/sources.txt` file.
1192
+ *
1193
+ * If it cannot find a repository, it will return various error messages.
1194
+ *
1195
+ * On success, it will return a string containing all packages and their descriptions, with each entry separated by a newline. */
1196
+ show(repositoryAddress: string): string;
1197
+ /** Update refreshes the list of available packages after adding a new repository in `/etc/apt/sources.txt`, or if the remote repository has updated its information in `/server/conf/repod.conf`.
1198
+ *
1199
+ * If the update is successful, an empty string will be returned. In case of failure, a string with an error message will be returned.
1200
+ *
1201
+ * If for some reason the `/etc/apt/sources.txt` is malformed this method will return false. */
382
1202
  update(): string | false;
383
1203
  }
384
1204
  interface SmartAppliance {
385
1205
  classID: "SmartAppliance";
1206
+ /** Returns a string with the appliance model ID. */
386
1207
  model(): string;
387
- overrideSettings(power: number, temperature: number): true | string | null;
388
- setAlarm(enable: boolean): true | string | null;
1208
+ /** Overrides the power and temperature settings of the appliance.
1209
+ *
1210
+ * If successful, true is returned; otherwise, it returns a string detailing the error. */
1211
+ overrideSettings(power: number, temperature: number): true | string;
1212
+ /** Activates or deactivates the sound alarm indicating any appliance malfunction.
1213
+ *
1214
+ * If successful, true is returned; otherwise, a string containing error details is returned. */
1215
+ setAlarm(enable: boolean): true | string;
389
1216
  }
390
1217
  interface TrafficNet {
391
1218
  classID: "TrafficNet";
1219
+ /** Accesses the traffic camera system, opening a window with controls to switch between different cameras.
1220
+ *
1221
+ * If the window opens successfully, this method returns true. In case of an error, it returns a string with details. */
392
1222
  cameraLinkSystem(): true | string;
1223
+ /** Returns string which contains job and name of a NPC. If an error occurs, a string with details is returned. */
393
1224
  getCredentialsInfo(): string;
394
- locateVehicle(licensePlate: string, password: string): true | string | null;
1225
+ /** Performs a search for the specified license plate to locate the vehicle.
1226
+ *
1227
+ * If the vehicle is visible on any camera, the viewer will switch to the camera currently displaying it and return true.
1228
+ *
1229
+ * If the vehicle cannot be located or the license plate is incorrect, a string indicating the error is returned. */
1230
+ locateVehicle(licensePlate: string, password: string): true | string;
395
1231
  }
396
1232
  }
397
1233
  interface Math {
1234
+ /** Returns the value of pi to the precision of 6 */
398
1235
  readonly PI: number;
399
- readonly abs: typeof GreyHack.abs;
400
- readonly acos: typeof GreyHack.acos;
401
- readonly asin: typeof GreyHack.asin;
402
- readonly atan: typeof GreyHack.atan;
403
- readonly ceil: typeof GreyHack.ceil;
404
- readonly floor: typeof GreyHack.floor;
405
- readonly cos: typeof GreyHack.cos;
406
- readonly sin: typeof GreyHack.sin;
407
- readonly tan: typeof GreyHack.tan;
408
- readonly sqrt: typeof GreyHack.sqrt;
409
- readonly sign: typeof GreyHack.sign;
410
- readonly round: typeof GreyHack.round;
411
- readonly random: typeof GreyHack.rnd;
412
- readonly log: typeof GreyHack.log;
1236
+ /** Returns the absolute value of number. */
1237
+ readonly abs: (value: number) => number;
1238
+ /** Returns the inverse cosine (in radians) of a number. */
1239
+ readonly acos: (value: number) => number;
1240
+ /** Returns the inverse sine (in radians) of a number. */
1241
+ readonly asin: (value: number) => number;
1242
+ /** Returns the inverse tangent (in radians) of a number. */
1243
+ readonly atan: (y: number, x?: number | undefined) => number;
1244
+ /** Returns number rounded up to the integer value of the provided number. */
1245
+ readonly ceil: (value: number) => number;
1246
+ /** Returns number rounded down to the integer value of the provided number. */
1247
+ readonly floor: (value: number) => number;
1248
+ /** Returns the cosine of a number in radians. */
1249
+ readonly cos: (value: number) => number;
1250
+ /** Returns the sine of a number in radians. */
1251
+ readonly sin: (value: number) => number;
1252
+ /** Returns the tangent of a number in radians. */
1253
+ readonly tan: (value: number) => number;
1254
+ /** Returns the square root of a number. */
1255
+ readonly sqrt: (value: number) => number;
1256
+ /** Returns 1 or -1 indicating the sign of the value passed or 0 if the value is 0 */
1257
+ readonly sign: (value: number) => -1 | 0 | 1;
1258
+ /** Returns number rounded to the integer value of the provided number. */
1259
+ readonly round: (value: number, fixed?: number | undefined) => number;
1260
+ /** Returns a random number between 0 and 1. Optionally a seed number can be provided. */
1261
+ readonly 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
+ readonly log: (value: number, base?: number | undefined) => number;
1268
+ /** Returns the smallest number of the given values */
413
1269
  readonly min: (...values: number[]) => number;
1270
+ /** Returns the largest number of the given values */
414
1271
  readonly max: (...values: number[]) => number;
415
1272
  }
416
1273
  declare var Math: Math;
417
1274
  declare namespace GreyHack {
418
1275
  interface CtfEvent {
419
1276
  classID: "ctfEvent";
1277
+ /** Returns string with the name of the CTF event creator. */
420
1278
  getCreatorName(): string;
1279
+ /** Returns string with the CTF event description. */
421
1280
  getDescription(): string;
1281
+ /** Returns string with the mail content of the CTF event. */
422
1282
  getMailContent(): string;
1283
+ /** Returns string with the CTF event template. */
423
1284
  getTemplate(): string;
1285
+ /** Returns a boolean indicating if the CTF event got completed successfully */
424
1286
  playerSuccess(): boolean;
425
1287
  }
426
1288
  interface MetaMail {
427
1289
  classID: "MetaMail";
428
- delete(mailId: string): true | string | null;
1290
+ /**
1291
+ * Delete the email corresponding to the provided email ID.
1292
+ *
1293
+ * Returns true if the email removal was successful. Otherwise, a string with an error message will be returned.
1294
+ */
1295
+ delete(mailId: string): true | string;
1296
+ /**
1297
+ * Returns an array where each item is a string containing mail id, from, subject and a small preview of the content consisting of the first 125 characters.
1298
+ *
1299
+ * If there is any issue a string will be returned with details.
1300
+ */
429
1301
  fetch(): string[] | string;
430
- read(mailId: string): string | null;
431
- send(emailAddress: string, subject: string, message: string): string | true | null;
1302
+ /**
1303
+ * Returns a string containing the content of a mail related to the provided mail id.
1304
+ *
1305
+ * The mail id argument can be obtained with fetch. In case the mail cannot be found this method will return `Mail not found`.
1306
+ */
1307
+ read(mailId: string): string;
1308
+ /**
1309
+ * Send a new mail to the provided email address.
1310
+ *
1311
+ * Keep in mind that the subject can not exceed 128 characters and the message size should not exceed 2500 characters.
1312
+ *
1313
+ * @returns true indicating that the mail has been sent correctly, or a string with an error
1314
+ */
1315
+ send(emailAddress: string, subject: string, message: string): string | true;
432
1316
  }
433
1317
  interface NetSession {
434
1318
  classID: "NetSession";
1319
+ /**
1320
+ * Returns the {@link MetaLib} associated with the remote service.
1321
+ *
1322
+ * For example if the {@link Metaxploit} method netUse was used on a ssh port it will return the MetaLib related to the ssh service. In case the port was zero is will return a MetaLib related to the kernel router.
1323
+ */
435
1324
  dumpLib(): MetaLib;
1325
+ /**
1326
+ * Initiates a DDoS attack targeting the computer associated with the currently active NetSession object.
1327
+ *
1328
+ * To successfully force a reboot, there must be at least 4 concurrent floodConnection calls for every 1 unit of net speed on the target computer. Keep in mind that these calls need to come from different IPs. So for example PackS would require 12 active floodConnection calls. If the threshold is met, the target computer will be forced to reboot, and the terminal will output: `remote connection interrupted`.
1329
+ *
1330
+ * This method always returns null and only prints a message upon a successful attack.
1331
+ */
436
1332
  floodConnection(): null;
1333
+ /** Returns the number of devices using this router as a gateway. If you obtained your NetSession from a computer, it will fetch and return the value from its gateway router. */
437
1334
  getNumConnGateway(): number;
1335
+ /** Returns the number of ports forwarded by this router. If you obtained your NetSession from a computer, it will fetch and return the value from its gateway router. */
438
1336
  getNumPortforward(): number;
1337
+ /** Returns the number of user accounts on the system. */
439
1338
  getNumUsers(): number;
1339
+ /** Return a boolean indicating if there is an active user on the system */
440
1340
  isAnyActiveUser(): boolean;
1341
+ /** Return a boolean indicating if there is an active root user on the system */
441
1342
  isRootActiveUser(): boolean;
442
1343
  }
443
1344
  interface Port {
444
1345
  classID: "port";
1346
+ /** Port number used by this port */
445
1347
  portNumber: number;
1348
+ /** Returns a boolean, where true indicates that the specified port is closed and false indicates that the port is open. */
446
1349
  isClosed: () => boolean;
1350
+ /** Returns a string containing the local IP address of the computer to which the port is pointing. */
447
1351
  getLanIp: () => string;
448
1352
  }
449
1353
  interface Router {
450
1354
  classID: "router";
1355
+ /** BSSID value of the router */
451
1356
  bssidName: string;
1357
+ /** ESSID value of the router */
452
1358
  essidName: string;
1359
+ /** Version of the `kernel_router.so` library */
453
1360
  kernelVersion: string;
1361
+ /** Local IP address of the router. */
454
1362
  localIp: string;
1363
+ /** Public IP address of the router. */
455
1364
  publicIp: string;
1365
+ /**
1366
+ * Returns an array where each item is an open port related to the device of the provided LAN IP address. The device needs to be within the network of the router.
1367
+ *
1368
+ * In case of failure, this method will return null or a string with details. In case an empty ip is provided this method will throw a runtime exception. */
456
1369
  devicePorts(ip: string): Port[] | string | null;
1370
+ /**
1371
+ * Returns an array where each item is a string representing a LAN IP address.
1372
+ *
1373
+ * All devices are within the network of the router and can be reached by using the ping method. Some of the devices might be behind a firewall.
1374
+ */
457
1375
  devicesLanIp(): string[];
1376
+ /** Returns an array where each item is a string containing a firewall rule. */
458
1377
  firewallRules(): string[];
1378
+ /** Returns a {@link Port} that is behind the port number provided. In case the port does not exist null gets returned. */
459
1379
  pingPort(portNumber: number): Port | null;
1380
+ /**
1381
+ * Returns a string with information about the provided port, including details about the running service and its version.
1382
+ *
1383
+ * For example, the output could be `http 1.0.0`. If the operation fails, null will be returned.
1384
+ */
460
1385
  portInfo(port: Port): string | null;
1386
+ /** Returns an array where each item is a {@link Port} used inside the router. */
461
1387
  usedPorts(): Port[];
462
1388
  }
463
1389
  interface FtpShell {
464
1390
  classID: "ftpShell";
1391
+ /** Returns a computer related to the shell. */
465
1392
  hostComputer: FtpComputer;
1393
+ /**
1394
+ * Send a file to the computer related to the provided shell.
1395
+ *
1396
+ * You require permission to read the file on the computer from which you are uploading and write permissions in the folder of the computer you are trying to upload to.
1397
+ *
1398
+ * Via the optional isUpload parameter you can define the direction.
1399
+ *
1400
+ * 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.
1401
+ */
466
1402
  scp: Shell["scp"];
467
1403
  }
468
1404
  interface Shell {
469
1405
  classID: "shell";
1406
+ /** Returns a computer related to the shell. */
470
1407
  hostComputer: Computer;
1408
+ /**
1409
+ * Compiles a plain code file provided in the arguments to a binary.
1410
+ *
1411
+ * On success, the new binary will be available under the provided build folder. The binary name will be the same as the source file just without the file extension. Optionally, an allowImport flag can be set which enables the use of import_code on the binary. All provided paths must be absolute. Returns an empty string on success. On failure, it will return a string containing details about the reason for failure.
1412
+ *
1413
+ * In case any provided values deviate from the defined signature a runtime exception will be thrown.
1414
+ */
471
1415
  build: (sourcePath: string, binaryPath: string, allowImport?: boolean) => string;
1416
+ /**
1417
+ * Returns a shell if the connection attempt to the provided IP was successful.
1418
+ *
1419
+ * This method can only connect to ports running an SSH or FTP service. SSH services usually run on port 22 and FTP services usually on port 21. Keep in mind to pass the right service value depending on which service is going to be used. By default, it will use SSH as the service. Please note that connecting will leave a log entry.
1420
+ *
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.
1422
+ */
472
1423
  connectService: (ip: string, port: number, user: string, password: string, service?: "ssh" | "ftp") => Shell | FtpShell | string | null;
1424
+ /**
1425
+ * Launches the binary located at the provided path.
1426
+ *
1427
+ * Optionally, parameters can be passed. Returns a boolean indicating the success of the launch. In some cases, a string will be returned containing an error message.
1428
+ *
1429
+ * If you need to share variables between a launched script and the current process, consider using {@link getCustomObject}.
1430
+ *
1431
+ * Note that launching a script is not asynchronous, meaning that the current script will pause its execution until the launched script finishes. If any provided values deviate from the method signature or it is used within an SSH encryption process, a runtime exception will be thrown.
1432
+ *
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.
1434
+ */
473
1435
  launch: (program: string, params?: string) => string | boolean;
1436
+ /**
1437
+ * Pings an IP address.
1438
+ *
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.
1440
+ */
474
1441
  ping: (ip: string) => string | boolean;
475
- scp: (file: string, folder: string, remoteShell: Shell, isUpload?: boolean) => boolean | string | null;
1442
+ /**
1443
+ * Send a file to the computer related to the provided shell.
1444
+ *
1445
+ * You require permission to read the file on the computer from which you are uploading and write permissions in the folder of the computer you are trying to upload to.
1446
+ *
1447
+ * Via the optional isUpload parameter you can define the direction.
1448
+ *
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.
1450
+ */
1451
+ scp: (file: string, folder: string, remoteShell: Shell, isUpload?: boolean) => boolean | string;
1452
+ /**
1453
+ * Launches an active terminal.
1454
+ *
1455
+ * The terminal's color will change, displaying the IP of the connected shell. Script execution will be stopped upon starting a new terminal, unless this is called from another script that was executed via {@link Shell.launch}. In that case, you will enter the shell after closing your root-level script within that terminal window.
1456
+ *
1457
+ * Using this method within an SSH encryption process will cause an error to be thrown, preventing further script execution.
1458
+ */
476
1459
  startTerminal: () => never;
477
1460
  }
478
1461
  }
@@ -494,21 +1477,93 @@ interface String {
494
1477
  indexOf(value: string, offset?: number): number | null;
495
1478
  indexes(): number[];
496
1479
  insert(index: number, value: string): string;
497
- isMatch(pattern: string | RegExp, regexOptions?: string): number;
498
- lastIndexOf(value: string): number;
499
- lower(): string;
1480
+ /**
1481
+ * Uses regular expression to check if a string matches a certain pattern.
1482
+ *
1483
+ * 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.
1484
+ */
1485
+ isMatch(pattern: string | RegExp, regexOptions?: string): boolean;
1486
+ /** Returns the last occurrence of a substring in the string. */
1487
+ lastIndexOf(searchString: string): number;
1488
+ /** Converts all the alphabetic characters in a string to lowercase. */
1489
+ toLowerCase(): string;
1490
+ /** Converts all the alphabetic characters in a string to uppercase. */
1491
+ toUpperCase(): string;
1492
+ /**
1493
+ * Returns an object with all search results for the provided regular expression.
1494
+ *
1495
+ * Each key contains the index and the value contains the matching string.
1496
+ *
1497
+ * 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.
1498
+ */
500
1499
  matches(pattern: string | RegExp, regexOptions?: string): Record<number, string>;
1500
+ /**
1501
+ * Returns a new string with the provided value removed
1502
+ * @example
1503
+ * const myString = "I will not eat an ice cream!";
1504
+ * const newString = myString.remove("not ");
1505
+ * print(newString); // Prints "I will eat an ice cream!"
1506
+ */
501
1507
  remove(value: string): string;
1508
+ /**
1509
+ * Returns a string with the replaced content by using regular expressions.
1510
+ *
1511
+ * 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.
1512
+ *
1513
+ * @example
1514
+ * const myString = "I am now online";
1515
+ * const newString = myString.replace("online", "offline");
1516
+ * print(newString); // Prints "I am now offline"
1517
+ */
502
1518
  replace(pattern: string | RegExp, newValue: string, regexOptions?: string): string;
1519
+ /**
1520
+ * Returns an array where each item is a segment of the string, separated by the provided separator string.
1521
+ *
1522
+ * This method uses regular expressions for matching, so remember to escape special characters such as dots.
1523
+ *
1524
+ * 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.
1525
+ *
1526
+ * @example
1527
+ * const csvString = "cat,turtle,dog,mouse";
1528
+ * const animals = csvString.split(",");
1529
+ * print(animals); // Prints ["cat", "turtle", "dog", "mouse"]
1530
+ */
503
1531
  split(pattern: string | RegExp, regexOptions?: string): string[];
1532
+ /**
1533
+ * Returns a number which is parsed from the string as an integer.
1534
+ *
1535
+ * In case the string is not numeric it will return the original string.
1536
+ */
504
1537
  toInt(): string | number;
1538
+ /** Removes the leading and trailing white space and line terminator characters from a string. */
505
1539
  trim(): string;
506
- upper(): string;
1540
+ /** Returns a number which is parsed from the string. In case the string is not numeric it will return a zero. */
507
1541
  val(): number;
1542
+ /** 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. */
508
1543
  values(): string[];
1544
+ /** Returns true if this string starts with the searchString. Otherwise returns false. */
1545
+ startsWith(searchString: string, position?: number): boolean;
1546
+ /** Returns true if this string ends with the searchString. Otherwise returns false. */
1547
+ endsWith(searchString: string, endPosition?: number): boolean;
1548
+ /**
1549
+ * Returns a string value that is made from count copies appended together.
1550
+ *
1551
+ * If count is 0, the empty string is returned.
1552
+ */
1553
+ repeat(count: number): string;
1554
+ /**
1555
+ * Returns a section of a string.
1556
+ * @param start The index to the beginning of the specified portion of string.
1557
+ * @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.
1558
+ */
1559
+ slice(start?: number, end?: number): string;
1560
+ /** Returns a string representation of a string. */
1561
+ toString(): string;
509
1562
  readonly [index: number]: string;
510
1563
  }
511
1564
  interface Number {
1565
+ /** Returns a string representation of a number. */
1566
+ toString(): string;
512
1567
  }
513
1568
  type PropertyKey = number | string | symbol;
514
1569
  interface Object {
@@ -525,10 +1580,13 @@ interface Object {
525
1580
  shuffle(): null;
526
1581
  sum(): number;
527
1582
  values(): any[];
1583
+ /** Returns a string representation of an object. */
1584
+ toString(): string;
528
1585
  }
529
1586
  interface ObjectConstructor {
530
1587
  new (value?: any): Object;
531
1588
  readonly prototype: Object;
1589
+ /** Determines whether an object has a property with the specified name. */
532
1590
  hasOwn<T extends PropertyKey, U = object>(o: U, key: T): o is (T extends keyof U ? U : U & {
533
1591
  [K in T]: unknown;
534
1592
  });
@@ -537,45 +1595,107 @@ interface ObjectConstructor {
537
1595
  assign<T extends {}, U, V>(target: T, source: U, source2: V): T & U & V;
538
1596
  assign<T extends {}, U, V, W>(target: T, source: U, source2: V, source3: W): T & U & V & W;
539
1597
  assign(target: object, ...sources: any[]): any;
1598
+ /** Returns an array of keys of the object */
540
1599
  keys<T extends Record<any, any>>(o: T): (Exclude<keyof T, symbol>)[];
1600
+ /** Returns an array of values of the object */
1601
+ values<T extends Record<any, any>>(o: T): (T[keyof T])[];
541
1602
  }
542
1603
  interface Array<T> {
543
1604
  readonly length: number;
1605
+ /** Returns a boolean indicating if the provided index exists in the array */
544
1606
  hasIndex(index: number): boolean;
1607
+ /** Returns the index of the first occurrence of a value in an array, or null if it is not present. */
545
1608
  indexOf(value: T, offset?: number): number | null;
1609
+ /** Returns an array containing the indexes of the array */
546
1610
  indexes(): number[];
1611
+ /** Inserts a value into the array at the provided index. This method mutates the array and returns a reference to the same array. */
547
1612
  insert(index: number, value: T): T[];
1613
+ /**
1614
+ * Returns a concatenated string containing all stringified values inside the list. These values will be separated via the provided separator.
1615
+ *
1616
+ * In case the list exceeds `16777215L` items or the delimiter exceeds 128 characters, this method will throw an error, interrupting further script execution.
1617
+ */
548
1618
  join(delimiter: string): string;
549
- pop(): T;
550
- pull(): T;
551
- push(value: T): T[];
1619
+ /** Removes the first element from an array and returns it. If the array is empty, null is returned. */
1620
+ shift(): T | null;
1621
+ /** Inserts new elements at the start of an array, and returns the new length of the array. */
1622
+ unshift(...items: T[]): number;
1623
+ /** Removes the last element from an array and returns it. If the array is empty, null is returned. */
1624
+ pop(): T | null;
1625
+ /** Appends new elements to the end of an array, and returns the new length of the array. */
1626
+ push(...items: T[]): number;
1627
+ /**
1628
+ * Removes an item from the list with the provided index. Due to the removal the list will get mutated.
1629
+ */
552
1630
  remove(index: number): null;
1631
+ /**
1632
+ * Changes every value of the array that matches `oldValue` into `newValue`
1633
+ *
1634
+ * This method mutates the array and returns a reference to the same array.
1635
+ */
553
1636
  replace(oldValue: T, newValue: T, maxCount?: number): T[];
554
- reverse(): null;
1637
+ /** Reverses the elements in an array in place. This method mutates the array and returns a reference to the same array. */
1638
+ reverse(): T;
1639
+ /** Shuffles all values in the array. This method mutates the array. */
555
1640
  shuffle(): null;
556
- sort(key: PropertyKey | null, ascending?: boolean): T[];
1641
+ /**
1642
+ * Sorts the values of an array alphanumerically.
1643
+ *
1644
+ * 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.
1645
+ * @example
1646
+ * const myArray = [{ key: 123 }, { key: 5 }, { key: 17 }];
1647
+ * myArray.sort("key");
1648
+ *
1649
+ * const numbers = [1,2,3,4,5];
1650
+ * numbers.sort()
1651
+ */
1652
+ sort(key?: PropertyKey | null, ascending?: boolean): T[];
1653
+ /** Returns a sum of all values inside the array. Any non-numeric values will be considered a zero. */
557
1654
  sum(): number;
558
1655
  values(): T[];
1656
+ /** Combines two or more arrays. This method returns a new array without modifying any existing arrays.
1657
+ * @param items Additional arrays and/or items to add to the end of the array.
1658
+ */
559
1659
  concat(...items: (T | T[])[]): T[];
1660
+ /** Calls a defined callback function on each element of an array, and returns an array that contains the results. */
560
1661
  map<U>(callbackfn: (value: T, index: number, array: T[]) => U): U[];
1662
+ /** Returns the elements of an array that meet the condition specified in a callback function. */
561
1663
  filter(predicate: (value: T, index: number, array: T[]) => unknown): T[];
1664
+ /** Returns the value of the first element in the array where predicate is true, and null otherwise. */
562
1665
  find(predicate: (value: T, index: number, array: T[]) => unknown): T | null;
1666
+ /** Determines whether the specified callback function returns true for any element of an array. */
563
1667
  some(predicate: (value: T, index: number, array: T[]) => unknown): boolean;
1668
+ /** Determines whether all the members of an array satisfy the specified test. */
564
1669
  every(predicate: (value: T, index: number, array: T[]) => unknown): boolean;
1670
+ /** Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array.
1671
+ *
1672
+ * For example, -2 refers to the second to last element of the array.
1673
+ * @param start The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0.
1674
+ * @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.
1675
+ * */
1676
+ slice(start?: number, end?: number): T[];
1677
+ /** Returns a string representation of an array. */
1678
+ toString(): string;
565
1679
  [n: number]: T;
566
1680
  }
567
1681
  interface Function {
1682
+ /** Returns a string representation of a function. */
1683
+ toString(): string;
568
1684
  }
569
1685
  declare var String: {
570
- new (value?: string): String;
1686
+ new (value?: any): String;
571
1687
  (value?: any): string;
572
1688
  readonly prototype: String;
573
1689
  };
574
1690
  declare var Number: {
1691
+ new (value?: any): Number;
1692
+ (value?: any): number;
575
1693
  readonly prototype: Number;
576
1694
  };
577
1695
  declare var Boolean: {
578
- readonly prototype: Number;
1696
+ new (value?: any): Boolean;
1697
+ <T>(value?: T): boolean;
1698
+ readonly prototype: Boolean;
579
1699
  };
580
1700
  declare var Array: {
581
1701
  readonly prototype: Array<any>;