Spaces:
Paused
Paused
File size: 1,529 Bytes
2276d59 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import { describe, it, expect } from 'vitest';
import { getProxyHeaders } from '../../src/utils/network/proxy.util.js';
describe('getProxyHeaders — cdn auth headers', () => {
it('forces the tiktok referer/origin and strips the frontend referer', () => {
const headers = getProxyHeaders(
'https://v16-webapp-prime.tiktok.com/video/tos/x.mp4?signature=abc',
{
referer: 'https://nex-stream.pages.dev/',
origin: 'https://nex-stream.pages.dev',
cookie: 'frontend_session=abc',
'sec-fetch-site': 'cross-site',
range: 'bytes=0-',
}
);
expect(headers.referer).toBe('https://www.tiktok.com/');
expect(headers.origin).toBe('https://www.tiktok.com');
expect(headers.range).toBe('bytes=0-');
// frontend identity must not leak
expect(headers.cookie).toBeUndefined();
expect(headers['sec-fetch-site']).toBeUndefined();
});
it('keeps youtube referer/origin and defaults a range', () => {
const headers = getProxyHeaders(
'https://rr5---sn-x.googlevideo.com/videoplayback?test',
{}
);
expect(headers.referer).toBe('https://www.youtube.com/');
expect(headers.origin).toBe('https://www.youtube.com');
expect(headers.range).toBe('bytes=0-');
});
it('sets the facebook referer for fbcdn hosts', () => {
const headers = getProxyHeaders('https://video.fmnl.fbcdn.net/v/x.mp4', {
referer: 'https://nex-stream.pages.dev/',
});
expect(headers.referer).toBe('https://www.facebook.com/');
});
});
|