Socket
Socket
Sign inDemoInstall

electron-updater

Package Overview
Dependencies
Maintainers
2
Versions
290
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-updater - npm Package Compare versions

Comparing version 6.2.0 to 6.2.1

1

out/AppUpdater.d.ts

@@ -176,3 +176,2 @@ /// <reference path="../../../typings/electron.d.ts" />

protected executeDownload(taskOptions: DownloadExecutorTask): Promise<Array<string>>;
protected differentialDownloadInstaller(fileInfo: ResolvedUpdateFileInfo, downloadUpdateOptions: DownloadUpdateOptions, installerPath: string, provider: Provider<any>, oldInstallerFileName: string): Promise<boolean>;
}

@@ -179,0 +178,0 @@ export interface DownloadUpdateOptions {

@@ -18,5 +18,2 @@ "use strict";

const providerFactory_1 = require("./providerFactory");
const zlib_1 = require("zlib");
const util_1 = require("./util");
const GenericDifferentialDownloader_1 = require("./differentialDownloader/GenericDifferentialDownloader");
class AppUpdater extends events_1.EventEmitter {

@@ -563,49 +560,2 @@ /**

}
async differentialDownloadInstaller(fileInfo, downloadUpdateOptions, installerPath, provider, oldInstallerFileName) {
try {
if (this._testOnlyOptions != null && !this._testOnlyOptions.isUseDifferentialDownload) {
return true;
}
const blockmapFileUrls = (0, util_1.blockmapFiles)(fileInfo.url, this.app.version, downloadUpdateOptions.updateInfoAndProvider.info.version);
this._logger.info(`Download block maps (old: "${blockmapFileUrls[0]}", new: ${blockmapFileUrls[1]})`);
const downloadBlockMap = async (url) => {
const data = await this.httpExecutor.downloadToBuffer(url, {
headers: downloadUpdateOptions.requestHeaders,
cancellationToken: downloadUpdateOptions.cancellationToken,
});
if (data == null || data.length === 0) {
throw new Error(`Blockmap "${url.href}" is empty`);
}
try {
return JSON.parse((0, zlib_1.gunzipSync)(data).toString());
}
catch (e) {
throw new Error(`Cannot parse blockmap "${url.href}", error: ${e}`);
}
};
const downloadOptions = {
newUrl: fileInfo.url,
oldFile: path.join(this.downloadedUpdateHelper.cacheDir, oldInstallerFileName),
logger: this._logger,
newFile: installerPath,
isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,
requestHeaders: downloadUpdateOptions.requestHeaders,
cancellationToken: downloadUpdateOptions.cancellationToken,
};
if (this.listenerCount(main_1.DOWNLOAD_PROGRESS) > 0) {
downloadOptions.onProgress = it => this.emit(main_1.DOWNLOAD_PROGRESS, it);
}
const blockMapDataList = await Promise.all(blockmapFileUrls.map(u => downloadBlockMap(u)));
await new GenericDifferentialDownloader_1.GenericDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download(blockMapDataList[0], blockMapDataList[1]);
return false;
}
catch (e) {
this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`);
if (this._testOnlyOptions != null) {
// test mode
throw e;
}
return true;
}
}
}

@@ -612,0 +562,0 @@ exports.AppUpdater = AppUpdater;

@@ -10,3 +10,2 @@ import { AllPublishOptions } from "builder-util-runtime";

private debug;
private closeServerIfExists;
protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>>;

@@ -13,0 +12,0 @@ private updateDownloaded;

39

out/MacUpdater.js

@@ -7,3 +7,2 @@ "use strict";

const fs_1 = require("fs");
const path = require("path");
const http_1 = require("http");

@@ -25,3 +24,2 @@ const AppUpdater_1 = require("./AppUpdater");

this.squirrelDownloadedUpdate = true;
this.debug("nativeUpdater.update-downloaded");
});

@@ -34,12 +32,2 @@ }

}
closeServerIfExists() {
if (this.server) {
this.debug("Closing proxy server");
this.server.close(err => {
if (err) {
this.debug("proxy server wasn't already open, probably attempted closing again as a safety check before quit");
}
});
}
}
async doDownloadUpdate(downloadUpdateOptions) {

@@ -84,4 +72,2 @@ let files = downloadUpdateOptions.updateInfoAndProvider.provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info);

}
const provider = downloadUpdateOptions.updateInfoAndProvider.provider;
const CURRENT_MAC_APP_ZIP_FILE_NAME = "update.zip";
return this.executeDownload({

@@ -91,15 +77,4 @@ fileExtension: "zip",

downloadUpdateOptions,
task: async (destinationFile, downloadOptions) => {
const cachedFile = path.join(this.downloadedUpdateHelper.cacheDir, CURRENT_MAC_APP_ZIP_FILE_NAME);
const canDifferentialDownload = () => {
if (!(0, fs_extra_1.pathExistsSync)(cachedFile)) {
log.info("Unable to locate previous update.zip for differential download (is this first install?), falling back to full download");
return false;
}
return !downloadUpdateOptions.disableDifferentialDownload;
};
if (canDifferentialDownload() && (await this.differentialDownloadInstaller(zipFileInfo, downloadUpdateOptions, destinationFile, provider, CURRENT_MAC_APP_ZIP_FILE_NAME))) {
await this.httpExecutor.download(zipFileInfo.url, destinationFile, downloadOptions);
}
(0, fs_1.copyFileSync)(destinationFile, cachedFile);
task: (destinationFile, downloadOptions) => {
return this.httpExecutor.download(zipFileInfo.url, destinationFile, downloadOptions);
},

@@ -110,3 +85,3 @@ done: event => this.updateDownloaded(zipFileInfo, event),

async updateDownloaded(zipFileInfo, event) {
var _a;
var _a, _b;
const downloadedFile = event.downloadedFile;

@@ -116,4 +91,4 @@ const updateFileSize = (_a = zipFileInfo.info.size) !== null && _a !== void 0 ? _a : (await (0, fs_extra_1.stat)(downloadedFile)).size;

const logContext = `fileToProxy=${zipFileInfo.url.href}`;
this.closeServerIfExists();
this.debug(`Creating proxy server for native Squirrel.Mac (${logContext})`);
(_b = this.server) === null || _b === void 0 ? void 0 : _b.close();
this.server = (0, http_1.createServer)();

@@ -221,6 +196,7 @@ this.debug(`Proxy server for native Squirrel.Mac is created (${logContext})`);

quitAndInstall() {
var _a;
if (this.squirrelDownloadedUpdate) {
// update already fetched by Squirrel, it's ready to install
this.nativeUpdater.quitAndInstall();
this.closeServerIfExists();
(_a = this.server) === null || _a === void 0 ? void 0 : _a.close();
}

@@ -230,4 +206,5 @@ else {

this.nativeUpdater.on("update-downloaded", () => {
var _a;
this.nativeUpdater.quitAndInstall();
this.closeServerIfExists();
(_a = this.server) === null || _a === void 0 ? void 0 : _a.close();
});

@@ -234,0 +211,0 @@ if (!this.autoInstallOnAppQuit) {

@@ -24,3 +24,4 @@ import { AllPublishOptions } from "builder-util-runtime";

protected doInstall(options: InstallOptions): boolean;
private differentialDownloadInstaller;
private differentialDownloadWebPackage;
}

@@ -8,3 +8,5 @@ "use strict";

const FileWithEmbeddedBlockMapDifferentialDownloader_1 = require("./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader");
const GenericDifferentialDownloader_1 = require("./differentialDownloader/GenericDifferentialDownloader");
const main_1 = require("./main");
const util_1 = require("./util");
const Provider_1 = require("./providers/Provider");

@@ -14,2 +16,3 @@ const fs_extra_1 = require("fs-extra");

const url_1 = require("url");
const zlib_1 = require("zlib");
class NsisUpdater extends BaseUpdater_1.BaseUpdater {

@@ -51,3 +54,3 @@ constructor(options, app) {

downloadUpdateOptions.disableDifferentialDownload ||
(await this.differentialDownloadInstaller(fileInfo, downloadUpdateOptions, destinationFile, provider, builder_util_runtime_1.CURRENT_APP_INSTALLER_FILE_NAME))) {
(await this.differentialDownloadInstaller(fileInfo, downloadUpdateOptions, destinationFile, provider))) {
await this.httpExecutor.download(fileInfo.url, destinationFile, downloadOptions);

@@ -148,2 +151,49 @@ }

}
async differentialDownloadInstaller(fileInfo, downloadUpdateOptions, installerPath, provider) {
try {
if (this._testOnlyOptions != null && !this._testOnlyOptions.isUseDifferentialDownload) {
return true;
}
const blockmapFileUrls = (0, util_1.blockmapFiles)(fileInfo.url, this.app.version, downloadUpdateOptions.updateInfoAndProvider.info.version);
this._logger.info(`Download block maps (old: "${blockmapFileUrls[0]}", new: ${blockmapFileUrls[1]})`);
const downloadBlockMap = async (url) => {
const data = await this.httpExecutor.downloadToBuffer(url, {
headers: downloadUpdateOptions.requestHeaders,
cancellationToken: downloadUpdateOptions.cancellationToken,
});
if (data == null || data.length === 0) {
throw new Error(`Blockmap "${url.href}" is empty`);
}
try {
return JSON.parse((0, zlib_1.gunzipSync)(data).toString());
}
catch (e) {
throw new Error(`Cannot parse blockmap "${url.href}", error: ${e}`);
}
};
const downloadOptions = {
newUrl: fileInfo.url,
oldFile: path.join(this.downloadedUpdateHelper.cacheDir, builder_util_runtime_1.CURRENT_APP_INSTALLER_FILE_NAME),
logger: this._logger,
newFile: installerPath,
isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,
requestHeaders: downloadUpdateOptions.requestHeaders,
cancellationToken: downloadUpdateOptions.cancellationToken,
};
if (this.listenerCount(main_1.DOWNLOAD_PROGRESS) > 0) {
downloadOptions.onProgress = it => this.emit(main_1.DOWNLOAD_PROGRESS, it);
}
const blockMapDataList = await Promise.all(blockmapFileUrls.map(u => downloadBlockMap(u)));
await new GenericDifferentialDownloader_1.GenericDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download(blockMapDataList[0], blockMapDataList[1]);
return false;
}
catch (e) {
this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`);
if (this._testOnlyOptions != null) {
// test mode
throw e;
}
return true;
}
}
async differentialDownloadWebPackage(downloadUpdateOptions, packageInfo, packagePath, provider) {

@@ -150,0 +200,0 @@ if (packageInfo.blockMapSize == null) {

{
"name": "electron-updater",
"version": "6.2.0",
"version": "6.2.1",
"description": "Cross platform updater for electron applications",

@@ -5,0 +5,0 @@ "main": "out/main.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc