New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@todesktop/runtime

Package Overview
Dependencies
Maintainers
2
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@todesktop/runtime - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2-0

95

dist/initSmokeTest.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const crypto = require("crypto");
const electron_1 = require("electron");
const crypto = require("crypto");
const http = require("http");
const version_1 = require("./version");
function sendMessageToParent(event, data = {}) {
var _a;
(_a = process.send) === null || _a === void 0 ? void 0 : _a.call(process, Object.assign({ event }, data));
function sendHttpRequest(url, body) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
const request = http.request(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
}, (res) => {
if (res.statusCode === 200) {
const chunks = [];
res.on("data", (chunk) => chunks.push(chunk));
res.on("error", reject);
res.on("end", () => {
resolve(JSON.parse(Buffer.concat(chunks).toString("utf8")));
});
}
else {
reject(new Error(`POST ${url} returns status code ${res.statusCode}`));
}
});
request.on("error", reject);
request.write(JSON.stringify(body));
request.end();
});
});
}
// Looks like there is no a better way. No event emitted on write
function patchWritableWrite(writable, handler) {
const originalWrite = writable.write.bind(writable);
writable.write = (chunk, ...rest) => {
if (chunk) {
handler(typeof chunk === "string" ? chunk : chunk.toString("utf8"));
}
return originalWrite(chunk, ...rest);
};
}
function sha256(input) {

@@ -20,6 +61,14 @@ const stringInput = typeof input === "string" ? input : "";

feedUrl: process.env.TODESKTOP_SMOKE_TEST_FEED_URL || "",
apiUrl: process.env.TODESKTOP_SMOKE_TEST_API_URL || "",
secret: process.env.TODESKTOP_SMOKE_TEST_SECRET || "",
startedAtMs: Date.now(),
};
if (!config.enabled || sha256(config.secret) !== SECRET_HASH) {
function callApi(event, data = {}) {
sendHttpRequest(config.apiUrl, Object.assign({ event }, data)).catch((e) => {
console.error("Smoke Test API:", e);
});
}
if (!config.enabled ||
!config.apiUrl ||
sha256(config.secret) !== SECRET_HASH) {
return;

@@ -44,35 +93,29 @@ }

autoUpdater.on("update-downloaded", (payload) => {
sendMessageToParent("updateDownloaded", { payload });
callApi("updateDownloaded", { payload });
autoUpdater.restartAndInstall();
});
autoUpdater.on("before-quit-for-update", (payload) => {
sendMessageToParent("beforeQuitForUpdate", { payload });
callApi("beforeQuitForUpdate", { payload });
});
process
.on("message", ({ cmd }) => {
switch (cmd) {
case "getAppVersion":
return sendMessageToParent("appVersion", {
version: electron_1.app.getVersion(),
});
case "getRuntimeVersion":
return sendMessageToParent("runtimeVersion", {
version: version_1.CLIENT_VERSION,
});
default:
console.error(`Unknown command ${cmd}`);
}
})
.on("uncaughtException", (e) => {
sendMessageToParent("uncaughtException", { stack: e.stack });
callApi("uncaughtException", { stack: e.stack });
})
.on("unhandledRejection", (reason) => {
sendMessageToParent("unhandledRejection", { reason });
callApi("unhandledRejection", { reason });
});
patchWritableWrite(process.stdout, (content) => {
callApi("stdout", { content });
});
patchWritableWrite(process.stderr, (content) => {
callApi("stderr", { content });
});
callApi("connect", {
appVersion: electron_1.app.getVersion(),
runtimeVersion: version_1.CLIENT_VERSION,
});
setInterval(() => {
sendMessageToParent("timer", {
fromStartMs: Date.now() - config.startedAtMs,
});
callApi("timer", { fromStartMs: Date.now() - config.startedAtMs });
}, 1000);
}
exports.default = initSmokeTest;

@@ -25,3 +25,2 @@ import * as electronUpdater from "electron-updater";

_convertToTDUpdateInfo(updateCheckResult: electronUpdater.UpdateCheckResult): TDUpdateInfo;
_isUpdateAlreadyDownloaded(updateCheckResult: electronUpdater.UpdateCheckResult): boolean;
_uninstallSquirrelWindowsAppIfItExists(): Promise<void>;

@@ -28,0 +27,0 @@ }

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

checkAndDownload() {
var _a;
return __awaiter(this, void 0, void 0, function* () {

@@ -60,13 +61,15 @@ try {

const currentVersion = electron.app.getVersion();
const newVersion = updateCheckResult.updateInfo.version;
const latestVersion = updateCheckResult.updateInfo.version;
const currentlyDownloadedVersion = (_a = this.currentTDUpdateInfo) === null || _a === void 0 ? void 0 : _a.version;
this._log("debug", "Analysing autoUpdater.checkForUpdates result", {
currentVersion,
newVersion,
latestVersion,
currentlyDownloadedVersion,
updateInfo: updateCheckResult.updateInfo,
});
if (!semver.gt(newVersion, currentVersion)) {
if (!semver.gt(latestVersion, currentVersion)) {
return null;
}
// If the same version is already downloaded, we don't need to download it again
if (this._isUpdateAlreadyDownloaded(updateCheckResult)) {
// if latest version is already downloaded, return it
if (currentlyDownloadedVersion === latestVersion) {
return this.currentTDUpdateInfo;

@@ -99,8 +102,2 @@ }

}
_isUpdateAlreadyDownloaded(updateCheckResult) {
var _a, _b;
return (((_a = this.currentTDUpdateInfo) === null || _a === void 0 ? void 0 : _a.releaseDate) ===
updateCheckResult.updateInfo.releaseDate &&
((_b = this.currentTDUpdateInfo) === null || _b === void 0 ? void 0 : _b.version) === updateCheckResult.updateInfo.version);
}
_uninstallSquirrelWindowsAppIfItExists() {

@@ -107,0 +104,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -1,1 +0,1 @@

export declare const CLIENT_VERSION = "1.2.1";
export declare const CLIENT_VERSION = "1.2.2-0";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CLIENT_VERSION = void 0;
exports.CLIENT_VERSION = "1.2.1";
exports.CLIENT_VERSION = "1.2.2-0";

@@ -7,3 +7,3 @@ {

"name": "@todesktop/runtime",
"version": "1.2.1",
"version": "1.2.2-0",
"license": "MIT",

@@ -10,0 +10,0 @@ "author": "ToDesktop <hi@todesktop.com> (https://www.todesktop.com/)",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc