electron-incremental-update 2.2.2 → 2.2.4

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.
@@ -0,0 +1,70 @@
1
+ import { Arrayable } from '@subframe7536/type-utils';
2
+ import { a as UpdateJSON, D as DownloadingInfo } from './types-C5M2xRjF.js';
3
+ import { IncomingMessage } from 'electron';
4
+
5
+ declare function hashBuffer(data: string | Buffer, length: number): Buffer;
6
+ declare function aesEncrypt(plainText: string, key: Buffer, iv: Buffer): string;
7
+ /**
8
+ * Default function to generate asar signature, returns generated signature
9
+ * @param buffer file buffer
10
+ * @param privateKey primary key
11
+ * @param cert certificate
12
+ * @param version target version
13
+ */
14
+ declare function defaultSignature(buffer: Buffer, privateKey: string, cert: string, version: string): string;
15
+ declare function aesDecrypt(encryptedText: string, key: Buffer, iv: Buffer): string;
16
+ /**
17
+ * Default function to verify asar signature,
18
+ * if signature is valid, returns the version, otherwise returns `undefined`
19
+ * @param buffer file buffer
20
+ * @param version target version
21
+ * @param signature signature
22
+ * @param cert certificate
23
+ */
24
+ declare function defaultVerifySignature(buffer: Buffer, version: string, signature: string, cert: string): boolean;
25
+
26
+ /**
27
+ * Safe get value from header
28
+ * @param headers response header
29
+ * @param key target header key
30
+ */
31
+ declare function getHeader(headers: Record<string, Arrayable<string>>, key: any): any;
32
+ declare function downloadUtil<T>(url: string, headers: Record<string, any>, signal: AbortSignal, onResponse: (resp: IncomingMessage, resolve: (data: T) => void, reject: (e: any) => void) => void): Promise<T>;
33
+ type ResolveDataFn = (data: string, resolve: (data: any) => void, reject: (e: any) => void) => void;
34
+ /**
35
+ * Default function to download json and parse to UpdateJson
36
+ * @param url target url
37
+ * @param headers extra headers
38
+ * @param signal abort signal
39
+ * @param resolveData on resolve
40
+ */
41
+ declare function defaultDownloadJSON<T>(url: string, headers: Record<string, any>, signal: AbortSignal, resolveData?: ResolveDataFn): Promise<T>;
42
+ /**
43
+ * Default function to download json and parse to UpdateJson
44
+ * @param url target url
45
+ * @param headers extra headers
46
+ * @param signal abort signal
47
+ */
48
+ declare function defaultDownloadUpdateJSON(url: string, headers: Record<string, any>, signal: AbortSignal): Promise<UpdateJSON>;
49
+ /**
50
+ * Default function to download asar buffer,
51
+ * get total size from `Content-Length` header
52
+ * @param url target url
53
+ * @param headers extra headers
54
+ * @param signal abort signal
55
+ * @param onDownloading on downloading callback
56
+ */
57
+ declare function defaultDownloadAsar(url: string, headers: Record<string, any>, signal: AbortSignal, onDownloading?: (progress: DownloadingInfo) => void): Promise<Buffer>;
58
+
59
+ /**
60
+ * Default function to compress file using brotli
61
+ * @param buffer uncompressed file buffer
62
+ */
63
+ declare function defaultZipFile(buffer: Buffer): Promise<Buffer>;
64
+ /**
65
+ * Default function to decompress file using brotli
66
+ * @param buffer compressed file buffer
67
+ */
68
+ declare function defaultUnzipFile(buffer: Buffer): Promise<Buffer>;
69
+
70
+ export { aesEncrypt as a, aesDecrypt as b, defaultVerifySignature as c, defaultSignature as d, downloadUtil as e, defaultDownloadJSON as f, getHeader as g, hashBuffer as h, defaultDownloadUpdateJSON as i, defaultDownloadAsar as j, defaultZipFile as k, defaultUnzipFile as l };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "type": "module",
4
- "version": "2.2.2",
4
+ "version": "2.2.4",
5
5
  "description": "Electron incremental update tools with Vite plugin, support bytecode protection",
6
6
  "author": "subframe7536",
7
7
  "license": "MIT",
@@ -60,27 +60,32 @@
60
60
  "esbuild": "*"
61
61
  },
