@internxt/cli 1.5.7 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -100
- package/dist/commands/add-cert.js +0 -1
- package/dist/commands/config.js +0 -1
- package/dist/commands/create-folder.js +0 -1
- package/dist/commands/delete-permanently-file.js +0 -1
- package/dist/commands/delete-permanently-folder.js +0 -1
- package/dist/commands/download-file.js +0 -1
- package/dist/commands/list.js +0 -1
- package/dist/commands/login-legacy.d.ts +24 -0
- package/dist/commands/login-legacy.js +175 -0
- package/dist/commands/login.d.ts +3 -9
- package/dist/commands/login.js +18 -133
- package/dist/commands/logout.js +0 -1
- package/dist/commands/logs.js +0 -1
- package/dist/commands/move-file.js +0 -1
- package/dist/commands/move-folder.js +0 -1
- package/dist/commands/rename-file.js +0 -1
- package/dist/commands/rename-folder.js +0 -1
- package/dist/commands/trash-clear.js +0 -1
- package/dist/commands/trash-file.js +1 -2
- package/dist/commands/trash-folder.js +1 -2
- package/dist/commands/trash-list.js +0 -1
- package/dist/commands/trash-restore-file.js +0 -1
- package/dist/commands/trash-restore-folder.js +0 -1
- package/dist/commands/upload-file.d.ts +2 -1
- package/dist/commands/upload-file.js +1 -2
- package/dist/commands/webdav-config.d.ts +1 -0
- package/dist/commands/webdav-config.js +10 -7
- package/dist/commands/webdav.js +0 -1
- package/dist/commands/whoami.js +1 -2
- package/dist/hooks/prerun/auth_check.js +2 -2
- package/dist/services/auth.service.d.ts +1 -2
- package/dist/services/auth.service.js +11 -26
- package/dist/services/config.service.d.ts +1 -0
- package/dist/services/config.service.js +3 -0
- package/dist/services/crypto.service.js +1 -1
- package/dist/services/database/drive-file/drive-file.domain.js +1 -0
- package/dist/services/database/drive-folder/drive-folder.domain.js +1 -0
- package/dist/services/drive/drive-file.service.js +1 -0
- package/dist/services/universal-link.service.d.ts +10 -0
- package/dist/services/universal-link.service.js +85 -0
- package/dist/types/command.types.d.ts +1 -2
- package/dist/types/drive.types.d.ts +3 -0
- package/dist/types/webdav.types.d.ts +0 -1
- package/dist/utils/cli.utils.d.ts +1 -2
- package/dist/utils/cli.utils.js +2 -2
- package/dist/utils/drive.utils.d.ts +2 -1
- package/dist/utils/drive.utils.js +17 -0
- package/dist/utils/errors.utils.d.ts +2 -1
- package/dist/utils/errors.utils.js +10 -4
- package/dist/utils/webdav.utils.d.ts +20 -6
- package/dist/utils/webdav.utils.js +52 -33
- package/dist/webdav/handlers/DELETE.handler.js +5 -5
- package/dist/webdav/handlers/GET.handler.js +6 -9
- package/dist/webdav/handlers/HEAD.handler.js +5 -10
- package/dist/webdav/handlers/MKCOL.handler.d.ts +2 -0
- package/dist/webdav/handlers/MKCOL.handler.js +10 -20
- package/dist/webdav/handlers/MOVE.handler.d.ts +2 -0
- package/dist/webdav/handlers/MOVE.handler.js +22 -27
- package/dist/webdav/handlers/OPTIONS.handler.js +3 -3
- package/dist/webdav/handlers/PROPFIND.handler.js +7 -31
- package/dist/webdav/handlers/PUT.handler.d.ts +3 -1
- package/dist/webdav/handlers/PUT.handler.js +20 -23
- package/dist/webdav/middewares/auth.middleware.js +8 -2
- package/dist/webdav/middewares/errors.middleware.js +9 -2
- package/dist/webdav/services/webdav-folder.service.d.ts +17 -0
- package/dist/webdav/services/webdav-folder.service.js +52 -0
- package/dist/webdav/webdav-server.js +8 -0
- package/oclif.manifest.json +68 -3
- package/package.json +23 -22
package/dist/commands/list.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class LoginLegacy extends Command {
|
|
3
|
+
static readonly args: {};
|
|
4
|
+
static readonly description: string;
|
|
5
|
+
static readonly aliases: never[];
|
|
6
|
+
static readonly examples: string[];
|
|
7
|
+
static readonly flags: {
|
|
8
|
+
email: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
password: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
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>;
|
|
12
|
+
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
static readonly enableJsonFlag = true;
|
|
15
|
+
run: () => Promise<{
|
|
16
|
+
success: boolean;
|
|
17
|
+
message: string;
|
|
18
|
+
login: import("../types/command.types").LoginCredentials;
|
|
19
|
+
}>;
|
|
20
|
+
catch: (error: Error) => Promise<never>;
|
|
21
|
+
private getEmail;
|
|
22
|
+
private getPassword;
|
|
23
|
+
private getTwoFactorCode;
|
|
24
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
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
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const core_1 = require("@oclif/core");
|
|
37
|
+
const command_types_1 = require("../types/command.types");
|
|
38
|
+
const auth_service_1 = require("../services/auth.service");
|
|
39
|
+
const config_service_1 = require("../services/config.service");
|
|
40
|
+
const validation_service_1 = require("../services/validation.service");
|
|
41
|
+
const cli_utils_1 = require("../utils/cli.utils");
|
|
42
|
+
const sdk_manager_service_1 = require("../services/sdk-manager.service");
|
|
43
|
+
const OTPAuth = __importStar(require("otpauth"));
|
|
44
|
+
class LoginLegacy extends core_1.Command {
|
|
45
|
+
static args = {};
|
|
46
|
+
static description = '[Legacy] Logs into an Internxt account using user and password. ' +
|
|
47
|
+
'If the account is two-factor protected, then an extra code will be required.';
|
|
48
|
+
static aliases = [];
|
|
49
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
50
|
+
static flags = {
|
|
51
|
+
...cli_utils_1.CLIUtils.CommonFlags,
|
|
52
|
+
email: core_1.Flags.string({
|
|
53
|
+
char: 'e',
|
|
54
|
+
aliases: ['mail'],
|
|
55
|
+
env: 'INXT_USER',
|
|
56
|
+
description: 'The email to log in',
|
|
57
|
+
required: false,
|
|
58
|
+
}),
|
|
59
|
+
password: core_1.Flags.string({
|
|
60
|
+
char: 'p',
|
|
61
|
+
aliases: ['pass'],
|
|
62
|
+
env: 'INXT_PASSWORD',
|
|
63
|
+
description: 'The plain password to log in',
|
|
64
|
+
required: false,
|
|
65
|
+
}),
|
|
66
|
+
twofactor: core_1.Flags.string({
|
|
67
|
+
char: 'w',
|
|
68
|
+
aliases: ['two', 'two-factor'],
|
|
69
|
+
env: 'INXT_TWOFACTORCODE',
|
|
70
|
+
description: 'The two factor auth code (TOTP). ',
|
|
71
|
+
required: false,
|
|
72
|
+
helpValue: '123456',
|
|
73
|
+
}),
|
|
74
|
+
twofactortoken: core_1.Flags.string({
|
|
75
|
+
char: 't',
|
|
76
|
+
aliases: ['otp', 'otp-token'],
|
|
77
|
+
env: 'INXT_OTPTOKEN',
|
|
78
|
+
description: 'The TOTP secret token. It is used to generate a TOTP code if needed.' +
|
|
79
|
+
' It has prority over the two factor code flag.',
|
|
80
|
+
required: false,
|
|
81
|
+
helpValue: 'token',
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
static enableJsonFlag = true;
|
|
85
|
+
run = async () => {
|
|
86
|
+
const { flags } = await this.parse(LoginLegacy);
|
|
87
|
+
const nonInteractive = flags['non-interactive'];
|
|
88
|
+
const email = await this.getEmail(flags['email'], nonInteractive);
|
|
89
|
+
const password = await this.getPassword(flags['password'], nonInteractive);
|
|
90
|
+
const is2FANeeded = await auth_service_1.AuthService.instance.is2FANeeded(email);
|
|
91
|
+
let twoFactorCode;
|
|
92
|
+
if (is2FANeeded) {
|
|
93
|
+
const twoFactorToken = flags['twofactortoken'];
|
|
94
|
+
if (twoFactorToken && twoFactorToken.trim().length > 0) {
|
|
95
|
+
const totp = new OTPAuth.TOTP({
|
|
96
|
+
secret: twoFactorToken,
|
|
97
|
+
digits: 6,
|
|
98
|
+
});
|
|
99
|
+
twoFactorCode = totp.generate();
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
twoFactorCode = await this.getTwoFactorCode(flags['twofactor'], nonInteractive);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const loginCredentials = await auth_service_1.AuthService.instance.doLogin(email, password, twoFactorCode);
|
|
106
|
+
sdk_manager_service_1.SdkManager.init({ token: loginCredentials.token });
|
|
107
|
+
await config_service_1.ConfigService.instance.saveUser(loginCredentials);
|
|
108
|
+
const message = `Succesfully logged in to: ${loginCredentials.user.email}`;
|
|
109
|
+
cli_utils_1.CLIUtils.success(this.log.bind(this), message);
|
|
110
|
+
return {
|
|
111
|
+
success: true,
|
|
112
|
+
message,
|
|
113
|
+
login: loginCredentials,
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
catch = async (error) => {
|
|
117
|
+
const { flags } = await this.parse(LoginLegacy);
|
|
118
|
+
cli_utils_1.CLIUtils.catchError({
|
|
119
|
+
error,
|
|
120
|
+
command: this.id,
|
|
121
|
+
logReporter: this.log.bind(this),
|
|
122
|
+
jsonFlag: flags['json'],
|
|
123
|
+
});
|
|
124
|
+
this.exit(1);
|
|
125
|
+
};
|
|
126
|
+
getEmail = async (emailFlag, nonInteractive) => {
|
|
127
|
+
const email = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
128
|
+
value: emailFlag,
|
|
129
|
+
name: LoginLegacy.flags['email'].name,
|
|
130
|
+
}, {
|
|
131
|
+
nonInteractive,
|
|
132
|
+
prompt: {
|
|
133
|
+
message: 'What is your email?',
|
|
134
|
+
options: { type: 'input' },
|
|
135
|
+
},
|
|
136
|
+
}, {
|
|
137
|
+
validate: validation_service_1.ValidationService.instance.validateEmail,
|
|
138
|
+
error: new command_types_1.NotValidEmailError(),
|
|
139
|
+
}, this.log.bind(this));
|
|
140
|
+
return email;
|
|
141
|
+
};
|
|
142
|
+
getPassword = async (passwordFlag, nonInteractive) => {
|
|
143
|
+
const password = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
144
|
+
value: passwordFlag,
|
|
145
|
+
name: LoginLegacy.flags['password'].name,
|
|
146
|
+
}, {
|
|
147
|
+
nonInteractive,
|
|
148
|
+
prompt: {
|
|
149
|
+
message: 'What is your password?',
|
|
150
|
+
options: { type: 'password' },
|
|
151
|
+
},
|
|
152
|
+
}, {
|
|
153
|
+
validate: validation_service_1.ValidationService.instance.validateStringIsNotEmpty,
|
|
154
|
+
error: new command_types_1.EmptyPasswordError(),
|
|
155
|
+
}, this.log.bind(this));
|
|
156
|
+
return password;
|
|
157
|
+
};
|
|
158
|
+
getTwoFactorCode = async (twoFactorFlag, nonInteractive) => {
|
|
159
|
+
const twoFactor = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
160
|
+
value: twoFactorFlag,
|
|
161
|
+
name: LoginLegacy.flags['twofactor'].name,
|
|
162
|
+
}, {
|
|
163
|
+
nonInteractive,
|
|
164
|
+
prompt: {
|
|
165
|
+
message: 'What is your two-factor code?',
|
|
166
|
+
options: { type: 'mask' },
|
|
167
|
+
},
|
|
168
|
+
}, {
|
|
169
|
+
validate: validation_service_1.ValidationService.instance.validate2FA,
|
|
170
|
+
error: new command_types_1.NotValidTwoFactorCodeError(),
|
|
171
|
+
}, this.log.bind(this));
|
|
172
|
+
return twoFactor;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
exports.default = LoginLegacy;
|
package/dist/commands/login.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
export default class Login extends Command {
|
|
3
3
|
static readonly args: {};
|
|
4
|
-
static readonly description
|
|
4
|
+
static readonly description: string;
|
|
5
5
|
static readonly aliases: never[];
|
|
6
6
|
static readonly examples: string[];
|
|
7
7
|
static readonly flags: {
|
|
8
|
-
|
|
9
|
-
|
|
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>;
|
|
12
|
-
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
host: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
port: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
10
|
};
|
|
14
11
|
static readonly enableJsonFlag = true;
|
|
15
12
|
run: () => Promise<{
|
|
@@ -18,7 +15,4 @@ export default class Login extends Command {
|
|
|
18
15
|
login: import("../types/command.types").LoginCredentials;
|
|
19
16
|
}>;
|
|
20
17
|
catch: (error: Error) => Promise<never>;
|
|
21
|
-
private getEmail;
|
|
22
|
-
private getPassword;
|
|
23
|
-
private getTwoFactorCode;
|
|
24
18
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -1,107 +1,41 @@
|
|
|
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
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
const core_1 = require("@oclif/core");
|
|
37
|
-
const command_types_1 = require("../types/command.types");
|
|
38
|
-
const auth_service_1 = require("../services/auth.service");
|
|
39
4
|
const config_service_1 = require("../services/config.service");
|
|
40
|
-
const validation_service_1 = require("../services/validation.service");
|
|
41
5
|
const cli_utils_1 = require("../utils/cli.utils");
|
|
42
6
|
const sdk_manager_service_1 = require("../services/sdk-manager.service");
|
|
43
|
-
const
|
|
7
|
+
const universal_link_service_1 = require("../services/universal-link.service");
|
|
44
8
|
class Login extends core_1.Command {
|
|
45
9
|
static args = {};
|
|
46
|
-
static description = 'Logs into
|
|
10
|
+
static description = 'Logs into your Internxt account using the web-based login flow. ' +
|
|
11
|
+
'A temporary local server is started to securely receive the authentication response.';
|
|
47
12
|
static aliases = [];
|
|
48
13
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
49
14
|
static flags = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
15
|
+
host: core_1.Flags.string({
|
|
16
|
+
char: 'h',
|
|
17
|
+
aliases: ['host'],
|
|
18
|
+
env: 'INXT_LOGIN_SERVER_HOST',
|
|
19
|
+
description: 'IP address of the machine where the CLI is running. ' +
|
|
20
|
+
'If you are opening the login page in a browser on another device, ' +
|
|
21
|
+
'set this to the IP address of the machine running the CLI. Defaults to 127.0.0.1.',
|
|
56
22
|
required: false,
|
|
57
23
|
}),
|
|
58
|
-
|
|
24
|
+
port: core_1.Flags.integer({
|
|
59
25
|
char: 'p',
|
|
60
|
-
aliases: ['
|
|
61
|
-
env: '
|
|
62
|
-
description: '
|
|
63
|
-
|
|
64
|
-
}),
|
|
65
|
-
twofactor: core_1.Flags.string({
|
|
66
|
-
char: 'w',
|
|
67
|
-
aliases: ['two', 'two-factor'],
|
|
68
|
-
env: 'INXT_TWOFACTORCODE',
|
|
69
|
-
description: 'The two factor auth code (TOTP). ',
|
|
26
|
+
aliases: ['port'],
|
|
27
|
+
env: 'INXT_LOGIN_SERVER_PORT',
|
|
28
|
+
description: 'Port used by the temporary local server to handle the login callback. ' +
|
|
29
|
+
'If not specified, a random available port will be used automatically.',
|
|
70
30
|
required: false,
|
|
71
|
-
helpValue: '123456',
|
|
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
31
|
}),
|
|
82
32
|
};
|
|
83
33
|
static enableJsonFlag = true;
|
|
84
34
|
run = async () => {
|
|
85
35
|
const { flags } = await this.parse(Login);
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
const is2FANeeded = await auth_service_1.AuthService.instance.is2FANeeded(email);
|
|
90
|
-
let twoFactorCode;
|
|
91
|
-
if (is2FANeeded) {
|
|
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
|
-
}
|
|
103
|
-
}
|
|
104
|
-
const loginCredentials = await auth_service_1.AuthService.instance.doLogin(email, password, twoFactorCode);
|
|
36
|
+
const host = flags['host'];
|
|
37
|
+
const port = flags['port'];
|
|
38
|
+
const loginCredentials = await universal_link_service_1.UniversalLinkService.instance.loginSSO(flags['json'] ?? false, this.log.bind(this), host, port);
|
|
105
39
|
sdk_manager_service_1.SdkManager.init({ token: loginCredentials.token });
|
|
106
40
|
await config_service_1.ConfigService.instance.saveUser(loginCredentials);
|
|
107
41
|
const message = `Succesfully logged in to: ${loginCredentials.user.email}`;
|
|
@@ -118,58 +52,9 @@ class Login extends core_1.Command {
|
|
|
118
52
|
error,
|
|
119
53
|
command: this.id,
|
|
120
54
|
logReporter: this.log.bind(this),
|
|
121
|
-
errorReporter: this.error.bind(this),
|
|
122
55
|
jsonFlag: flags['json'],
|
|
123
56
|
});
|
|
124
57
|
this.exit(1);
|
|
125
58
|
};
|
|
126
|
-
getEmail = async (emailFlag, nonInteractive) => {
|
|
127
|
-
const email = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
128
|
-
value: emailFlag,
|
|
129
|
-
name: Login.flags['email'].name,
|
|
130
|
-
}, {
|
|
131
|
-
nonInteractive,
|
|
132
|
-
prompt: {
|
|
133
|
-
message: 'What is your email?',
|
|
134
|
-
options: { type: 'input' },
|
|
135
|
-
},
|
|
136
|
-
}, {
|
|
137
|
-
validate: validation_service_1.ValidationService.instance.validateEmail,
|
|
138
|
-
error: new command_types_1.NotValidEmailError(),
|
|
139
|
-
}, this.log.bind(this));
|
|
140
|
-
return email;
|
|
141
|
-
};
|
|
142
|
-
getPassword = async (passwordFlag, nonInteractive) => {
|
|
143
|
-
const password = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
144
|
-
value: passwordFlag,
|
|
145
|
-
name: Login.flags['password'].name,
|
|
146
|
-
}, {
|
|
147
|
-
nonInteractive,
|
|
148
|
-
prompt: {
|
|
149
|
-
message: 'What is your password?',
|
|
150
|
-
options: { type: 'password' },
|
|
151
|
-
},
|
|
152
|
-
}, {
|
|
153
|
-
validate: validation_service_1.ValidationService.instance.validateStringIsNotEmpty,
|
|
154
|
-
error: new command_types_1.EmptyPasswordError(),
|
|
155
|
-
}, this.log.bind(this));
|
|
156
|
-
return password;
|
|
157
|
-
};
|
|
158
|
-
getTwoFactorCode = async (twoFactorFlag, nonInteractive) => {
|
|
159
|
-
const twoFactor = await cli_utils_1.CLIUtils.getValueFromFlag({
|
|
160
|
-
value: twoFactorFlag,
|
|
161
|
-
name: Login.flags['twofactor'].name,
|
|
162
|
-
}, {
|
|
163
|
-
nonInteractive,
|
|
164
|
-
prompt: {
|
|
165
|
-
message: 'What is your two-factor code?',
|
|
166
|
-
options: { type: 'mask' },
|
|
167
|
-
},
|
|
168
|
-
}, {
|
|
169
|
-
validate: validation_service_1.ValidationService.instance.validate2FA,
|
|
170
|
-
error: new command_types_1.NotValidTwoFactorCodeError(),
|
|
171
|
-
}, this.log.bind(this));
|
|
172
|
-
return twoFactor;
|
|
173
|
-
};
|
|
174
59
|
}
|
|
175
60
|
exports.default = Login;
|
package/dist/commands/logout.js
CHANGED
package/dist/commands/logs.js
CHANGED
|
@@ -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' }] });
|
|
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 } };
|
|
@@ -38,7 +38,6 @@ class TrashFile extends core_1.Command {
|
|
|
38
38
|
error,
|
|
39
39
|
command: this.id,
|
|
40
40
|
logReporter: this.log.bind(this),
|
|
41
|
-
errorReporter: this.error.bind(this),
|
|
42
41
|
jsonFlag: flags['json'],
|
|
43
42
|
});
|
|
44
43
|
this.exit(1);
|
|
@@ -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' }] });
|
|
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 } };
|
|
@@ -38,7 +38,6 @@ class TrashFolder extends core_1.Command {
|
|
|
38
38
|
error,
|
|
39
39
|
command: this.id,
|
|
40
40
|
logReporter: this.log.bind(this),
|
|
41
|
-
errorReporter: this.error.bind(this),
|
|
42
41
|
jsonFlag: flags['json'],
|
|
43
42
|
});
|
|
44
43
|
this.exit(1);
|
|
@@ -17,12 +17,13 @@ export default class UploadFile extends Command {
|
|
|
17
17
|
plainName: string;
|
|
18
18
|
name: string;
|
|
19
19
|
id: number;
|
|
20
|
-
bucket: string;
|
|
21
20
|
uuid: string;
|
|
21
|
+
bucket: string;
|
|
22
22
|
folderUuid: string;
|
|
23
23
|
folderId: number;
|
|
24
24
|
status: "EXISTS" | "TRASHED" | "DELETED";
|
|
25
25
|
fileId: string;
|
|
26
|
+
itemType: "file";
|
|
26
27
|
size: number;
|
|
27
28
|
createdAt: Date;
|
|
28
29
|
updatedAt: Date;
|
|
@@ -121,7 +121,7 @@ class UploadFile extends core_1.Command {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
catch (error) {
|
|
124
|
-
errors_utils_1.ErrorUtils.report(
|
|
124
|
+
errors_utils_1.ErrorUtils.report(error, { command: this.id });
|
|
125
125
|
}
|
|
126
126
|
progressBar?.update(100);
|
|
127
127
|
progressBar?.stop();
|
|
@@ -144,7 +144,6 @@ class UploadFile extends core_1.Command {
|
|
|
144
144
|
error,
|
|
145
145
|
command: this.id,
|
|
146
146
|
logReporter: this.log.bind(this),
|
|
147
|
-
errorReporter: this.error.bind(this),
|
|
148
147
|
jsonFlag: flags['json'],
|
|
149
148
|
});
|
|
150
149
|
this.exit(1);
|
|
@@ -10,6 +10,7 @@ export default class WebDAVConfig extends Command {
|
|
|
10
10
|
https: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
11
|
http: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
12
|
timeout: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
createFullPath: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
14
|
};
|
|
14
15
|
static readonly enableJsonFlag = true;
|
|
15
16
|
run: () => Promise<{
|