@internxt/cli 1.5.5 → 1.5.7

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 (59) hide show
  1. package/README.md +34 -31
  2. package/dist/commands/create-folder.js +2 -0
  3. package/dist/commands/download-file.d.ts +1 -1
  4. package/dist/commands/download-file.js +7 -1
  5. package/dist/commands/list.d.ts +40 -2
  6. package/dist/commands/login.d.ts +1 -0
  7. package/dist/commands/login.js +58 -8
  8. package/dist/commands/move-file.d.ts +19 -1
  9. package/dist/commands/move-file.js +1 -1
  10. package/dist/commands/move-folder.js +3 -1
  11. package/dist/commands/rename-file.d.ts +1 -0
  12. package/dist/commands/rename-file.js +11 -4
  13. package/dist/commands/trash-file.js +1 -1
  14. package/dist/commands/trash-folder.js +1 -1
  15. package/dist/commands/trash-list.d.ts +40 -2
  16. package/dist/commands/trash-restore-file.d.ts +19 -1
  17. package/dist/commands/trash-restore-file.js +1 -1
  18. package/dist/commands/trash-restore-folder.js +3 -1
  19. package/dist/commands/upload-file.d.ts +17 -1
  20. package/dist/commands/upload-file.js +16 -11
  21. package/dist/commands/webdav-config.d.ts +1 -0
  22. package/dist/commands/webdav-config.js +9 -0
  23. package/dist/commands/webdav.js +2 -2
  24. package/dist/commands/whoami.js +14 -8
  25. package/dist/hooks/prerun/auth_check.js +2 -5
  26. package/dist/services/auth.service.d.ts +2 -1
  27. package/dist/services/auth.service.js +31 -37
  28. package/dist/services/config.service.d.ts +1 -1
  29. package/dist/services/config.service.js +4 -7
  30. package/dist/services/database/drive-file/drive-file.attributes.d.ts +3 -1
  31. package/dist/services/database/drive-file/drive-file.domain.d.ts +4 -2
  32. package/dist/services/database/drive-file/drive-file.domain.js +9 -2
  33. package/dist/services/drive/drive-file.service.d.ts +1 -1
  34. package/dist/services/drive/drive-file.service.js +5 -4
  35. package/dist/services/drive/drive-folder.service.d.ts +41 -4
  36. package/dist/services/drive/drive-folder.service.js +2 -2
  37. package/dist/services/drive/trash.service.d.ts +40 -2
  38. package/dist/services/keys.service.d.ts +0 -3
  39. package/dist/services/keys.service.js +0 -59
  40. package/dist/services/sdk-manager.service.d.ts +1 -3
  41. package/dist/services/sdk-manager.service.js +5 -15
  42. package/dist/services/thumbnail.service.js +59 -15
  43. package/dist/services/validation.service.js +2 -2
  44. package/dist/types/command.types.d.ts +27 -3
  45. package/dist/types/drive.types.d.ts +5 -4
  46. package/dist/types/keys.types.d.ts +0 -12
  47. package/dist/types/keys.types.js +0 -29
  48. package/dist/utils/drive.utils.js +4 -3
  49. package/dist/utils/network.utils.d.ts +4 -3
  50. package/dist/utils/network.utils.js +8 -8
  51. package/dist/webdav/handlers/DELETE.handler.js +1 -1
  52. package/dist/webdav/handlers/MOVE.handler.js +9 -7
  53. package/dist/webdav/handlers/PROPFIND.handler.js +8 -5
  54. package/dist/webdav/handlers/PUT.handler.js +5 -6
  55. package/dist/webdav/index.js +2 -5
  56. package/dist/webdav/middewares/auth.middleware.js +3 -10
  57. package/dist/webdav/webdav-server.js +3 -3
  58. package/oclif.manifest.json +27 -3
  59. package/package.json +20 -17
package/README.md CHANGED
@@ -51,7 +51,7 @@ $ npm install -g @internxt/cli
51
51
  $ internxt COMMAND
52
52
  running command...
