@internxt/cli 1.5.2 → 1.5.4
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/.env +2 -6
- package/README.md +46 -26
- package/bin/dev.js +1 -1
- package/bin/run.js +1 -1
- package/dist/commands/add-cert.d.ts +1 -1
- package/dist/commands/add-cert.js +23 -23
- package/dist/commands/config.js +8 -3
- package/dist/commands/create-folder.js +11 -6
- package/dist/commands/delete-permanently-file.js +9 -4
- package/dist/commands/delete-permanently-folder.js +9 -4
- package/dist/commands/download-file.js +21 -16
- package/dist/commands/list.js +8 -3
- package/dist/commands/login.js +8 -3
- package/dist/commands/logout.js +10 -3
- package/dist/commands/logs.js +8 -3
- package/dist/commands/move-file.js +8 -3
- package/dist/commands/move-folder.js +8 -3
- package/dist/commands/rename-file.js +8 -3
- package/dist/commands/rename-folder.js +8 -3
- package/dist/commands/trash-clear.js +8 -3
- package/dist/commands/trash-file.js +8 -3
- package/dist/commands/trash-folder.js +8 -3
- package/dist/commands/trash-list.js +8 -3
- package/dist/commands/trash-restore-file.js +8 -3
- package/dist/commands/trash-restore-folder.js +8 -3
- package/dist/commands/upload-file.js +17 -11
- package/dist/commands/webdav-config.js +8 -3
- package/dist/commands/webdav.js +22 -22
- package/dist/commands/whoami.js +8 -3
- package/dist/hooks/prerun/auth_check.js +13 -7
- package/dist/services/auth.service.d.ts +1 -0
- package/dist/services/auth.service.js +13 -1
- package/dist/services/crypto.service.d.ts +1 -1
- package/dist/services/crypto.service.js +2 -2
- package/dist/services/drive/drive-file.service.d.ts +1 -1
- package/dist/services/drive/drive-file.service.js +7 -7
- package/dist/services/drive/drive-folder.service.js +7 -7
- package/dist/services/drive/trash.service.d.ts +6 -4
- package/dist/services/drive/trash.service.js +6 -6
- package/dist/services/sdk-manager.service.d.ts +3 -5
- package/dist/services/sdk-manager.service.js +14 -34
- package/dist/services/thumbnail.service.d.ts +2 -2
- package/dist/services/thumbnail.service.js +6 -6
- package/dist/services/usage.service.d.ts +2 -2
- package/dist/services/usage.service.js +2 -2
- package/dist/types/config.types.d.ts +1 -4
- package/dist/utils/cli.utils.d.ts +13 -4
- package/dist/utils/cli.utils.js +44 -10
- package/dist/utils/pm2.utils.d.ts +1 -1
- package/dist/utils/thumbnail.utils.js +3 -3
- package/dist/utils/webdav.utils.d.ts +2 -3
- package/dist/utils/webdav.utils.js +6 -18
- package/dist/utils/xml.utils.d.ts +1 -1
- package/dist/utils/xml.utils.js +3 -3
- package/dist/webdav/handlers/DELETE.handler.js +5 -1
- package/dist/webdav/handlers/GET.handler.js +6 -2
- package/dist/webdav/handlers/HEAD.handler.js +7 -2
- package/dist/webdav/handlers/MKCOL.handler.js +10 -8
- package/dist/webdav/handlers/MOVE.handler.js +10 -3
- package/dist/webdav/handlers/OPTIONS.handler.js +2 -5
- package/dist/webdav/handlers/PROPFIND.handler.js +31 -21
- package/dist/webdav/handlers/PUT.handler.js +8 -4
- package/dist/webdav/index.js +1 -1
- package/dist/webdav/middewares/auth.middleware.js +10 -2
- package/dist/webdav/middewares/errors.middleware.js +8 -13
- package/dist/webdav/webdav-server.d.ts +2 -1
- package/dist/webdav/webdav-server.js +6 -3
- package/oclif.manifest.json +1 -1
- package/package.json +29 -28
- package/scripts/restart-webdav.js +2 -1
package/dist/commands/logout.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const config_service_1 = require("../services/config.service");
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
|
-
const
|
|
6
|
+
const auth_service_1 = require("../services/auth.service");
|
|
7
7
|
class Logout extends core_1.Command {
|
|
8
8
|
static args = {};
|
|
9
9
|
static description = 'Logs out the current internxt user that is logged into the Internxt CLI.';
|
|
@@ -14,6 +14,7 @@ class Logout extends core_1.Command {
|
|
|
14
14
|
run = async () => {
|
|
15
15
|
const user = await config_service_1.ConfigService.instance.readUser();
|
|
16
16
|
if (user) {
|
|
17
|
+
await auth_service_1.AuthService.instance.logout();
|
|
17
18
|
await config_service_1.ConfigService.instance.clearUser();
|
|
18
19
|
const message = 'User logged out successfully.';
|
|
19
20
|
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
@@ -26,8 +27,14 @@ class Logout extends core_1.Command {
|
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
29
|
catch = async (error) => {
|
|
29
|
-
|
|
30
|
-
cli_utils_1.CLIUtils.
|
|
30
|
+
const { flags } = await this.parse(Logout);
|
|
31
|
+
cli_utils_1.CLIUtils.catchError({
|
|
32
|
+
error,
|
|
33
|
+
command: this.id,
|
|
34
|
+
logReporter: this.log.bind(this),
|
|
35
|
+
errorReporter: this.error.bind(this),
|
|
36
|
+
jsonFlag: flags['json'],
|
|
37
|
+
});
|
|
31
38
|
this.exit(1);
|
|
32
39
|
};
|
|
33
40
|
}
|
package/dist/commands/logs.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const config_service_1 = require("../services/config.service");
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
7
6
|
class Logs extends core_1.Command {
|
|
8
7
|
static args = {};
|
|
9
8
|
static description = 'Displays the Internxt CLI logs directory path';
|
|
@@ -17,8 +16,14 @@ class Logs extends core_1.Command {
|
|
|
17
16
|
return { success: true, message, path: config_service_1.ConfigService.INTERNXT_CLI_LOGS_DIR };
|
|
18
17
|
};
|
|
19
18
|
catch = async (error) => {
|
|
20
|
-
|
|
21
|
-
cli_utils_1.CLIUtils.
|
|
19
|
+
const { flags } = await this.parse(Logs);
|
|
20
|
+
cli_utils_1.CLIUtils.catchError({
|
|
21
|
+
error,
|
|
22
|
+
command: this.id,
|
|
23
|
+
logReporter: this.log.bind(this),
|
|
24
|
+
errorReporter: this.error.bind(this),
|
|
25
|
+
jsonFlag: flags['json'],
|
|
26
|
+
});
|
|
22
27
|
this.exit(1);
|
|
23
28
|
};
|
|
24
29
|
}
|
|
@@ -6,7 +6,6 @@ const cli_utils_1 = require("../utils/cli.utils");
|
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const validation_service_1 = require("../services/validation.service");
|
|
8
8
|
const drive_file_service_1 = require("../services/drive/drive-file.service");
|
|
9
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
10
9
|
class MoveFile extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
12
11
|
static description = 'Move a file into a destination folder.';
|
|
@@ -44,8 +43,14 @@ class MoveFile extends core_1.Command {
|
|
|
44
43
|
return { success: true, message, file: newFile };
|
|
45
44
|
};
|
|
46
45
|
catch = async (error) => {
|
|
47
|
-
|
|
48
|
-
cli_utils_1.CLIUtils.
|
|
46
|
+
const { flags } = await this.parse(MoveFile);
|
|
47
|
+
cli_utils_1.CLIUtils.catchError({
|
|
48
|
+
error,
|
|
49
|
+
command: this.id,
|
|
50
|
+
logReporter: this.log.bind(this),
|
|
51
|
+
errorReporter: this.error.bind(this),
|
|
52
|
+
jsonFlag: flags['json'],
|
|
53
|
+
});
|
|
49
54
|
this.exit(1);
|
|
50
55
|
};
|
|
51
56
|
getFileUuid = async (fileUuidFlag, nonInteractive) => {
|
|
@@ -6,7 +6,6 @@ const drive_folder_service_1 = require("../services/drive/drive-folder.service")
|
|
|
6
6
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
7
7
|
const command_types_1 = require("../types/command.types");
|
|
8
8
|
const validation_service_1 = require("../services/validation.service");
|
|
9
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
10
9
|
class MoveFolder extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
12
11
|
static description = 'Move a folder into a destination folder.';
|
|
@@ -44,8 +43,14 @@ class MoveFolder extends core_1.Command {
|
|
|
44
43
|
return { success: true, message, folder: newFolder };
|
|
45
44
|
};
|
|
46
45
|
catch = async (error) => {
|
|
47
|
-
|
|
48
|
-
cli_utils_1.CLIUtils.
|
|
46
|
+
const { flags } = await this.parse(MoveFolder);
|
|
47
|
+
cli_utils_1.CLIUtils.catchError({
|
|
48
|
+
error,
|
|
49
|
+
command: this.id,
|
|
50
|
+
logReporter: this.log.bind(this),
|
|
51
|
+
errorReporter: this.error.bind(this),
|
|
52
|
+
jsonFlag: flags['json'],
|
|
53
|
+
});
|
|
49
54
|
this.exit(1);
|
|
50
55
|
};
|
|
51
56
|
getFolderUuid = async (folderUuidFlag, nonInteractive) => {
|
|
@@ -6,7 +6,6 @@ const cli_utils_1 = require("../utils/cli.utils");
|
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const validation_service_1 = require("../services/validation.service");
|
|
8
8
|
const drive_file_service_1 = require("../services/drive/drive-file.service");
|
|
9
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
10
9
|
class RenameFile extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
12
11
|
static description = 'Rename a file.';
|
|
@@ -40,8 +39,14 @@ class RenameFile extends core_1.Command {
|
|
|
40
39
|
return { success: true, message, file: { uuid: fileUuid, plainName: newName } };
|
|
41
40
|
};
|
|
42
41
|
catch = async (error) => {
|
|
43
|
-
|
|
44
|
-
cli_utils_1.CLIUtils.
|
|
42
|
+
const { flags } = await this.parse(RenameFile);
|
|
43
|
+
cli_utils_1.CLIUtils.catchError({
|
|
44
|
+
error,
|
|
45
|
+
command: this.id,
|
|
46
|
+
logReporter: this.log.bind(this),
|
|
47
|
+
errorReporter: this.error.bind(this),
|
|
48
|
+
jsonFlag: flags['json'],
|
|
49
|
+
});
|
|
45
50
|
this.exit(1);
|
|
46
51
|
};
|
|
47
52
|
getFileUuid = async (fileUuidFlag, nonInteractive) => {
|
|
@@ -6,7 +6,6 @@ const cli_utils_1 = require("../utils/cli.utils");
|
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const validation_service_1 = require("../services/validation.service");
|
|
8
8
|
const drive_folder_service_1 = require("../services/drive/drive-folder.service");
|
|
9
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
10
9
|
class RenameFolder extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
12
11
|
static description = 'Rename a folder.';
|
|
@@ -40,8 +39,14 @@ class RenameFolder extends core_1.Command {
|
|
|
40
39
|
return { success: true, message, folder: { uuid: folderUuid, plainName: name } };
|
|
41
40
|
};
|
|
42
41
|
catch = async (error) => {
|
|
43
|
-
|
|
44
|
-
cli_utils_1.CLIUtils.
|
|
42
|
+
const { flags } = await this.parse(RenameFolder);
|
|
43
|
+
cli_utils_1.CLIUtils.catchError({
|
|
44
|
+
error,
|
|
45
|
+
command: this.id,
|
|
46
|
+
logReporter: this.log.bind(this),
|
|
47
|
+
errorReporter: this.error.bind(this),
|
|
48
|
+
jsonFlag: flags['json'],
|
|
49
|
+
});
|
|
45
50
|
this.exit(1);
|
|
46
51
|
};
|
|
47
52
|
getFolderUuid = async (folderUuidFlag, nonInteractive) => {
|
|
@@ -4,7 +4,6 @@ const core_1 = require("@oclif/core");
|
|
|
4
4
|
const config_service_1 = require("../services/config.service");
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
8
7
|
const trash_service_1 = require("../services/drive/trash.service");
|
|
9
8
|
const inquirer_utils_1 = require("../utils/inquirer.utils");
|
|
10
9
|
class TrashClear extends core_1.Command {
|
|
@@ -45,8 +44,14 @@ class TrashClear extends core_1.Command {
|
|
|
45
44
|
return { success: true, message };
|
|
46
45
|
};
|
|
47
46
|
catch = async (error) => {
|
|
48
|
-
|
|
49
|
-
cli_utils_1.CLIUtils.
|
|
47
|
+
const { flags } = await this.parse(TrashClear);
|
|
48
|
+
cli_utils_1.CLIUtils.catchError({
|
|
49
|
+
error,
|
|
50
|
+
command: this.id,
|
|
51
|
+
logReporter: this.log.bind(this),
|
|
52
|
+
errorReporter: this.error.bind(this),
|
|
53
|
+
jsonFlag: flags['json'],
|
|
54
|
+
});
|
|
50
55
|
this.exit(1);
|
|
51
56
|
};
|
|
52
57
|
getConfirmation = async () => {
|
|
@@ -5,7 +5,6 @@ const config_service_1 = require("../services/config.service");
|
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const validation_service_1 = require("../services/validation.service");
|
|
8
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
9
8
|
const trash_service_1 = require("../services/drive/trash.service");
|
|
10
9
|
class TrashFile extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
@@ -34,8 +33,14 @@ class TrashFile extends core_1.Command {
|
|
|
34
33
|
return { success: true, message, file: { uuid } };
|
|
35
34
|
};
|
|
36
35
|
catch = async (error) => {
|
|
37
|
-
|
|
38
|
-
cli_utils_1.CLIUtils.
|
|
36
|
+
const { flags } = await this.parse(TrashFile);
|
|
37
|
+
cli_utils_1.CLIUtils.catchError({
|
|
38
|
+
error,
|
|
39
|
+
command: this.id,
|
|
40
|
+
logReporter: this.log.bind(this),
|
|
41
|
+
errorReporter: this.error.bind(this),
|
|
42
|
+
jsonFlag: flags['json'],
|
|
43
|
+
});
|
|
39
44
|
this.exit(1);
|
|
40
45
|
};
|
|
41
46
|
getFileUuid = async (fileUuidFlag, nonInteractive) => {
|
|
@@ -5,7 +5,6 @@ const config_service_1 = require("../services/config.service");
|
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const validation_service_1 = require("../services/validation.service");
|
|
8
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
9
8
|
const trash_service_1 = require("../services/drive/trash.service");
|
|
10
9
|
class TrashFolder extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
@@ -34,8 +33,14 @@ class TrashFolder extends core_1.Command {
|
|
|
34
33
|
return { success: true, message, folder: { uuid } };
|
|
35
34
|
};
|
|
36
35
|
catch = async (error) => {
|
|
37
|
-
|
|
38
|
-
cli_utils_1.CLIUtils.
|
|
36
|
+
const { flags } = await this.parse(TrashFolder);
|
|
37
|
+
cli_utils_1.CLIUtils.catchError({
|
|
38
|
+
error,
|
|
39
|
+
command: this.id,
|
|
40
|
+
logReporter: this.log.bind(this),
|
|
41
|
+
errorReporter: this.error.bind(this),
|
|
42
|
+
jsonFlag: flags['json'],
|
|
43
|
+
});
|
|
39
44
|
this.exit(1);
|
|
40
45
|
};
|
|
41
46
|
getFolderUuid = async (folderUuidFlag, nonInteractive) => {
|
|
@@ -5,7 +5,6 @@ const config_service_1 = require("../services/config.service");
|
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const format_utils_1 = require("../utils/format.utils");
|
|
8
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
9
8
|
const trash_service_1 = require("../services/drive/trash.service");
|
|
10
9
|
class TrashList extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
@@ -58,8 +57,14 @@ class TrashList extends core_1.Command {
|
|
|
58
57
|
return { success: true, list: { folders, files } };
|
|
59
58
|
};
|
|
60
59
|
catch = async (error) => {
|
|
61
|
-
|
|
62
|
-
cli_utils_1.CLIUtils.
|
|
60
|
+
const { flags } = await this.parse(TrashList);
|
|
61
|
+
cli_utils_1.CLIUtils.catchError({
|
|
62
|
+
error,
|
|
63
|
+
command: this.id,
|
|
64
|
+
logReporter: this.log.bind(this),
|
|
65
|
+
errorReporter: this.error.bind(this),
|
|
66
|
+
jsonFlag: flags['json'],
|
|
67
|
+
});
|
|
63
68
|
this.exit(1);
|
|
64
69
|
};
|
|
65
70
|
}
|
|
@@ -6,7 +6,6 @@ const cli_utils_1 = require("../utils/cli.utils");
|
|
|
6
6
|
const command_types_1 = require("../types/command.types");
|
|
7
7
|
const validation_service_1 = require("../services/validation.service");
|
|
8
8
|
const drive_file_service_1 = require("../services/drive/drive-file.service");
|
|
9
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
10
9
|
class TrashRestoreFile extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
12
11
|
static description = 'Restore a trashed file into a destination folder.';
|
|
@@ -44,8 +43,14 @@ class TrashRestoreFile extends core_1.Command {
|
|
|
44
43
|
return { success: true, message, file };
|
|
45
44
|
};
|
|
46
45
|
catch = async (error) => {
|
|
47
|
-
|
|
48
|
-
cli_utils_1.CLIUtils.
|
|
46
|
+
const { flags } = await this.parse(TrashRestoreFile);
|
|
47
|
+
cli_utils_1.CLIUtils.catchError({
|
|
48
|
+
error,
|
|
49
|
+
command: this.id,
|
|
50
|
+
logReporter: this.log.bind(this),
|
|
51
|
+
errorReporter: this.error.bind(this),
|
|
52
|
+
jsonFlag: flags['json'],
|
|
53
|
+
});
|
|
49
54
|
this.exit(1);
|
|
50
55
|
};
|
|
51
56
|
getFileUuid = async (fileUuidFlag, nonInteractive) => {
|
|
@@ -6,7 +6,6 @@ const drive_folder_service_1 = require("../services/drive/drive-folder.service")
|
|
|
6
6
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
7
7
|
const command_types_1 = require("../types/command.types");
|
|
8
8
|
const validation_service_1 = require("../services/validation.service");
|
|
9
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
10
9
|
class TrashRestoreFolder extends core_1.Command {
|
|
11
10
|
static args = {};
|
|
12
11
|
static description = 'Restore a trashed folder into a destination folder.';
|
|
@@ -44,8 +43,14 @@ class TrashRestoreFolder extends core_1.Command {
|
|
|
44
43
|
return { success: true, message, folder };
|
|
45
44
|
};
|
|
46
45
|
catch = async (error) => {
|
|
47
|
-
|
|
48
|
-
cli_utils_1.CLIUtils.
|
|
46
|
+
const { flags } = await this.parse(TrashRestoreFolder);
|
|
47
|
+
cli_utils_1.CLIUtils.catchError({
|
|
48
|
+
error,
|
|
49
|
+
command: this.id,
|
|
50
|
+
logReporter: this.log.bind(this),
|
|
51
|
+
errorReporter: this.error.bind(this),
|
|
52
|
+
jsonFlag: flags['json'],
|
|
53
|
+
});
|
|
49
54
|
this.exit(1);
|
|
50
55
|
};
|
|
51
56
|
getFolderUuid = async (folderUuidFlag, nonInteractive) => {
|
|
@@ -60,7 +60,7 @@ class UploadFile extends core_1.Command {
|
|
|
60
60
|
if (destinationFolderUuid.trim().length === 0) {
|
|
61
61
|
destinationFolderUuid = userCredentials.user.rootFolderId;
|
|
62
62
|
}
|
|
63
|
-
cli_utils_1.CLIUtils.doing('Preparing Network');
|
|
63
|
+
cli_utils_1.CLIUtils.doing('Preparing Network', flags['json']);
|
|
64
64
|
const { user } = await auth_service_1.AuthService.instance.getAuthDetails();
|
|
65
65
|
const networkModule = sdk_manager_service_1.SdkManager.instance.getNetwork({
|
|
66
66
|
user: user.bridgeUser,
|
|
@@ -73,14 +73,14 @@ class UploadFile extends core_1.Command {
|
|
|
73
73
|
encryptionKey: user.mnemonic,
|
|
74
74
|
});
|
|
75
75
|
const networkFacade = new network_facade_service_1.NetworkFacade(networkModule, environment, download_service_1.DownloadService.instance, crypto_service_1.CryptoService.instance);
|
|
76
|
-
cli_utils_1.CLIUtils.done();
|
|
76
|
+
cli_utils_1.CLIUtils.done(flags['json']);
|
|
77
77
|
const readStream = (0, node_fs_1.createReadStream)(filePath);
|
|
78
78
|
const timer = cli_utils_1.CLIUtils.timer();
|
|
79
79
|
const progressBar = cli_utils_1.CLIUtils.progress({
|
|
80
80
|
format: 'Uploading file [{bar}] {percentage}%',
|
|
81
81
|
linewrap: true,
|
|
82
|
-
});
|
|
83
|
-
progressBar
|
|
82
|
+
}, flags['json']);
|
|
83
|
+
progressBar?.start(100, 0);
|
|
84
84
|
let bufferStream;
|
|
85
85
|
let fileStream = readStream;
|
|
86
86
|
const isThumbnailable = (0, thumbnail_utils_1.isFileThumbnailable)(fileType);
|
|
@@ -89,7 +89,7 @@ class UploadFile extends core_1.Command {
|
|
|
89
89
|
fileStream = readStream.pipe(bufferStream);
|
|
90
90
|
}
|
|
91
91
|
const progressCallback = (progress) => {
|
|
92
|
-
progressBar
|
|
92
|
+
progressBar?.update(progress * 100 * 0.99);
|
|
93
93
|
};
|
|
94
94
|
const fileId = await new Promise((resolve, reject) => {
|
|
95
95
|
const state = networkFacade.uploadFile(fileStream, stats.size, user.bucket, (err, res) => {
|
|
@@ -117,24 +117,30 @@ class UploadFile extends core_1.Command {
|
|
|
117
117
|
if (isThumbnailable && bufferStream) {
|
|
118
118
|
const thumbnailBuffer = bufferStream.getBuffer();
|
|
119
119
|
if (thumbnailBuffer) {
|
|
120
|
-
await thumbnail_service_1.ThumbnailService.instance.uploadThumbnail(thumbnailBuffer, fileType, user.bucket, createdDriveFile.
|
|
120
|
+
await thumbnail_service_1.ThumbnailService.instance.uploadThumbnail(thumbnailBuffer, fileType, user.bucket, createdDriveFile.uuid, networkFacade);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
catch (error) {
|
|
125
125
|
errors_utils_1.ErrorUtils.report(this.error.bind(this), error, { command: this.id });
|
|
126
126
|
}
|
|
127
|
-
progressBar
|
|
128
|
-
progressBar
|
|
127
|
+
progressBar?.update(100);
|
|
128
|
+
progressBar?.stop();
|
|
129
129
|
const uploadTime = timer.stop();
|
|
130
130
|
this.log('\n');
|
|
131
|
-
const message = `File uploaded in ${uploadTime}ms, view it at ${config_service_1.ConfigService.instance.get('
|
|
131
|
+
const message = `File uploaded in ${uploadTime}ms, view it at ${config_service_1.ConfigService.instance.get('DRIVE_WEB_URL')}/file/${createdDriveFile.uuid}`;
|
|
132
132
|
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
133
133
|
return { success: true, message, file: createdDriveFile };
|
|
134
134
|
};
|
|
135
135
|
catch = async (error) => {
|
|
136
|
-
|
|
137
|
-
cli_utils_1.CLIUtils.
|
|
136
|
+
const { flags } = await this.parse(UploadFile);
|
|
137
|
+
cli_utils_1.CLIUtils.catchError({
|
|
138
|
+
error,
|
|
139
|
+
command: this.id,
|
|
140
|
+
logReporter: this.log.bind(this),
|
|
141
|
+
errorReporter: this.error.bind(this),
|
|
142
|
+
jsonFlag: flags['json'],
|
|
143
|
+
});
|
|
138
144
|
this.exit(1);
|
|
139
145
|
};
|
|
140
146
|
getDestinationFolderUuid = async (destinationFolderUuidFlag, nonInteractive) => {
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const config_service_1 = require("../services/config.service");
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
7
6
|
const command_types_1 = require("../types/command.types");
|
|
8
7
|
const validation_service_1 = require("../services/validation.service");
|
|
9
8
|
class WebDAVConfig extends core_1.Command {
|
|
@@ -67,8 +66,14 @@ class WebDAVConfig extends core_1.Command {
|
|
|
67
66
|
return { success: true, message, config: webdavConfig };
|
|
68
67
|
};
|
|
69
68
|
catch = async (error) => {
|
|
70
|
-
|
|
71
|
-
cli_utils_1.CLIUtils.
|
|
69
|
+
const { flags } = await this.parse(WebDAVConfig);
|
|
70
|
+
cli_utils_1.CLIUtils.catchError({
|
|
71
|
+
error,
|
|
72
|
+
command: this.id,
|
|
73
|
+
logReporter: this.log.bind(this),
|
|
74
|
+
errorReporter: this.error.bind(this),
|
|
75
|
+
jsonFlag: flags['json'],
|
|
76
|
+
});
|
|
72
77
|
this.exit(1);
|
|
73
78
|
};
|
|
74
79
|
}
|
package/dist/commands/webdav.js
CHANGED
|
@@ -4,7 +4,6 @@ const core_1 = require("@oclif/core");
|
|
|
4
4
|
const pm2_utils_1 = require("../utils/pm2.utils");
|
|
5
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
6
|
const config_service_1 = require("../services/config.service");
|
|
7
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
8
7
|
const auth_service_1 = require("../services/auth.service");
|
|
9
8
|
class Webdav extends core_1.Command {
|
|
10
9
|
static args = {
|
|
@@ -24,23 +23,23 @@ class Webdav extends core_1.Command {
|
|
|
24
23
|
static flags = {};
|
|
25
24
|
static enableJsonFlag = true;
|
|
26
25
|
run = async () => {
|
|
27
|
-
const { args } = await this.parse(Webdav);
|
|
26
|
+
const { args, flags } = await this.parse(Webdav);
|
|
28
27
|
let message = '';
|
|
29
28
|
let success = true;
|
|
30
29
|
await pm2_utils_1.PM2Utils.connect();
|
|
31
30
|
switch (args.action) {
|
|
32
31
|
case 'enable': {
|
|
33
32
|
await auth_service_1.AuthService.instance.getAuthDetails();
|
|
34
|
-
message = await this.enableWebDav();
|
|
33
|
+
message = await this.enableWebDav(flags['json']);
|
|
35
34
|
break;
|
|
36
35
|
}
|
|
37
36
|
case 'disable': {
|
|
38
|
-
message = await this.disableWebDav();
|
|
37
|
+
message = await this.disableWebDav(flags['json']);
|
|
39
38
|
break;
|
|
40
39
|
}
|
|
41
40
|
case 'restart': {
|
|
42
41
|
await auth_service_1.AuthService.instance.getAuthDetails();
|
|
43
|
-
message = await this.restartWebDav();
|
|
42
|
+
message = await this.restartWebDav(flags['json']);
|
|
44
43
|
break;
|
|
45
44
|
}
|
|
46
45
|
case 'status': {
|
|
@@ -58,20 +57,21 @@ class Webdav extends core_1.Command {
|
|
|
58
57
|
return { success, message, action: args.action };
|
|
59
58
|
};
|
|
60
59
|
catch = async (error) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
const { flags } = await this.parse(Webdav);
|
|
61
|
+
cli_utils_1.CLIUtils.catchError({
|
|
62
|
+
error,
|
|
63
|
+
command: this.id,
|
|
64
|
+
logReporter: this.log.bind(this),
|
|
65
|
+
errorReporter: this.error.bind(this),
|
|
66
|
+
jsonFlag: flags['json'],
|
|
67
|
+
});
|
|
68
68
|
this.exit(1);
|
|
69
69
|
};
|
|
70
|
-
enableWebDav = async () => {
|
|
71
|
-
cli_utils_1.CLIUtils.doing('Starting Internxt WebDav server...');
|
|
70
|
+
enableWebDav = async (jsonFlag) => {
|
|
71
|
+
cli_utils_1.CLIUtils.doing('Starting Internxt WebDav server...', jsonFlag);
|
|
72
72
|
await pm2_utils_1.PM2Utils.killWebDavServer();
|
|
73
73
|
await pm2_utils_1.PM2Utils.startWebDavServer();
|
|
74
|
-
cli_utils_1.CLIUtils.done();
|
|
74
|
+
cli_utils_1.CLIUtils.done(jsonFlag);
|
|
75
75
|
const { status } = await pm2_utils_1.PM2Utils.webdavServerStatus();
|
|
76
76
|
const webdavConfigs = await config_service_1.ConfigService.instance.readWebdavConfig();
|
|
77
77
|
if (status === 'online') {
|
|
@@ -87,27 +87,27 @@ class Webdav extends core_1.Command {
|
|
|
87
87
|
return message;
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
|
-
disableWebDav = async () => {
|
|
91
|
-
cli_utils_1.CLIUtils.doing('Stopping Internxt WebDav server...');
|
|
90
|
+
disableWebDav = async (jsonFlag) => {
|
|
91
|
+
cli_utils_1.CLIUtils.doing('Stopping Internxt WebDav server...', jsonFlag);
|
|
92
92
|
await pm2_utils_1.PM2Utils.killWebDavServer();
|
|
93
|
-
cli_utils_1.CLIUtils.done();
|
|
93
|
+
cli_utils_1.CLIUtils.done(jsonFlag);
|
|
94
94
|
const message = 'Internxt WebDav server stopped successfully';
|
|
95
95
|
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
96
96
|
return message;
|
|
97
97
|
};
|
|
98
|
-
restartWebDav = async () => {
|
|
99
|
-
cli_utils_1.CLIUtils.doing('Restarting Internxt WebDav server...');
|
|
98
|
+
restartWebDav = async (jsonFlag) => {
|
|
99
|
+
cli_utils_1.CLIUtils.doing('Restarting Internxt WebDav server...', jsonFlag);
|
|
100
100
|
const { status } = await pm2_utils_1.PM2Utils.webdavServerStatus();
|
|
101
101
|
if (status === 'online') {
|
|
102
102
|
await pm2_utils_1.PM2Utils.killWebDavServer();
|
|
103
103
|
await pm2_utils_1.PM2Utils.startWebDavServer();
|
|
104
|
-
cli_utils_1.CLIUtils.done();
|
|
104
|
+
cli_utils_1.CLIUtils.done(jsonFlag);
|
|
105
105
|
const message = 'Internxt WebDav server restarted successfully';
|
|
106
106
|
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
107
107
|
return message;
|
|
108
108
|
}
|
|
109
109
|
else {
|
|
110
|
-
cli_utils_1.CLIUtils.done();
|
|
110
|
+
cli_utils_1.CLIUtils.done(jsonFlag);
|
|
111
111
|
const message = 'Internxt WebDav server is not running, it wont be restarted';
|
|
112
112
|
cli_utils_1.CLIUtils.warning(this.log.bind(this), message);
|
|
113
113
|
return message;
|
package/dist/commands/whoami.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
5
|
-
const errors_utils_1 = require("../utils/errors.utils");
|
|
6
5
|
const config_service_1 = require("../services/config.service");
|
|
7
6
|
const validation_service_1 = require("../services/validation.service");
|
|
8
7
|
class Whoami extends core_1.Command {
|
|
@@ -35,8 +34,14 @@ class Whoami extends core_1.Command {
|
|
|
35
34
|
}
|
|
36
35
|
};
|
|
37
36
|
catch = async (error) => {
|
|
38
|
-
|
|
39
|
-
cli_utils_1.CLIUtils.
|
|
37
|
+
const { flags } = await this.parse(Whoami);
|
|
38
|
+
cli_utils_1.CLIUtils.catchError({
|
|
39
|
+
error,
|
|
40
|
+
command: this.id,
|
|
41
|
+
logReporter: this.log.bind(this),
|
|
42
|
+
errorReporter: this.error.bind(this),
|
|
43
|
+
jsonFlag: flags['json'],
|
|
44
|
+
});
|
|
40
45
|
this.exit(1);
|
|
41
46
|
};
|
|
42
47
|
checkUserAndTokens = (loginCreds) => {
|
|
@@ -14,22 +14,28 @@ const webdav_1 = __importDefault(require("../../commands/webdav"));
|
|
|
14
14
|
const webdav_config_1 = __importDefault(require("../../commands/webdav-config"));
|
|
15
15
|
const CommandsToSkip = [whoami_1.default, login_1.default, logout_1.default, logs_1.default, webdav_1.default, webdav_config_1.default];
|
|
16
16
|
const hook = async function (opts) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const { Command, argv } = opts;
|
|
18
|
+
const jsonFlag = argv.includes('--json');
|
|
19
|
+
if (!CommandsToSkip.map((command) => command.name).includes(Command.name)) {
|
|
20
|
+
cli_utils_1.CLIUtils.doing('Checking credentials', jsonFlag);
|
|
19
21
|
try {
|
|
20
22
|
const { token, newToken } = await auth_service_1.AuthService.instance.getAuthDetails();
|
|
21
23
|
sdk_manager_service_1.SdkManager.init({
|
|
22
24
|
token,
|
|
23
25
|
newToken,
|
|
24
26
|
});
|
|
25
|
-
cli_utils_1.CLIUtils.done();
|
|
26
|
-
cli_utils_1.CLIUtils.clearPreviousLine();
|
|
27
|
+
cli_utils_1.CLIUtils.done(jsonFlag);
|
|
28
|
+
cli_utils_1.CLIUtils.clearPreviousLine(jsonFlag);
|
|
27
29
|
}
|
|
28
30
|
catch (error) {
|
|
29
31
|
const err = error;
|
|
30
|
-
cli_utils_1.CLIUtils.
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
cli_utils_1.CLIUtils.catchError({
|
|
33
|
+
error: err,
|
|
34
|
+
command: Command.id,
|
|
35
|
+
logReporter: this.log.bind(this),
|
|
36
|
+
errorReporter: this.error.bind(this),
|
|
37
|
+
jsonFlag,
|
|
38
|
+
});
|
|
33
39
|
opts.context.exit(1);
|
|
34
40
|
}
|
|
35
41
|
}
|
|
@@ -73,7 +73,7 @@ class AuthService {
|
|
|
73
73
|
token: oldCreds.token,
|
|
74
74
|
newToken: oldCreds.newToken,
|
|
75
75
|
});
|
|
76
|
-
const usersClient = sdk_manager_service_1.SdkManager.instance.getUsers(
|
|
76
|
+
const usersClient = sdk_manager_service_1.SdkManager.instance.getUsers();
|
|
77
77
|
const newCreds = await usersClient.getUserData({ userUuid: oldCreds.user.uuid });
|
|
78
78
|
const loginCreds = {
|
|
79
79
|
user: {
|
|
@@ -92,5 +92,17 @@ class AuthService {
|
|
|
92
92
|
});
|
|
93
93
|
return loginCreds;
|
|
94
94
|
};
|
|
95
|
+
logout = async () => {
|
|
96
|
+
try {
|
|
97
|
+
const user = await config_service_1.ConfigService.instance.readUser();
|
|
98
|
+
if (!user || !user.newToken) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const authClient = sdk_manager_service_1.SdkManager.instance.getAuth();
|
|
102
|
+
return authClient.logout(user.newToken);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
}
|
|
106
|
+
};
|
|
95
107
|
}
|
|
96
108
|
exports.AuthService = AuthService;
|
|
@@ -14,5 +14,5 @@ export declare class CryptoService {
|
|
|
14
14
|
encryptTextWithKey: (textToEncrypt: string, secret: string) => string;
|
|
15
15
|
decryptTextWithKey: (encryptedText: string, secret: string) => string;
|
|
16
16
|
decryptStream: (inputSlices: ReadableStream<Uint8Array>[], key: Buffer, iv: Buffer, startOffsetByte?: number) => ReadableStream<any>;
|
|
17
|
-
private getKeyAndIvFrom;
|
|
17
|
+
private readonly getKeyAndIvFrom;
|
|
18
18
|
}
|
|
@@ -8,7 +8,7 @@ const stream_utils_1 = require("../utils/stream.utils");
|
|
|
8
8
|
class CryptoService {
|
|
9
9
|
static instance = new CryptoService();
|
|
10
10
|
static cryptoProvider = {
|
|
11
|
-
|
|
11
|
+
encryptPasswordHash(password, encryptedSalt) {
|
|
12
12
|
const salt = CryptoService.instance.decryptText(encryptedSalt);
|
|
13
13
|
const hashObj = CryptoService.instance.passToHash({ password, salt });
|
|
14
14
|
return CryptoService.instance.encryptText(hashObj.hash);
|
|
@@ -32,7 +32,7 @@ class CryptoService {
|
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
34
|
passToHash = (passObject) => {
|
|
35
|
-
const salt = passObject.salt
|
|
35
|
+
const salt = passObject.salt ?? (0, node_crypto_1.randomBytes)(128 / 8).toString('hex');
|
|
36
36
|
const hash = (0, node_crypto_1.pbkdf2Sync)(passObject.password, Buffer.from(salt, 'hex'), 10000, 256 / 8, 'sha1').toString('hex');
|
|
37
37
|
const hashedObjetc = {
|
|
38
38
|
salt,
|