@internxt/cli 1.6.6 → 1.6.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.
package/README.md CHANGED
@@ -52,7 +52,7 @@ $ npm install -g @internxt/cli
52
52
  $ internxt COMMAND
53
53
  running command...
54
54
  $ internxt (--version)
55
- @internxt/cli/1.6.6 linux-x64 node-v22.22.3
55
+ @internxt/cli/1.6.7 linux-x64 node-v22.23.1
56
56
  $ internxt --help [COMMAND]
57
57
  USAGE
58
58
  $ internxt COMMAND
@@ -145,7 +145,7 @@ EXAMPLES
145
145
  $ internxt add-cert
146
146
  ```
147
147
 
148
- _See code: [src/commands/add-cert.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/add-cert.ts)_
148
+ _See code: [src/commands/add-cert.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/add-cert.ts)_
149
149
 
150
150
  ## `internxt add cert`
151
151
 
@@ -203,7 +203,7 @@ EXAMPLES
203
203
  $ internxt autocomplete --refresh-cache
204
204
  ```
205
205
 
206
- _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.52/src/commands/autocomplete/index.ts)_
206
+ _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.53/src/commands/autocomplete/index.ts)_
207
207
 
208
208
  ## `internxt config`
209
209
 
@@ -232,7 +232,7 @@ EXAMPLES
232
232
  $ internxt config
233
233
  ```
234
234
 
235
- _See code: [src/commands/config.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/config.ts)_
235
+ _See code: [src/commands/config.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/config.ts)_
236
236
 
237
237
  ## `internxt create-folder`
238
238
 
@@ -266,7 +266,7 @@ EXAMPLES
266
266
  $ internxt create-folder
267
267
  ```
268
268
 
269
- _See code: [src/commands/create-folder.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/create-folder.ts)_
269
+ _See code: [src/commands/create-folder.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/create-folder.ts)_
270
270
 
271
271
  ## `internxt create folder`
272
272
 
@@ -330,7 +330,7 @@ EXAMPLES
330
330
  $ internxt delete-permanently-file
331
331
  ```
332
332
 
333
- _See code: [src/commands/delete-permanently-file.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/delete-permanently-file.ts)_
333
+ _See code: [src/commands/delete-permanently-file.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/delete-permanently-file.ts)_
334
334
 
335
335
  ## `internxt delete-permanently-folder`
336
336
 
@@ -362,7 +362,7 @@ EXAMPLES
362
362
  $ internxt delete-permanently-folder
363
363
  ```
364
364
 
365
- _See code: [src/commands/delete-permanently-folder.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/delete-permanently-folder.ts)_
365
+ _See code: [src/commands/delete-permanently-folder.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/delete-permanently-folder.ts)_
366
366
 
367
367
  ## `internxt delete permanently file`
368
368
 
@@ -457,7 +457,7 @@ EXAMPLES
457
457
  $ internxt download-file
458
458
  ```
459
459
 
460
- _See code: [src/commands/download-file.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/download-file.ts)_
460
+ _See code: [src/commands/download-file.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/download-file.ts)_
461
461
 
462
462
  ## `internxt download file`
463
463
 
@@ -520,7 +520,7 @@ EXAMPLES
520
520
  $ internxt list
521
521
  ```
522
522
 
523
- _See code: [src/commands/list.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/list.ts)_
523
+ _See code: [src/commands/list.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/list.ts)_
524
524
 
525
525
  ## `internxt login`
526
526
 
@@ -554,7 +554,7 @@ EXAMPLES
554
554
  $ internxt login
555
555
  ```
556
556
 
557
- _See code: [src/commands/login.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/login.ts)_
557
+ _See code: [src/commands/login.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/login.ts)_
558
558
 
559
559
  ## `internxt login-legacy`
560
560
 
@@ -588,7 +588,7 @@ EXAMPLES
588
588
  $ internxt login-legacy
589
589
  ```
590
590
 
591
- _See code: [src/commands/login-legacy.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/login-legacy.ts)_
591
+ _See code: [src/commands/login-legacy.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/login-legacy.ts)_
592
592
 
593
593
  ## `internxt logout`
594
594
 
@@ -614,7 +614,7 @@ EXAMPLES
614
614
  $ internxt logout
615
615
  ```
616
616
 
617
- _See code: [src/commands/logout.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/logout.ts)_
617
+ _See code: [src/commands/logout.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/logout.ts)_
618
618
 
619
619
  ## `internxt logs`
620
620
 
@@ -640,7 +640,7 @@ EXAMPLES
640
640
  $ internxt logs
641
641
  ```
642
642
 
643
- _See code: [src/commands/logs.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/logs.ts)_
643
+ _See code: [src/commands/logs.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/logs.ts)_
644
644
 
645
645
  ## `internxt move-file`
646
646
 
@@ -674,7 +674,7 @@ EXAMPLES
674
674
  $ internxt move-file
