electron-incremental-update 2.0.0-beta.9 → 2.0.0

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.
@@ -1,10 +1,33 @@
1
1
  declare function hashBuffer(data: string | Buffer, length: number): Buffer;
2
2
  declare function aesEncrypt(plainText: string, key: Buffer, iv: Buffer): string;
3
+ /**
4
+ * Default function to generate asar signature, returns generated signature
5
+ * @param buffer file buffer
6
+ * @param privateKey primary key
7
+ * @param cert certificate
8
+ * @param version target version
9
+ */
3
10
  declare function defaultSignature(buffer: Buffer, privateKey: string, cert: string, version: string): string;
4
11
  declare function aesDecrypt(encryptedText: string, key: Buffer, iv: Buffer): string;
12
+ /**
13
+ * Default function to verify asar signature,
14
+ * if signature is valid, returns the version, otherwise returns `undefined`
15
+ * @param buffer file buffer
16
+ * @param version target version
17
+ * @param signature signature
18
+ * @param cert certificate
19
+ */
5
20
  declare function defaultVerifySignature(buffer: Buffer, version: string, signature: string, cert: string): boolean;
6
21
 
22
+ /**
23
+ * Default function to compress file using brotli
24
+ * @param buffer uncompressed file buffer
25
+ */
7
26
  declare function defaultZipFile(buffer: Buffer): Promise<Buffer>;
27
+ /**
28
+ * Default function to decompress file using brotli
29
+ * @param buffer compressed file buffer
30
+ */
8
31
  declare function defaultUnzipFile(buffer: Buffer): Promise<Buffer>;
9
32
 
10
33
  export { defaultUnzipFile as a, aesEncrypt as b, defaultSignature as c, defaultZipFile as d, aesDecrypt as e, defaultVerifySignature as f, hashBuffer as h };
@@ -1,10 +1,33 @@
1
1
  declare function hashBuffer(data: string | Buffer, length: number): Buffer;
2
2
  declare function aesEncrypt(plainText: string, key: Buffer, iv: Buffer): string;
3
+ /**
4
+ * Default function to generate asar signature, returns generated signature
5
+ * @param buffer file buffer
6
+ * @param privateKey primary key
7
+ * @param cert certificate
8
+ * @param version target version
9
+ */
3
10
  declare function defaultSignature(buffer: Buffer, privateKey: string, cert: string, version: string): string;
4
11
  declare function aesDecrypt(encryptedText: string, key: Buffer, iv: Buffer): string;
12
+ /**
13
+ * Default function to verify asar signature,
14
+ * if signature is valid, returns the version, otherwise returns `undefined`
15
+ * @param buffer file buffer
16
+ * @param version target version
17
+ * @param signature signature
18
+ * @param cert certificate
19
+ */
5
20
  declare function defaultVerifySignature(buffer: Buffer, version: string, signature: string, cert: string): boolean;
6
21
 
22
+ /**
23
+ * Default function to compress file using brotli
24
+ * @param buffer uncompressed file buffer
25
+ */
7
26
  declare function defaultZipFile(buffer: Buffer): Promise<Buffer>;
27
+ /**
28
+ * Default function to decompress file using brotli
29
+ * @param buffer compressed file buffer
30
+ */
8
31
  declare function defaultUnzipFile(buffer: Buffer): Promise<Buffer>;
9
32
 
10
33
  export { defaultUnzipFile as a, aesEncrypt as b, defaultSignature as c, defaultZipFile as d, aesDecrypt as e, defaultVerifySignature as f, hashBuffer as h };
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.9",
5
- "description": "electron incremental update tools, powered by vite",
4
+ "version": "2.0.0",
5
+ "description": "Electron incremental update tools with Vite plugin, support bytecode protection",
6
6
  "author": "subframe7536",
7
7
  "license": "MIT",
8
- "repository": "https://github.com/subframe7536/electron-incremental-update",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/subframe7536/electron-incremental-update.git"
11
+ },
9
12
  "keywords": [
10
13
  "electron",
11
14
  "incremental update",
@@ -70,15 +73,15 @@
70
73
  "devDependencies": {
71
74
  "@subframe7536/eslint-config": "^0.7.3",
72
75
  "@types/babel__core": "^7.20.5",
73
- "@types/node": "^20.14.11",
76
+ "@types/node": "^20.14.12",
74
77
  "bumpp": "^9.4.1",
75
78
  "electron": "28.2.10",
76
79
  "eslint": "^9.7.0",
77
80
  "esno": "^4.7.0",
78
- "tsup": "^8.2.1",
79
- "typescript": "^5.5.3",
81
+ "tsup": "^8.2.2",
82
+ "typescript": "^5.5.4",
80
83
  "vite": "^5.3.4",
81
84
  "vite-plugin-electron": "^0.28.7",
82
- "vitest": "^2.0.3"
85
+ "vitest": "^2.0.4"
83
86
  }
84
87
  }