53
53
  $ internxt (--version)
54
- @internxt/cli/1.5.5 linux-x64 node-v22.19.0
54
+ @internxt/cli/1.5.7 linux-x64 node-v22.20.0
55
55
  $ internxt --help [COMMAND]
56
56
  USAGE
57
57
  $ internxt COMMAND
@@ -120,7 +120,7 @@ EXAMPLES
120
120
  $ internxt add-cert
121
121
  ```
122
122
 
123
- _See code: [src/commands/add-cert.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/add-cert.ts)_
123
+ _See code: [src/commands/add-cert.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/add-cert.ts)_
124
124
 
125
125
  ## `internxt autocomplete [SHELL]`
126
126
 
@@ -151,7 +151,7 @@ EXAMPLES
151
151
  $ internxt autocomplete --refresh-cache
152
152
  ```
153
153
 
154
- _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.34/src/commands/autocomplete/index.ts)_
154
+ _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.36/src/commands/autocomplete/index.ts)_
155
155
 
156
156
  ## `internxt config`
157
157
 
@@ -171,7 +171,7 @@ EXAMPLES
171
171
  $ internxt config
172
172
  ```
173
173
 
174
- _See code: [src/commands/config.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/config.ts)_
174
+ _See code: [src/commands/config.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/config.ts)_
175
175
 
176
176
  ## `internxt create-folder`
177
177
 
@@ -200,7 +200,7 @@ EXAMPLES
200
200
  $ internxt create-folder
201
201
  ```
202
202
 
203
- _See code: [src/commands/create-folder.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/create-folder.ts)_
203
+ _See code: [src/commands/create-folder.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/create-folder.ts)_
204
204
 
205
205
  ## `internxt delete-permanently-file`
206
206
 
@@ -230,7 +230,7 @@ EXAMPLES
230
230
  $ internxt delete-permanently-file
231
231
  ```
232
232
 
233
- _See code: [src/commands/delete-permanently-file.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/delete-permanently-file.ts)_
233
+ _See code: [src/commands/delete-permanently-file.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/delete-permanently-file.ts)_
234
234
 
235
235
  ## `internxt delete-permanently-folder`
236
236
 
@@ -260,7 +260,7 @@ EXAMPLES
260
260
  $ internxt delete-permanently-folder
261
261
  ```
262
262
 
263
- _See code: [src/commands/delete-permanently-folder.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/delete-permanently-folder.ts)_
263
+ _See code: [src/commands/delete-permanently-folder.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/delete-permanently-folder.ts)_
264
264
 
265
265
  ## `internxt delete permanently file`
266
266
 
@@ -349,7 +349,7 @@ EXAMPLES
349
349
  $ internxt download-file
350
350
  ```
351
351
 
352
- _See code: [src/commands/download-file.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/download-file.ts)_
352
+ _See code: [src/commands/download-file.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/download-file.ts)_
353
353
 
354
354
  ## `internxt download file`
355
355
 
@@ -408,7 +408,7 @@ EXAMPLES
408
408
  $ internxt list
409
409
  ```
410
410
 
411
- _See code: [src/commands/list.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/list.ts)_
411
+ _See code: [src/commands/list.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/list.ts)_
412
412
 
413
413
  ## `internxt login`
414
414
 
@@ -416,12 +416,14 @@ Logs into an Internxt account. If the account is two-factor protected, then an e
416
416
 
417
417
  ```
418
418
  USAGE
419
- $ internxt login [--json] [-x] [-e <value>] [-p <value>] [-w 123456]
419
+ $ internxt login [--json] [-x] [-e <value>] [-p <value>] [-w 123456] [-t token]
420
420
 
421
421
  FLAGS
422
- -e, --email=<value> The email to log in
423
- -p, --password=<value> The plain password to log in
424
- -w, --twofactor=123456 The two factor auth code (only needed if the account is two-factor protected)
422
+ -e, --email=<value> The email to log in
423
+ -p, --password=<value> The plain password to log in
424
+ -t, --twofactortoken=token The TOTP secret token. It is used to generate a TOTP code if needed. It has prority over
425
+ the two factor code flag.
426
+ -w, --twofactor=123456 The two factor auth code (TOTP).
425
427
 
426
428
  HELPER FLAGS
427
429
  -x, --non-interactive Prevents the CLI from being interactive. When enabled, the CLI will not request input through
@@ -437,7 +439,7 @@ EXAMPLES
437
439
  $ internxt login
438
440
  ```
