squidcloudctl 3.0.6 → 3.0.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/dist/lib/transfer.js +21 -1
- package/package.json +1 -1
package/dist/lib/transfer.js
CHANGED
|
@@ -358,6 +358,26 @@ export async function downloadFile(target, destPath, onProgress) {
|
|
|
358
358
|
const msg = e instanceof Error ? e.message : String(e);
|
|
359
359
|
if (msg.startsWith('VAULT_KEY_DRIFT'))
|
|
360
360
|
throw e;
|
|
361
|
+
if (msg.startsWith('WEB_SESSION_REQUIRED')) {
|
|
362
|
+
// No fresh web JWT — fall back to signed-mode + vault key (no JWT needed).
|
|
363
|
+
try {
|
|
364
|
+
const key0 = defaultKey || tagsKey || '';
|
|
365
|
+
const usable = key0 && !/^(managed_key|sha256:.*|byok_encrypted|byok_protected)$/.test(key0);
|
|
366
|
+
const vaultKey = usable ? key0 : await fetchVaultKey(target.id);
|
|
367
|
+
if (!vaultKey && !usable && encrypted)
|
|
368
|
+
throw new Error(msg);
|
|
369
|
+
const sres = await apiRaw(`/download/${target.id}?signed=true`);
|
|
370
|
+
if (!sres.ok)
|
|
371
|
+
throw new Error(`signed HTTP ${sres.status}`);
|
|
372
|
+
const smeta = (await sres.json());
|
|
373
|
+
if (!smeta?.success || !smeta.signed_urls?.length)
|
|
374
|
+
throw new Error('signed: empty');
|
|
375
|
+
return await fetchDecryptWrite(smeta.signed_urls, target, destPath, onProgress, vaultKey ?? undefined, chunks.length);
|
|
376
|
+
}
|
|
377
|
+
catch (e2) {
|
|
378
|
+
errors.push(`signed: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
361
381
|
errors.push(`cluster: ${msg}`);
|
|
362
382
|
}
|
|
363
383
|
}
|
|
@@ -380,7 +400,7 @@ async function resolveKey(fileId, tagsKey) {
|
|
|
380
400
|
return tagsKey;
|
|
381
401
|
return fetchVaultKey(fileId);
|
|
382
402
|
}
|
|
383
|
-
async function fetchDecryptWrite(urls, target, destPath, onProgress) {
|
|
403
|
+
async function fetchDecryptWrite(urls, target, destPath, onProgress, preKey, declaredChunks) {
|
|
384
404
|
const totalChunks = urls.length;
|
|
385
405
|
const finalPath = destPath || target.name;
|
|
386
406
|
const out = fs.createWriteStream(finalPath);
|