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:
@@ -3,9 +3,15 @@ const assert = require('node:assert/strict');
|
||||
|
||||
const { assertUploadConfirmation } = require('../lib/upload-confirmation');
|
||||
|
||||
test('accepts a host-confirmed file code without a public URL', () => {
|
||||
const result = { file_code: 'AB1', download_url: null, embed_url: null };
|
||||
assert.equal(assertUploadConfirmation(result, 'doodstream.com'), result);
|
||||
test('materializes canonical Doodstream URLs from a confirmed file code', () => {
|
||||
assert.deepEqual(
|
||||
assertUploadConfirmation({ file_code: 'AB1', download_url: null, embed_url: null }, 'doodstream.com'),
|
||||
{
|
||||
file_code: 'AB1',
|
||||
download_url: 'https://doodstream.com/d/AB1',
|
||||
embed_url: 'https://doodstream.com/e/AB1'
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('accepts upload URLs for every supported hoster and its subdomains', () => {
|
||||
@@ -18,7 +24,15 @@ test('accepts upload URLs for every supported hoster and its subdomains', () =>
|
||||
];
|
||||
for (const [hoster, downloadUrl] of cases) {
|
||||
const result = { file_code: 'abc123', download_url: downloadUrl };
|
||||
assert.equal(assertUploadConfirmation(result, hoster), result);
|
||||
const confirmed = assertUploadConfirmation(result, hoster);
|
||||
if (hoster === 'doodstream.com') {
|
||||
assert.deepEqual(confirmed, {
|
||||
...result,
|
||||
embed_url: 'https://doodstream.com/e/abc123'
|
||||
});
|
||||
} else {
|
||||
assert.equal(confirmed, result);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -48,6 +62,40 @@ test('accepts the Doodstream result domain returned by the current upload servic
|
||||
});
|
||||
});
|
||||
|
||||
test('rebuilds every accepted Doodstream transport URL from the file code', () => {
|
||||
const variants = [
|
||||
'http://dsvplay.com/d/DOODCODE1234?token=SYNTHETIC_SECRET#fragment',
|
||||
'https://edge.dsvplay.com/result/DOODCODE1234?session=SYNTHETIC_SESSION',
|
||||
'https://dood.to/e/DOODCODE1234',
|
||||
'https://dood.la/arbitrary/DOODCODE1234'
|
||||
];
|
||||
|
||||
for (const downloadUrl of variants) {
|
||||
assert.deepEqual(
|
||||
assertUploadConfirmation({ file_code: 'DOODCODE1234', download_url: downloadUrl }, 'doodstream.com'),
|
||||
{
|
||||
file_code: 'DOODCODE1234',
|
||||
download_url: 'https://doodstream.com/d/DOODCODE1234',
|
||||
embed_url: 'https://doodstream.com/e/DOODCODE1234'
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('rejects code-only confirmations for hosters without canonical materialization', () => {
|
||||
assert.throws(
|
||||
() => assertUploadConfirmation({ file_code: 'BYSE123' }, 'byse.sx'),
|
||||
/Upload zu byse\.sx wurde nicht bestätigt/
|
||||
);
|
||||
});
|
||||
|
||||
test('rejects non-HTTPS public URLs outside Doodstream transport normalization', () => {
|
||||
assert.throws(
|
||||
() => assertUploadConfirmation({ file_code: 'VOE123', download_url: 'http://voe.sx/VOE123' }, 'voe.sx'),
|
||||
/Upload zu voe\.sx wurde nicht bestätigt/
|
||||
);
|
||||
});
|
||||
|
||||
test('rejects an upload URL from a different domain', () => {
|
||||
assert.throws(
|
||||
() => assertUploadConfirmation({ file_code: 'abc123', download_url: 'https://attacker.invalid/file/abc123' }, 'voe.sx'),
|
||||
|
||||
Reference in New Issue
Block a user