d-drive-cli 1.1.1 → 1.1.3
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/dist/commands/config.js
CHANGED
|
@@ -26,18 +26,20 @@ async function configCommand(options) {
|
|
|
26
26
|
// Accept keys entered with or without the `dd_` prefix, and strip any accidental "Bearer " prefix
|
|
27
27
|
const rawKey = options.key.replace(/^Bearer\s+/i, '').trim();
|
|
28
28
|
const normalizedKey = rawKey.startsWith('dd_') ? rawKey : `dd_${rawKey}`;
|
|
29
|
-
|
|
29
|
+
// Validate API key by calling a protected endpoint that accepts API keys (authenticate middleware)
|
|
30
|
+
const validateUrl = apiUrl.replace(/\/$/, '') + '/api-keys';
|
|
31
|
+
const response = await axios_1.default.get(validateUrl, {
|
|
30
32
|
headers: {
|
|
31
33
|
Authorization: `Bearer ${normalizedKey}`,
|
|
32
34
|
},
|
|
33
35
|
timeout: 10000,
|
|
34
36
|
});
|
|
35
|
-
if (response.status === 200
|
|
37
|
+
if (response.status === 200) {
|
|
36
38
|
(0, config_1.setConfig)('apiKey', normalizedKey);
|
|
37
39
|
if (options.url) {
|
|
38
40
|
(0, config_1.setConfig)('apiUrl', options.url);
|
|
39
41
|
}
|
|
40
|
-
spinner.succeed(chalk_1.default.green(
|
|
42
|
+
spinner.succeed(chalk_1.default.green('✓ API key validated and saved!'));
|
|
41
43
|
}
|
|
42
44
|
else {
|
|
43
45
|
spinner.fail(chalk_1.default.red('✗ Invalid API key'));
|
package/dist/commands/upload.js
CHANGED
|
@@ -63,6 +63,8 @@ async function uploadSingleFile(api, filePath, destination, showProgress) {
|
|
|
63
63
|
const formData = new form_data_1.default();
|
|
64
64
|
formData.append('file', fs_extra_1.default.createReadStream(filePath));
|
|
65
65
|
formData.append('path', destination);
|
|
66
|
+
// Ensure CLI uploads follow frontend behavior and request server-side encryption by default
|
|
67
|
+
formData.append('encrypt', 'true');
|
|
66
68
|
let progressBar = null;
|
|
67
69
|
if (showProgress) {
|
|
68
70
|
progressBar = new progress_1.default('[:bar] :percent :etas', {
|
package/package.json
CHANGED
package/src/commands/config.ts
CHANGED
|
@@ -31,19 +31,20 @@ export async function configCommand(options: ConfigOptions) {
|
|
|
31
31
|
const rawKey = options.key.replace(/^Bearer\s+/i, '').trim();
|
|
32
32
|
const normalizedKey = rawKey.startsWith('dd_') ? rawKey : `dd_${rawKey}`;
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
// Validate API key by calling a protected endpoint that accepts API keys (authenticate middleware)
|
|
35
|
+
const validateUrl = apiUrl.replace(/\/$/, '') + '/api-keys';
|
|
36
|
+
const response = await axios.get(validateUrl, {
|
|
35
37
|
headers: {
|
|
36
38
|
Authorization: `Bearer ${normalizedKey}`,
|
|
37
39
|
},
|
|
38
40
|
timeout: 10000,
|
|
39
41
|
});
|
|
40
|
-
|
|
41
|
-
if (response.status === 200 && response.data) {
|
|
42
|
+
if (response.status === 200) {
|
|
42
43
|
setConfig('apiKey', normalizedKey);
|
|
43
44
|
if (options.url) {
|
|
44
45
|
setConfig('apiUrl', options.url);
|
|
45
46
|
}
|
|
46
|
-
spinner.succeed(chalk.green(
|
|
47
|
+
spinner.succeed(chalk.green('✓ API key validated and saved!'));
|
|
47
48
|
} else {
|
|
48
49
|
spinner.fail(chalk.red('✗ Invalid API key'));
|
|
49
50
|
process.exit(1);
|
package/src/commands/upload.ts
CHANGED
|
@@ -87,6 +87,8 @@ async function uploadSingleFile(
|
|
|
87
87
|
const formData = new FormData();
|
|
88
88
|
formData.append('file', fs.createReadStream(filePath));
|
|
89
89
|
formData.append('path', destination);
|
|
90
|
+
// Ensure CLI uploads follow frontend behavior and request server-side encryption by default
|
|
91
|
+
formData.append('encrypt', 'true');
|
|
90
92
|
|
|
91
93
|
let progressBar: ProgressBar | null = null;
|
|
92
94
|
|