62
62
  "dependencies": {
63
- "@babel/core": "^7.25.7",
64
- "@babel/plugin-transform-arrow-functions": "^7.25.7",
65
- "@babel/plugin-transform-template-literals": "^7.25.7",
63
+ "@babel/core": "^7.26.7",
64
+ "@babel/plugin-transform-arrow-functions": "^7.25.9",
65
+ "@babel/plugin-transform-template-literals": "^7.25.9",
66
66
  "@subframe7536/type-utils": "^0.1.6",
67
- "ci-info": "^4.0.0",
68
- "local-pkg": "^0.5.0",
69
- "magic-string": "^0.30.11",
67
+ "ci-info": "^4.1.0",
68
+ "local-pkg": "^1.0.0",
69
+ "magic-string": "^0.30.17",
70
70
  "selfsigned": "^2.4.1",
71
- "vite-plugin-electron": "^0.28.8"
71
+ "vite-plugin-electron": "^0.29.0"
72
72
  },
73
73
  "devDependencies": {
74
- "@subframe7536/eslint-config": "^0.9.4",
74
+ "@subframe7536/eslint-config": "^1.1.8",
75
75
  "@types/babel__core": "^7.20.5",
76
- "@types/node": "^20.16.11",
77
- "bumpp": "^9.6.1",
78
- "electron": "28.2.10",
79
- "eslint": "^9.12.0",
80
- "tsup": "^8.3.0",
81
- "typescript": "^5.6.3",
82
- "vite": "^5.4.8",
83
- "vite-plugin-electron": "^0.28.8",
84
- "vitest": "^2.1.2"
76
+ "@types/node": "^20.17.17",
77
+ "bumpp": "^10.0.1",
78
+ "electron": "34.0.2",
79
+ "eslint": "^9.19.0",
80
+ "tsup": "^8.3.6",
81
+ "typescript": "^5.7.3",
82
+ "vite": "^6.0.11",
83
+ "vite-plugin-electron": "^0.29.0",
84
+ "vitest": "^3.0.5"
85
+ },
86
+ "pnpm": {
87
+ "overrides": {
88
+ "is-core-module": "npm:@nolyfill/is-core-module@^1"
89
+ }
85
90
  }
86
91
  }
