π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
fix(youtube,tiktok): request identity encoding on the media reads
Gilad Resisi5a9b1cc9c599
diff --git a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.tsindex 28325f64f..c1eb7c323 100644--- a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts+++ b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts@@ -688,8 +688,13 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {// read stream for local files.private async tiktokChunkStream(path: string, start: number, end: number) {if (path.indexOf('http') === 0) {+ // identity encoding so the store keeps content-length and can answer+ // with the requested range, matching every other media readconst response = await fetch(path, {- headers: { Range: `bytes=${start}-${end}` },+ headers: {+ Range: `bytes=${start}-${end}`,+ 'accept-encoding': 'identity',+ },dispatcher: getSsrfSafeDispatcher(),} as any);diff --git a/libraries/nestjs-libraries/src/integrations/social/youtube.provider.ts b/libraries/nestjs-libraries/src/integrations/social/youtube.provider.tsindex 5567b1339..1e6f3852a 100644--- a/libraries/nestjs-libraries/src/integrations/social/youtube.provider.ts+++ b/libraries/nestjs-libraries/src/integrations/social/youtube.provider.ts@@ -431,9 +431,12 @@ export class YoutubeProvider extends SocialAbstract implements SocialProvider {private async youtubeMediaSize(path: string): Promise<number> {if (path.indexOf('http') === 0) {// the media path is user-influenced, keep the SSRF-safe dispatcher that- // this.fetch applies to every other outbound request+ // this.fetch applies to every other outbound request. identity encoding+ // so content-length matches the bytes a later GET actually streams+ // (fetch transparently decompresses encoded bodies).const head = await fetch(path, {method: 'HEAD',+ headers: { 'accept-encoding': 'identity' },dispatcher: getSsrfSafeDispatcher(),} as any);const length = head.headers.get('content-length');@@ -456,8 +459,14 @@ export class YoutubeProvider extends SocialAbstract implements SocialProvider {// read stream for local files.private async youtubeChunkStream(path: string, start: number, end: number) {if (path.indexOf('http') === 0) {+ // identity encoding so the store keeps content-length and can answer+ // with the requested range: a transformed (compressed) response loses+ // its length, and a length-less object is answered with the full body.const response = await fetch(path, {- headers: { Range: `bytes=${start}-${end}` },+ headers: {+ Range: `bytes=${start}-${end}`,+ 'accept-encoding': 'identity',+ },dispatcher: getSsrfSafeDispatcher(),} as any);