From 8c2774b45fa9657893ca0c552df0d3b97bd2e9fe Mon Sep 17 00:00:00 2001 From: alanef Date: Tue, 2 Sep 2025 09:28:57 +0100 Subject: [PATCH 1/3] Fix: Accept all 2xx HTTP status codes as success The SDK was only accepting 200 as success, but 201 (Created) and 204 (No Content) are also valid success responses, especially for POST/PUT/DELETE operations. --- Freemius.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Freemius.js b/Freemius.js index d2d962e..9b36dac 100644 --- a/Freemius.js +++ b/Freemius.js @@ -414,8 +414,9 @@ class Freemius { request(options, function (error, response, body) { //console.log(error); //console.log(response); - if (!error && response.statusCode == 200) { - responseCallback(response.body); + // Accept any 2xx status code as success (200-299) + if (!error && response.statusCode >= 200 && response.statusCode < 300) { + responseCallback(response.body || ''); } else { console.log("Error:Stats Code:"+response.statusCode); From b93e2f6fb752fbd176b4593614c5e54b327c9298 Mon Sep 17 00:00:00 2001 From: alanef Date: Tue, 14 Oct 2025 16:02:27 +0100 Subject: [PATCH 2/3] Fix multipart file upload MIME type corruption Add missing blank line (EOL) after Content-Type header in multipart form data. Without this, the MIME type and file content were being concatenated, causing "application/zipPK..." instead of "application/zip". This fixes the "file must be a Zip file" error when deploying to Freemius. --- Freemius.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Freemius.js b/Freemius.js index 9b36dac..3bb78be 100644 --- a/Freemius.js +++ b/Freemius.js @@ -455,8 +455,9 @@ class Freemius { data += ('--' + pBoundary + os.EOL) + (`Content-Disposition: form-data; name="${name}"; filename="${filename}"` + os.EOL) + - (`Content-Type: ${this.GetMimeContentType(file_path)}` + os.EOL); - + (`Content-Type: ${this.GetMimeContentType(file_path)}` + os.EOL) + + os.EOL; + content = fs.readFileSync(file_path); } From 925809e06dd792d2ac30257e56b9ed90ad3e0b99 Mon Sep 17 00:00:00 2001 From: alanef Date: Tue, 14 Oct 2025 17:09:06 +0100 Subject: [PATCH 3/3] Fix binary download corruption by setting encoding to null for ZIP files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When downloading .zip files, set encoding: null in request options to return a Buffer instead of parsing as UTF-8 string. This prevents binary data corruption. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- Freemius.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Freemius.js b/Freemius.js index 3bb78be..4897b42 100644 --- a/Freemius.js +++ b/Freemius.js @@ -346,6 +346,11 @@ class Freemius { }; + // For binary downloads (like .zip files), set encoding to null + if (pCanonizedPath.endsWith('.zip')) { + options.encoding = null; + } + let content_type = 'application/json'; let json_encoded_params = empty(pParams) ? '' : JSON.stringify(pParams);