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
+14 -27
View File
@@ -11,13 +11,13 @@ const HOSTER_RESULT_DOMAINS = {
'doodstream.com': ['doodstream.com', 'dood.to', 'dood.la', 'dood.so', 'dsvplay.com']
};
function isExpectedHostUrl(value, expectedHost) {
function isExpectedHostUrl(value, expectedHost, allowHttp = false) {
if (typeof value !== 'string' || value.trim() === '') return false;
try {
const url = new URL(value);
const hostname = url.hostname.toLowerCase();
const acceptedDomains = HOSTER_RESULT_DOMAINS[expectedHost] || [expectedHost];
return (url.protocol === 'http:' || url.protocol === 'https:')
return (url.protocol === 'https:' || (allowHttp && url.protocol === 'http:'))
&& acceptedDomains.some(domain => hostname === domain || hostname.endsWith(`.${domain}`));
} catch {
return false;
@@ -32,27 +32,6 @@ function getUrlHost(value) {
}
}
function normalizeDoodstreamUrl(value) {
if (typeof value !== 'string' || value.trim() === '') return value;
try {
const url = new URL(value);
const hostname = url.hostname.toLowerCase();
if (hostname !== 'doodstream.com' && HOSTER_RESULT_DOMAINS['doodstream.com'].includes(hostname)) {
url.hostname = 'doodstream.com';
return url.toString();
}
} catch {}
return value;
}
function normalizeConfirmedResult(result, hoster) {
if (hoster !== 'doodstream.com') return result;
const downloadUrl = normalizeDoodstreamUrl(result.download_url);
const embedUrl = normalizeDoodstreamUrl(result.embed_url);
if (downloadUrl === result.download_url && embedUrl === result.embed_url) return result;
return { ...result, download_url: downloadUrl, embed_url: embedUrl };
}
function assertUploadConfirmation(result, hoster) {
const expectedHost = typeof hoster === 'string' ? hoster.trim().toLowerCase() : '';
const fileCode = typeof result?.file_code === 'string' ? result.file_code.trim() : '';
@@ -61,10 +40,18 @@ function assertUploadConfirmation(result, hoster) {
&& value !== undefined
&& !(typeof value === 'string' && value.trim() === '')
));
if (SUPPORTED_HOSTERS.has(expectedHost)
&& FILE_CODE_PATTERN.test(fileCode)
&& urls.every(value => isExpectedHostUrl(value, expectedHost))) {
return normalizeConfirmedResult(result, expectedHost);
if (SUPPORTED_HOSTERS.has(expectedHost) && FILE_CODE_PATTERN.test(fileCode)) {
if (expectedHost === 'doodstream.com' && urls.every(value => isExpectedHostUrl(value, expectedHost, true))) {
return {
...result,
file_code: fileCode,
download_url: `https://doodstream.com/d/${fileCode}`,
embed_url: `https://doodstream.com/e/${fileCode}`
};
}
if (urls.length > 0 && urls.every(value => isExpectedHostUrl(value, expectedHost))) {
return fileCode === result.file_code ? result : { ...result, file_code: fileCode };
}
}
const error = new Error(`Upload zu ${hoster || 'unbekanntem Hoster'} wurde nicht bestätigt`);
error.diagnostic = {