fix: harden hoster confirmation and recovery

Require every successful upload to expose a validated HTTPS result and rebuild all Doodstream and DSVPlay output from the confirmed file code.

Keep failed baselines distinct from empty accounts, reject stale, foreign, and ambiguous recovery candidates across Doodstream, Byse, VOE, and Vidmoly, and preserve exact filename recovery with normalized extensions.

Emit bounded structured transport diagnostics without raw response bodies or tokenized URLs, and remove sensitive values from Doodstream debug traces.

Tests: node --test tests/upload-confirmation.test.js tests/hosters.test.js tests/doodstream-api-upload.test.js tests/doodstream-upload.test.js tests/byse-reject-recovery.test.js tests/hoster-recovery-provenance.test.js tests/suspect-reject-alternates.test.js

Lint: eslint lib/hoster-transport-error.js lib/hosters.js lib/doodstream-upload.js lib/voe-upload.js lib/vidmoly-upload.js lib/upload-confirmation.js
This commit is contained in:
Sucukdeluxe
2026-08-13 20:43:48 +02:00
parent e63214cae8
commit b64cdd0ff3
12 changed files with 1320 additions and 378 deletions
+88
View File
@@ -171,6 +171,94 @@ test('byse empty filecode WITHOUT explicit rejection still polls recovery', asyn
assert.ok(listCalls >= 2, 'recovery polling must run when there is no explicit rejection');
});
test('byse never recovers an old file after a failed baseline', async () => {
stubByseUploadServer();
const abort = new AbortController();
const fileName = path.basename(tmpFile);
let listCalls = 0;
requestRouter = async (url, opts) => {
if (/\/file\/list/.test(String(url))) {
listCalls++;
if (listCalls === 1) {
return {
statusCode: 503,
headers: { 'content-type': 'text/html' },
body: { text: async () => '<html>baseline-token=SYNTHETIC_BYSE_BASELINE</html>' }
};
}
abort.abort();
return {
statusCode: 200,
headers: { 'content-type': 'application/json' },
body: { text: async () => JSON.stringify({ status: 200, result: { files: [{ file_code: 'OLD_BYSE_123', title: fileName }] } }) }
};
}
if (opts && opts.body && typeof opts.body[Symbol.asyncIterator] === 'function') {
for await (const chunk of opts.body) { if (chunk && chunk.length === -1) break; }
}
return {
statusCode: 200,
headers: { 'content-type': 'application/json' },
body: { text: async () => JSON.stringify({ status: 200, msg: 'OK' }) }
};
};
await assert.rejects(
() => uploadFile('byse.sx', tmpFile, 'VALIDKEY', null, abort.signal, null),
(err) => {
assert.doesNotMatch(err.message, /SYNTHETIC_BYSE_BASELINE/);
assert.equal(err.diagnostic.phase, 'recovery-baseline');
assert.equal(err.diagnostic.http, 503);
return true;
}
);
assert.equal(listCalls, 1);
});
test('byse recovery rejects ambiguous same-title candidates', async () => {
stubByseUploadServer();
const abort = new AbortController();
const fileName = path.basename(tmpFile);
let listCalls = 0;
requestRouter = async (url, opts) => {
if (/\/file\/list/.test(String(url))) {
listCalls++;
if (listCalls === 1) {
return { statusCode: 200, headers: {}, body: { text: async () => '{"status":200,"result":{"files":[]}}' } };
}
abort.abort();
return {
statusCode: 200,
headers: {},
body: {
text: async () => JSON.stringify({
status: 200,
result: {
files: [
{ file_code: 'PARALLEL_A', title: fileName },
{ file_code: 'PARALLEL_B', title: fileName }
]
}
})
}
};
}
if (opts && opts.body && typeof opts.body[Symbol.asyncIterator] === 'function') {
for await (const chunk of opts.body) { if (chunk && chunk.length === -1) break; }
}
return {
statusCode: 200,
headers: { 'content-type': 'application/json' },
body: { text: async () => JSON.stringify({ status: 200, msg: 'OK' }) }
};
};
await assert.rejects(
() => uploadFile('byse.sx', tmpFile, 'VALIDKEY', null, abort.signal, null),
(err) => err.hosterTransient === true
);
});
function stubBysePost(response) {
requestRouter = async (url, opts) => {
const u = String(url);