439
441
 
440
- _See code: [src/commands/login.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/login.ts)_
442
+ _See code: [src/commands/login.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/login.ts)_
441
443
 
442
444
  ## `internxt logout`
443
445
 
@@ -457,7 +459,7 @@ EXAMPLES
457
459
  $ internxt logout
458
460
  ```
459
461
 
460
- _See code: [src/commands/logout.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/logout.ts)_
462
+ _See code: [src/commands/logout.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/logout.ts)_
461
463
 
462
464
  ## `internxt logs`
463
465
 
@@ -477,7 +479,7 @@ EXAMPLES
477
479
  $ internxt logs
478
480
  ```
479
481
 
480
- _See code: [src/commands/logs.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/logs.ts)_
482
+ _See code: [src/commands/logs.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/logs.ts)_
481
483
 
482
484
  ## `internxt move-file`
483
485
 
@@ -509,7 +511,7 @@ EXAMPLES
509
511
  $ internxt move-file
510
512
  ```
511
513
 
512
- _See code: [src/commands/move-file.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/move-file.ts)_
514
+ _See code: [src/commands/move-file.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/move-file.ts)_
513
515
 
514
516
  ## `internxt move-folder`
515
517
 
@@ -541,7 +543,7 @@ EXAMPLES
541
543
  $ internxt move-folder
542
544
  ```
543
545
 
544
- _See code: [src/commands/move-folder.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/move-folder.ts)_
546
+ _See code: [src/commands/move-folder.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/move-folder.ts)_
545
547
 
546
548
  ## `internxt move file`
547
549
 
@@ -632,7 +634,7 @@ EXAMPLES
632
634
  $ internxt rename-file
633
635
  ```
634
636
 
635
- _See code: [src/commands/rename-file.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/rename-file.ts)_
637
+ _See code: [src/commands/rename-file.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/rename-file.ts)_
636
638
 
637
639
  ## `internxt rename-folder`
638
640
 
@@ -663,7 +665,7 @@ EXAMPLES
663
665
  $ internxt rename-folder
664
666
  ```
665
667
 
666
- _See code: [src/commands/rename-folder.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/rename-folder.ts)_
668
+ _See code: [src/commands/rename-folder.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/rename-folder.ts)_
667
669
 
668
670
  ## `internxt rename file`
669
671
 
@@ -751,7 +753,7 @@ EXAMPLES
751
753
  $ internxt trash-clear
752
754
  ```
753
755
 
754
- _See code: [src/commands/trash-clear.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/trash-clear.ts)_
756
+ _See code: [src/commands/trash-clear.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/trash-clear.ts)_
755
757
 
756
758
  ## `internxt trash-file`
757
759
 
@@ -781,7 +783,7 @@ EXAMPLES
781
783
  $ internxt trash-file
782
784
  ```
783
785
 
784
- _See code: [src/commands/trash-file.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/trash-file.ts)_
786
+ _See code: [src/commands/trash-file.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/trash-file.ts)_
785
787
 
786
788
  ## `internxt trash-folder`
787
789
 
@@ -811,7 +813,7 @@ EXAMPLES
811
813
  $ internxt trash-folder
812
814
  ```
813
815
 
814
- _See code: [src/commands/trash-folder.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/trash-folder.ts)_
816
+ _See code: [src/commands/trash-folder.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/trash-folder.ts)_
815
817
 
816
818
  ## `internxt trash-list`
817
819
 
@@ -837,7 +839,7 @@ EXAMPLES
837
839
  $ internxt trash-list
838
840
  ```
839
841
 
840
- _See code: [src/commands/trash-list.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/trash-list.ts)_
842
+ _See code: [src/commands/trash-list.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/trash-list.ts)_
841
843
 
842
844
  ## `internxt trash-restore-file`
843
845
 
@@ -868,7 +870,7 @@ EXAMPLES
868
870
  $ internxt trash-restore-file
869
871
  ```
870
872
 
871
- _See code: [src/commands/trash-restore-file.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/trash-restore-file.ts)_
873
+ _See code: [src/commands/trash-restore-file.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/trash-restore-file.ts)_
872
874
 
873
875
  ## `internxt trash-restore-folder`
874
876
 
@@ -899,7 +901,7 @@ EXAMPLES
899
901
  $ internxt trash-restore-folder
900
902
  ```
901
903
 
902
- _See code: [src/commands/trash-restore-folder.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/trash-restore-folder.ts)_
904
+ _See code: [src/commands/trash-restore-folder.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/trash-restore-folder.ts)_
903
905
 
904
906
  ## `internxt trash clear`
905
907
 
@@ -1096,7 +1098,7 @@ EXAMPLES
1096
1098
  $ internxt upload-file
1097
1099
  ```
1098
1100
 
1099
- _See code: [src/commands/upload-file.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/upload-file.ts)_
1101
+ _See code: [src/commands/upload-file.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/upload-file.ts)_
1100
1102
 
1101
1103
  ## `internxt upload file`
1102
1104
 
@@ -1151,7 +1153,7 @@ EXAMPLES
1151
1153
  $ internxt webdav status
1152
1154
  ```
1153
1155
 
1154
- _See code: [src/commands/webdav.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/webdav.ts)_
1156
+ _See code: [src/commands/webdav.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/webdav.ts)_
1155
1157
 
1156
1158
  ## `internxt webdav-config`
1157
1159
 
@@ -1159,10 +1161,11 @@ Edit the configuration of the Internxt CLI WebDav server as the port or the prot
1159
1161
 
1160
1162
  ```
1161
1163
  USAGE
1162
- $ internxt webdav-config [--json] [-p <value>] [-s | -h] [-t <value>]
1164
+ $ internxt webdav-config [--json] [-l <value>] [-p <value>] [-s | -h] [-t <value>]
1163
1165
 
1164
1166
  FLAGS
1165
1167
  -h, --http Configures the WebDAV server to use insecure plain HTTP.
1168
+ -l, --host=<value> The listening host for the WebDAV server.
1166
1169
  -p, --port=<value> The new port for the WebDAV server.
1167
1170
  -s, --https Configures the WebDAV server to use HTTPS with self-signed certificates.
1168
1171
  -t, --timeout=<value> Configures the WebDAV server to use this timeout in minutes.
@@ -1177,7 +1180,7 @@ EXAMPLES
1177
1180
  $ internxt webdav-config
1178
1181
  ```
1179
1182
 
1180
- _See code: [src/commands/webdav-config.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/webdav-config.ts)_
1183
+ _See code: [src/commands/webdav-config.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/webdav-config.ts)_
1181
1184
 
1182
1185
  ## `internxt whoami`
1183
1186
 
@@ -1197,7 +1200,7 @@ EXAMPLES
1197
1200
  $ internxt whoami
