@internxt/cli 1.5.4 → 1.5.6

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 (60) hide show
  1. package/.env +4 -3
  2. package/README.md +65 -30
  3. package/dist/commands/create-folder.js +2 -0
  4. package/dist/commands/download-file.d.ts +1 -1
  5. package/dist/commands/download-file.js +9 -2
  6. package/dist/commands/list.d.ts +40 -2
  7. package/dist/commands/login.d.ts +1 -0
  8. package/dist/commands/login.js +58 -8
  9. package/dist/commands/move-file.d.ts +19 -1
  10. package/dist/commands/move-file.js +1 -1
  11. package/dist/commands/move-folder.js +3 -1
  12. package/dist/commands/rename-file.d.ts +1 -0
  13. package/dist/commands/rename-file.js +11 -4
  14. package/dist/commands/trash-file.js +1 -1
  15. package/dist/commands/trash-folder.js +1 -1
  16. package/dist/commands/trash-list.d.ts +40 -2
  17. package/dist/commands/trash-restore-file.d.ts +19 -1
  18. package/dist/commands/trash-restore-file.js +1 -1
  19. package/dist/commands/trash-restore-folder.js +3 -1
  20. package/dist/commands/upload-file.d.ts +17 -1
  21. package/dist/commands/upload-file.js +17 -11
  22. package/dist/commands/webdav-config.d.ts +1 -0
  23. package/dist/commands/webdav-config.js +9 -0
  24. package/dist/commands/webdav.js +2 -2
  25. package/dist/commands/whoami.js +14 -8
  26. package/dist/hooks/prerun/auth_check.js +2 -5
  27. package/dist/services/auth.service.d.ts +2 -1
  28. package/dist/services/auth.service.js +32 -37
  29. package/dist/services/config.service.d.ts +1 -1
  30. package/dist/services/config.service.js +4 -7
  31. package/dist/services/database/drive-file/drive-file.attributes.d.ts +3 -1
  32. package/dist/services/database/drive-file/drive-file.domain.d.ts +4 -2
  33. package/dist/services/database/drive-file/drive-file.domain.js +9 -2
  34. package/dist/services/drive/drive-file.service.d.ts +1 -1
  35. package/dist/services/drive/drive-file.service.js +5 -4
  36. package/dist/services/drive/drive-folder.service.d.ts +41 -4
  37. package/dist/services/drive/drive-folder.service.js +2 -2
  38. package/dist/services/drive/trash.service.d.ts +40 -2
  39. package/dist/services/keys.service.d.ts +0 -3
  40. package/dist/services/keys.service.js +1 -60
  41. package/dist/services/sdk-manager.service.d.ts +1 -3
  42. package/dist/services/sdk-manager.service.js +6 -15
  43. package/dist/services/thumbnail.service.js +59 -15
  44. package/dist/types/command.types.d.ts +27 -3
  45. package/dist/types/config.types.d.ts +1 -0
  46. package/dist/types/drive.types.d.ts +5 -4
  47. package/dist/types/keys.types.d.ts +0 -12
  48. package/dist/types/keys.types.js +0 -29
  49. package/dist/utils/drive.utils.js +4 -3
  50. package/dist/utils/network.utils.d.ts +4 -3
  51. package/dist/utils/network.utils.js +8 -8
  52. package/dist/webdav/handlers/DELETE.handler.js +1 -1
  53. package/dist/webdav/handlers/MOVE.handler.js +9 -7
  54. package/dist/webdav/handlers/PROPFIND.handler.js +8 -5
  55. package/dist/webdav/handlers/PUT.handler.js +5 -6
  56. package/dist/webdav/index.js +2 -5
  57. package/dist/webdav/middewares/auth.middleware.js +3 -10
  58. package/dist/webdav/webdav-server.js +4 -3
  59. package/oclif.manifest.json +27 -3
  60. package/package.json +27 -28
package/.env CHANGED
@@ -1,6 +1,7 @@
1
1
  DRIVE_WEB_URL=https://drive.internxt.com
2
- DRIVE_NEW_API_URL=https://api.internxt.com/drive
3
- NETWORK_URL=https://api.internxt.com
2
+ DRIVE_NEW_API_URL=https://gateway.internxt.com/drive
3
+ NETWORK_URL=https://gateway.internxt.com/network
4
4
  APP_CRYPTO_SECRET=6KYQBP847D4ATSFA
5
5
  APP_MAGIC_IV=d139cb9a2cd17092e79e1861cf9d7023
