electron-updater 6.6.0 → 6.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/out/AppImageUpdater.js +3 -3
  2. package/out/AppImageUpdater.js.map +1 -1
  3. package/out/AppUpdater.d.ts +3 -2
  4. package/out/AppUpdater.js +7 -7
  5. package/out/AppUpdater.js.map +1 -1
  6. package/out/DebUpdater.js +3 -3
  7. package/out/DebUpdater.js.map +1 -1
  8. package/out/DownloadedUpdateHelper.d.ts +2 -1
  9. package/out/DownloadedUpdateHelper.js.map +1 -1
  10. package/out/MacUpdater.js.map +1 -1
  11. package/out/NsisUpdater.js +3 -3
  12. package/out/NsisUpdater.js.map +1 -1
  13. package/out/PacmanUpdater.js +3 -3
  14. package/out/PacmanUpdater.js.map +1 -1
  15. package/out/RpmUpdater.js +3 -3
  16. package/out/RpmUpdater.js.map +1 -1
  17. package/out/differentialDownloader/DifferentialDownloader.d.ts +1 -1
  18. package/out/differentialDownloader/DifferentialDownloader.js.map +1 -1
  19. package/out/differentialDownloader/downloadPlanBuilder.d.ts +1 -1
  20. package/out/differentialDownloader/downloadPlanBuilder.js.map +1 -1
  21. package/out/main.d.ts +2 -42
  22. package/out/main.js +16 -38
  23. package/out/main.js.map +1 -1
  24. package/out/providers/BitbucketProvider.d.ts +1 -1
  25. package/out/providers/BitbucketProvider.js.map +1 -1
  26. package/out/providers/GenericProvider.d.ts +1 -1
  27. package/out/providers/GenericProvider.js.map +1 -1
  28. package/out/providers/GitHubProvider.d.ts +1 -1
  29. package/out/providers/GitHubProvider.js.map +1 -1
  30. package/out/providers/KeygenProvider.d.ts +1 -1
  31. package/out/providers/KeygenProvider.js.map +1 -1
  32. package/out/providers/PrivateGitHubProvider.d.ts +1 -1
  33. package/out/providers/PrivateGitHubProvider.js.map +1 -1
  34. package/out/providers/Provider.d.ts +1 -1
  35. package/out/providers/Provider.js.map +1 -1
  36. package/out/types.d.ts +43 -0
  37. package/out/types.js +42 -0
  38. package/out/types.js.map +1 -0
  39. package/out/windowsExecutableCodeSignatureVerifier.d.ts +1 -1
  40. package/out/windowsExecutableCodeSignatureVerifier.js.map +1 -1
  41. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"MacUpdater.js","sourceRoot":"","sources":["../src/MacUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAqF;AACrF,uCAAyD;AACzD,2BAAqC;AACrC,6BAA4B;AAC5B,+BAA4E;AAE5E,6CAAgE;AAEhE,mDAA+C;AAE/C,iDAA4C;AAC5C,mCAAoC;AAEpC,MAAa,UAAW,SAAQ,uBAAU;IAOxC,YAAY,OAA2B,EAAE,GAAgB;QACvD,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAPJ,kBAAa,GAAgB,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAAA;QAErE,6BAAwB,GAAG,KAAK,CAAA;QAOtC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE;YAClC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACrB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;YAC9C,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAA;YACpC,IAAI,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAA;QAC/C,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,KAAK,CAAC,OAAe;QAC3B,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YAC/B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC7B,CAAC;IACH,CAAC;IAEO,mBAAmB;QACzB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;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;;mBAGG;gBACH,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAA;YACtC,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA5QD,gCA4QC","sourcesContent":["import { AllPublishOptions, newError, safeStringifyJson } from \"builder-util-runtime\"\nimport { pathExistsSync, stat, copyFile } from \"fs-extra\"\nimport { createReadStream } from \"fs\"\nimport * as path from \"path\"\nimport { createServer, IncomingMessage, Server, ServerResponse } from \"http\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { AppUpdater, DownloadUpdateOptions } from \"./AppUpdater\"\nimport { ResolvedUpdateFileInfo, UpdateDownloadedEvent } from \"./main\"\nimport { findFile } from \"./providers/Provider\"\nimport AutoUpdater = Electron.AutoUpdater\nimport { execFileSync } from \"child_process\"\nimport { randomBytes } from \"crypto\"\n\nexport class MacUpdater extends AppUpdater {\n private readonly nativeUpdater: AutoUpdater = require(\"electron\").autoUpdater\n\n private squirrelDownloadedUpdate = false\n\n private server?: Server\n\n constructor(options?: AllPublishOptions, app?: AppAdapter) {\n super(options, app)\n\n this.nativeUpdater.on(\"error\", it => {\n this._logger.warn(it)\n this.emit(\"error\", it)\n })\n this.nativeUpdater.on(\"update-downloaded\", () => {\n this.squirrelDownloadedUpdate = true\n this.debug(\"nativeUpdater.update-downloaded\")\n })\n }\n\n private debug(message: string): void {\n if (this._logger.debug != null) {\n this._logger.debug(message)\n }\n }\n\n private closeServerIfExists() {\n if (this.server) {\n this.debug(\"Closing proxy server\")\n this.server.close(err => {\n if (err) {\n this.debug(\"proxy server wasn't already open, probably attempted closing again as a safety check before quit\")\n }\n })\n }\n }\n\n protected async doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n let files = downloadUpdateOptions.updateInfoAndProvider.provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info)\n\n const log = this._logger\n\n // detect if we are running inside Rosetta emulation\n const sysctlRosettaInfoKey = \"sysctl.proc_translated\"\n let isRosetta = false\n try {\n this.debug(\"Checking for macOS Rosetta environment\")\n const result = execFileSync(\"sysctl\", [sysctlRosettaInfoKey], { encoding: \"utf8\" })\n isRosetta = result.includes(`${sysctlRosettaInfoKey}: 1`)\n log.info(`Checked for macOS Rosetta environment (isRosetta=${isRosetta})`)\n } catch (e: any) {\n log.warn(`sysctl shell command to check for macOS Rosetta environment failed: ${e}`)\n }\n\n let isArm64Mac = false\n try {\n this.debug(\"Checking for arm64 in uname\")\n const result = execFileSync(\"uname\", [\"-a\"], { encoding: \"utf8\" })\n const isArm = result.includes(\"ARM\")\n log.info(`Checked 'uname -a': arm64=${isArm}`)\n isArm64Mac = isArm64Mac || isArm\n } catch (e: any) {\n log.warn(`uname shell command to check for arm64 failed: ${e}`)\n }\n\n isArm64Mac = isArm64Mac || process.arch === \"arm64\" || isRosetta\n\n // allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524\n const isArm64 = (file: ResolvedUpdateFileInfo) => file.url.pathname.includes(\"arm64\") || file.info.url?.includes(\"arm64\")\n if (isArm64Mac && files.some(isArm64)) {\n files = files.filter(file => isArm64Mac === isArm64(file))\n } else {\n files = files.filter(file => !isArm64(file))\n }\n\n const zipFileInfo = findFile(files, \"zip\", [\"pkg\", \"dmg\"])\n\n if (zipFileInfo == null) {\n throw newError(`ZIP file not provided: ${safeStringifyJson(files)}`, \"ERR_UPDATER_ZIP_FILE_NOT_FOUND\")\n }\n\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const CURRENT_MAC_APP_ZIP_FILE_NAME = \"update.zip\"\n\n return this.executeDownload({\n fileExtension: \"zip\",\n fileInfo: zipFileInfo,\n downloadUpdateOptions,\n task: async (destinationFile, downloadOptions) => {\n const cachedUpdateFilePath = path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_MAC_APP_ZIP_FILE_NAME)\n const canDifferentialDownload = () => {\n if (!pathExistsSync(cachedUpdateFilePath)) {\n log.info(\"Unable to locate previous update.zip for differential download (is this first install?), falling back to full download\")\n return false\n }\n return !downloadUpdateOptions.disableDifferentialDownload\n }\n let differentialDownloadFailed = true\n if (canDifferentialDownload()) {\n differentialDownloadFailed = await this.differentialDownloadInstaller(zipFileInfo, downloadUpdateOptions, destinationFile, provider, CURRENT_MAC_APP_ZIP_FILE_NAME)\n }\n\n if (differentialDownloadFailed) {\n await this.httpExecutor.download(zipFileInfo.url, destinationFile, downloadOptions)\n }\n },\n done: async event => {\n if (!downloadUpdateOptions.disableDifferentialDownload) {\n try {\n const cachedUpdateFilePath = path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_MAC_APP_ZIP_FILE_NAME)\n await copyFile(event.downloadedFile, cachedUpdateFilePath)\n } catch (error: any) {\n this._logger.warn(`Unable to copy file for caching for future differential downloads: ${error.message}`)\n }\n }\n return this.updateDownloaded(zipFileInfo, event)\n },\n })\n }\n\n private async updateDownloaded(zipFileInfo: ResolvedUpdateFileInfo, event: UpdateDownloadedEvent): Promise<Array<string>> {\n const downloadedFile = event.downloadedFile\n const updateFileSize = zipFileInfo.info.size ?? (await stat(downloadedFile)).size\n\n const log = this._logger\n const logContext = `fileToProxy=${zipFileInfo.url.href}`\n this.closeServerIfExists()\n this.debug(`Creating proxy server for native Squirrel.Mac (${logContext})`)\n this.server = createServer()\n this.debug(`Proxy server for native Squirrel.Mac is created (${logContext})`)\n this.server.on(\"close\", () => {\n log.info(`Proxy server for native Squirrel.Mac is closed (${logContext})`)\n })\n\n // must be called after server is listening, otherwise address is null\n const getServerUrl = (s: Server): string => {\n const address = s.address()\n if (typeof address === \"string\") {\n return address\n }\n return `http://127.0.0.1:${address?.port}`\n }\n\n return await new Promise<Array<string>>((resolve, reject) => {\n const pass = randomBytes(64).toString(\"base64\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\")\n const authInfo = Buffer.from(`autoupdater:${pass}`, \"ascii\")\n\n // insecure random is ok\n const fileUrl = `/${randomBytes(64).toString(\"hex\")}.zip`\n this.server!.on(\"request\", (request: IncomingMessage, response: ServerResponse) => {\n const requestUrl = request.url!\n log.info(`${requestUrl} requested`)\n if (requestUrl === \"/\") {\n // check for basic auth header\n if (!request.headers.authorization || request.headers.authorization.indexOf(\"Basic \") === -1) {\n response.statusCode = 401\n response.statusMessage = \"Invalid Authentication Credentials\"\n response.end()\n log.warn(\"No authenthication info\")\n return\n }\n\n // verify auth credentials\n const base64Credentials = request.headers.authorization.split(\" \")[1]\n const credentials = Buffer.from(base64Credentials, \"base64\").toString(\"ascii\")\n const [username, password] = credentials.split(\":\")\n if (username !== \"autoupdater\" || password !== pass) {\n response.statusCode = 401\n response.statusMessage = \"Invalid Authentication Credentials\"\n response.end()\n log.warn(\"Invalid authenthication credentials\")\n return\n }\n\n const data = Buffer.from(`{ \"url\": \"${getServerUrl(this.server!)}${fileUrl}\" }`)\n response.writeHead(200, { \"Content-Type\": \"application/json\", \"Content-Length\": data.length })\n response.end(data)\n return\n }\n\n if (!requestUrl.startsWith(fileUrl)) {\n log.warn(`${requestUrl} requested, but not supported`)\n response.writeHead(404)\n response.end()\n return\n }\n\n log.info(`${fileUrl} requested by Squirrel.Mac, pipe ${downloadedFile}`)\n\n let errorOccurred = false\n response.on(\"finish\", () => {\n if (!errorOccurred) {\n this.nativeUpdater.removeListener(\"error\", reject)\n resolve([])\n }\n })\n\n const readStream = createReadStream(downloadedFile)\n readStream.on(\"error\", error => {\n try {\n response.end()\n } catch (e: any) {\n log.warn(`cannot end response: ${e}`)\n }\n errorOccurred = true\n this.nativeUpdater.removeListener(\"error\", reject)\n reject(new Error(`Cannot pipe \"${downloadedFile}\": ${error}`))\n })\n\n response.writeHead(200, {\n \"Content-Type\": \"application/zip\",\n \"Content-Length\": updateFileSize,\n })\n readStream.pipe(response)\n })\n\n this.debug(`Proxy server for native Squirrel.Mac is starting to listen (${logContext})`)\n\n this.server!.listen(0, \"127.0.0.1\", () => {\n this.debug(`Proxy server for native Squirrel.Mac is listening (address=${getServerUrl(this.server!)}, ${logContext})`)\n this.nativeUpdater.setFeedURL({\n url: getServerUrl(this.server!),\n headers: {\n \"Cache-Control\": \"no-cache\",\n Authorization: `Basic ${authInfo.toString(\"base64\")}`,\n },\n })\n\n // The update has been downloaded and is ready to be served to Squirrel\n this.dispatchUpdateDownloaded(event)\n\n if (this.autoInstallOnAppQuit) {\n this.nativeUpdater.once(\"error\", reject)\n // This will trigger fetching and installing the file on Squirrel side\n this.nativeUpdater.checkForUpdates()\n } else {\n resolve([])\n }\n })\n })\n }\n\n private handleUpdateDownloaded() {\n if (this.autoRunAppAfterInstall) {\n this.nativeUpdater.quitAndInstall()\n } else {\n this.app.quit()\n }\n this.closeServerIfExists()\n }\n\n quitAndInstall(): void {\n if (this.squirrelDownloadedUpdate) {\n // update already fetched by Squirrel, it's ready to install\n this.handleUpdateDownloaded()\n } else {\n // Quit and install as soon as Squirrel get the update\n this.nativeUpdater.on(\"update-downloaded\", () => this.handleUpdateDownloaded())\n\n if (!this.autoInstallOnAppQuit) {\n /**\n * If this was not `true` previously then MacUpdater.doDownloadUpdate()\n * would not actually initiate the downloading by electron's autoUpdater\n */\n this.nativeUpdater.checkForUpdates()\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"MacUpdater.js","sourceRoot":"","sources":["../src/MacUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAqF;AACrF,uCAAyD;AACzD,2BAAqC;AACrC,6BAA4B;AAC5B,+BAA4E;AAE5E,6CAAgE;AAGhE,mDAA+C;AAE/C,iDAA4C;AAC5C,mCAAoC;AAEpC,MAAa,UAAW,SAAQ,uBAAU;IAOxC,YAAY,OAA2B,EAAE,GAAgB;QACvD,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAPJ,kBAAa,GAAgB,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAAA;QAErE,6BAAwB,GAAG,KAAK,CAAA;QAOtC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE;YAClC,IAAI,CAAC,OAAO,CAAC,IAA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5B,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAChC,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAA;QACrC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;QACjB,CAAC;QACD,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED,cAAc;QACZ,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAClC,4DAA4D;YAC5D,IAAI,CAAC,sBAAsB,EAAE,CAAA;QAC/B,CAAC;aAAM,CAAC;YACN,sDAAsD;YACtD,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAA;YAE/E,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAC/B;;;mBAGG;gBACH,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAA;YACtC,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA5QD,gCA4QC","sourcesContent":["import { AllPublishOptions, newError, safeStringifyJson } from \"builder-util-runtime\"\nimport { pathExistsSync, stat, copyFile } from \"fs-extra\"\nimport { createReadStream } from \"fs\"\nimport * as path from \"path\"\nimport { createServer, IncomingMessage, Server, ServerResponse } from \"http\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { AppUpdater, DownloadUpdateOptions } from \"./AppUpdater\"\nimport { ResolvedUpdateFileInfo } from \"./main\"\nimport { UpdateDownloadedEvent } from \"./types\"\nimport { findFile } from \"./providers/Provider\"\nimport AutoUpdater = Electron.AutoUpdater\nimport { execFileSync } from \"child_process\"\nimport { randomBytes } from \"crypto\"\n\nexport class MacUpdater extends AppUpdater {\n private readonly nativeUpdater: AutoUpdater = require(\"electron\").autoUpdater\n\n private squirrelDownloadedUpdate = false\n\n private server?: Server\n\n constructor(options?: AllPublishOptions, app?: AppAdapter) {\n super(options, app)\n\n this.nativeUpdater.on(\"error\", it => {\n this._logger.warn(it)\n this.emit(\"error\", it)\n })\n this.nativeUpdater.on(\"update-downloaded\", () => {\n this.squirrelDownloadedUpdate = true\n this.debug(\"nativeUpdater.update-downloaded\")\n })\n }\n\n private debug(message: string): void {\n if (this._logger.debug != null) {\n this._logger.debug(message)\n }\n }\n\n private closeServerIfExists() {\n if (this.server) {\n this.debug(\"Closing proxy server\")\n this.server.close(err => {\n if (err) {\n this.debug(\"proxy server wasn't already open, probably attempted closing again as a safety check before quit\")\n }\n })\n }\n }\n\n protected async doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n let files = downloadUpdateOptions.updateInfoAndProvider.provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info)\n\n const log = this._logger\n\n // detect if we are running inside Rosetta emulation\n const sysctlRosettaInfoKey = \"sysctl.proc_translated\"\n let isRosetta = false\n try {\n this.debug(\"Checking for macOS Rosetta environment\")\n const result = execFileSync(\"sysctl\", [sysctlRosettaInfoKey], { encoding: \"utf8\" })\n isRosetta = result.includes(`${sysctlRosettaInfoKey}: 1`)\n log.info(`Checked for macOS Rosetta environment (isRosetta=${isRosetta})`)\n } catch (e: any) {\n log.warn(`sysctl shell command to check for macOS Rosetta environment failed: ${e}`)\n }\n\n let isArm64Mac = false\n try {\n this.debug(\"Checking for arm64 in uname\")\n const result = execFileSync(\"uname\", [\"-a\"], { encoding: \"utf8\" })\n const isArm = result.includes(\"ARM\")\n log.info(`Checked 'uname -a': arm64=${isArm}`)\n isArm64Mac = isArm64Mac || isArm\n } catch (e: any) {\n log.warn(`uname shell command to check for arm64 failed: ${e}`)\n }\n\n isArm64Mac = isArm64Mac || process.arch === \"arm64\" || isRosetta\n\n // allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524\n const isArm64 = (file: ResolvedUpdateFileInfo) => file.url.pathname.includes(\"arm64\") || file.info.url?.includes(\"arm64\")\n if (isArm64Mac && files.some(isArm64)) {\n files = files.filter(file => isArm64Mac === isArm64(file))\n } else {\n files = files.filter(file => !isArm64(file))\n }\n\n const zipFileInfo = findFile(files, \"zip\", [\"pkg\", \"dmg\"])\n\n if (zipFileInfo == null) {\n throw newError(`ZIP file not provided: ${safeStringifyJson(files)}`, \"ERR_UPDATER_ZIP_FILE_NOT_FOUND\")\n }\n\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const CURRENT_MAC_APP_ZIP_FILE_NAME = \"update.zip\"\n\n return this.executeDownload({\n fileExtension: \"zip\",\n fileInfo: zipFileInfo,\n downloadUpdateOptions,\n task: async (destinationFile, downloadOptions) => {\n const cachedUpdateFilePath = path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_MAC_APP_ZIP_FILE_NAME)\n const canDifferentialDownload = () => {\n if (!pathExistsSync(cachedUpdateFilePath)) {\n log.info(\"Unable to locate previous update.zip for differential download (is this first install?), falling back to full download\")\n return false\n }\n return !downloadUpdateOptions.disableDifferentialDownload\n }\n let differentialDownloadFailed = true\n if (canDifferentialDownload()) {\n differentialDownloadFailed = await this.differentialDownloadInstaller(zipFileInfo, downloadUpdateOptions, destinationFile, provider, CURRENT_MAC_APP_ZIP_FILE_NAME)\n }\n\n if (differentialDownloadFailed) {\n await this.httpExecutor.download(zipFileInfo.url, destinationFile, downloadOptions)\n }\n },\n done: async event => {\n if (!downloadUpdateOptions.disableDifferentialDownload) {\n try {\n const cachedUpdateFilePath = path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_MAC_APP_ZIP_FILE_NAME)\n await copyFile(event.downloadedFile, cachedUpdateFilePath)\n } catch (error: any) {\n this._logger.warn(`Unable to copy file for caching for future differential downloads: ${error.message}`)\n }\n }\n return this.updateDownloaded(zipFileInfo, event)\n },\n })\n }\n\n private async updateDownloaded(zipFileInfo: ResolvedUpdateFileInfo, event: UpdateDownloadedEvent): Promise<Array<string>> {\n const downloadedFile = event.downloadedFile\n const updateFileSize = zipFileInfo.info.size ?? (await stat(downloadedFile)).size\n\n const log = this._logger\n const logContext = `fileToProxy=${zipFileInfo.url.href}`\n this.closeServerIfExists()\n this.debug(`Creating proxy server for native Squirrel.Mac (${logContext})`)\n this.server = createServer()\n this.debug(`Proxy server for native Squirrel.Mac is created (${logContext})`)\n this.server.on(\"close\", () => {\n log.info(`Proxy server for native Squirrel.Mac is closed (${logContext})`)\n })\n\n // must be called after server is listening, otherwise address is null\n const getServerUrl = (s: Server): string => {\n const address = s.address()\n if (typeof address === \"string\") {\n return address\n }\n return `http://127.0.0.1:${address?.port}`\n }\n\n return await new Promise<Array<string>>((resolve, reject) => {\n const pass = randomBytes(64).toString(\"base64\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\")\n const authInfo = Buffer.from(`autoupdater:${pass}`, \"ascii\")\n\n // insecure random is ok\n const fileUrl = `/${randomBytes(64).toString(\"hex\")}.zip`\n this.server!.on(\"request\", (request: IncomingMessage, response: ServerResponse) => {\n const requestUrl = request.url!\n log.info(`${requestUrl} requested`)\n if (requestUrl === \"/\") {\n // check for basic auth header\n if (!request.headers.authorization || request.headers.authorization.indexOf(\"Basic \") === -1) {\n response.statusCode = 401\n response.statusMessage = \"Invalid Authentication Credentials\"\n response.end()\n log.warn(\"No authenthication info\")\n return\n }\n\n // verify auth credentials\n const base64Credentials = request.headers.authorization.split(\" \")[1]\n const credentials = Buffer.from(base64Credentials, \"base64\").toString(\"ascii\")\n const [username, password] = credentials.split(\":\")\n if (username !== \"autoupdater\" || password !== pass) {\n response.statusCode = 401\n response.statusMessage = \"Invalid Authentication Credentials\"\n response.end()\n log.warn(\"Invalid authenthication credentials\")\n return\n }\n\n const data = Buffer.from(`{ \"url\": \"${getServerUrl(this.server!)}${fileUrl}\" }`)\n response.writeHead(200, { \"Content-Type\": \"application/json\", \"Content-Length\": data.length })\n response.end(data)\n return\n }\n\n if (!requestUrl.startsWith(fileUrl)) {\n log.warn(`${requestUrl} requested, but not supported`)\n response.writeHead(404)\n response.end()\n return\n }\n\n log.info(`${fileUrl} requested by Squirrel.Mac, pipe ${downloadedFile}`)\n\n let errorOccurred = false\n response.on(\"finish\", () => {\n if (!errorOccurred) {\n this.nativeUpdater.removeListener(\"error\", reject)\n resolve([])\n }\n })\n\n const readStream = createReadStream(downloadedFile)\n readStream.on(\"error\", error => {\n try {\n response.end()\n } catch (e: any) {\n log.warn(`cannot end response: ${e}`)\n }\n errorOccurred = true\n this.nativeUpdater.removeListener(\"error\", reject)\n reject(new Error(`Cannot pipe \"${downloadedFile}\": ${error}`))\n })\n\n response.writeHead(200, {\n \"Content-Type\": \"application/zip\",\n \"Content-Length\": updateFileSize,\n })\n readStream.pipe(response)\n })\n\n this.debug(`Proxy server for native Squirrel.Mac is starting to listen (${logContext})`)\n\n this.server!.listen(0, \"127.0.0.1\", () => {\n this.debug(`Proxy server for native Squirrel.Mac is listening (address=${getServerUrl(this.server!)}, ${logContext})`)\n this.nativeUpdater.setFeedURL({\n url: getServerUrl(this.server!),\n headers: {\n \"Cache-Control\": \"no-cache\",\n Authorization: `Basic ${authInfo.toString(\"base64\")}`,\n },\n })\n\n // The update has been downloaded and is ready to be served to Squirrel\n this.dispatchUpdateDownloaded(event)\n\n if (this.autoInstallOnAppQuit) {\n this.nativeUpdater.once(\"error\", reject)\n // This will trigger fetching and installing the file on Squirrel side\n this.nativeUpdater.checkForUpdates()\n } else {\n resolve([])\n }\n })\n })\n }\n\n private handleUpdateDownloaded() {\n if (this.autoRunAppAfterInstall) {\n this.nativeUpdater.quitAndInstall()\n } else {\n this.app.quit()\n }\n this.closeServerIfExists()\n }\n\n quitAndInstall(): void {\n if (this.squirrelDownloadedUpdate) {\n // update already fetched by Squirrel, it's ready to install\n this.handleUpdateDownloaded()\n } else {\n // Quit and install as soon as Squirrel get the update\n this.nativeUpdater.on(\"update-downloaded\", () => this.handleUpdateDownloaded())\n\n if (!this.autoInstallOnAppQuit) {\n /**\n * If this was not `true` previously then MacUpdater.doDownloadUpdate()\n * would not actually initiate the downloading by electron's autoUpdater\n */\n this.nativeUpdater.checkForUpdates()\n }\n }\n }\n}\n"]}