1198
1201
  ```
1199
1202
 
1200
- _See code: [src/commands/whoami.ts](https://github.com/internxt/cli/blob/v1.5.5/src/commands/whoami.ts)_
1203
+ _See code: [src/commands/whoami.ts](https://github.com/internxt/cli/blob/v1.5.7/src/commands/whoami.ts)_
1201
1204
  <!-- commandsstop -->
1202
1205
 
1203
1206
  # Current Limitations
@@ -6,6 +6,7 @@ const drive_folder_service_1 = require("../services/drive/drive-folder.service")
6
6
  const config_service_1 = require("../services/config.service");
7
7
  const validation_service_1 = require("../services/validation.service");
8
8
  const command_types_1 = require("../types/command.types");
9
+ const async_utils_1 = require("../utils/async.utils");
9
10
  class CreateFolder extends core_1.Command {
10
11
  static args = {};
11
12
  static description = 'Create a folder in your Internxt Drive';
@@ -47,6 +48,7 @@ class CreateFolder extends core_1.Command {
47
48
  process.exit(1);
48
49
  });
49
50
  const newFolder = await createNewFolder;
51
+ await async_utils_1.AsyncUtils.sleep(500);
50
52
  cli_utils_1.CLIUtils.done(flags['json']);
51
53
  const message = `Folder ${newFolder.plainName} created successfully, view it at ${config_service_1.ConfigService.instance.get('DRIVE_WEB_URL')}/folder/${newFolder.uuid}`;
52
54
  cli_utils_1.CLIUtils.success(this.log.bind(this), message);
@@ -2,7 +2,7 @@ import { Command } from '@oclif/core';
2
2
  import { DriveFileItem } from '../types/drive.types';
3
3
  export default class DownloadFile extends Command {
4
4
  static readonly args: {};
5
- static readonly description = "Download and decrypts a file from Internxt Drive to a directory. The file name will be the same as the file name in your Drive.";
5
+ static readonly description: string;
6
6
  static readonly aliases: string[];
7
7
  static readonly examples: string[];
8
8
  static readonly flags: {
@@ -21,7 +21,8 @@ const inxt_js_1 = require("@internxt/inxt-js");
21
21
  const config_service_1 = require("../services/config.service");
22
22
  class DownloadFile extends core_1.Command {
23
23
  static args = {};
24
- static description = 'Download and decrypts a file from Internxt Drive to a directory. The file name will be the same as the file name in your Drive.';
24
+ static description = 'Download and decrypts a file from Internxt Drive to a directory.' +
25
+ ' The file name will be the same as the file name in your Drive.';
25
26
  static aliases = ['download:file'];
26
27
  static examples = ['<%= config.bin %> <%= command.id %>'];
27
28
  static flags = {
@@ -74,6 +75,11 @@ class DownloadFile extends core_1.Command {
74
75
  process.exit(1);
75
76
  });
76
77
  await executeDownload;
78
+ try {
79
+ await promises_1.default.utimes(downloadPath, new Date(), driveFile.modificationTime ?? driveFile.updatedAt);
80
+ }
81
+ catch {
82
+ }
77
83
  progressBar?.update(100);
78
84
  progressBar?.stop();
79
85
  const message = `File downloaded successfully to ${downloadPath}`;
@@ -13,8 +13,46 @@ export default class List extends Command {
13
13
  run: () => Promise<{
14
14
  success: boolean;
15
15
  list: {
16
- folders: import("@internxt/sdk/dist/drive/storage/types").FetchPaginatedFolder[];
17
- files: import("@internxt/sdk/dist/drive/storage/types").FetchPaginatedFile[];
16
+ folders: {
17
+ type: string;
18
+ id: number;
19
+ parentId: number;
20
+ parentUuid: string;
21
+ name: string;
22
+ parent: import("@internxt/sdk/dist/schema").components["schemas"]["Folder"];
23
+ bucket: string;
24
+ userId: number;
25
+ encryptVersion: string;
26
+ createdAt: string;
27
+ updatedAt: string;
28
+ uuid: string;
29
+ plainName: string;
30
+ size: number;
31
+ creationTime: string;
32
+ modificationTime: string;
33
+ status: "EXISTS" | "TRASHED" | "DELETED";
34
+ removed: boolean;
35
+ deleted: boolean;
36
+ }[];
37
+ files: {
38
+ id: number;
39
+ uuid: string;
40
+ fileId: string;
41
+ name: string;
42
+ type: string;
43
+ size: string;
44
+ bucket: string;
45
+ folderId: number;
46
+ folderUuid: string;
47
+ encryptVersion: string;
48
+ userId: number;
49
+ creationTime: string;
50
+ modificationTime: string;
51
+ createdAt: string;
52
+ updatedAt: string;
53
+ plainName: string;
54
+ status: "EXISTS" | "TRASHED" | "DELETED";
55
+ }[];
18
56
  };
19
57
  }>;
20
58
  catch: (error: Error) => Promise<never>;
@@ -8,6 +8,7 @@ export default class Login extends Command {
8
8
  email: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
9
  password: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
10
  twofactor: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
+ twofactortoken: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
12
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
13
  };
13
14
  static readonly enableJsonFlag = true;
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  const core_1 = require("@oclif/core");
4
37
  const command_types_1 = require("../types/command.types");
@@ -7,6 +40,7 @@ const config_service_1 = require("../services/config.service");
7
40
  const validation_service_1 = require("../services/validation.service");
8
41
  const cli_utils_1 = require("../utils/cli.utils");
9
42
  const sdk_manager_service_1 = require("../services/sdk-manager.service");
43
+ const OTPAuth = __importStar(require("otpauth"));
10
44
  class Login extends core_1.Command {
11
45
  static args = {};
12
46
  static description = 'Logs into an Internxt account. If the account is two-factor protected, then an extra code will be required.';
@@ -17,7 +51,7 @@ class Login extends core_1.Command {
17
51
  email: core_1.Flags.string({
18
52
  char: 'e',
19
53
  aliases: ['mail'],
20
- env: 'INXT_EMAIL',
54
+ env: 'INXT_USER',
21
55
  description: 'The email to log in',
22
56
  required: false,
23
57
  }),
@@ -32,10 +66,19 @@ class Login extends core_1.Command {
32
66
  char: 'w',
33
67
  aliases: ['two', 'two-factor'],
34
68
  env: 'INXT_TWOFACTORCODE',
35
- description: 'The two factor auth code (only needed if the account is two-factor protected)',
69
+ description: 'The two factor auth code (TOTP). ',
36
70
  required: false,
37
71
  helpValue: '123456',
38
72
  }),
73
+ twofactortoken: core_1.Flags.string({
74
+ char: 't',
75
+ aliases: ['otp', 'otp-token'],
76
+ env: 'INXT_OTPTOKEN',
77
+ description: 'The TOTP secret token. It is used to generate a TOTP code if needed.' +
78
+ ' It has prority over the two factor code flag.',
79
+ required: false,
80
+ helpValue: 'token',
81
+ }),
39
82
  };
40
83
  static enableJsonFlag = true;
41
84
  run = async () => {
@@ -46,13 +89,20 @@ class Login extends core_1.Command {
46
89
  const is2FANeeded = await auth_service_1.AuthService.instance.is2FANeeded(email);
47
90
  let twoFactorCode;
48
91
  if (is2FANeeded) {
49
- twoFactorCode = await this.getTwoFactorCode(flags['twofactor'], nonInteractive);
92
+ const twoFactorToken = flags['twofactortoken'];
93
+ if (twoFactorToken && twoFactorToken.trim().length > 0) {
94
+ const totp = new OTPAuth.TOTP({
95
+ secret: twoFactorToken,
96
+ digits: 6,
97
+ });
98
+ twoFactorCode = totp.generate();
99
+ }
100
+ else {
101
+ twoFactorCode = await this.getTwoFactorCode(flags['twofactor'], nonInteractive);
102
+ }
50
103
  }
51
104
  const loginCredentials = await auth_service_1.AuthService.instance.doLogin(email, password, twoFactorCode);
52
- sdk_manager_service_1.SdkManager.init({
53
- token: loginCredentials.token,
54
- newToken: loginCredentials.newToken,
55
- });
105
+ sdk_manager_service_1.SdkManager.init({ token: loginCredentials.token });
56
106
  await config_service_1.ConfigService.instance.saveUser(loginCredentials);
57
107
  const message = `Succesfully logged in to: ${loginCredentials.user.email}`;
58
108
  cli_utils_1.CLIUtils.success(this.log.bind(this), message);
@@ -112,7 +162,7 @@ class Login extends core_1.Command {
112
162
  }, {
113
163
  nonInteractive,
114
164
  prompt: {
115
- message: 'What is your two-factor token?',
165
+ message: 'What is your two-factor code?',
116
166
  options: { type: 'mask' },
117
167
  },
118
168
  }, {
@@ -13,7 +13,25 @@ export default class MoveFile extends Command {
13
13
  run: () => Promise<{
14
14
  success: boolean;
15
15
  message: string;
16
- file: import("@internxt/sdk/dist/drive/storage/types").FileMeta;
16
+ file: {
17
+ id: number;
18
+ uuid: string;
19
+ fileId: string;
20
+ name: string;
21
+ type: string;
22
+ size: string;
23
+ bucket: string;
24
+ folderId: number;
25
+ folderUuid: string;
26
+ encryptVersion: string;
27
+ userId: number;
28
+ creationTime: string;
29
+ modificationTime: string;
30
+ createdAt: string;
31
+ updatedAt: string;
32
+ plainName: string;
33
+ status: "EXISTS" | "TRASHED" | "DELETED";
34
+ };
17
35
  }>;
18
36
  catch: (error: Error) => Promise<never>;
19
37
  private getFileUuid;
@@ -37,7 +37,7 @@ class MoveFile extends core_1.Command {
37
37
  if (destinationFolderUuid.trim().length === 0) {
38
38
  destinationFolderUuid = userCredentials.user.rootFolderId;
39
39
  }
40
- const newFile = await drive_file_service_1.DriveFileService.instance.moveFile({ fileUuid, destinationFolderUuid });
40
+ const newFile = await drive_file_service_1.DriveFileService.instance.moveFile(fileUuid, { destinationFolder: destinationFolderUuid });
41
41
  const message = `File moved successfully to: ${destinationFolderUuid}`;
42
42
  cli_utils_1.CLIUtils.success(this.log.bind(this), message);
43
43
  return { success: true, message, file: newFile };
@@ -37,7 +37,9 @@ class MoveFolder extends core_1.Command {
37
37
  if (destinationFolderUuid.trim().length === 0) {
38
38
  destinationFolderUuid = userCredentials.user.rootFolderId;
39
39
  }
40
- const newFolder = await drive_folder_service_1.DriveFolderService.instance.moveFolder({ folderUuid, destinationFolderUuid });
40
+ const newFolder = await drive_folder_service_1.DriveFolderService.instance.moveFolder(folderUuid, {
41
+ destinationFolder: destinationFolderUuid,
42
+ });
41
43
  const message = `Folder moved successfully to: ${destinationFolderUuid}`;
42
44
  cli_utils_1.CLIUtils.success(this.log.bind(this), message);
43
45
  return { success: true, message, folder: newFolder };
@@ -16,6 +16,7 @@ export default class RenameFile extends Command {
16
16
  file: {
17
17
  uuid: string;
18
18
  plainName: string;
19
+ type: string;
19
20
  };
20
21
  }>;
21
22
  catch: (error: Error) => Promise<never>;
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  const core_1 = require("@oclif/core");
4
7
  const config_service_1 = require("../services/config.service");
@@ -6,6 +9,7 @@ const cli_utils_1 = require("../utils/cli.utils");
6
9
  const command_types_1 = require("../types/command.types");
7
10
  const validation_service_1 = require("../services/validation.service");
8
11
  const drive_file_service_1 = require("../services/drive/drive-file.service");
12
+ const node_path_1 = __importDefault(require("node:path"));
9
13
  class RenameFile extends core_1.Command {
10
14
  static args = {};
11
15
  static description = 'Rename a file.';
@@ -32,11 +36,14 @@ class RenameFile extends core_1.Command {
32
36
  if (!userCredentials)
33
37
  throw new command_types_1.MissingCredentialsError();
34
38
  const fileUuid = await this.getFileUuid(flags['id'], nonInteractive);
35
- const newName = await this.getFileName(flags['name'], nonInteractive);
36
- await drive_file_service_1.DriveFileService.instance.renameFile(fileUuid, { plainName: newName });
37
- const message = `File renamed successfully with: ${newName}`;
39
+ const fileName = await this.getFileName(flags['name'], nonInteractive);
40
+ const pathInfo = node_path_1.default.parse(fileName);
41
+ const newName = pathInfo.name;
42
+ const newType = pathInfo.ext.replace('.', '');
43
+ await drive_file_service_1.DriveFileService.instance.renameFile(fileUuid, { plainName: newName, type: newType });
44
+ const message = `File renamed successfully with: ${newName}${newType ? '.' + newType : ''}`;
38
45
  cli_utils_1.CLIUtils.success(this.log.bind(this), message);
39
- return { success: true, message, file: { uuid: fileUuid, plainName: newName } };
46
+ return { success: true, message, file: { uuid: fileUuid, plainName: newName, type: newType } };
40
47
  };
41
48
  catch = async (error) => {
42
49
  const { flags } = await this.parse(RenameFile);
@@ -27,7 +27,7 @@ class TrashFile extends core_1.Command {
27
27
  if (!userCredentials)
28
28
  throw new command_types_1.MissingCredentialsError();
29
29
  const uuid = await this.getFileUuid(flags['id'], nonInteractive);
30
- await trash_service_1.TrashService.instance.trashItems({ items: [{ uuid, type: 'file' }] });
30
+ await trash_service_1.TrashService.instance.trashItems({ items: [{ uuid, type: 'file', id: null }] });
31
31
  const message = 'File trashed successfully.';
32
32
  cli_utils_1.CLIUtils.success(this.log.bind(this), message);
33
33
  return { success: true, message, file: { uuid } };
@@ -27,7 +27,7 @@ class TrashFolder extends core_1.Command {
27
27
  if (!userCredentials)
28
28
  throw new command_types_1.MissingCredentialsError();
29
29
  const uuid = await this.getFolderUuid(flags['id'], nonInteractive);
30
- await trash_service_1.TrashService.instance.trashItems({ items: [{ uuid, type: 'folder' }] });
30
+ await trash_service_1.TrashService.instance.trashItems({ items: [{ uuid, type: 'folder', id: null }] });
31
31
  const message = 'Folder trashed successfully.';
32
32
  cli_utils_1.CLIUtils.success(this.log.bind(this), message);
33
33
  return { success: true, message, folder: { uuid } };
@@ -11,8 +11,46 @@ export default class TrashList extends Command {
11
11
  run: () => Promise<{
12
12
  success: boolean;
13
13
  list: {
14
- folders: import("@internxt/sdk/dist/drive/storage/types").FetchPaginatedFolder[];
15
- files: import("@internxt/sdk/dist/drive/storage/types").FetchPaginatedFile[];
14
+ folders: {
15
+ type: string;
16
+ id: number;
17
+ parentId: number;
18
+ parentUuid: string;
19
+ name: string;
20
+ parent: import("@internxt/sdk/dist/schema").components["schemas"]["Folder"];
21
+ bucket: string;
22
+ userId: number;
23
+ encryptVersion: string;
24
+ createdAt: string;
25
+ updatedAt: string;
26
+ uuid: string;
27
+ plainName: string;
28
+ size: number;
29
+ creationTime: string;
30
+ modificationTime: string;
31
+ status: "EXISTS" | "TRASHED" | "DELETED";
32
+ removed: boolean;
33
+ deleted: boolean;
34
+ }[];
35
+ files: {
36
+ id: number;
37
+ uuid: string;
38
+ fileId: string;
39
+ name: string;
40
+ type: string;
41
+ size: string;
42
+ bucket: string;
43
+ folderId: number;
44
+ folderUuid: string;
45
+ encryptVersion: string;
46
+ userId: number;
47
+ creationTime: string;
48
+ modificationTime: string;
49
+ createdAt: string;
50
+ updatedAt: string;
51
+ plainName: string;
52
+ status: "EXISTS" | "TRASHED" | "DELETED";
53
+ }[];
16
54
  };
17
55
  }>;
18
56
  catch: (error: Error) => Promise<never>;