6
- APP_MAGIC_SALT=38dce0391b49efba88dbc8c39ebf868f0267eb110bb0012ab27dc52a528d61b1d1ed9d76f400ff58e3240028442b1eab9bb84e111d9dadd997982dbde9dbd25e
6
+ APP_MAGIC_SALT=38dce0391b49efba88dbc8c39ebf868f0267eb110bb0012ab27dc52a528d61b1d1ed9d76f400ff58e3240028442b1eab9bb84e111d9dadd997982dbde9dbd25e
7
+ DESKTOP_HEADER=3b68706a367fd567b929396290b1de40768bb768
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.4 linux-x64 node-v22.17.0
54
+ @internxt/cli/1.5.6 linux-x64 node-v22.20.0
55
55
  $ internxt --help [COMMAND]
56
56
  USAGE
57
57
  $ internxt COMMAND
@@ -63,6 +63,7 @@ USAGE
63
63
 
64
64
  <!-- commands -->
65
65
  * [`internxt add-cert`](#internxt-add-cert)
66
+ * [`internxt autocomplete [SHELL]`](#internxt-autocomplete-shell)
66
67
  * [`internxt config`](#internxt-config)
67
68
  * [`internxt create-folder`](#internxt-create-folder)
68
69
  * [`internxt delete-permanently-file`](#internxt-delete-permanently-file)
@@ -119,7 +120,38 @@ EXAMPLES
119
120
  $ internxt add-cert
120
121
  ```
121
122
 
122
- _See code: [src/commands/add-cert.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/add-cert.ts)_
123
+ _See code: [src/commands/add-cert.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/add-cert.ts)_
124
+
125
+ ## `internxt autocomplete [SHELL]`
126
+
127
+ Display autocomplete installation instructions.
128
+
129
+ ```
130
+ USAGE
131
+ $ internxt autocomplete [SHELL] [-r]
132
+
133
+ ARGUMENTS
134
+ SHELL (zsh|bash|powershell) Shell type
135
+
136
+ FLAGS
137
+ -r, --refresh-cache Refresh cache (ignores displaying instructions)
138
+
139
+ DESCRIPTION
140
+ Display autocomplete installation instructions.
141
+
142
+ EXAMPLES
143
+ $ internxt autocomplete
144
+
145
+ $ internxt autocomplete bash
146
+
147
+ $ internxt autocomplete zsh
148
+
149
+ $ internxt autocomplete powershell
150
+
151
+ $ internxt autocomplete --refresh-cache
152
+ ```
153
+
154
+ _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.35/src/commands/autocomplete/index.ts)_
123
155
 
124
156
  ## `internxt config`
125
157
 
@@ -139,7 +171,7 @@ EXAMPLES
139
171
  $ internxt config
140
172
  ```
141
173
 
142
- _See code: [src/commands/config.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/config.ts)_
174
+ _See code: [src/commands/config.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/config.ts)_
143
175
 
144
176
  ## `internxt create-folder`
145
177
 
@@ -168,7 +200,7 @@ EXAMPLES
168
200
  $ internxt create-folder
169
201
  ```
170
202
 
171
- _See code: [src/commands/create-folder.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/create-folder.ts)_
203
+ _See code: [src/commands/create-folder.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/create-folder.ts)_
172
204
 
173
205
  ## `internxt delete-permanently-file`
174
206
 
@@ -198,7 +230,7 @@ EXAMPLES
198
230
  $ internxt delete-permanently-file
199
231
  ```
200
232
 
201
- _See code: [src/commands/delete-permanently-file.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/delete-permanently-file.ts)_
233
+ _See code: [src/commands/delete-permanently-file.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/delete-permanently-file.ts)_
202
234
 
203
235
  ## `internxt delete-permanently-folder`
204
236
 
@@ -228,7 +260,7 @@ EXAMPLES
228
260
  $ internxt delete-permanently-folder
229
261
  ```
230
262
 
231
- _See code: [src/commands/delete-permanently-folder.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/delete-permanently-folder.ts)_
263
+ _See code: [src/commands/delete-permanently-folder.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/delete-permanently-folder.ts)_
232
264
 
233
265
  ## `internxt delete permanently file`
234
266
 
@@ -317,7 +349,7 @@ EXAMPLES
317
349
  $ internxt download-file
318
350
  ```
319
351
 
320
- _See code: [src/commands/download-file.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/download-file.ts)_
352
+ _See code: [src/commands/download-file.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/download-file.ts)_
321
353
 
322
354
  ## `internxt download file`
323
355
 
@@ -376,7 +408,7 @@ EXAMPLES
376
408
  $ internxt list
377
409
  ```
378
410
 
379
- _See code: [src/commands/list.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/list.ts)_
411
+ _See code: [src/commands/list.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/list.ts)_
380
412
 
381
413
  ## `internxt login`
382
414
 
@@ -384,12 +416,14 @@ Logs into an Internxt account. If the account is two-factor protected, then an e
384
416
 
385
417
  ```
386
418
  USAGE
387
- $ internxt login [--json] [-x] [-e <value>] [-p <value>] [-w 123456]
419
+ $ internxt login [--json] [-x] [-e <value>] [-p <value>] [-w 123456] [-t token]
388
420
 
389
421
  FLAGS
390
- -e, --email=<value> The email to log in
391
- -p, --password=<value> The plain password to log in
392
- -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).
393
427
 
394
428
  HELPER FLAGS
395
429
  -x, --non-interactive Prevents the CLI from being interactive. When enabled, the CLI will not request input through
@@ -405,7 +439,7 @@ EXAMPLES
405
439
  $ internxt login
406
440
  ```
407
441
 
408
- _See code: [src/commands/login.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/login.ts)_
442
+ _See code: [src/commands/login.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/login.ts)_
409
443
 
410
444
  ## `internxt logout`
411
445
 
@@ -425,7 +459,7 @@ EXAMPLES
425
459
  $ internxt logout
426
460
  ```
427
461
 
428
- _See code: [src/commands/logout.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/logout.ts)_
462
+ _See code: [src/commands/logout.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/logout.ts)_
429
463
 
430
464
  ## `internxt logs`
431
465
 
@@ -445,7 +479,7 @@ EXAMPLES
445
479
  $ internxt logs
446
480
  ```
447
481
 
448
- _See code: [src/commands/logs.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/logs.ts)_
482
+ _See code: [src/commands/logs.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/logs.ts)_
449
483
 
450
484
  ## `internxt move-file`
451
485
 
@@ -477,7 +511,7 @@ EXAMPLES
477
511
  $ internxt move-file
478
512
  ```
479
513
 
480
- _See code: [src/commands/move-file.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/move-file.ts)_
514
+ _See code: [src/commands/move-file.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/move-file.ts)_
481
515
 
482
516
  ## `internxt move-folder`
483
517
 
@@ -509,7 +543,7 @@ EXAMPLES
509
543
  $ internxt move-folder
510
544
  ```
511
545
 
512
- _See code: [src/commands/move-folder.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/move-folder.ts)_
546
+ _See code: [src/commands/move-folder.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/move-folder.ts)_
513
547
 
514
548
  ## `internxt move file`
515
549
 
@@ -600,7 +634,7 @@ EXAMPLES
600
634
  $ internxt rename-file
601
635
  ```
602
636
 
603
- _See code: [src/commands/rename-file.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/rename-file.ts)_
637
+ _See code: [src/commands/rename-file.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/rename-file.ts)_
604
638
 
605
639
  ## `internxt rename-folder`
606
640
 
@@ -631,7 +665,7 @@ EXAMPLES
631
665
  $ internxt rename-folder
632
666
  ```
633
667
 
634
- _See code: [src/commands/rename-folder.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/rename-folder.ts)_
668
+ _See code: [src/commands/rename-folder.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/rename-folder.ts)_
635
669
 
636
670
  ## `internxt rename file`
637
671
 
@@ -719,7 +753,7 @@ EXAMPLES
719
753
  $ internxt trash-clear
720
754
  ```
721
755
 
722
- _See code: [src/commands/trash-clear.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/trash-clear.ts)_
756
+ _See code: [src/commands/trash-clear.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/trash-clear.ts)_
723
757
 
724
758
  ## `internxt trash-file`
725
759
 
@@ -749,7 +783,7 @@ EXAMPLES
749
783
  $ internxt trash-file
750
784
  ```
751
785
 
752
- _See code: [src/commands/trash-file.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/trash-file.ts)_
786
+ _See code: [src/commands/trash-file.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/trash-file.ts)_
753
787
 
754
788
  ## `internxt trash-folder`
755
789
 
@@ -779,7 +813,7 @@ EXAMPLES
779
813
  $ internxt trash-folder
780
814
  ```
781
815
 
782
- _See code: [src/commands/trash-folder.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/trash-folder.ts)_
816
+ _See code: [src/commands/trash-folder.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/trash-folder.ts)_
783
817
 
784
818
  ## `internxt trash-list`
785
819
 
@@ -805,7 +839,7 @@ EXAMPLES
805
839
  $ internxt trash-list
806
840
  ```
807
841
 
808
- _See code: [src/commands/trash-list.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/trash-list.ts)_
842
+ _See code: [src/commands/trash-list.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/trash-list.ts)_
809
843
 
810
844
  ## `internxt trash-restore-file`
811
845
 
@@ -836,7 +870,7 @@ EXAMPLES
836
870
  $ internxt trash-restore-file
837
871
  ```
838
872
 
839
- _See code: [src/commands/trash-restore-file.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/trash-restore-file.ts)_
873
+ _See code: [src/commands/trash-restore-file.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/trash-restore-file.ts)_
840
874
 
841
875
  ## `internxt trash-restore-folder`
842
876
 
@@ -867,7 +901,7 @@ EXAMPLES
867
901
  $ internxt trash-restore-folder
868
902
  ```
869
903
 
870
- _See code: [src/commands/trash-restore-folder.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/trash-restore-folder.ts)_
904
+ _See code: [src/commands/trash-restore-folder.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/trash-restore-folder.ts)_
871
905
 
872
906
  ## `internxt trash clear`
873
907
 
@@ -1064,7 +1098,7 @@ EXAMPLES
1064
1098
  $ internxt upload-file
1065
1099
  ```
1066
1100
 
1067
- _See code: [src/commands/upload-file.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/upload-file.ts)_
1101
+ _See code: [src/commands/upload-file.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/upload-file.ts)_
1068
1102
 
1069
1103
  ## `internxt upload file`
1070
1104
 
@@ -1119,7 +1153,7 @@ EXAMPLES
1119
1153
  $ internxt webdav status
1120
1154
  ```
1121
1155
 
1122
- _See code: [src/commands/webdav.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/webdav.ts)_
1156
+ _See code: [src/commands/webdav.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/webdav.ts)_
1123
1157
 
1124
1158
  ## `internxt webdav-config`
1125
1159
 
@@ -1127,10 +1161,11 @@ Edit the configuration of the Internxt CLI WebDav server as the port or the prot
1127
1161
 
1128
1162
  ```
1129
1163
  USAGE
1130
- $ internxt webdav-config [--json] [-p <value>] [-s | -h] [-t <value>]
1164
+ $ internxt webdav-config [--json] [-l <value>] [-p <value>] [-s | -h] [-t <value>]
1131
1165
 
1132
1166
  FLAGS
1133
1167
  -h, --http Configures the WebDAV server to use insecure plain HTTP.
1168
+ -l, --host=<value> The listening host for the WebDAV server.
1134
1169
  -p, --port=<value> The new port for the WebDAV server.
1135
1170
  -s, --https Configures the WebDAV server to use HTTPS with self-signed certificates.
1136
1171
  -t, --timeout=<value> Configures the WebDAV server to use this timeout in minutes.
@@ -1145,7 +1180,7 @@ EXAMPLES
1145
1180
  $ internxt webdav-config
1146
1181
  ```
1147
1182
 
1148
- _See code: [src/commands/webdav-config.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/webdav-config.ts)_
1183
+ _See code: [src/commands/webdav-config.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/webdav-config.ts)_
1149
1184
 
1150
1185
  ## `internxt whoami`
1151
1186
 
@@ -1165,7 +1200,7 @@ EXAMPLES
1165
1200
  $ internxt whoami
1166
1201
  ```
1167
1202
 
1168
- _See code: [src/commands/whoami.ts](https://github.com/internxt/cli/blob/v1.5.4/src/commands/whoami.ts)_
1203
+ _See code: [src/commands/whoami.ts](https://github.com/internxt/cli/blob/v1.5.6/src/commands/whoami.ts)_
1169
1204
  <!-- commandsstop -->
1170
1205
 
1171
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 = {
@@ -63,7 +64,7 @@ class DownloadFile extends core_1.Command {
63
64
  linewrap: true,
64
65
  }, flags['json']);
65
66
  progressBar?.start(100, 0);
66
- const [executeDownload, abortable] = await networkFacade.downloadToStream(user.bucket, user.mnemonic, driveFile.fileId, driveFile.size, stream_utils_1.StreamUtils.writeStreamToWritableStream(fileWriteStream), undefined, {
67
+ const [executeDownload, abortable] = await networkFacade.downloadToStream(driveFile.bucket, user.mnemonic, driveFile.fileId, driveFile.size, stream_utils_1.StreamUtils.writeStreamToWritableStream(fileWriteStream), undefined, {
67
68
  abortController: new AbortController(),
68
69
  progressCallback: (progress) => {
69
70
  progressBar?.update(progress * 0.99);
@@ -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}`;
@@ -165,6 +171,7 @@ class DownloadFile extends core_1.Command {
165
171
  bridgePass: user.userId,
166
172
  bridgeUrl: config_service_1.ConfigService.instance.get('NETWORK_URL'),
167
173
  encryptionKey: user.mnemonic,
174
+ appDetails: sdk_manager_service_1.SdkManager.getAppDetails(),
168
175
  });
169
176
  const networkFacade = new network_facade_service_1.NetworkFacade(networkModule, environment, download_service_1.DownloadService.instance, crypto_service_1.CryptoService.instance);
170
177
  cli_utils_1.CLIUtils.done(jsonFlag);
@@ -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 } };