@@ -1,43 +0,0 @@
1
- import crypto from 'node:crypto';
2
- import zlib from 'node:zlib';
3
-
4
- // src/utils/crypto.ts
5
- function hashBuffer(data, length) {
6
- const hash = crypto.createHash("SHA256").update(data).digest("binary");
7
- return Buffer.from(hash).subarray(0, length);
8
- }
9
- function aesEncrypt(plainText, key, iv) {
10
- const cipher = crypto.createCipheriv("aes-256-cbc", key, iv);
11
- return cipher.update(plainText, "utf8", "base64url") + cipher.final("base64url");
12
- }
13
- function defaultSignature(buffer, privateKey, cert, version) {
14
- const sig = crypto.createSign("RSA-SHA256").update(buffer).sign(crypto.createPrivateKey(privateKey), "base64");
15
- return aesEncrypt(`${sig}%${version}`, hashBuffer(cert, 32), hashBuffer(buffer, 16));
16
- }
17
- function aesDecrypt(encryptedText, key, iv) {
18
- const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
19
- return decipher.update(encryptedText, "base64url", "utf8") + decipher.final("utf8");
20
- }
21
- function defaultVerifySignature(buffer, version, signature, cert) {
22
- try {
23
- const [sig, ver] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
24
- if (ver !== version) {
25
- return false;
26
- }
27
- return crypto.createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
28
- } catch {
29
- return false;
30
- }
31
- }
32
- async function defaultZipFile(buffer) {
33
- return new Promise((resolve, reject) => {
34
- zlib.brotliCompress(buffer, (err, buffer2) => err ? reject(err) : resolve(buffer2));
35
- });
36
- }
37
- async function defaultUnzipFile(buffer) {
38
- return new Promise((resolve, reject) => {
39
- zlib.brotliDecompress(buffer, (err, buffer2) => err ? reject(err) : resolve(buffer2));
40
- });
41
- }
42
-
43
- export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, hashBuffer };
@@ -1,74 +0,0 @@
1
- interface Version {
2
- /**
3
- * `4` of `4.3.2-beta.1`
4
- */
5
- major: number;
6
- /**
7
- * `3` of `4.3.2-beta.1`
8
- */
9
- minor: number;
10
- /**
11
- * `2` of `4.3.2-beta.1`
12
- */
13
- patch: number;
14
- /**
15
- * `beta` of `4.3.2-beta.1`
16
- */
17
- stage: string;
18
- /**
19
- * `1` of `4.3.2-beta.1`
20
- */
21
- stageVersion: number;
22
- }
23
- /**
24
- * Parse version string to {@link Version}, like `0.2.0-beta.1`
25
- * @param version version string
26
- */
27
- declare function parseVersion(version: string): Version;
28
- /**
29
- * Default function to check the old version is less than new version
30
- * @param oldVer old version string
31
- * @param newVer new version string
32
- */
33
- declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
34
- /**
35
- * Update info json
36
- */
37
- type UpdateInfo = {
38
- /**
39
- * Update Asar signature
40
- */
41
- signature: string;
42
- /**
43
- * Minimum version
44
- */
45
- minimumVersion: string;
46
- /**
47
- * Target version
48
- */
49
- version: string;
50
- };
51
- /**
52
- * {@link UpdateInfo} with beta
53
- */
54
- type UpdateJSON = UpdateInfo & {
55
- /**
56
- * Beta update info
57
- */
58
- beta: UpdateInfo;
59
- };
60
- /**
61
- * Check is `UpdateJSON`
62
- * @param json any variable
63
- */
64
- declare function isUpdateJSON(json: any): json is UpdateJSON;
65
- /**
66
- * Default function to generate `UpdateJSON`
67
- * @param existingJson exising update json
68
- * @param signature sigature
69
- * @param version target version
70
- * @param minimumVersion minimum version
71
- */
72
- declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
73
-
74
- export { type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
@@ -1,74 +0,0 @@
1
- interface Version {
2
- /**
3
- * `4` of `4.3.2-beta.1`
4
- */
5
- major: number;
6
- /**
7
- * `3` of `4.3.2-beta.1`
8
- */
9
- minor: number;
10
- /**
11
- * `2` of `4.3.2-beta.1`
12
- */
13
- patch: number;
14
- /**
15
- * `beta` of `4.3.2-beta.1`
16
- */
17
- stage: string;
18
- /**
19
- * `1` of `4.3.2-beta.1`
20
- */
21
- stageVersion: number;
22
- }
23
- /**
24
- * Parse version string to {@link Version}, like `0.2.0-beta.1`
25
- * @param version version string
26
- */
27
- declare function parseVersion(version: string): Version;
28
- /**
29
- * Default function to check the old version is less than new version
30
- * @param oldVer old version string
31
- * @param newVer new version string
32
- */
33
- declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
34
- /**
35
- * Update info json
36
- */
37
- type UpdateInfo = {
38
- /**
39
- * Update Asar signature
40
- */
41
- signature: string;
42
- /**
43
- * Minimum version
44
- */
45
- minimumVersion: string;
46
- /**
47
- * Target version
48
- */
49
- version: string;
50
- };
51
- /**
52
- * {@link UpdateInfo} with beta
53
- */
54
- type UpdateJSON = UpdateInfo & {
55
- /**
56
- * Beta update info
57
- */
58
- beta: UpdateInfo;
59
- };
60
- /**
61
- * Check is `UpdateJSON`
62
- * @param json any variable
63
- */
64
- declare function isUpdateJSON(json: any): json is UpdateJSON;
65
- /**
66
- * Default function to generate `UpdateJSON`
67
- * @param existingJson exising update json
68
- * @param signature sigature
69
- * @param version target version
70
- * @param minimumVersion minimum version
71
- */
72
- declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
73
-
74
- export { type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
@@ -1,33 +0,0 @@
1
- declare function hashBuffer(data: string | Buffer, length: number): Buffer;
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
- */
10
- declare function defaultSignature(buffer: Buffer, privateKey: string, cert: string, version: string): string;
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
- */
20
- declare function defaultVerifySignature(buffer: Buffer, version: string, signature: string, cert: string): boolean;
21
-
22
- /**
23
- * Default function to compress file using brotli
24
- * @param buffer uncompressed file buffer
25
- */
26
- declare function defaultZipFile(buffer: Buffer): Promise<Buffer>;
27
- /**
28
- * Default function to decompress file using brotli
29
- * @param buffer compressed file buffer
30
- */
31
- declare function defaultUnzipFile(buffer: Buffer): Promise<Buffer>;
32
-
33
- export { aesEncrypt as a, aesDecrypt as b, defaultVerifySignature as c, defaultSignature as d, defaultZipFile as e, defaultUnzipFile as f, hashBuffer as h };
@@ -1,33 +0,0 @@
1
- declare function hashBuffer(data: string | Buffer, length: number): Buffer;
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
- */
10
- declare function defaultSignature(buffer: Buffer, privateKey: string, cert: string, version: string): string;
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
- */
20
- declare function defaultVerifySignature(buffer: Buffer, version: string, signature: string, cert: string): boolean;
21
-
22
- /**
23
- * Default function to compress file using brotli
24
- * @param buffer uncompressed file buffer
25
- */
26
- declare function defaultZipFile(buffer: Buffer): Promise<Buffer>;
27
- /**
28
- * Default function to decompress file using brotli
29
- * @param buffer compressed file buffer
30
- */
31
- declare function defaultUnzipFile(buffer: Buffer): Promise<Buffer>;
32
-
33
- export { aesEncrypt as a, aesDecrypt as b, defaultVerifySignature as c, defaultSignature as d, defaultZipFile as e, defaultUnzipFile as f, hashBuffer as h };