@@ -5,7 +5,7 @@ const builder_util_runtime_1 = require("builder-util-runtime");
5
5
  const path = require("path");
6
6
  const BaseUpdater_1 = require("./BaseUpdater");
7
7
  const FileWithEmbeddedBlockMapDifferentialDownloader_1 = require("./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader");
8
- const main_1 = require("./main");
8
+ const types_1 = require("./types");
9
9
  const Provider_1 = require("./providers/Provider");
10
10
  const fs_extra_1 = require("fs-extra");
11
11
  const windowsExecutableCodeSignatureVerifier_1 = require("./windowsExecutableCodeSignatureVerifier");
@@ -161,8 +161,8 @@ class NsisUpdater extends BaseUpdater_1.BaseUpdater {
161
161
  isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,
162
162
  cancellationToken: downloadUpdateOptions.cancellationToken,
163
163
  };
164
- if (this.listenerCount(main_1.DOWNLOAD_PROGRESS) > 0) {
165
- downloadOptions.onProgress = it => this.emit(main_1.DOWNLOAD_PROGRESS, it);
164
+ if (this.listenerCount(types_1.DOWNLOAD_PROGRESS) > 0) {
165
+ downloadOptions.onProgress = it => this.emit(types_1.DOWNLOAD_PROGRESS, it);
166
166
  }
167
167
  await new FileWithEmbeddedBlockMapDifferentialDownloader_1.FileWithEmbeddedBlockMapDifferentialDownloader(packageInfo, this.httpExecutor, downloadOptions).download();
168
168
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NsisUpdater.js","sourceRoot":"","sources":["../src/NsisUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAmJ;AACnJ,6BAA4B;AAG5B,+CAA2D;AAE3D,4IAAwI;AACxI,iCAAqE;AACrE,mDAAyD;AACzD,uCAAiC;AACjC,qGAA0E;AAC1E,6BAAyB;AAEzB,MAAa,WAAY,SAAQ,yBAAW;IAO1C,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAGX,+BAA0B,GAA8B,CAAC,cAA6B,EAAE,uBAA+B,E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QACtH,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAA;YAChG,mEAAmE;YACnE,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;QACrC,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AAzMD,kCAyMC","sourcesContent":["import { AllPublishOptions, newError, PackageFileInfo, CURRENT_APP_INSTALLER_FILE_NAME, CURRENT_APP_PACKAGE_FILE_NAME } from \"builder-util-runtime\"\nimport * as path from \"path\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader\"\nimport { FileWithEmbeddedBlockMapDifferentialDownloader } from \"./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader\"\nimport { DOWNLOAD_PROGRESS, VerifyUpdateCodeSignature } from \"./main\"\nimport { findFile, Provider } from \"./providers/Provider\"\nimport { unlink } from \"fs-extra\"\nimport { verifySignature } from \"./windowsExecutableCodeSignatureVerifier\"\nimport { URL } from \"url\"\n\nexport class NsisUpdater extends BaseUpdater {\n /**\n * Specify custom install directory path\n *\n */\n installDirectory?: string\n\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n protected _verifyUpdateCodeSignature: VerifyUpdateCodeSignature = (publisherNames: Array<string>, unescapedTempUpdateFile: string) =>\n verifySignature(publisherNames, unescapedTempUpdateFile, this._logger)\n\n /**\n * The verifyUpdateCodeSignature. You can pass [win-verify-signature](https://github.com/beyondkmp/win-verify-trust) or another custom verify function: ` (publisherName: string[], path: string) => Promise<string | null>`.\n * The default verify function uses [windowsExecutableCodeSignatureVerifier](https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts)\n */\n get verifyUpdateCodeSignature(): VerifyUpdateCodeSignature {\n return this._verifyUpdateCodeSignature\n }\n\n set verifyUpdateCodeSignature(value: VerifyUpdateCodeSignature) {\n if (value) {\n this._verifyUpdateCodeSignature = value\n }\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"exe\")!\n return this.executeDownload({\n fileExtension: \"exe\",\n downloadUpdateOptions,\n fileInfo,\n task: async (destinationFile, downloadOptions, packageFile, removeTempDirIfAny) => {\n const packageInfo = fileInfo.packageInfo\n const isWebInstaller = packageInfo != null && packageFile != null\n if (isWebInstaller && downloadUpdateOptions.disableWebInstaller) {\n throw newError(\n `Unable to download new version ${downloadUpdateOptions.updateInfoAndProvider.info.version}. Web Installers are disabled`,\n \"ERR_UPDATER_WEB_INSTALLER_DISABLED\"\n )\n }\n if (!isWebInstaller && !downloadUpdateOptions.disableWebInstaller) {\n this._logger.warn(\n \"disableWebInstaller is set to false, you should set it to true if you do not plan on using a web installer. This will default to true in a future version.\"\n )\n }\n if (\n isWebInstaller ||\n downloadUpdateOptions.disableDifferentialDownload ||\n (await this.differentialDownloadInstaller(fileInfo, downloadUpdateOptions, destinationFile, provider, CURRENT_APP_INSTALLER_FILE_NAME))\n ) {\n await this.httpExecutor.download(fileInfo.url, destinationFile, downloadOptions)\n }\n\n const signatureVerificationStatus = await this.verifySignature(destinationFile)\n if (signatureVerificationStatus != null) {\n await removeTempDirIfAny()\n // noinspection ThrowInsideFinallyBlockJS\n throw newError(\n `New version ${downloadUpdateOptions.updateInfoAndProvider.info.version} is not signed by the application owner: ${signatureVerificationStatus}`,\n \"ERR_UPDATER_INVALID_SIGNATURE\"\n )\n }\n\n if (isWebInstaller) {\n if (await this.differentialDownloadWebPackage(downloadUpdateOptions, packageInfo, packageFile, provider)) {\n try {\n await this.httpExecutor.download(new URL(packageInfo.path), packageFile, {\n headers: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n sha512: packageInfo.sha512,\n })\n } catch (e: any) {\n try {\n await unlink(packageFile)\n } catch (_ignored) {\n // ignore\n }\n\n throw e\n }\n }\n }\n },\n })\n }\n\n // $certificateInfo = (Get-AuthenticodeSignature 'xxx\\yyy.exe'\n // | where {$_.Status.Equals([System.Management.Automation.SignatureStatus]::Valid) -and $_.SignerCertificate.Subject.Contains(\"CN=siemens.com\")})\n // | Out-String ; if ($certificateInfo) { exit 0 } else { exit 1 }\n private async verifySignature(tempUpdateFile: string): Promise<string | null> {\n let publisherName: Array<string> | string | null\n try {\n publisherName = (await this.configOnDisk.value).publisherName\n if (publisherName == null) {\n return null\n }\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n // no app-update.yml\n return null\n }\n throw e\n }\n return await this._verifyUpdateCodeSignature(Array.isArray(publisherName) ? publisherName : [publisherName], tempUpdateFile)\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No valid update available, can't quit and install\"))\n return false\n }\n\n const args = [\"--updated\"]\n if (options.isSilent) {\n args.push(\"/S\")\n }\n\n if (options.isForceRunAfter) {\n args.push(\"--force-run\")\n }\n\n if (this.installDirectory) {\n // maybe check if folder exists\n args.push(`/D=${this.installDirectory}`)\n }\n\n const packagePath = this.downloadedUpdateHelper == null ? null : this.downloadedUpdateHelper.packageFile\n if (packagePath != null) {\n // only = form is supported\n args.push(`--package-file=${packagePath}`)\n }\n\n const callUsingElevation = (): void => {\n this.spawnLog(path.join(process.resourcesPath, \"elevate.exe\"), [installerPath].concat(args)).catch(e => this.dispatchError(e))\n }\n\n if (options.isAdminRightsRequired) {\n this._logger.info(\"isAdminRightsRequired is set to true, run installer using elevate.exe\")\n callUsingElevation()\n return true\n }\n\n this.spawnLog(installerPath, args).catch((e: Error) => {\n // https://github.com/electron-userland/electron-builder/issues/1129\n // Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors\n const errorCode = (e as NodeJS.ErrnoException).code\n this._logger.info(\n `Cannot run installer: error code: ${errorCode}, error message: \"${e.message}\", will be executed again using elevate if EACCES, and will try to use electron.shell.openItem if ENOENT`\n )\n if (errorCode === \"UNKNOWN\" || errorCode === \"EACCES\") {\n callUsingElevation()\n } else if (errorCode === \"ENOENT\") {\n require(\"electron\")\n .shell.openPath(installerPath)\n .catch((err: Error) => this.dispatchError(err))\n } else {\n this.dispatchError(e)\n }\n })\n return true\n }\n\n private async differentialDownloadWebPackage(\n downloadUpdateOptions: DownloadUpdateOptions,\n packageInfo: PackageFileInfo,\n packagePath: string,\n provider: Provider<any>\n ): Promise<boolean> {\n if (packageInfo.blockMapSize == null) {\n return true\n }\n\n try {\n const downloadOptions: DifferentialDownloaderOptions = {\n newUrl: new URL(packageInfo.path),\n oldFile: path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_APP_PACKAGE_FILE_NAME),\n logger: this._logger,\n newFile: packagePath,\n requestHeaders: this.requestHeaders,\n isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n await new FileWithEmbeddedBlockMapDifferentialDownloader(packageInfo, this.httpExecutor, downloadOptions).download()\n } catch (e: any) {\n this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)\n // during test (developer machine mac or linux) we must throw error\n return process.platform === \"win32\"\n }\n return false\n }\n}\n"]}
1
+ {"version":3,"file":"NsisUpdater.js","sourceRoot":"","sources":["../src/NsisUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAmJ;AACnJ,6BAA4B;AAG5B,+CAA2D;AAE3D,4IAAwI;AACxI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,CAAC;gBAC9C,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAiB,EAAE,EAAE,CAAC,CAAA;YACrE,CAAC;YAED,MAAM,IAAI,+FAA8C,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAA;QACtH,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAA;YAChG,mEAAmE;YACnE,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;QACrC,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AAzMD,kCAyMC","sourcesContent":["import { AllPublishOptions, newError, PackageFileInfo, CURRENT_APP_INSTALLER_FILE_NAME, CURRENT_APP_PACKAGE_FILE_NAME } from \"builder-util-runtime\"\nimport * as path from \"path\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader\"\nimport { FileWithEmbeddedBlockMapDifferentialDownloader } from \"./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader\"\nimport { DOWNLOAD_PROGRESS } from \"./types\"\nimport { VerifyUpdateCodeSignature } from \"./main\"\nimport { findFile, Provider } from \"./providers/Provider\"\nimport { unlink } from \"fs-extra\"\nimport { verifySignature } from \"./windowsExecutableCodeSignatureVerifier\"\nimport { URL } from \"url\"\n\nexport class NsisUpdater extends BaseUpdater {\n /**\n * Specify custom install directory path\n *\n */\n installDirectory?: string\n\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n protected _verifyUpdateCodeSignature: VerifyUpdateCodeSignature = (publisherNames: Array<string>, unescapedTempUpdateFile: string) =>\n verifySignature(publisherNames, unescapedTempUpdateFile, this._logger)\n\n /**\n * The verifyUpdateCodeSignature. You can pass [win-verify-signature](https://github.com/beyondkmp/win-verify-trust) or another custom verify function: ` (publisherName: string[], path: string) => Promise<string | null>`.\n * The default verify function uses [windowsExecutableCodeSignatureVerifier](https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts)\n */\n get verifyUpdateCodeSignature(): VerifyUpdateCodeSignature {\n return this._verifyUpdateCodeSignature\n }\n\n set verifyUpdateCodeSignature(value: VerifyUpdateCodeSignature) {\n if (value) {\n this._verifyUpdateCodeSignature = value\n }\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"exe\")!\n return this.executeDownload({\n fileExtension: \"exe\",\n downloadUpdateOptions,\n fileInfo,\n task: async (destinationFile, downloadOptions, packageFile, removeTempDirIfAny) => {\n const packageInfo = fileInfo.packageInfo\n const isWebInstaller = packageInfo != null && packageFile != null\n if (isWebInstaller && downloadUpdateOptions.disableWebInstaller) {\n throw newError(\n `Unable to download new version ${downloadUpdateOptions.updateInfoAndProvider.info.version}. Web Installers are disabled`,\n \"ERR_UPDATER_WEB_INSTALLER_DISABLED\"\n )\n }\n if (!isWebInstaller && !downloadUpdateOptions.disableWebInstaller) {\n this._logger.warn(\n \"disableWebInstaller is set to false, you should set it to true if you do not plan on using a web installer. This will default to true in a future version.\"\n )\n }\n if (\n isWebInstaller ||\n downloadUpdateOptions.disableDifferentialDownload ||\n (await this.differentialDownloadInstaller(fileInfo, downloadUpdateOptions, destinationFile, provider, CURRENT_APP_INSTALLER_FILE_NAME))\n ) {\n await this.httpExecutor.download(fileInfo.url, destinationFile, downloadOptions)\n }\n\n const signatureVerificationStatus = await this.verifySignature(destinationFile)\n if (signatureVerificationStatus != null) {\n await removeTempDirIfAny()\n // noinspection ThrowInsideFinallyBlockJS\n throw newError(\n `New version ${downloadUpdateOptions.updateInfoAndProvider.info.version} is not signed by the application owner: ${signatureVerificationStatus}`,\n \"ERR_UPDATER_INVALID_SIGNATURE\"\n )\n }\n\n if (isWebInstaller) {\n if (await this.differentialDownloadWebPackage(downloadUpdateOptions, packageInfo, packageFile, provider)) {\n try {\n await this.httpExecutor.download(new URL(packageInfo.path), packageFile, {\n headers: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n sha512: packageInfo.sha512,\n })\n } catch (e: any) {\n try {\n await unlink(packageFile)\n } catch (_ignored) {\n // ignore\n }\n\n throw e\n }\n }\n }\n },\n })\n }\n\n // $certificateInfo = (Get-AuthenticodeSignature 'xxx\\yyy.exe'\n // | where {$_.Status.Equals([System.Management.Automation.SignatureStatus]::Valid) -and $_.SignerCertificate.Subject.Contains(\"CN=siemens.com\")})\n // | Out-String ; if ($certificateInfo) { exit 0 } else { exit 1 }\n private async verifySignature(tempUpdateFile: string): Promise<string | null> {\n let publisherName: Array<string> | string | null\n try {\n publisherName = (await this.configOnDisk.value).publisherName\n if (publisherName == null) {\n return null\n }\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n // no app-update.yml\n return null\n }\n throw e\n }\n return await this._verifyUpdateCodeSignature(Array.isArray(publisherName) ? publisherName : [publisherName], tempUpdateFile)\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No valid update available, can't quit and install\"))\n return false\n }\n\n const args = [\"--updated\"]\n if (options.isSilent) {\n args.push(\"/S\")\n }\n\n if (options.isForceRunAfter) {\n args.push(\"--force-run\")\n }\n\n if (this.installDirectory) {\n // maybe check if folder exists\n args.push(`/D=${this.installDirectory}`)\n }\n\n const packagePath = this.downloadedUpdateHelper == null ? null : this.downloadedUpdateHelper.packageFile\n if (packagePath != null) {\n // only = form is supported\n args.push(`--package-file=${packagePath}`)\n }\n\n const callUsingElevation = (): void => {\n this.spawnLog(path.join(process.resourcesPath, \"elevate.exe\"), [installerPath].concat(args)).catch(e => this.dispatchError(e))\n }\n\n if (options.isAdminRightsRequired) {\n this._logger.info(\"isAdminRightsRequired is set to true, run installer using elevate.exe\")\n callUsingElevation()\n return true\n }\n\n this.spawnLog(installerPath, args).catch((e: Error) => {\n // https://github.com/electron-userland/electron-builder/issues/1129\n // Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors\n const errorCode = (e as NodeJS.ErrnoException).code\n this._logger.info(\n `Cannot run installer: error code: ${errorCode}, error message: \"${e.message}\", will be executed again using elevate if EACCES, and will try to use electron.shell.openItem if ENOENT`\n )\n if (errorCode === \"UNKNOWN\" || errorCode === \"EACCES\") {\n callUsingElevation()\n } else if (errorCode === \"ENOENT\") {\n require(\"electron\")\n .shell.openPath(installerPath)\n .catch((err: Error) => this.dispatchError(err))\n } else {\n this.dispatchError(e)\n }\n })\n return true\n }\n\n private async differentialDownloadWebPackage(\n downloadUpdateOptions: DownloadUpdateOptions,\n packageInfo: PackageFileInfo,\n packagePath: string,\n provider: Provider<any>\n ): Promise<boolean> {\n if (packageInfo.blockMapSize == null) {\n return true\n }\n\n try {\n const downloadOptions: DifferentialDownloaderOptions = {\n newUrl: new URL(packageInfo.path),\n oldFile: path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_APP_PACKAGE_FILE_NAME),\n logger: this._logger,\n newFile: packagePath,\n requestHeaders: this.requestHeaders,\n isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n await new FileWithEmbeddedBlockMapDifferentialDownloader(packageInfo, this.httpExecutor, downloadOptions).download()\n } catch (e: any) {\n this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)\n // during test (developer machine mac or linux) we must throw error\n return process.platform === \"win32\"\n }\n return false\n }\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PacmanUpdater = void 0;
4
4
  const BaseUpdater_1 = require("./BaseUpdater");
5
- const main_1 = require("./main");
5
+ const types_1 = require("./types");
6
6
  const Provider_1 = require("./providers/Provider");
7
7
  class PacmanUpdater extends BaseUpdater_1.BaseUpdater {
8
8
  constructor(options, app) {
@@ -17,8 +17,8 @@ class PacmanUpdater extends BaseUpdater_1.BaseUpdater {
17
17
  fileInfo,
18
18
  downloadUpdateOptions,
19
19
  task: async (updateFile, downloadOptions) => {
20
- if (this.listenerCount(main_1.DOWNLOAD_PROGRESS) > 0) {
21
- downloadOptions.onProgress = it => this.emit(main_1.DOWNLOAD_PROGRESS, it);
20
+ if (this.listenerCount(types_1.DOWNLOAD_PROGRESS) > 0) {
21
+ downloadOptions.onProgress = it => this.emit(types_1.DOWNLOAD_PROGRESS, it);
22
22
  }
23
23
  await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions);
24
24
  },
@@ -1 +1 @@
1
- {"version":3,"file":"PacmanUpdater.js","sourceRoot":"","sources":["../src/PacmanUpdater.ts"],"names":[],"mappings":";;;AAGA,+CAA2D;AAC3D,iCAA0C;AAC1C,mDAA+C;AAE/C,MAAa,aAAc,SAAQ,yBAAW;IAC5C,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,qBAA4C;QACrE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,QAAQ,CAAA;QACrE,MAAM,QAAQ,GAAG,IAAA,mBAAQ,EAAC,QAAQ,CAAC,YAAY,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,QAA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,EAAE,CAAC,GAAG,OAAO,WAAW,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAA;QACtF,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;YAC5B,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;QACrB,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AA1CD,sCA0CC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DOWNLOAD_PROGRESS } from \"./main\"\nimport { findFile } from \"./providers/Provider\"\n\nexport class PacmanUpdater extends BaseUpdater {\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"pacman\", [\"AppImage\", \"deb\", \"rpm\"])!\n return this.executeDownload({\n fileExtension: \"pacman\",\n fileInfo,\n downloadUpdateOptions,\n task: async (updateFile, downloadOptions) => {\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n },\n })\n }\n\n protected get installerPath(): string | null {\n return super.installerPath?.replace(/ /g, \"\\\\ \") ?? null\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const sudo = this.wrapSudo()\n // pkexec doesn't want the command to be wrapped in \" quotes\n const wrapper = /pkexec/i.test(sudo) ? \"\" : `\"`\n const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No valid update available, can't quit and install\"))\n return false\n }\n const cmd = [\"pacman\", \"-U\", \"--noconfirm\", installerPath]\n this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, \"-c\", `'${cmd.join(\" \")}'${wrapper}`])\n if (options.isForceRunAfter) {\n this.app.relaunch()\n }\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"PacmanUpdater.js","sourceRoot":"","sources":["../src/PacmanUpdater.ts"],"names":[],"mappings":";;;AAGA,+CAA2D;AAC3D,mCAA2C;AAC3C,mDAA+C;AAE/C,MAAa,aAAc,SAAQ,yBAAW;IAC5C,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,qBAA4C;QACrE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,QAAQ,CAAA;QACrE,MAAM,QAAQ,GAAG,IAAA,mBAAQ,EAAC,QAAQ,CAAC,YAAY,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAE,CAAA;QACzI,OAAO,IAAI,CAAC,eAAe,CAAC;YAC1B,aAAa,EAAE,QAAQ;YACvB,QAAQ;YACR,qBAAqB;YACrB,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE;gBAC1C,IAAI,IAAI,CAAC,aAAa,CAAC,yBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC9C,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAiB,EAAE,EAAE,CAAC,CAAA;gBACrE,CAAC;gBACD,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,eAAe,CAAC,CAAA;YAC7E,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;IAED,IAAc,aAAa;;QACzB,OAAO,MAAA,MAAA,KAAK,CAAC,aAAa,0CAAE,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,mCAAI,IAAI,CAAA;IAC1D,CAAC;IAES,SAAS,CAAC,OAAuB;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QAC5B,4DAA4D;QAC5D,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;QAC/C,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAA;QACxC,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;YAC1B,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC,CAAA;YAClF,OAAO,KAAK,CAAA;QACd,CAAC;QACD,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,CAAC,CAAA;QAC1D,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,WAAW,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAA;QACtF,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;YAC5B,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;QACrB,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AA1CD,sCA0CC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DOWNLOAD_PROGRESS } from \"./types\"\nimport { findFile } from \"./providers/Provider\"\n\nexport class PacmanUpdater extends BaseUpdater {\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"pacman\", [\"AppImage\", \"deb\", \"rpm\"])!\n return this.executeDownload({\n fileExtension: \"pacman\",\n fileInfo,\n downloadUpdateOptions,\n task: async (updateFile, downloadOptions) => {\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n },\n })\n }\n\n protected get installerPath(): string | null {\n return super.installerPath?.replace(/ /g, \"\\\\ \") ?? null\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const sudo = this.wrapSudo()\n // pkexec doesn't want the command to be wrapped in \" quotes\n const wrapper = /pkexec/i.test(sudo) ? \"\" : `\"`\n const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No valid update available, can't quit and install\"))\n return false\n }\n const cmd = [\"pacman\", \"-U\", \"--noconfirm\", installerPath]\n this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, \"-c\", `'${cmd.join(\" \")}'${wrapper}`])\n if (options.isForceRunAfter) {\n this.app.relaunch()\n }\n return true\n }\n}\n"]}
package/out/RpmUpdater.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RpmUpdater = void 0;
4
4
  const BaseUpdater_1 = require("./BaseUpdater");
5
- const main_1 = require("./main");
5
+ const types_1 = require("./types");
6
6
  const Provider_1 = require("./providers/Provider");
7
7
  class RpmUpdater extends BaseUpdater_1.BaseUpdater {
8
8
  constructor(options, app) {
@@ -17,8 +17,8 @@ class RpmUpdater extends BaseUpdater_1.BaseUpdater {
17
17
  fileInfo,
18
18
  downloadUpdateOptions,
19
19
  task: async (updateFile, downloadOptions) => {
20
- if (this.listenerCount(main_1.DOWNLOAD_PROGRESS) > 0) {
21
- downloadOptions.onProgress = it => this.emit(main_1.DOWNLOAD_PROGRESS, it);
20
+ if (this.listenerCount(types_1.DOWNLOAD_PROGRESS) > 0) {
21
+ downloadOptions.onProgress = it => this.emit(types_1.DOWNLOAD_PROGRESS, it);
22
22
  }
23
23
  await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions);
24
24
  },
@@ -1 +1 @@
1
- {"version":3,"file":"RpmUpdater.js","sourceRoot":"","sources":["../src/RpmUpdater.ts"],"names":[],"mappings":";;;AAGA,+CAA2D;AAC3D,iCAA0C;AAC1C,mDAA+C;AAE/C,MAAa,UAAW,SAAQ,yBAAW;IACzC,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,qBAA4C;QACrE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,QAAQ,CAAA;QACrE,MAAM,QAAQ,GAAG,IAAA,mBAAQ,EAAC,QAAQ,CAAC,YAAY,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAE,CAAA;QACzI,OAAO,IAAI,CAAC,eAAe,CAAC;YAC1B,aAAa,EAAE,KAAK;YACpB,QAAQ;YACR,qBAAqB;YACrB,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE;gBAC1C,IAAI,IAAI,CAAC,aAAa,CAAC,wBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC9C,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,wBAAiB,EAAE,EAAE,CAAC,CAAA;gBACrE,CAAC;gBACD,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ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CAAA;QACtF,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;YAC5B,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;QACrB,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAjDD,gCAiDC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DOWNLOAD_PROGRESS } from \"./main\"\nimport { findFile } from \"./providers/Provider\"\n\nexport class RpmUpdater extends BaseUpdater {\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"rpm\", [\"AppImage\", \"deb\", \"pacman\"])!\n return this.executeDownload({\n fileExtension: \"rpm\",\n fileInfo,\n downloadUpdateOptions,\n task: async (updateFile, downloadOptions) => {\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n },\n })\n }\n\n protected get installerPath(): string | null {\n return super.installerPath?.replace(/ /g, \"\\\\ \") ?? null\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const sudo = this.wrapSudo()\n // pkexec doesn't want the command to be wrapped in \" quotes\n const wrapper = /pkexec/i.test(sudo) ? \"\" : `\"`\n const packageManager = this.spawnSyncLog(\"which zypper\")\n const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No valid update available, can't quit and install\"))\n return false\n }\n let cmd: string[]\n if (!packageManager) {\n const packageManager = this.spawnSyncLog(\"which dnf || which yum\")\n cmd = [packageManager, \"-y\", \"install\", installerPath]\n } else {\n cmd = [packageManager, \"--no-refresh\", \"install\", \"--allow-unsigned-rpm\", \"-y\", \"-f\", installerPath]\n }\n this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, \"-c\", `'${cmd.join(\" \")}'${wrapper}`])\n if (options.isForceRunAfter) {\n this.app.relaunch()\n }\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"RpmUpdater.js","sourceRoot":"","sources":["../src/RpmUpdater.ts"],"names":[],"mappings":";;;AAGA,+CAA2D;AAC3D,mCAA2C;AAC3C,mDAA+C;AAE/C,MAAa,UAAW,SAAQ,yBAAW;IACzC,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,qBAA4C;QACrE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,QAAQ,CAAA;QACrE,MAAM,QAAQ,GAAG,IAAA,mBAAQ,EAAC,QAAQ,CAAC,YAAY,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAE,CAAA;QACzI,OAAO,IAAI,CAAC,eAAe,CAAC;YAC1B,aAAa,EAAE,KAAK;YACpB,QAAQ;YACR,qBAAqB;YACrB,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE;gBAC1C,IAAI,IAAI,CAAC,aAAa,CAAC,yBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC9C,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAiB,EAAE,EAAE,CAAC,CAAA;gBACrE,CAAC;gBACD,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,eAAe,CAAC,CA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I,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;QACrB,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAjDD,gCAiDC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DOWNLOAD_PROGRESS } from \"./types\"\nimport { findFile } from \"./providers/Provider\"\n\nexport class RpmUpdater extends BaseUpdater {\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"rpm\", [\"AppImage\", \"deb\", \"pacman\"])!\n return this.executeDownload({\n fileExtension: \"rpm\",\n fileInfo,\n downloadUpdateOptions,\n task: async (updateFile, downloadOptions) => {\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n },\n })\n }\n\n protected get installerPath(): string | null {\n return super.installerPath?.replace(/ /g, \"\\\\ \") ?? null\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const sudo = this.wrapSudo()\n // pkexec doesn't want the command to be wrapped in \" quotes\n const wrapper = /pkexec/i.test(sudo) ? \"\" : `\"`\n const packageManager = this.spawnSyncLog(\"which zypper\")\n const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No valid update available, can't quit and install\"))\n return false\n }\n let cmd: string[]\n if (!packageManager) {\n const packageManager = this.spawnSyncLog(\"which dnf || which yum\")\n cmd = [packageManager, \"-y\", \"install\", installerPath]\n } else {\n cmd = [packageManager, \"--no-refresh\", \"install\", \"--allow-unsigned-rpm\", \"-y\", \"-f\", installerPath]\n }\n this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, \"-c\", `'${cmd.join(\" \")}'${wrapper}`])\n if (options.isForceRunAfter) {\n this.app.relaunch()\n }\n return true\n }\n}\n"]}
@@ -2,7 +2,7 @@ import { BlockMapDataHolder, HttpExecutor } from "builder-util-runtime";
2
2
  import { BlockMap } from "builder-util-runtime/out/blockMapApi";
3
3
  import { OutgoingHttpHeaders, RequestOptions } from "http";
4
4
  import { ProgressInfo, CancellationToken } from "builder-util-runtime";
5
- import { Logger } from "../main";
5
+ import { Logger } from "../types";
6
6
  import { URL } from "url";
7
7
  export interface DifferentialDownloaderOptions {
8
8
  readonly oldFile: string;
@@ -1 +1 @@
1
- {"version":3,"file":"DifferentialDownloader.js","sourceRoot":"","sources":["../../src/differentialDownloader/DifferentialDownloader.ts"],"names":[],"mappings":";;;AAAA,+DAAuJ;AAEvJ,uCAAsC;AACtC,2BAAsC;AAItC,iDAAyC;AACzC,6BAAyB;AACzB,+DAAmF;AACnF,uEAA0G;AAC1G,mHAAiJ;AAgBjJ,MAAsB,sBAAsB;IAK1C,oEAAoE;IACpE,YACqB,kBAAsC,EAChD,YAA+B,EAC/B,OAAsC;QAF5B,uBAAkB,GAAlB,kBAAkB,CAAoB;QAChD,iBAAY,GAAZ,YAAY,CAAmB;QAC/B,YAAO,GAAP,OAAO,CAA+B;QARjD,uBAAkB,GAAkB,IAAI,CAAA;QAUtC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC9B,CAAC;IAED,oBAAoB;QAClB,MAAM,MAAM,GAAG;YACb,OAAO,EAAE;gBACP,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc;gBAC9B,MAAM,EAAE,KAAK;aACd;SACF,CAAA;QACD,IAAA,0CAAmB,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAChD,qDAAqD;QACrD,IAAA,8CAAu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CAAA;YACF,IAAI,CAAC,YAAY,CAAC,0BAA0B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;YAC7D,OAAO,CAAC,GAAG,EAAE,CAAA;QACf,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AA1RD,wDA0RC;AAED,SAAS,WAAW,CAAC,KAAa,EAAE,MAAM,GAAG,KAAK;IAChD,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAQ,CAAC,GAAG,MAAM,CAAA;AACtF,CAAC;AAED,SAAS;AACT,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC9B,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;AAClD,CAAC","sourcesContent":["import { BlockMapDataHolder, createHttpError, DigestTransform, HttpExecutor, configureRequestUrl, configureRequestOptions } from \"builder-util-runtime\"\nimport { BlockMap } from \"builder-util-runtime/out/blockMapApi\"\nimport { close, open } from \"fs-extra\"\nimport { createWriteStream } from \"fs\"\nimport { OutgoingHttpHeaders, RequestOptions } from \"http\"\nimport { ProgressInfo, CancellationToken } from \"builder-util-runtime\"\nimport { Logger } from \"../main\"\nimport { copyData } from \"./DataSplitter\"\nimport { URL } from \"url\"\nimport { computeOperations, Operation, OperationKind } from \"./downloadPlanBuilder\"\nimport { checkIsRangesSupported, executeTasksUsingMultipleRangeRequests } from \"./multipleRangeDownloader\"\nimport { ProgressDifferentialDownloadCallbackTransform, ProgressDifferentialDownloadInfo } from \"./ProgressDifferentialDownloadCallbackTransform\"\n\nexport interface DifferentialDownloaderOptions {\n readonly oldFile: string\n readonly newUrl: URL\n readonly logger: Logger\n readonly newFile: string\n\n readonly requestHeaders: OutgoingHttpHeaders | null\n\n readonly isUseMultipleRangeRequest?: boolean\n\n readonly cancellationToken: CancellationToken\n onProgress?: (progress: ProgressInfo) => void\n}\n\nexport abstract class DifferentialDownloader {\n fileMetadataBuffer: Buffer | null = null\n\n private readonly logger: Logger\n\n // noinspection TypeScriptAbstractClassConstructorCanBeMadeProtected\n constructor(\n protected readonly blockAwareFileInfo: BlockMapDataHolder,\n readonly httpExecutor: HttpExecutor<any>,\n readonly options: DifferentialDownloaderOptions\n ) {\n this.logger = options.logger\n }\n\n createRequestOptions(): RequestOptions {\n const result = {\n headers: {\n ...this.options.requestHeaders,\n accept: \"*/*\",\n },\n }\n configureRequestUrl(this.options.newUrl, result)\n // user-agent, cache-control and other common options\n configureRequestOptions(result)\n return result\n }\n\n protected doDownload(oldBlockMap: BlockMap, newBlockMap: BlockMap): Promise<any> {\n // we don't check other metadata like compressionMethod - generic check that it is make sense to differentially update is suitable for it\n if (oldBlockMap.version !== newBlockMap.version) {\n throw new Error(`version is different (${oldBlockMap.version} - ${newBlockMap.version}), full download is required`)\n }\n\n const logger = this.logger\n const operations = computeOperations(oldBlockMap, newBlockMap, logger)\n if (logger.debug != null) {\n logger.debug(JSON.stringify(operations, null, 2))\n }\n\n let downloadSize = 0\n let copySize = 0\n for (const operation of operations) {\n const length = operation.end - operation.start\n if (operation.kind === OperationKind.DOWNLOAD) {\n downloadSize += length\n } else {\n copySize += length\n }\n }\n\n const newSize = this.blockAwareFileInfo.size\n if (downloadSize + copySize + (this.fileMetadataBuffer == null ? 0 : this.fileMetadataBuffer.length) !== newSize) {\n throw new Error(`Internal error, size mismatch: downloadSize: ${downloadSize}, copySize: ${copySize}, newSize: ${newSize}`)\n }\n\n logger.info(`Full: ${formatBytes(newSize)}, To download: ${formatBytes(downloadSize)} (${Math.round(downloadSize / (newSize / 100))}%)`)\n\n return this.downloadFile(operations)\n }\n\n private downloadFile(tasks: Array<Operation>): Promise<any> {\n const fdList: Array<OpenedFile> = []\n const closeFiles = (): Promise<Array<void>> => {\n return Promise.all(\n fdList.map(openedFile => {\n return close(openedFile.descriptor).catch((e: any) => {\n this.logger.error(`cannot close file \"${openedFile.path}\": ${e}`)\n })\n })\n )\n }\n return this.doDownloadFile(tasks, fdList)\n .then(closeFiles)\n .catch((e: any) => {\n // then must be after catch here (since then always throws error)\n return closeFiles()\n .catch(closeFilesError => {\n // closeFiles never throw error, but just to be sure\n try {\n this.logger.error(`cannot close files: ${closeFilesError}`)\n } catch (errorOnLog) {\n try {\n console.error(errorOnLog)\n } catch (_ignored) {\n // ok, give up and ignore error\n }\n }\n throw e\n })\n .then(() => {\n throw e\n })\n })\n }\n\n private async doDownloadFile(tasks: Array<Operation>, fdList: Array<OpenedFile>): Promise<any> {\n const oldFileFd = await open(this.options.oldFile, \"r\")\n fdList.push({ descriptor: oldFileFd, path: this.options.oldFile })\n const newFileFd = await open(this.options.newFile, \"w\")\n fdList.push({ descriptor: newFileFd, path: this.options.newFile })\n const fileOut = createWriteStream(this.options.newFile, { fd: newFileFd })\n await new Promise((resolve, reject) => {\n const streams: Array<any> = []\n\n // Create our download info transformer if we have one\n let downloadInfoTransform: ProgressDifferentialDownloadCallbackTransform | undefined = undefined\n if (!this.options.isUseMultipleRangeRequest && this.options.onProgress) {\n // TODO: Does not support multiple ranges (someone feel free to PR this!)\n const expectedByteCounts: Array<number> = []\n let grandTotalBytes = 0\n\n for (const task of tasks) {\n if (task.kind === OperationKind.DOWNLOAD) {\n expectedByteCounts.push(task.end - task.start)\n grandTotalBytes += task.end - task.start\n }\n }\n\n const progressDifferentialDownloadInfo: ProgressDifferentialDownloadInfo = {\n expectedByteCounts: expectedByteCounts,\n grandTotal: grandTotalBytes,\n }\n\n downloadInfoTransform = new ProgressDifferentialDownloadCallbackTransform(progressDifferentialDownloadInfo, this.options.cancellationToken, this.options.onProgress)\n streams.push(downloadInfoTransform)\n }\n\n const digestTransform = new DigestTransform(this.blockAwareFileInfo.sha512)\n // to simply debug, do manual validation to allow file to be fully written\n digestTransform.isValidateOnEnd = false\n streams.push(digestTransform)\n\n // noinspection JSArrowFunctionCanBeReplacedWithShorthand\n fileOut.on(\"finish\", () => {\n ;(fileOut.close as any)(() => {\n // remove from fd list because closed successfully\n fdList.splice(1, 1)\n try {\n digestTransform.validate()\n } catch (e: any) {\n reject(e)\n return\n }\n\n resolve(undefined)\n })\n })\n\n streams.push(fileOut)\n\n let lastStream = null\n for (const stream of streams) {\n stream.on(\"error\", reject)\n if (lastStream == null) {\n lastStream = stream\n } else {\n lastStream = lastStream.pipe(stream)\n }\n }\n\n const firstStream = streams[0]\n\n let w: any\n if (this.options.isUseMultipleRangeRequest) {\n w = executeTasksUsingMultipleRangeRequests(this, tasks, firstStream, oldFileFd, reject)\n w(0)\n return\n }\n\n let downloadOperationCount = 0\n let actualUrl: string | null = null\n this.logger.info(`Differential download: ${this.options.newUrl}`)\n\n const requestOptions = this.createRequestOptions()\n ;(requestOptions as any).redirect = \"manual\"\n\n w = (index: number): void => {\n if (index >= tasks.length) {\n if (this.fileMetadataBuffer != null) {\n firstStream.write(this.fileMetadataBuffer)\n }\n firstStream.end()\n return\n }\n\n const operation = tasks[index++]\n if (operation.kind === OperationKind.COPY) {\n // We are copying, let's not send status updates to the UI\n if (downloadInfoTransform) {\n downloadInfoTransform.beginFileCopy()\n }\n\n copyData(operation, firstStream, oldFileFd, reject, () => w(index))\n return\n }\n\n const range = `bytes=${operation.start}-${operation.end - 1}`\n requestOptions.headers!.range = range\n\n this.logger?.debug?.(`download range: ${range}`)\n\n // We are starting to download\n if (downloadInfoTransform) {\n downloadInfoTransform.beginRangeDownload()\n }\n\n const request = this.httpExecutor.createRequest(requestOptions, response => {\n response.on(\"error\", reject)\n response.on(\"aborted\", () => {\n reject(new Error(\"response has been aborted by the server\"))\n })\n // Electron net handles redirects automatically, our NodeJS test server doesn't use redirects - so, we don't check 3xx codes.\n if (response.statusCode >= 400) {\n reject(createHttpError(response))\n }\n\n response.pipe(firstStream, {\n end: false,\n })\n response.once(\"end\", () => {\n // Pass on that we are downloading a segment\n if (downloadInfoTransform) {\n downloadInfoTransform.endRangeDownload()\n }\n\n if (++downloadOperationCount === 100) {\n downloadOperationCount = 0\n setTimeout(() => w(index), 1000)\n } else {\n w(index)\n }\n })\n })\n request.on(\"redirect\", (statusCode: number, method: string, redirectUrl: string) => {\n this.logger.info(`Redirect to ${removeQuery(redirectUrl)}`)\n actualUrl = redirectUrl\n configureRequestUrl(new URL(actualUrl), requestOptions)\n request.followRedirect()\n })\n this.httpExecutor.addErrorAndTimeoutHandlers(request, reject)\n request.end()\n }\n\n w(0)\n })\n }\n\n protected async readRemoteBytes(start: number, endInclusive: number): Promise<Buffer> {\n const buffer = Buffer.allocUnsafe(endInclusive + 1 - start)\n const requestOptions = this.createRequestOptions()\n requestOptions.headers!.range = `bytes=${start}-${endInclusive}`\n let position = 0\n await this.request(requestOptions, chunk => {\n chunk.copy(buffer, position)\n position += chunk.length\n })\n\n if (position !== buffer.length) {\n throw new Error(`Received data length ${position} is not equal to expected ${buffer.length}`)\n }\n return buffer\n }\n\n private request(requestOptions: RequestOptions, dataHandler: (chunk: Buffer) => void): Promise<void> {\n return new Promise((resolve, reject) => {\n const request = this.httpExecutor.createRequest(requestOptions, response => {\n if (!checkIsRangesSupported(response, reject)) {\n return\n }\n\n response.on(\"error\", reject)\n response.on(\"aborted\", () => {\n reject(new Error(\"response has been aborted by the server\"))\n })\n\n response.on(\"data\", dataHandler)\n response.on(\"end\", () => resolve())\n })\n this.httpExecutor.addErrorAndTimeoutHandlers(request, reject)\n request.end()\n })\n }\n}\n\nfunction formatBytes(value: number, symbol = \" KB\"): string {\n return new Intl.NumberFormat(\"en\").format((value / 1024).toFixed(2) as any) + symbol\n}\n\n// safety\nfunction removeQuery(url: string): string {\n const index = url.indexOf(\"?\")\n return index < 0 ? url : url.substring(0, index)\n}\n\ninterface OpenedFile {\n readonly descriptor: number\n readonly path: string\n}\n"]}
1
+ {"version":3,"file":"DifferentialDownloader.js","sourceR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B,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;AAClD,CAAC","sourcesContent":["import { BlockMapDataHolder, createHttpError, DigestTransform, HttpExecutor, configureRequestUrl, configureRequestOptions } from \"builder-util-runtime\"\nimport { BlockMap } from \"builder-util-runtime/out/blockMapApi\"\nimport { close, open } from \"fs-extra\"\nimport { createWriteStream } from \"fs\"\nimport { OutgoingHttpHeaders, RequestOptions } from \"http\"\nimport { ProgressInfo, CancellationToken } from \"builder-util-runtime\"\nimport { Logger } from \"../types\"\nimport { copyData } from \"./DataSplitter\"\nimport { URL } from \"url\"\nimport { computeOperations, Operation, OperationKind } from \"./downloadPlanBuilder\"\nimport { checkIsRangesSupported, executeTasksUsingMultipleRangeRequests } from \"./multipleRangeDownloader\"\nimport { ProgressDifferentialDownloadCallbackTransform, ProgressDifferentialDownloadInfo } from \"./ProgressDifferentialDownloadCallbackTransform\"\n\nexport interface DifferentialDownloaderOptions {\n readonly oldFile: string\n readonly newUrl: URL\n readonly logger: Logger\n readonly newFile: string\n\n readonly requestHeaders: OutgoingHttpHeaders | null\n\n readonly isUseMultipleRangeRequest?: boolean\n\n readonly cancellationToken: CancellationToken\n onProgress?: (progress: ProgressInfo) => void\n}\n\nexport abstract class DifferentialDownloader {\n fileMetadataBuffer: Buffer | null = null\n\n private readonly logger: Logger\n\n // noinspection TypeScriptAbstractClassConstructorCanBeMadeProtected\n constructor(\n protected readonly blockAwareFileInfo: BlockMapDataHolder,\n readonly httpExecutor: HttpExecutor<any>,\n readonly options: DifferentialDownloaderOptions\n ) {\n this.logger = options.logger\n }\n\n createRequestOptions(): RequestOptions {\n const result = {\n headers: {\n ...this.options.requestHeaders,\n accept: \"*/*\",\n },\n }\n configureRequestUrl(this.options.newUrl, result)\n // user-agent, cache-control and other common options\n configureRequestOptions(result)\n return result\n }\n\n protected doDownload(oldBlockMap: BlockMap, newBlockMap: BlockMap): Promise<any> {\n // we don't check other metadata like compressionMethod - generic check that it is make sense to differentially update is suitable for it\n if (oldBlockMap.version !== newBlockMap.version) {\n throw new Error(`version is different (${oldBlockMap.version} - ${newBlockMap.version}), full download is required`)\n }\n\n const logger = this.logger\n const operations = computeOperations(oldBlockMap, newBlockMap, logger)\n if (logger.debug != null) {\n logger.debug(JSON.stringify(operations, null, 2))\n }\n\n let downloadSize = 0\n let copySize = 0\n for (const operation of operations) {\n const length = operation.end - operation.start\n if (operation.kind === OperationKind.DOWNLOAD) {\n downloadSize += length\n } else {\n copySize += length\n }\n }\n\n const newSize = this.blockAwareFileInfo.size\n if (downloadSize + copySize + (this.fileMetadataBuffer == null ? 0 : this.fileMetadataBuffer.length) !== newSize) {\n throw new Error(`Internal error, size mismatch: downloadSize: ${downloadSize}, copySize: ${copySize}, newSize: ${newSize}`)\n }\n\n logger.info(`Full: ${formatBytes(newSize)}, To download: ${formatBytes(downloadSize)} (${Math.round(downloadSize / (newSize / 100))}%)`)\n\n return this.downloadFile(operations)\n }\n\n private downloadFile(tasks: Array<Operation>): Promise<any> {\n const fdList: Array<OpenedFile> = []\n const closeFiles = (): Promise<Array<void>> => {\n return Promise.all(\n fdList.map(openedFile => {\n return close(openedFile.descriptor).catch((e: any) => {\n this.logger.error(`cannot close file \"${openedFile.path}\": ${e}`)\n })\n })\n )\n }\n return this.doDownloadFile(tasks, fdList)\n .then(closeFiles)\n .catch((e: any) => {\n // then must be after catch here (since then always throws error)\n return closeFiles()\n .catch(closeFilesError => {\n // closeFiles never throw error, but just to be sure\n try {\n this.logger.error(`cannot close files: ${closeFilesError}`)\n } catch (errorOnLog) {\n try {\n console.error(errorOnLog)\n } catch (_ignored) {\n // ok, give up and ignore error\n }\n }\n throw e\n })\n .then(() => {\n throw e\n })\n })\n }\n\n private async doDownloadFile(tasks: Array<Operation>, fdList: Array<OpenedFile>): Promise<any> {\n const oldFileFd = await open(this.options.oldFile, \"r\")\n fdList.push({ descriptor: oldFileFd, path: this.options.oldFile })\n const newFileFd = await open(this.options.newFile, \"w\")\n fdList.push({ descriptor: newFileFd, path: this.options.newFile })\n const fileOut = createWriteStream(this.options.newFile, { fd: newFileFd })\n await new Promise((resolve, reject) => {\n const streams: Array<any> = []\n\n // Create our download info transformer if we have one\n let downloadInfoTransform: ProgressDifferentialDownloadCallbackTransform | undefined = undefined\n if (!this.options.isUseMultipleRangeRequest && this.options.onProgress) {\n // TODO: Does not support multiple ranges (someone feel free to PR this!)\n const expectedByteCounts: Array<number> = []\n let grandTotalBytes = 0\n\n for (const task of tasks) {\n if (task.kind === OperationKind.DOWNLOAD) {\n expectedByteCounts.push(task.end - task.start)\n grandTotalBytes += task.end - task.start\n }\n }\n\n const progressDifferentialDownloadInfo: ProgressDifferentialDownloadInfo = {\n expectedByteCounts: expectedByteCounts,\n grandTotal: grandTotalBytes,\n }\n\n downloadInfoTransform = new ProgressDifferentialDownloadCallbackTransform(progressDifferentialDownloadInfo, this.options.cancellationToken, this.options.onProgress)\n streams.push(downloadInfoTransform)\n }\n\n const digestTransform = new DigestTransform(this.blockAwareFileInfo.sha512)\n // to simply debug, do manual validation to allow file to be fully written\n digestTransform.isValidateOnEnd = false\n streams.push(digestTransform)\n\n // noinspection JSArrowFunctionCanBeReplacedWithShorthand\n fileOut.on(\"finish\", () => {\n ;(fileOut.close as any)(() => {\n // remove from fd list because closed successfully\n fdList.splice(1, 1)\n try {\n digestTransform.validate()\n } catch (e: any) {\n reject(e)\n return\n }\n\n resolve(undefined)\n })\n })\n\n streams.push(fileOut)\n\n let lastStream = null\n for (const stream of streams) {\n stream.on(\"error\", reject)\n if (lastStream == null) {\n lastStream = stream\n } else {\n lastStream = lastStream.pipe(stream)\n }\n }\n\n const firstStream = streams[0]\n\n let w: any\n if (this.options.isUseMultipleRangeRequest) {\n w = executeTasksUsingMultipleRangeRequests(this, tasks, firstStream, oldFileFd, reject)\n w(0)\n return\n }\n\n let downloadOperationCount = 0\n let actualUrl: string | null = null\n this.logger.info(`Differential download: ${this.options.newUrl}`)\n\n const requestOptions = this.createRequestOptions()\n ;(requestOptions as any).redirect = \"manual\"\n\n w = (index: number): void => {\n if (index >= tasks.length) {\n if (this.fileMetadataBuffer != null) {\n firstStream.write(this.fileMetadataBuffer)\n }\n firstStream.end()\n return\n }\n\n const operation = tasks[index++]\n if (operation.kind === OperationKind.COPY) {\n // We are copying, let's not send status updates to the UI\n if (downloadInfoTransform) {\n downloadInfoTransform.beginFileCopy()\n }\n\n copyData(operation, firstStream, oldFileFd, reject, () => w(index))\n return\n }\n\n const range = `bytes=${operation.start}-${operation.end - 1}`\n requestOptions.headers!.range = range\n\n this.logger?.debug?.(`download range: ${range}`)\n\n // We are starting to download\n if (downloadInfoTransform) {\n downloadInfoTransform.beginRangeDownload()\n }\n\n const request = this.httpExecutor.createRequest(requestOptions, response => {\n response.on(\"error\", reject)\n response.on(\"aborted\", () => {\n reject(new Error(\"response has been aborted by the server\"))\n })\n // Electron net handles redirects automatically, our NodeJS test server doesn't use redirects - so, we don't check 3xx codes.\n if (response.statusCode >= 400) {\n reject(createHttpError(response))\n }\n\n response.pipe(firstStream, {\n end: false,\n })\n response.once(\"end\", () => {\n // Pass on that we are downloading a segment\n if (downloadInfoTransform) {\n downloadInfoTransform.endRangeDownload()\n }\n\n if (++downloadOperationCount === 100) {\n downloadOperationCount = 0\n setTimeout(() => w(index), 1000)\n } else {\n w(index)\n }\n })\n })\n request.on(\"redirect\", (statusCode: number, method: string, redirectUrl: string) => {\n this.logger.info(`Redirect to ${removeQuery(redirectUrl)}`)\n actualUrl = redirectUrl\n configureRequestUrl(new URL(actualUrl), requestOptions)\n request.followRedirect()\n })\n this.httpExecutor.addErrorAndTimeoutHandlers(request, reject)\n request.end()\n }\n\n w(0)\n })\n }\n\n protected async readRemoteBytes(start: number, endInclusive: number): Promise<Buffer> {\n const buffer = Buffer.allocUnsafe(endInclusive + 1 - start)\n const requestOptions = this.createRequestOptions()\n requestOptions.headers!.range = `bytes=${start}-${endInclusive}`\n let position = 0\n await this.request(requestOptions, chunk => {\n chunk.copy(buffer, position)\n position += chunk.length\n })\n\n if (position !== buffer.length) {\n throw new Error(`Received data length ${position} is not equal to expected ${buffer.length}`)\n }\n return buffer\n }\n\n private request(requestOptions: RequestOptions, dataHandler: (chunk: Buffer) => void): Promise<void> {\n return new Promise((resolve, reject) => {\n const request = this.httpExecutor.createRequest(requestOptions, response => {\n if (!checkIsRangesSupported(response, reject)) {\n return\n }\n\n response.on(\"error\", reject)\n response.on(\"aborted\", () => {\n reject(new Error(\"response has been aborted by the server\"))\n })\n\n response.on(\"data\", dataHandler)\n response.on(\"end\", () => resolve())\n })\n this.httpExecutor.addErrorAndTimeoutHandlers(request, reject)\n request.end()\n })\n }\n}\n\nfunction formatBytes(value: number, symbol = \" KB\"): string {\n return new Intl.NumberFormat(\"en\").format((value / 1024).toFixed(2) as any) + symbol\n}\n\n// safety\nfunction removeQuery(url: string): string {\n const index = url.indexOf(\"?\")\n return index < 0 ? url : url.substring(0, index)\n}\n\ninterface OpenedFile {\n readonly descriptor: number\n readonly path: string\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { BlockMap } from "builder-util-runtime/out/blockMapApi";
2
- import { Logger } from "../main";
2
+ import { Logger } from "../types";
3
3
  export declare enum OperationKind {
4
4
  COPY = 0,
5
5
  DOWNLOAD = 1
@@ -1 +1 @@
1
- {"version":3,"file":"downloadPlanBuilder.js","sourceRoot":"","sources":["../../src/differentialDownloader/downloadPlanBuilder.ts"],"names":[],"mappings":";;;AAoBA,8CAmEC;AApFD,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,iDAAI,CAAA;IACJ,yDAAQ,CAAA;AACV,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAcD,SAAgB,iBAAiB,CAAC,WAAqB,EAAE,WAAqB,EAAE,MAAc;IAC5F,MAAM,eAAe,GAAG,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IAC5D,MAAM,e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IAAI,CAAA;IAChB,CAAC;IACD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAA;AAChE,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAyB;IAClD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAA;IAC9C,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC7B,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { BlockMap, BlockMapFile } from \"builder-util-runtime/out/blockMapApi\"\nimport { Logger } from \"../main\"\n\nexport enum OperationKind {\n COPY,\n DOWNLOAD,\n}\n\nexport interface Operation {\n kind: OperationKind\n\n // inclusive\n start: number\n // exclusive\n end: number\n\n // debug only\n // oldBlocks: Array<string> | null\n}\n\nexport function computeOperations(oldBlockMap: BlockMap, newBlockMap: BlockMap, logger: Logger): Array<Operation> {\n const nameToOldBlocks = buildBlockFileMap(oldBlockMap.files)\n const nameToNewBlocks = buildBlockFileMap(newBlockMap.files)\n\n let lastOperation: Operation | null = null\n\n // for now only one file is supported in block map\n const blockMapFile: { name: string; offset: number } = newBlockMap.files[0]\n const operations: Array<Operation> = []\n const name = blockMapFile.name\n const oldEntry = nameToOldBlocks.get(name)\n if (oldEntry == null) {\n // new file (unrealistic case for now, because in any case both blockmap contain the only file named as \"file\")\n throw new Error(`no file ${name} in old blockmap`)\n }\n\n const newFile = nameToNewBlocks.get(name)!\n let changedBlockCount = 0\n\n const { checksumToOffset: checksumToOldOffset, checksumToOldSize } = buildChecksumMap(nameToOldBlocks.get(name)!, oldEntry.offset, logger)\n\n let newOffset = blockMapFile.offset\n for (let i = 0; i < newFile.checksums.length; newOffset += newFile.sizes[i], i++) {\n const blockSize: number = newFile.sizes[i]\n const checksum = newFile.checksums[i]\n let oldOffset = checksumToOldOffset.get(checksum)\n if (oldOffset != null && checksumToOldSize.get(checksum) !== blockSize) {\n logger.warn(`Checksum (\"${checksum}\") matches, but size differs (old: ${checksumToOldSize.get(checksum)}, new: ${blockSize})`)\n oldOffset = undefined\n }\n\n if (oldOffset === undefined) {\n // download data from new file\n changedBlockCount++\n\n if (lastOperation != null && lastOperation.kind === OperationKind.DOWNLOAD && lastOperation.end === newOffset) {\n lastOperation.end += blockSize\n } else {\n lastOperation = {\n kind: OperationKind.DOWNLOAD,\n start: newOffset,\n end: newOffset + blockSize,\n // oldBlocks: null,\n }\n validateAndAdd(lastOperation, operations, checksum, i)\n }\n } else {\n // reuse data from old file\n if (lastOperation != null && lastOperation.kind === OperationKind.COPY && lastOperation.end === oldOffset) {\n lastOperation.end += blockSize\n // lastOperation.oldBlocks!!.push(checksum)\n } else {\n lastOperation = {\n kind: OperationKind.COPY,\n start: oldOffset,\n end: oldOffset + blockSize,\n // oldBlocks: [checksum]\n }\n validateAndAdd(lastOperation, operations, checksum, i)\n }\n }\n }\n\n if (changedBlockCount > 0) {\n logger.info(`File${blockMapFile.name === \"file\" ? \"\" : \" \" + blockMapFile.name} has ${changedBlockCount} changed blocks`)\n }\n return operations\n}\n\nconst isValidateOperationRange = process.env[\"DIFFERENTIAL_DOWNLOAD_PLAN_BUILDER_VALIDATE_RANGES\"] === \"true\"\n\nfunction validateAndAdd(operation: Operation, operations: Array<Operation>, checksum: string, index: number): void {\n if (isValidateOperationRange && operations.length !== 0) {\n const lastOperation = operations[operations.length - 1]\n if (lastOperation.kind === operation.kind && operation.start < lastOperation.end && operation.start > lastOperation.start) {\n const min = [lastOperation.start, lastOperation.end, operation.start, operation.end].reduce((p, v) => (p < v ? p : v))\n throw new Error(\n `operation (block index: ${index}, checksum: ${checksum}, kind: ${OperationKind[operation.kind]}) overlaps previous operation (checksum: ${checksum}):\\n` +\n `abs: ${lastOperation.start} until ${lastOperation.end} and ${operation.start} until ${operation.end}\\n` +\n `rel: ${lastOperation.start - min} until ${lastOperation.end - min} and ${operation.start - min} until ${operation.end - min}`\n )\n }\n }\n operations.push(operation)\n}\n\nfunction buildChecksumMap(file: BlockMapFile, fileOffset: number, logger: Logger) {\n const checksumToOffset = new Map<string, number>()\n const checksumToSize = new Map<string, number>()\n let offset = fileOffset\n for (let i = 0; i < file.checksums.length; i++) {\n const checksum = file.checksums[i]\n const size = file.sizes[i]\n\n const existing = checksumToSize.get(checksum)\n if (existing === undefined) {\n checksumToOffset.set(checksum, offset)\n checksumToSize.set(checksum, size)\n } else if (logger.debug != null) {\n const sizeExplanation = existing === size ? \"(same size)\" : `(size: ${existing}, this size: ${size})`\n logger.debug(`${checksum} duplicated in blockmap ${sizeExplanation}, it doesn't lead to broken differential downloader, just corresponding block will be skipped)`)\n }\n offset += size\n }\n return { checksumToOffset, checksumToOldSize: checksumToSize }\n}\n\nfunction buildBlockFileMap(list: Array<BlockMapFile>): Map<string, BlockMapFile> {\n const result = new Map<string, BlockMapFile>()\n for (const item of list) {\n result.set(item.name, item)\n }\n return result\n}\n"]}
1
+ {"version":3,"file":"downloadPlanBuilder.js","sourceRoot":"","sources":["../../src/differentialDownloader/downloadPlanBuilder.ts"],"names":[],"mappings":";;;AAoBA,8CAmEC;AApFD,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,iDAAI,CAAA;IACJ,yDAAQ,CAAA;AACV,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAcD,SAAgB,iBAAiB,CAAC,WAAqB,EAAE,WAAqB,EAAE,MAAc;IAC5F,MAAM,eAAe,GAAG,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IAC5D,MAAM,eAAe,GAAG,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IAE5D,IAAI,aAAa,GAAqB,IAAI,CAAA;IAE1C,kDAAkD;IAClD,MAAM,YAAY,GAAqC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC3E,MAAM,UAAU,GAAqB,EAAE,CAAA;IACvC,MAAM,IAAI,GAAG,YAAY,C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C,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC7B,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { BlockMap, BlockMapFile } from \"builder-util-runtime/out/blockMapApi\"\nimport { Logger } from \"../types\"\n\nexport enum OperationKind {\n COPY,\n DOWNLOAD,\n}\n\nexport interface Operation {\n kind: OperationKind\n\n // inclusive\n start: number\n // exclusive\n end: number\n\n // debug only\n // oldBlocks: Array<string> | null\n}\n\nexport function computeOperations(oldBlockMap: BlockMap, newBlockMap: BlockMap, logger: Logger): Array<Operation> {\n const nameToOldBlocks = buildBlockFileMap(oldBlockMap.files)\n const nameToNewBlocks = buildBlockFileMap(newBlockMap.files)\n\n let lastOperation: Operation | null = null\n\n // for now only one file is supported in block map\n const blockMapFile: { name: string; offset: number } = newBlockMap.files[0]\n const operations: Array<Operation> = []\n const name = blockMapFile.name\n const oldEntry = nameToOldBlocks.get(name)\n if (oldEntry == null) {\n // new file (unrealistic case for now, because in any case both blockmap contain the only file named as \"file\")\n throw new Error(`no file ${name} in old blockmap`)\n }\n\n const newFile = nameToNewBlocks.get(name)!\n let changedBlockCount = 0\n\n const { checksumToOffset: checksumToOldOffset, checksumToOldSize } = buildChecksumMap(nameToOldBlocks.get(name)!, oldEntry.offset, logger)\n\n let newOffset = blockMapFile.offset\n for (let i = 0; i < newFile.checksums.length; newOffset += newFile.sizes[i], i++) {\n const blockSize: number = newFile.sizes[i]\n const checksum = newFile.checksums[i]\n let oldOffset = checksumToOldOffset.get(checksum)\n if (oldOffset != null && checksumToOldSize.get(checksum) !== blockSize) {\n logger.warn(`Checksum (\"${checksum}\") matches, but size differs (old: ${checksumToOldSize.get(checksum)}, new: ${blockSize})`)\n oldOffset = undefined\n }\n\n if (oldOffset === undefined) {\n // download data from new file\n changedBlockCount++\n\n if (lastOperation != null && lastOperation.kind === OperationKind.DOWNLOAD && lastOperation.end === newOffset) {\n lastOperation.end += blockSize\n } else {\n lastOperation = {\n kind: OperationKind.DOWNLOAD,\n start: newOffset,\n end: newOffset + blockSize,\n // oldBlocks: null,\n }\n validateAndAdd(lastOperation, operations, checksum, i)\n }\n } else {\n // reuse data from old file\n if (lastOperation != null && lastOperation.kind === OperationKind.COPY && lastOperation.end === oldOffset) {\n lastOperation.end += blockSize\n // lastOperation.oldBlocks!!.push(checksum)\n } else {\n lastOperation = {\n kind: OperationKind.COPY,\n start: oldOffset,\n end: oldOffset + blockSize,\n // oldBlocks: [checksum]\n }\n validateAndAdd(lastOperation, operations, checksum, i)\n }\n }\n }\n\n if (changedBlockCount > 0) {\n logger.info(`File${blockMapFile.name === \"file\" ? \"\" : \" \" + blockMapFile.name} has ${changedBlockCount} changed blocks`)\n }\n return operations\n}\n\nconst isValidateOperationRange = process.env[\"DIFFERENTIAL_DOWNLOAD_PLAN_BUILDER_VALIDATE_RANGES\"] === \"true\"\n\nfunction validateAndAdd(operation: Operation, operations: Array<Operation>, checksum: string, index: number): void {\n if (isValidateOperationRange && operations.length !== 0) {\n const lastOperation = operations[operations.length - 1]\n if (lastOperation.kind === operation.kind && operation.start < lastOperation.end && operation.start > lastOperation.start) {\n const min = [lastOperation.start, lastOperation.end, operation.start, operation.end].reduce((p, v) => (p < v ? p : v))\n throw new Error(\n `operation (block index: ${index}, checksum: ${checksum}, kind: ${OperationKind[operation.kind]}) overlaps previous operation (checksum: ${checksum}):\\n` +\n `abs: ${lastOperation.start} until ${lastOperation.end} and ${operation.start} until ${operation.end}\\n` +\n `rel: ${lastOperation.start - min} until ${lastOperation.end - min} and ${operation.start - min} until ${operation.end - min}`\n )\n }\n }\n operations.push(operation)\n}\n\nfunction buildChecksumMap(file: BlockMapFile, fileOffset: number, logger: Logger) {\n const checksumToOffset = new Map<string, number>()\n const checksumToSize = new Map<string, number>()\n let offset = fileOffset\n for (let i = 0; i < file.checksums.length; i++) {\n const checksum = file.checksums[i]\n const size = file.sizes[i]\n\n const existing = checksumToSize.get(checksum)\n if (existing === undefined) {\n checksumToOffset.set(checksum, offset)\n checksumToSize.set(checksum, size)\n } else if (logger.debug != null) {\n const sizeExplanation = existing === size ? \"(same size)\" : `(size: ${existing}, this size: ${size})`\n logger.debug(`${checksum} duplicated in blockmap ${sizeExplanation}, it doesn't lead to broken differential downloader, just corresponding block will be skipped)`)\n }\n offset += size\n }\n return { checksumToOffset, checksumToOldSize: checksumToSize }\n}\n\nfunction buildBlockFileMap(list: Array<BlockMapFile>): Map<string, BlockMapFile> {\n const result = new Map<string, BlockMapFile>()\n for (const item of list) {\n result.set(item.name, item)\n }\n return result\n}\n"]}
package/out/main.d.ts CHANGED
@@ -1,11 +1,7 @@
1
- import { CancellationToken, PackageFileInfo, ProgressInfo, UpdateFileInfo, UpdateInfo } from "builder-util-runtime";
2
- import { EventEmitter } from "events";
3
- import { URL } from "url";
4
1
  import { AppUpdater } from "./AppUpdater";
5
- import { LoginCallback } from "./electronHttpExecutor";
2
+ import { UpdateInfo } from "builder-util-runtime";
6
3
  export { BaseUpdater } from "./BaseUpdater";
7
4
  export { AppUpdater, NoOpLogger } from "./AppUpdater";
8
- export { CancellationToken, PackageFileInfo, ProgressInfo, UpdateFileInfo, UpdateInfo };
9
5
  export { Provider } from "./providers/Provider";
10
6
  export { AppImageUpdater } from "./AppImageUpdater";
11
7
  export { DebUpdater } from "./DebUpdater";
@@ -13,44 +9,8 @@ export { PacmanUpdater } from "./PacmanUpdater";
13
9
  export { RpmUpdater } from "./RpmUpdater";
14
10
  export { MacUpdater } from "./MacUpdater";
15
11
  export { NsisUpdater } from "./NsisUpdater";
12
+ export * from "./types";
16
13
  export declare const autoUpdater: AppUpdater;
17
- export interface ResolvedUpdateFileInfo {
18
- readonly url: URL;
19
- readonly info: UpdateFileInfo;
20
- packageInfo?: PackageFileInfo;
21
- }
22
- export interface UpdateCheckResult {
23
- readonly isUpdateAvailable: boolean;
24
- readonly updateInfo: UpdateInfo;
25
- readonly downloadPromise?: Promise<Array<string>> | null;
26
- readonly cancellationToken?: CancellationToken;
27
- /** @deprecated */
28
- readonly versionInfo: UpdateInfo;
29
- }
30
- export type UpdaterEvents = "login" | "checking-for-update" | "update-available" | "update-not-available" | "update-cancelled" | "download-progress" | "update-downloaded" | "error";
31
- export declare const DOWNLOAD_PROGRESS = "download-progress";
32
- export declare const UPDATE_DOWNLOADED = "update-downloaded";
33
- export type LoginHandler = (authInfo: any, callback: LoginCallback) => void;
34
- export declare class UpdaterSignal {
35
- private emitter;
36
- constructor(emitter: EventEmitter);
37
- /**
38
- * Emitted when an authenticating proxy is [asking for user credentials](https://github.com/electron/electron/blob/master/docs/api/client-request.md#event-login).
39
- */
40
- login(handler: LoginHandler): void;
41
- progress(handler: (info: ProgressInfo) => void): void;
42
- updateDownloaded(handler: (info: UpdateDownloadedEvent) => void): void;
43
- updateCancelled(handler: (info: UpdateInfo) => void): void;
44
- }
45
- export interface UpdateDownloadedEvent extends UpdateInfo {
46
- downloadedFile: string;
47
- }
48
- export interface Logger {
49
- info(message?: any): void;
50
- warn(message?: any): void;
51
- error(message?: any): void;
52
- debug?(message: string): void;
53
- }
54
14
  /**
55
15
  * return null if verify signature succeed
56
16
  * return error message if verify signature failed
package/out/main.js CHANGED
@@ -1,8 +1,20 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UpdaterSignal = exports.UPDATE_DOWNLOADED = exports.DOWNLOAD_PROGRESS = exports.NsisUpdater = exports.MacUpdater = exports.RpmUpdater = exports.PacmanUpdater = exports.DebUpdater = exports.AppImageUpdater = exports.Provider = exports.CancellationToken = exports.NoOpLogger = exports.AppUpdater = exports.BaseUpdater = void 0;
4
- const builder_util_runtime_1 = require("builder-util-runtime");
5
- Object.defineProperty(exports, "CancellationToken", { enumerable: true, get: function () { return builder_util_runtime_1.CancellationToken; } });
17
+ exports.NsisUpdater = exports.MacUpdater = exports.RpmUpdater = exports.PacmanUpdater = exports.DebUpdater = exports.AppImageUpdater = exports.Provider = exports.NoOpLogger = exports.AppUpdater = exports.BaseUpdater = void 0;
6
18
  const fs_extra_1 = require("fs-extra");
7
19
  const path = require("path");
8
20
  var BaseUpdater_1 = require("./BaseUpdater");
@@ -24,6 +36,7 @@ var MacUpdater_1 = require("./MacUpdater");
24
36
  Object.defineProperty(exports, "MacUpdater", { enumerable: true, get: function () { return MacUpdater_1.MacUpdater; } });
25
37
  var NsisUpdater_1 = require("./NsisUpdater");
26
38
  Object.defineProperty(exports, "NsisUpdater", { enumerable: true, get: function () { return NsisUpdater_1.NsisUpdater; } });
39
+ __exportStar(require("./types"), exports);
27
40
  // autoUpdater to mimic electron bundled autoUpdater
28
41
  let _autoUpdater;
29
42
  function doLoadAutoUpdater() {
@@ -70,39 +83,4 @@ Object.defineProperty(exports, "autoUpdater", {
70
83
  return _autoUpdater || doLoadAutoUpdater();
71
84
  },
72
85
  });
73
- exports.DOWNLOAD_PROGRESS = "download-progress";
74
- exports.UPDATE_DOWNLOADED = "update-downloaded";
75
- class UpdaterSignal {
76
- constructor(emitter) {
77
- this.emitter = emitter;
78
- }
79
- /**
80
- * Emitted when an authenticating proxy is [asking for user credentials](https://github.com/electron/electron/blob/master/docs/api/client-request.md#event-login).
81
- */
82
- login(handler) {
83
- addHandler(this.emitter, "login", handler);
84
- }
85
- progress(handler) {
86
- addHandler(this.emitter, exports.DOWNLOAD_PROGRESS, handler);
87
- }
88
- updateDownloaded(handler) {
89
- addHandler(this.emitter, exports.UPDATE_DOWNLOADED, handler);
90
- }
91
- updateCancelled(handler) {
92
- addHandler(this.emitter, "update-cancelled", handler);
93
- }
94
- }
95
- exports.UpdaterSignal = UpdaterSignal;
96
- const isLogEvent = false;
97
- function addHandler(emitter, event, handler) {
98
- if (isLogEvent) {
99
- emitter.on(event, (...args) => {
100
- console.log("%s %s", event, args);
101
- handler(...args);
102
- });
103
- }
104
- else {
105
- emitter.on(event, handler);
106
- }
107
- }
108
86
  //# sourceMappingURL=main.js.map