675
675
  ```
676
676
 
677
- _See code: [src/commands/move-file.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/move-file.ts)_
677
+ _See code: [src/commands/move-file.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/move-file.ts)_
678
678
 
679
679
  ## `internxt move-folder`
680
680
 
@@ -708,7 +708,7 @@ EXAMPLES
708
708
  $ internxt move-folder
709
709
  ```
710
710
 
711
- _See code: [src/commands/move-folder.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/move-folder.ts)_
711
+ _See code: [src/commands/move-folder.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/move-folder.ts)_
712
712
 
713
713
  ## `internxt move file`
714
714
 
@@ -805,7 +805,7 @@ EXAMPLES
805
805
  $ internxt rename-file
806
806
  ```
807
807
 
808
- _See code: [src/commands/rename-file.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/rename-file.ts)_
808
+ _See code: [src/commands/rename-file.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/rename-file.ts)_
809
809
 
810
810
  ## `internxt rename-folder`
811
811
 
@@ -838,7 +838,7 @@ EXAMPLES
838
838
  $ internxt rename-folder
839
839
  ```
840
840
 
841
- _See code: [src/commands/rename-folder.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/rename-folder.ts)_
841
+ _See code: [src/commands/rename-folder.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/rename-folder.ts)_
842
842
 
843
843
  ## `internxt rename file`
844
844
 
@@ -932,7 +932,7 @@ EXAMPLES
932
932
  $ internxt trash-clear
933
933
  ```
934
934
 
935
- _See code: [src/commands/trash-clear.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/trash-clear.ts)_
935
+ _See code: [src/commands/trash-clear.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/trash-clear.ts)_
936
936
 
937
937
  ## `internxt trash-file`
938
938
 
@@ -964,7 +964,7 @@ EXAMPLES
964
964
  $ internxt trash-file
965
965
  ```
966
966
 
967
- _See code: [src/commands/trash-file.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/trash-file.ts)_
967
+ _See code: [src/commands/trash-file.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/trash-file.ts)_
968
968
 
969
969
  ## `internxt trash-folder`
970
970
 
@@ -996,7 +996,7 @@ EXAMPLES
996
996
  $ internxt trash-folder
997
997
  ```
998
998
 
999
- _See code: [src/commands/trash-folder.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/trash-folder.ts)_
999
+ _See code: [src/commands/trash-folder.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/trash-folder.ts)_
1000
1000
 
1001
1001
  ## `internxt trash-list`
1002
1002
 
@@ -1028,7 +1028,7 @@ EXAMPLES
1028
1028
  $ internxt trash-list
1029
1029
  ```
1030
1030
 
1031
- _See code: [src/commands/trash-list.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/trash-list.ts)_
1031
+ _See code: [src/commands/trash-list.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/trash-list.ts)_
1032
1032
 
1033
1033
  ## `internxt trash-restore-file`
1034
1034
 
@@ -1061,7 +1061,7 @@ EXAMPLES
1061
1061
  $ internxt trash-restore-file
1062
1062
  ```
1063
1063
 
1064
- _See code: [src/commands/trash-restore-file.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/trash-restore-file.ts)_
1064
+ _See code: [src/commands/trash-restore-file.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/trash-restore-file.ts)_
1065
1065
 
1066
1066
  ## `internxt trash-restore-folder`
1067
1067
 
@@ -1094,7 +1094,7 @@ EXAMPLES
1094
1094
  $ internxt trash-restore-folder
1095
1095
  ```
1096
1096
 
1097
- _See code: [src/commands/trash-restore-folder.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/trash-restore-folder.ts)_
1097
+ _See code: [src/commands/trash-restore-folder.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/trash-restore-folder.ts)_
1098
1098
 
1099
1099
  ## `internxt trash clear`
1100
1100
 
@@ -1309,7 +1309,7 @@ EXAMPLES
1309
1309
  $ internxt upload-file
1310
1310
  ```
1311
1311
 
1312
- _See code: [src/commands/upload-file.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/upload-file.ts)_
1312
+ _See code: [src/commands/upload-file.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/upload-file.ts)_
1313
1313
 
1314
1314
  ## `internxt upload-folder`
1315
1315
 
@@ -1342,7 +1342,7 @@ EXAMPLES
1342
1342
  $ internxt upload-folder
1343
1343
  ```
1344
1344
 
1345
- _See code: [src/commands/upload-folder.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/upload-folder.ts)_
1345
+ _See code: [src/commands/upload-folder.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/upload-folder.ts)_
1346
1346
 
1347
1347
  ## `internxt upload file`
1348
1348
 
@@ -1436,7 +1436,7 @@ EXAMPLES
1436
1436
  $ internxt webdav status
1437
1437
  ```
1438
1438
 
1439
- _See code: [src/commands/webdav.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/webdav.ts)_
1439
+ _See code: [src/commands/webdav.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/webdav.ts)_
1440
1440
 
1441
1441
  ## `internxt webdav-config`
1442
1442
 
@@ -1475,7 +1475,7 @@ EXAMPLES
1475
1475
  $ internxt webdav-config
1476
1476
  ```
1477
1477
 
1478
- _See code: [src/commands/webdav-config.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/webdav-config.ts)_
1478
+ _See code: [src/commands/webdav-config.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/webdav-config.ts)_
1479
1479
 
1480
1480
  ## `internxt whoami`
1481
1481
 
@@ -1501,7 +1501,7 @@ EXAMPLES
1501
1501
  $ internxt whoami
1502
1502
  ```
1503
1503
 
1504
- _See code: [src/commands/whoami.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/whoami.ts)_
1504
+ _See code: [src/commands/whoami.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/whoami.ts)_
1505
1505
 
1506
1506
  ## `internxt workspaces-list`
1507
1507
 
@@ -1533,7 +1533,7 @@ EXAMPLES
1533
1533
  $ internxt workspaces-list
1534
1534
  ```
1535
1535
 
1536
- _See code: [src/commands/workspaces-list.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/workspaces-list.ts)_
1536
+ _See code: [src/commands/workspaces-list.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/workspaces-list.ts)_
1537
1537
 
1538
1538
  ## `internxt workspaces-unset`
1539
1539
 
@@ -1563,7 +1563,7 @@ EXAMPLES
1563
1563
  $ internxt workspaces-unset
1564
1564
  ```
1565
1565
 
1566
- _See code: [src/commands/workspaces-unset.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/workspaces-unset.ts)_
1566
+ _See code: [src/commands/workspaces-unset.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/workspaces-unset.ts)_
1567
1567
 
1568
1568
  ## `internxt workspaces-use`
1569
1569
 
@@ -1599,7 +1599,7 @@ EXAMPLES
1599
1599
  $ internxt workspaces-use
1600
1600
  ```
1601
1601
 
1602
- _See code: [src/commands/workspaces-use.ts](https://github.com/internxt/cli/blob/v1.6.6/src/commands/workspaces-use.ts)_
1602
+ _See code: [src/commands/workspaces-use.ts](https://github.com/internxt/cli/blob/v1.6.7/src/commands/workspaces-use.ts)_
1603
1603
 
1604
1604
  ## `internxt workspaces list`
1605
1605
 
@@ -43,7 +43,8 @@ class List extends core_1.Command {
43
43
  name: folder.plainName,
44
44
  id: folder.uuid,
45
45
  size: '-',
46
- modified: format_utils_1.FormatUtils.formatDate(folder.updatedAt),
46
+ created: format_utils_1.FormatUtils.formatDate(folder.creationTime ?? folder.createdAt),
47
+ modified: format_utils_1.FormatUtils.formatDate(folder.modificationTime ?? folder.updatedAt),
47
48
  };
48
49
  }),
49
50
  ...files.map((file) => {
@@ -52,7 +53,8 @@ class List extends core_1.Command {
52
53
  name: file.type && file.type.length > 0 ? `${file.plainName}.${file.type}` : file.plainName,
53
54
  id: file.uuid,
54
55
  size: format_utils_1.FormatUtils.humanFileSize(Number(file.size)),
55
- modified: format_utils_1.FormatUtils.formatDate(file.updatedAt),
56
+ created: format_utils_1.FormatUtils.formatDate(file.creationTime ?? file.createdAt),
57
+ modified: format_utils_1.FormatUtils.formatDate(file.modificationTime ?? file.updatedAt),
56
58
  };
57
59
  }),
58
60
  ];
@@ -62,7 +64,7 @@ class List extends core_1.Command {
62
64
  { value: 'id', alias: 'Id' },
63
65
  ];
64
66
  if (flags.extended) {
65
- headers.push({ value: 'modified', alias: 'Modified' }, { value: 'size', alias: 'Size' });
67
+ headers.push({ value: 'created', alias: 'Created' }, { value: 'modified', alias: 'Modified' }, { value: 'size', alias: 'Size' });
66
68
  }
67
69
  cli_utils_1.CLIUtils.table(this.log.bind(this), headers, allItems);
68
70
  return { success: true, list: { folders, files } };
@@ -33,7 +33,8 @@ class TrashList extends core_1.Command {
33
33
  name: folder.plainName,
34
34
  id: folder.uuid,
35
35
  size: '-',
36
- modified: format_utils_1.FormatUtils.formatDate(folder.updatedAt),
36
+ created: format_utils_1.FormatUtils.formatDate(folder.creationTime ?? folder.createdAt),
37
+ modified: format_utils_1.FormatUtils.formatDate(folder.modificationTime ?? folder.updatedAt),
37
38
  };
38
39
  }),
39
40
  ...files.map((file) => {
@@ -42,7 +43,8 @@ class TrashList extends core_1.Command {
42
43
  name: file.type && file.type.length > 0 ? `${file.plainName}.${file.type}` : file.plainName,
43
44
  id: file.uuid,
44
45
  size: format_utils_1.FormatUtils.humanFileSize(Number(file.size)),
45
- modified: format_utils_1.FormatUtils.formatDate(file.updatedAt),
46
+ created: format_utils_1.FormatUtils.formatDate(file.creationTime ?? file.createdAt),
47
+ modified: format_utils_1.FormatUtils.formatDate(file.modificationTime ?? file.updatedAt),
46
48
  };
47
49
  }),
48
50
  ];
@@ -52,7 +54,7 @@ class TrashList extends core_1.Command {
52
54
  { value: 'id', alias: 'Id' },
53
55
  ];
54
56
  if (flags.extended) {
55
- headers.push({ value: 'modified', alias: 'Modified' }, { value: 'size', alias: 'Size' });
57
+ headers.push({ value: 'created', alias: 'Created' }, { value: 'modified', alias: 'Modified' }, { value: 'size', alias: 'Size' });
56
58
  }
57
59
  cli_utils_1.CLIUtils.table(this.log.bind(this), headers, allItems);
58
60
  return { success: true, list: { folders, files } };
@@ -5,6 +5,7 @@ const cli_utils_1 = require("../utils/cli.utils");
5
5
  const config_service_1 = require("../services/config.service");
6
6
  const validation_service_1 = require("../services/validation.service");
7
7
  const auth_service_1 = require("../services/auth.service");
8
+ const lib_1 = require("@internxt/lib");
8
9
  class Whoami extends core_1.Command {
9
10
  static args = {};
10
11
  static description = 'Display the current user logged into the Internxt CLI.';
@@ -15,6 +16,7 @@ class Whoami extends core_1.Command {
15
16
  };
16
17
  static enableJsonFlag = true;
17
18
  run = async () => {
19
+ await this.parse(Whoami);
18
20
  const userCredentials = await config_service_1.ConfigService.instance.readUser();
19
21
  if (!userCredentials) {
20
22
  const message = 'You are not logged in.';
@@ -59,10 +61,11 @@ class Whoami extends core_1.Command {
59
61
  if (!(loginCreds?.token && loginCreds?.user?.mnemonic)) {
60
62
  return { valid: false, refreshRequired: false };
61
63
  }
62
- const tokenDetails = validation_service_1.ValidationService.instance.validateTokenAndCheckExpiration(loginCreds.token);
64
+ const tokenStatus = validation_service_1.ValidationService.instance.validateTokenAndCheckExpiration(loginCreds.token);
63
65
  const goodMnemonic = validation_service_1.ValidationService.instance.validateMnemonic(loginCreds.user.mnemonic);
64
- const goodToken = tokenDetails.isValid && !tokenDetails.expiration.expired;
65
- return { valid: goodToken && goodMnemonic, refreshRequired: tokenDetails.expiration.refreshRequired };
66
+ const isRefreshRequired = tokenStatus === lib_1.TokenStatus.REFRESH_REQUIRED;
67
+ const isTokenValid = tokenStatus === lib_1.TokenStatus.VALID || isRefreshRequired;
68
+ return { valid: isTokenValid && goodMnemonic, refreshRequired: isRefreshRequired };
66
69
  };
67
70
  }
68
71
  exports.default = Whoami;
@@ -8,6 +8,7 @@ const config_service_1 = require("./config.service");
8
8
  const command_types_1 = require("../types/command.types");
9
9
  const validation_service_1 = require("./validation.service");
10
10
  const workspace_service_1 = require("./drive/workspace.service");
11
+ const lib_1 = require("@internxt/lib");
11
12
  class AuthService {
12
13
  static instance = new AuthService();
13
14
  doLogin = async (email, password, twoFactorCode) => {
@@ -46,16 +47,16 @@ class AuthService {
46
47
  if (!loginCreds?.token || !loginCreds?.user?.mnemonic) {
47
48
  throw new command_types_1.MissingCredentialsError();
48
49
  }
49
- const tokenDetails = validation_service_1.ValidationService.instance.validateTokenAndCheckExpiration(loginCreds.token);
50
+ const tokenStatus = validation_service_1.ValidationService.instance.validateTokenAndCheckExpiration(loginCreds.token);
50
51
  const isValidMnemonic = validation_service_1.ValidationService.instance.validateMnemonic(loginCreds.user.mnemonic);
51
- if (!tokenDetails.isValid || !isValidMnemonic) {
52
+ if (tokenStatus === lib_1.TokenStatus.INVALID || !isValidMnemonic) {
52
53
  throw new command_types_1.InvalidCredentialsError();
53
54
  }
54
- if (tokenDetails.expiration.expired) {
55
+ if (tokenStatus === lib_1.TokenStatus.EXPIRED) {
55
56
  throw new command_types_1.ExpiredCredentialsError();
56
57
  }
57
58
  let credentialsChanged = false;
58
- if (tokenDetails.expiration.refreshRequired) {
59
+ if (tokenStatus === lib_1.TokenStatus.REFRESH_REQUIRED) {
59
60
  try {
60
61
  loginCreds = await this.refreshUserToken(loginCreds.token, loginCreds.user.mnemonic, loginCreds.user.keys.ecc.privateKey);
61
62
  credentialsChanged = true;
@@ -108,14 +109,17 @@ class AuthService {
108
109
  if (loginCreds.workspace?.workspaceCredentials && loginCreds.workspace?.workspaceData) {
109
110
  const workspaceToken = loginCreds.workspace.workspaceCredentials.token;
110
111
  const workspaceUuid = loginCreds.workspace.workspaceCredentials.id;
111
- const workspaceTokenDetails = validation_service_1.ValidationService.instance.validateTokenAndCheckExpiration(workspaceToken);
112
- if (!workspaceTokenDetails.isValid) {
112
+ const workspaceTokenStatus = validation_service_1.ValidationService.instance.validateTokenAndCheckExpiration(workspaceToken);
113
+ if (workspaceTokenStatus === lib_1.TokenStatus.VALID) {
114
+ return loginCreds.workspace;
115
+ }
116
+ else if (workspaceTokenStatus === lib_1.TokenStatus.INVALID) {
113
117
  throw new command_types_1.InvalidCredentialsError();
114
118
  }
115
- if (workspaceTokenDetails.expiration.expired) {
119
+ else if (workspaceTokenStatus === lib_1.TokenStatus.EXPIRED) {
116
120
  throw new command_types_1.ExpiredCredentialsError();
117
121
  }
118
- if (workspaceTokenDetails.expiration.refreshRequired) {
122
+ else if (workspaceTokenStatus === lib_1.TokenStatus.REFRESH_REQUIRED) {
119
123
  sdk_manager_service_1.SdkManager.init({ token: loginCreds.token, workspaceToken: loginCreds.workspace.workspaceCredentials.token });
120
124
  const workspaceCredentials = await workspace_service_1.WorkspaceService.instance.getWorkspaceCredentials(workspaceUuid);
121
125
  return {
@@ -123,9 +127,6 @@ class AuthService {
123
127
  workspaceData: loginCreds.workspace.workspaceData,
124
128
  };
125
129
  }
126
- else {
127
- return loginCreds.workspace;
128
- }
129
130
  }
130
131
  };
131
132
  getCurrentWorkspace = async () => {
@@ -1,3 +1,4 @@
1
+ import { TokenStatus } from '@internxt/lib';
1
2
  export declare class ValidationService {
2
3
  static readonly instance: ValidationService;
3
4
  validateEmail: (email: string) => boolean;
@@ -9,16 +10,5 @@ export declare class ValidationService {
9
10
  validateStringIsNotEmpty: (str: string) => boolean;
10
11
  validateDirectoryExists: (path: string) => Promise<boolean>;
11
12
  validateFileExists: (path: string) => Promise<boolean>;
12
- validateJwtAndCheckExpiration: (token?: string) => number | null;
13
- checkTokenExpiration: (expirationTimestamp: number) => {
14
- expired: boolean;
15
- refreshRequired: boolean;
16
- };
17
- validateTokenAndCheckExpiration: (token?: string) => {
18
- isValid: boolean;
19
- expiration: {
20
- expired: boolean;
21
- refreshRequired: boolean;
22
- };
23
- };
13
+ validateTokenAndCheckExpiration: (token: string) => TokenStatus;
24
14
  }
@@ -48,33 +48,8 @@ class ValidationService {
48
48
  return false;
49
49
  }
50
50
  };
51
- validateJwtAndCheckExpiration = (token) => {
52
- if (!token || typeof token !== 'string' || token.split('.').length !== 3) {
53
- return null;
54
- }
55
- try {
56
- const payload = JSON.parse(atob(token.split('.')[1]));
57
- return typeof payload.exp === 'number' ? payload.exp : null;
58
- }
59
- catch {
60
- return null;
61
- }
62
- };
63
- checkTokenExpiration = (expirationTimestamp) => {
64
- const TWO_DAYS_IN_SECONDS = 2 * 24 * 60 * 60;
65
- const currentTime = Math.floor(Date.now() / 1000);
66
- const remainingSeconds = expirationTimestamp - currentTime;
67
- return {
68
- expired: remainingSeconds <= 0,
69
- refreshRequired: remainingSeconds > 0 && remainingSeconds <= TWO_DAYS_IN_SECONDS,
70
- };
71
- };
72
51
  validateTokenAndCheckExpiration = (token) => {
73
- const expiration = this.validateJwtAndCheckExpiration(token);
74
- return {
75
- isValid: expiration !== null,
76
- expiration: expiration ? this.checkTokenExpiration(expiration) : { expired: true, refreshRequired: false },
77
- };
52
+ return lib_1.auth.validateTokenAndCheckExpiration(token);
78
53
  };
79
54
  }
80
55
  exports.ValidationService = ValidationService;
@@ -114,6 +114,7 @@ export interface PaginatedItem {
114
114
  type: string;
115
115
  id: string;
116
116
  size: string;
117
+ created: string;
117
118
  modified: string;
118
119
  }
119
120
  export interface PromptOptions {
@@ -1,6 +1,7 @@
1
1
  import { FileMeta, FolderMeta, CreateFolderResponse } from '@internxt/sdk/dist/drive/storage/types';
2
2
  import { DriveFileItem, DriveFolderItem } from '../types/drive.types';
3
3
  export declare class DriveUtils {
4
+ static parseFileSize(size: string | number): number;
4
5
  static driveFileMetaToItem(fileMeta: FileMeta): DriveFileItem;
5
6
  static driveFolderMetaToItem(folderMeta: FolderMeta): DriveFolderItem;
6
7
  static createFolderResponseToItem(folderResponse: CreateFolderResponse): DriveFolderItem;
@@ -3,13 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DriveUtils = void 0;
4
4
  const types_1 = require("@internxt/sdk/dist/drive/storage/types");
5
5
  class DriveUtils {
6
+ static parseFileSize(size) {
7
+ const parsed = Number(size);
8
+ return Number.isFinite(parsed) ? parsed : 0;
9
+ }
6
10
  static driveFileMetaToItem(fileMeta) {
7
11
  return {
8
12
  itemType: 'file',
9
13
  uuid: fileMeta.uuid ?? '',
10
14
  status: fileMeta.status,
11
15
  folderUuid: fileMeta.folderUuid,
12
- size: Number(fileMeta.size),
16
+ size: DriveUtils.parseFileSize(fileMeta.size),
13
17
  name: fileMeta.plainName ?? fileMeta.name,
14
18
  bucket: fileMeta.bucket,
15
19
  createdAt: new Date(fileMeta.createdAt),
@@ -15,10 +15,14 @@ class FormatUtils {
15
15
  return Number((size / Math.pow(1024, unitIndex)).toFixed(2)) + ' ' + units[unitIndex];
16
16
  };
17
17
  static formatDate = (date) => {
18
- return (0, dayjs_1.default)(date).format('D MMMM, YYYY [at] HH:mm');
18
+ const d = (0, dayjs_1.default)(date);
19
+ return d.isValid() ? d.format('D MMMM, YYYY [at] HH:mm') : '-';
19
20
  };
20
21
  static formatDateForWebDav = (date) => {
21
- return dayjs_1.default.utc(date).format('ddd, DD MMM YYYY HH:mm:ss [GMT]');
22
+ const d = dayjs_1.default.utc(date);
23
+ return d.isValid()
24
+ ? d.format('ddd, DD MMM YYYY HH:mm:ss [GMT]')
25
+ : dayjs_1.default.utc().format('ddd, DD MMM YYYY HH:mm:ss [GMT]');
22
26
  };
23
27
  static formatLimit = (limit) => {
24
28
  let result = '...';
@@ -100,10 +100,10 @@ class NetworkUtils {
100
100
  }
101
101
  }
102
102
  else if (parsed === -1) {
103
- throw new Error(`Malformed Range-Request. ${JSON.stringify(rangeOptions)}`);
103
+ throw new Error(`Unsatisfiable Range-Request. ${JSON.stringify(rangeOptions)}`);
104
104
  }
105
105
  else if (parsed === -2) {
106
- throw new Error(`Unsatisfiable Range-Request. ${JSON.stringify(rangeOptions)}`);
106
+ throw new Error(`Malformed Range-Request. ${JSON.stringify(rangeOptions)}`);
107
107
  }
108
108
  else {
109
109
  throw new Error(`Unknown error from Range-Request. ${JSON.stringify(rangeOptions)}`);
@@ -20,6 +20,7 @@ class GETRequestHandler {
20
20
  const { user } = await auth_service_1.AuthService.instance.getAuthDetails();
21
21
  logger_utils_1.webdavLogger.info(`[GET] [${driveFile.uuid}] Network ready for download`);
22
22
  res.header('Content-Type', 'application/octet-stream');
23
+ res.header('Accept-Ranges', 'bytes');
23
24
  const fileSize = driveFile.size ?? 0;
24
25
  if (fileSize > 0) {
25
26
  const range = req.headers['range'];
@@ -26,6 +26,7 @@ class HEADRequestHandler {
26
26
  contentLength = rangeOptions.rangeSize;
27
27
  }
28
28
  res.header('Content-Type', 'application/octet-stream');
29
+ res.header('Accept-Ranges', 'bytes');
29
30
  res.header('Content-length', contentLength.toString());
30
31
  }
31
32
  res.status(200).send();
@@ -7,6 +7,7 @@ const logger_utils_1 = require("../../utils/logger.utils");
7
7
  const xml_utils_1 = require("../../utils/xml.utils");
8
8
  const webdav_folder_service_1 = require("../../services/webdav/webdav-folder.service");
9
9
  const async_utils_1 = require("../../utils/async.utils");
10
+ const errors_utils_1 = require("../../utils/errors.utils");
10
11
  class MKCOLRequestHandler {
11
12
  handle = async (req, res) => {
12
13
  const resource = await webdav_utils_1.WebDavUtils.getRequestedResource(req.url);
@@ -16,9 +17,8 @@ class MKCOLRequestHandler {
16
17
  const driveFolderItem = await webdav_utils_1.WebDavUtils.getDriveFolderFromResource(resource.url);
17
18
  const folderAlreadyExists = !!driveFolderItem;
18
19
  if (folderAlreadyExists) {
19
- logger_utils_1.webdavLogger.info(`[MKCOL] Folder '${resource.url}' already exists, ignoring the creation request`);
20
- res.status(200).send(xml_utils_1.XMLUtils.toWebDavXML({}, {}));
21
- return;
20
+ logger_utils_1.webdavLogger.info(`[MKCOL] Folder '${resource.url}' already exists, throwing 405 error`);
21
+ throw new errors_utils_1.MethodNotAllowed('Folder already exists');
22
22
  }
23
23
  const newFolder = await webdav_folder_service_1.WebDavFolderService.instance.createFolder({
24
24
  folderName: resource.path.base,
@@ -8,6 +8,7 @@ const xml_utils_1 = require("../../utils/xml.utils");
8
8
  const drive_item_domain_1 = require("../../services/database/drive-item/drive-item.domain");
9
9
  const drive_item_repository_1 = require("../../services/database/drive-item/drive-item.repository");
10
10
  const drive_folder_service_1 = require("../../services/drive/drive-folder.service");
11
+ const drive_utils_1 = require("../../utils/drive.utils");
11
12
  const format_utils_1 = require("../../utils/format.utils");
12
13
  const node_crypto_1 = require("node:crypto");
13
14
  const mime_types_1 = __importDefault(require("mime-types"));
@@ -23,6 +24,7 @@ class PROPFINDRequestHandler {
23
24
  res.status(404).send();
24
25
  return;
25
26
  }
27
+ res.set('Content-Type', 'application/xml; charset="utf-8"');
26
28
  switch (driveItem.itemType) {
27
29
  case 'file': {
28
30
  const fileMetaXML = await this.getFileMetaXML(resource, driveItem);
@@ -113,7 +115,7 @@ class PROPFINDRequestHandler {
113
115
  type: file.type,
114
116
  status: file.status,
115
117
  folderUuid: file.folderUuid,
116
- size: Number(file.size),
118
+ size: drive_utils_1.DriveUtils.parseFileSize(file.size),
117
119
  creationTime: new Date(file.creationTime),
118
120
  modificationTime: new Date(file.modificationTime),
119
121
  createdAt: new Date(file.createdAt),
@@ -140,7 +142,8 @@ class PROPFINDRequestHandler {
140
142
  [xml_utils_1.XMLUtils.addDefaultNamespace('propstat')]: {
141
143
  [xml_utils_1.XMLUtils.addDefaultNamespace('status')]: 'HTTP/1.1 200 OK',
142
144
  [xml_utils_1.XMLUtils.addDefaultNamespace('prop')]: {
143
- [xml_utils_1.XMLUtils.addDefaultNamespace('getcontenttype')]: 'application/octet-stream',
145
+ [xml_utils_1.XMLUtils.addDefaultNamespace('getcontenttype')]: 'httpd/unix-directory',
146
+ [xml_utils_1.XMLUtils.addDefaultNamespace('getetag')]: '"' + (0, node_crypto_1.randomUUID)().replaceAll('-', '') + '"',
144
147
  'x1:lastmodified': {
145
148
  '#text': format_utils_1.FormatUtils.formatDateForWebDav(driveFolderItem.updatedAt),
146
149
  '@_xmlns:x1': 'SAR:',
@@ -173,6 +176,8 @@ class PROPFINDRequestHandler {
173
176
  [xml_utils_1.XMLUtils.addDefaultNamespace('displayname')]: displayName,
174
177
  [xml_utils_1.XMLUtils.addDefaultNamespace('getlastmodified')]: format_utils_1.FormatUtils.formatDateForWebDav(driveFolderItem.updatedAt),
175
178
  [xml_utils_1.XMLUtils.addDefaultNamespace('getcontentlength')]: 0,
179
+ [xml_utils_1.XMLUtils.addDefaultNamespace('getcontenttype')]: 'httpd/unix-directory',
180
+ [xml_utils_1.XMLUtils.addDefaultNamespace('getetag')]: '"' + (0, node_crypto_1.randomUUID)().replaceAll('-', '') + '"',
176
181
  [xml_utils_1.XMLUtils.addDefaultNamespace('resourcetype')]: {
177
182
  [xml_utils_1.XMLUtils.addDefaultNamespace('collection')]: '',
178
183
  },
@@ -35,6 +35,7 @@ const AuthMiddleware = () => {
35
35
  const errorBodyXML = xml_utils_1.XMLUtils.toWebDavXML({
36
36
  [xml_utils_1.XMLUtils.addDefaultNamespace('responsedescription')]: message,
37
37
  }, {}, 'error');
38
+ res.set('WWW-Authenticate', 'Basic realm="Internxt WebDAV"');
38
39
  res.status(401).send(errorBodyXML);
39
40
  }
40
41
  })();
@@ -37,5 +37,6 @@ const sendUnauthorizedError = (res, message) => {
37
37
  const errorBodyXML = xml_utils_1.XMLUtils.toWebDavXML({
38
38
  [xml_utils_1.XMLUtils.addDefaultNamespace('responsedescription')]: message,
39
39
  }, {}, 'error');
40
+ res.set('WWW-Authenticate', 'Basic realm="Internxt WebDAV"');
40
41
  res.status(401).send(errorBodyXML);
41
42
  };
@@ -35,11 +35,11 @@ class WebDavServer {
35
35
  this.app = app;
36
36
  }
37
37
  registerStartMiddlewares = (configs) => {
38
- this.app.use((0, webdav_auth_middleware_1.WebDAVAuthMiddleware)(configs));
39
- this.app.use((0, auth_middleware_1.AuthMiddleware)());
40
38
  this.app.use((0, request_logger_middleware_1.RequestLoggerMiddleware)({
41
39
  enable: true,
42
40
  }));
41
+ this.app.use((0, webdav_auth_middleware_1.WebDAVAuthMiddleware)(configs));
42
+ this.app.use((0, auth_middleware_1.AuthMiddleware)());
43
43
  this.app.use(body_parser_1.default.text({ type: ['application/xml', 'text/xml'] }));
44
44
  this.app.use(mkcol_middleware_1.MkcolMiddleware);
45
45
  };
@@ -1972,5 +1972,5 @@
1972
1972
  ]
1973
1973
  }
1974
1974
  },
1975
- "version": "1.6.6"
1975
+ "version": "1.6.7"
1976
1976
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "author": "Internxt <hello@internxt.com>",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
4
4
  "description": "Internxt CLI to manage your encrypted storage",
5
5
  "scripts": {
6
6
  "build": "npm run clean && tsc",
@@ -39,11 +39,11 @@
39
39
  "@dashlane/pqc-kem-kyber512-node": "1.0.0",
40
40
  "@inquirer/prompts": "8.5.2",
41
41
  "@internxt/inxt-js": "3.3.1",
42
- "@internxt/lib": "1.4.2",
43
- "@internxt/sdk": "1.17.9",
44
- "@oclif/core": "4.11.10",
45
- "@oclif/plugin-autocomplete": "3.2.52",
46
- "axios": "1.18.0",
42
+ "@internxt/lib": "1.5.1",
43
+ "@internxt/sdk": "1.17.13",
44
+ "@oclif/core": "4.11.14",
45
+ "@oclif/plugin-autocomplete": "3.2.53",
46
+ "axios": "1.18.1",
47
47
  "better-sqlite3": "12.11.1",
48
48
  "bip39": "3.1.0",
49
49
  "body-parser": "2.3.0",
@@ -52,15 +52,15 @@
52
52
  "dotenv": "17.4.2",
53
53
  "express": "5.2.1",
54
54
  "express-async-handler": "1.2.0",
55
- "fast-xml-builder": "1.2.0",
55
+ "fast-xml-builder": "1.2.1",
56
56
  "fast-xml-parser": "5.9.3",
57
57
  "hash-wasm": "4.12.0",
58
58
  "mime-types": "3.0.2",
59
59
  "open": "11.0.0",
60
60
  "openpgp": "6.3.1",
61
61
  "otpauth": "9.5.1",
62
- "pm2": "7.0.1",
63
- "range-parser": "1.2.1",
62
+ "pm2": "7.0.3",
63
+ "range-parser": "1.3.0",
64
64
  "selfsigned": "5.5.0",
65
65
  "tty-table": "5.0.0",
66
66
  "typeorm": "1.0.0",
@@ -73,21 +73,21 @@
73
73
  "@types/cli-progress": "^3.11.6",
74
74
  "@types/express": "^5.0.6",
75
75
  "@types/mime-types": "^3.0.1",
76
- "@types/node": "^26.0.0",
76
+ "@types/node": "^26.1.1",
77
77
  "@types/range-parser": "^1.2.7",
78
- "@vitest/coverage-istanbul": "^4.1.9",
79
- "@vitest/spy": "^4.1.9",
80
- "eslint": "^10.5.0",
78
+ "@vitest/coverage-istanbul": "^4.1.10",
79
+ "@vitest/spy": "^4.1.10",
80
+ "eslint": "^10.6.0",
81
81
  "husky": "^9.1.7",
82
82
  "lint-staged": "^17.0.8",
83
83
  "nodemon": "^3.1.14",
84
- "oclif": "^4.23.19",
85
- "prettier": "^3.8.4",
84
+ "oclif": "^4.23.27",
85
+ "prettier": "^3.9.4",
86
86
  "rimraf": "^6.1.3",
87
87
  "sql.js": "^1.14.1",
88
88
  "ts-node": "^10.9.2",
89
89
  "typescript": "^6.0.3",
90
- "vitest": "^4.1.9",
90
+ "vitest": "^4.1.10",
91
91
  "vitest-mock-express": "^2.2.0"
92
92
  },
93
93
  "optionalDependencies": {