@@ -1,81 +0,0 @@
1
- import { __require } from './chunk-72ZAJ7AF.js';
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import { app } from 'electron';
5
-
6
- var isDev = __EIU_IS_DEV__;
7
- var isWin = process.platform === "win32";
8
- var isMac = process.platform === "darwin";
9
- var isLinux = process.platform === "linux";
10
- function getPathFromAppNameAsar(...paths) {
11
- return isDev ? "DEV.asar" : path.join(path.dirname(app.getAppPath()), `${app.name}.asar`, ...paths);
12
- }
13
- function getAppVersion() {
14
- return isDev ? getEntryVersion() : fs.readFileSync(getPathFromAppNameAsar("version"), "utf-8");
15
- }
16
- function getEntryVersion() {
17
- return app.getVersion();
18
- }
19
- function requireNative(moduleName) {
20
- return __require(path.join(app.getAppPath(), __EIU_ENTRY_DIST_PATH__, moduleName));
21
- }
22
- function restartApp() {
23
- app.relaunch();
24
- app.quit();
25
- }
26
- function setAppUserModelId(id) {
27
- if (isWin) {
28
- app.setAppUserModelId(id ?? `org.${app.name}`);
29
- }
30
- }
31
- function disableHWAccForWin7() {
32
- if (__require("node:os").release().startsWith("6.1")) {
33
- app.disableHardwareAcceleration();
34
- }
35
- }
36
- function singleInstance(window) {
37
- const result = app.requestSingleInstanceLock();
38
- if (result) {
39
- app.on("second-instance", () => {
40
- if (window) {
41
- window.show();
42
- if (window.isMinimized()) {
43
- window.restore();
44
- }
45
- window.focus();
46
- }
47
- });
48
- } else {
49
- app.quit();
50
- }
51
- return result;
52
- }
53
- function setPortableAppDataPath(dirName = "data") {
54
- const portablePath = path.join(path.dirname(app.getPath("exe")), dirName);
55
- if (!fs.existsSync(portablePath)) {
56
- fs.mkdirSync(portablePath);
57
- }
58
- app.setPath("appData", portablePath);
59
- }
60
- function loadPage(win, htmlFilePath = "index.html") {
61
- if (isDev) {
62
- win.loadURL(process.env.VITE_DEV_SERVER_URL + htmlFilePath);
63
- } else {
64
- win.loadFile(getPathFromAppNameAsar("renderer", htmlFilePath));
65
- }
66
- }
67
- function getPathFromPreload(...paths) {
68
- return isDev ? path.join(app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "preload", ...paths) : getPathFromAppNameAsar("preload", ...paths);
69
- }
70
- function getPathFromPublic(...paths) {
71
- return isDev ? path.join(app.getAppPath(), "public", ...paths) : getPathFromAppNameAsar("renderer", ...paths);
72
- }
73
- function getPathFromEntryAsar(...paths) {
74
- return path.join(app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
75
- }
76
- function handleUnexpectedErrors(callback) {
77
- process.on("uncaughtException", callback);
78
- process.on("unhandledRejection", callback);
79
- }
80
-
81
- export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
@@ -1,27 +0,0 @@
1
- interface Version {
2
- major: number;
3
- minor: number;
4
- patch: number;
5
- stage: string;
6
- stageVersion: number;
7
- }
8
- declare function parseVersion(version: string): Version;
9
- declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
10
- /**
11
- * update info json
12
- */
13
- type UpdateInfo = {
14
- signature: string;
15
- minimumVersion: string;
16
- version: string;
17
- };
18
- /**
19
- * {@link UpdateInfo} with beta
20
- */
21
- type UpdateJSON = UpdateInfo & {
22
- beta: UpdateInfo;
23
- };
24
- declare function isUpdateJSON(json: any): json is UpdateJSON;
25
- declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
26
-
27
- export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
@@ -1,27 +0,0 @@
1
- interface Version {
2
- major: number;
3
- minor: number;
4
- patch: number;
5
- stage: string;
6
- stageVersion: number;
7
- }
8
- declare function parseVersion(version: string): Version;
9
- declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
10
- /**
11
- * update info json
12
- */
13
- type UpdateInfo = {
14
- signature: string;
15
- minimumVersion: string;
16
- version: string;
17
- };
18
- /**
19
- * {@link UpdateInfo} with beta
20
- */
21
- type UpdateJSON = UpdateInfo & {
22
- beta: UpdateInfo;
23
- };
24
- declare function isUpdateJSON(json: any): json is UpdateJSON;
25
- declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
26
-
27
- export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };