electron-incremental-update 2.0.0-beta.1 → 2.0.0-beta.11
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.
- package/README.md +3 -3
- package/dist/chunk-IABBXJFB.js +87 -0
- package/dist/chunk-KZSYEXLO.js +55 -0
- package/dist/chunk-RCRKUKFX.js +70 -0
- package/dist/index.cjs +193 -233
- package/dist/index.d.cts +89 -117
- package/dist/index.d.ts +89 -117
- package/dist/index.js +166 -169
- package/dist/provider.cjs +165 -146
- package/dist/provider.d.cts +94 -22
- package/dist/provider.d.ts +94 -22
- package/dist/provider.js +125 -71
- package/dist/types-C8JhnJjU.d.ts +80 -0
- package/dist/types-CGSkHX4Y.d.cts +80 -0
- package/dist/utils.cjs +142 -191
- package/dist/utils.d.cts +42 -30
- package/dist/utils.d.ts +42 -30
- package/dist/utils.js +3 -62
- package/dist/version-BYVQ367i.d.cts +62 -0
- package/dist/version-BYVQ367i.d.ts +62 -0
- package/dist/vite.d.ts +372 -0
- package/dist/vite.js +326 -274
- package/dist/zip-rm9ED9nU.d.cts +33 -0
- package/dist/zip-rm9ED9nU.d.ts +33 -0
- package/package.json +21 -15
- package/dist/chunk-RSLOPAIZ.js +0 -247
- package/dist/decrypt-BNBcodiO.d.cts +0 -4
- package/dist/decrypt-BNBcodiO.d.ts +0 -4
- package/dist/types-DxPmQmaq.d.cts +0 -61
- package/dist/types-seJf3Wbc.d.ts +0 -61
- package/dist/version-CffZWDhZ.d.cts +0 -32
- package/dist/version-CffZWDhZ.d.ts +0 -32
|
@@ -0,0 +1,33 @@
|
|
|
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 { defaultUnzipFile as a, aesEncrypt as b, defaultSignature as c, defaultZipFile as d, aesDecrypt as e, defaultVerifySignature as f, hashBuffer as h };
|
|
@@ -0,0 +1,33 @@
|
|
|
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 { 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.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "2.0.0-beta.11",
|
|
5
|
+
"description": "Electron incremental update tools with vite plugin, support bytecode protection",
|
|
6
6
|
"author": "subframe7536",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"repository":
|
|
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",
|
|
@@ -45,6 +48,7 @@
|
|
|
45
48
|
"build": "tsup && esno fix-module.cjs",
|
|
46
49
|
"release": "pnpm test && pnpm run build && bumpp --all && npm publish",
|
|
47
50
|
"test": "vitest --run",
|
|
51
|
+
"test:dev": "vitest",
|
|
48
52
|
"format": "eslint . --fix"
|
|
49
53
|
},
|
|
50
54
|
"publishConfig": {
|
|
@@ -52,30 +56,32 @@
|
|
|
52
56
|
"registry": "https://registry.npmjs.org/"
|
|
53
57
|
},
|
|
54
58
|
"peerDependencies": {
|
|
55
|
-
"@babel/core": "^7.24.7",
|
|
56
|
-
"@babel/plugin-transform-arrow-functions": "^7.24.7",
|
|
57
59
|
"@electron/asar": "*",
|
|
58
|
-
"esbuild": "*"
|
|
59
|
-
"magic-string": "*",
|
|
60
|
-
"vite-plugin-electron": "^0.15.6 || ^0.28"
|
|
60
|
+
"esbuild": "*"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
+
"@babel/core": "^7.24.9",
|
|
64
|
+
"@babel/plugin-transform-arrow-functions": "^7.24.7",
|
|
65
|
+
"@babel/plugin-transform-template-literals": "^7.24.7",
|
|
63
66
|
"@subframe7536/type-utils": "^0.1.6",
|
|
67
|
+
"ci-info": "^4.0.0",
|
|
64
68
|
"local-pkg": "^0.5.0",
|
|
65
|
-
"
|
|
69
|
+
"magic-string": "^0.30.10",
|
|
70
|
+
"selfsigned": "^2.4.1",
|
|
71
|
+
"vite-plugin-electron": "^0.28.7"
|
|
66
72
|
},
|
|
67
73
|
"devDependencies": {
|
|
68
|
-
"@subframe7536/eslint-config": "^0.
|
|
74
|
+
"@subframe7536/eslint-config": "^0.7.3",
|
|
69
75
|
"@types/babel__core": "^7.20.5",
|
|
70
|
-
"@types/node": "^20.14.
|
|
76
|
+
"@types/node": "^20.14.12",
|
|
71
77
|
"bumpp": "^9.4.1",
|
|
72
78
|
"electron": "28.2.10",
|
|
73
79
|
"eslint": "^9.7.0",
|
|
74
80
|
"esno": "^4.7.0",
|
|
75
|
-
"tsup": "^8.
|
|
76
|
-
"typescript": "^5.5.
|
|
77
|
-
"vite": "^5.3.
|
|
81
|
+
"tsup": "^8.2.2",
|
|
82
|
+
"typescript": "^5.5.4",
|
|
83
|
+
"vite": "^5.3.4",
|
|
78
84
|
"vite-plugin-electron": "^0.28.7",
|
|
79
|
-
"vitest": "^2.0.
|
|
85
|
+
"vitest": "^2.0.4"
|
|
80
86
|
}
|
|
81
87
|
}
|
package/dist/chunk-RSLOPAIZ.js
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
// src/utils/electron.ts
|
|
9
|
-
import { existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
10
|
-
import { dirname, join } from "node:path";
|
|
11
|
-
import { app } from "electron";
|
|
12
|
-
var isDev = __EIU_IS_DEV__;
|
|
13
|
-
var isWin = process.platform === "win32";
|
|
14
|
-
var isMac = process.platform === "darwin";
|
|
15
|
-
var isLinux = process.platform === "linux";
|
|
16
|
-
function getPathFromAppNameAsar(...path) {
|
|
17
|
-
return isDev ? "DEV.asar" : join(dirname(app.getAppPath()), `${app.name}.asar`, ...path);
|
|
18
|
-
}
|
|
19
|
-
function getAppVersion() {
|
|
20
|
-
return isDev ? getEntryVersion() : readFileSync(getPathFromAppNameAsar("version"), "utf-8");
|
|
21
|
-
}
|
|
22
|
-
function getEntryVersion() {
|
|
23
|
-
return app.getVersion();
|
|
24
|
-
}
|
|
25
|
-
function requireNative(moduleName) {
|
|
26
|
-
return __require(join(app.getAppPath(), __EIU_ENTRY_DIST_PATH__, moduleName));
|
|
27
|
-
}
|
|
28
|
-
function restartApp() {
|
|
29
|
-
app.relaunch();
|
|
30
|
-
app.quit();
|
|
31
|
-
}
|
|
32
|
-
function setAppUserModelId(id) {
|
|
33
|
-
isWin && app.setAppUserModelId(id ?? `org.${app.name}`);
|
|
34
|
-
}
|
|
35
|
-
function disableHWAccForWin7() {
|
|
36
|
-
if (__require("node:os").release().startsWith("6.1")) {
|
|
37
|
-
app.disableHardwareAcceleration();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function singleInstance(window) {
|
|
41
|
-
const result = app.requestSingleInstanceLock();
|
|
42
|
-
result ? app.on("second-instance", () => {
|
|
43
|
-
if (window) {
|
|
44
|
-
window.show();
|
|
45
|
-
if (window.isMinimized()) {
|
|
46
|
-
window.restore();
|
|
47
|
-
}
|
|
48
|
-
window.focus();
|
|
49
|
-
}
|
|
50
|
-
}) : app.quit();
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
function setPortableAppDataPath(dirName = "data") {
|
|
54
|
-
const portablePath = join(dirname(app.getPath("exe")), dirName);
|
|
55
|
-
if (!existsSync(portablePath)) {
|
|
56
|
-
mkdirSync(portablePath);
|
|
57
|
-
}
|
|
58
|
-
app.setPath("appData", portablePath);
|
|
59
|
-
}
|
|
60
|
-
function waitAppReady(timeout = 1e3) {
|
|
61
|
-
return app.isReady() ? Promise.resolve() : new Promise((resolve, reject) => {
|
|
62
|
-
const _ = setTimeout(() => {
|
|
63
|
-
reject(new Error("app is not ready"));
|
|
64
|
-
}, timeout);
|
|
65
|
-
app.whenReady().then(() => {
|
|
66
|
-
clearTimeout(_);
|
|
67
|
-
resolve();
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
function loadPage(win, htmlFilePath = "index.html") {
|
|
72
|
-
isDev ? win.loadURL(process.env.VITE_DEV_SERVER_URL + htmlFilePath) : win.loadFile(getPathFromAppNameAsar("renderer", htmlFilePath));
|
|
73
|
-
}
|
|
74
|
-
function getPathFromPreload(...paths) {
|
|
75
|
-
return isDev ? join(app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "preload", ...paths) : getPathFromAppNameAsar("preload", ...paths);
|
|
76
|
-
}
|
|
77
|
-
function getPathFromPublic(...paths) {
|
|
78
|
-
return isDev ? join(app.getAppPath(), "public", ...paths) : getPathFromAppNameAsar("renderer", ...paths);
|
|
79
|
-
}
|
|
80
|
-
function getPathFromEntryAsar(...paths) {
|
|
81
|
-
return join(app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// src/utils/zip.ts
|
|
85
|
-
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
86
|
-
import { brotliCompress } from "node:zlib";
|
|
87
|
-
async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
|
|
88
|
-
if (!existsSync2(filePath)) {
|
|
89
|
-
throw new Error(`path to be zipped not exist: ${filePath}`);
|
|
90
|
-
}
|
|
91
|
-
const buffer = readFileSync2(filePath);
|
|
92
|
-
return new Promise((resolve, reject) => {
|
|
93
|
-
brotliCompress(buffer, (err, buffer2) => {
|
|
94
|
-
if (err) {
|
|
95
|
-
reject(err);
|
|
96
|
-
}
|
|
97
|
-
writeFileSync(targetFilePath, buffer2);
|
|
98
|
-
resolve(null);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// src/utils/unzip.ts
|
|
104
|
-
import { existsSync as existsSync3, readFileSync as readFileSync3, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
105
|
-
import { brotliDecompress } from "node:zlib";
|
|
106
|
-
async function unzipFile(gzipPath, targetFilePath = gzipPath.slice(0, -3)) {
|
|
107
|
-
if (!existsSync3(gzipPath)) {
|
|
108
|
-
throw new Error(`path to zipped file not exist: ${gzipPath}`);
|
|
109
|
-
}
|
|
110
|
-
const compressedBuffer = readFileSync3(gzipPath);
|
|
111
|
-
return new Promise((resolve, reject) => {
|
|
112
|
-
brotliDecompress(compressedBuffer, (err, buffer) => {
|
|
113
|
-
rmSync(gzipPath);
|
|
114
|
-
if (err) {
|
|
115
|
-
reject(err);
|
|
116
|
-
}
|
|
117
|
-
writeFileSync2(targetFilePath, buffer);
|
|
118
|
-
resolve(null);
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// src/utils/version.ts
|
|
124
|
-
function handleUnexpectedErrors(callback) {
|
|
125
|
-
process.on("uncaughtException", callback);
|
|
126
|
-
process.on("unhandledRejection", callback);
|
|
127
|
-
}
|
|
128
|
-
function parseVersion(version) {
|
|
129
|
-
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i.exec(version);
|
|
130
|
-
if (!match) {
|
|
131
|
-
throw new TypeError(`invalid version: ${version}`);
|
|
132
|
-
}
|
|
133
|
-
const [major, minor, patch] = match.slice(1, 4).map(Number);
|
|
134
|
-
const ret = {
|
|
135
|
-
major,
|
|
136
|
-
minor,
|
|
137
|
-
patch,
|
|
138
|
-
stage: "",
|
|
139
|
-
stageVersion: -1
|
|
140
|
-
};
|
|
141
|
-
if (match[4]) {
|
|
142
|
-
let [stage, _v] = match[4].split(".");
|
|
143
|
-
ret.stage = stage;
|
|
144
|
-
ret.stageVersion = Number(_v) || -1;
|
|
145
|
-
}
|
|
146
|
-
if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) || Number.isNaN(ret.stageVersion)) {
|
|
147
|
-
throw new TypeError(`invalid version: ${version}`);
|
|
148
|
-
}
|
|
149
|
-
return ret;
|
|
150
|
-
}
|
|
151
|
-
function isLowerVersionDefault(oldVer, newVer) {
|
|
152
|
-
const oldV = parseVersion(oldVer);
|
|
153
|
-
const newV = parseVersion(newVer);
|
|
154
|
-
function compareStrings(str1, str2) {
|
|
155
|
-
if (str1 === "") {
|
|
156
|
-
return str2 !== "";
|
|
157
|
-
} else if (str2 === "") {
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
return str1 < str2;
|
|
161
|
-
}
|
|
162
|
-
for (let key of Object.keys(oldV)) {
|
|
163
|
-
if (key === "stage" && compareStrings(oldV[key], newV[key])) {
|
|
164
|
-
return true;
|
|
165
|
-
} else if (oldV[key] !== newV[key]) {
|
|
166
|
-
return oldV[key] < newV[key];
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
function isUpdateJSON(json) {
|
|
172
|
-
const is = (j) => !!(j && j.minimumVersion && j.signature && j.size && j.version);
|
|
173
|
-
return is(json) && is(json?.beta);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// src/utils/crypto/decrypt.ts
|
|
177
|
-
import { createDecipheriv, createVerify } from "node:crypto";
|
|
178
|
-
|
|
179
|
-
// src/utils/crypto/utils.ts
|
|
180
|
-
import { createHash } from "node:crypto";
|
|
181
|
-
function hashString(data, length) {
|
|
182
|
-
const hash = createHash("SHA256").update(data).digest("binary");
|
|
183
|
-
return Buffer.from(hash).subarray(0, length);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// src/utils/crypto/decrypt.ts
|
|
187
|
-
function decrypt(encryptedText, key, iv) {
|
|
188
|
-
const decipher = createDecipheriv("aes-256-cbc", key, iv);
|
|
189
|
-
let decrypted = decipher.update(encryptedText, "base64url", "utf8");
|
|
190
|
-
decrypted += decipher.final("utf8");
|
|
191
|
-
return decrypted;
|
|
192
|
-
}
|
|
193
|
-
function verifySignatureDefault(buffer, signature2, cert) {
|
|
194
|
-
try {
|
|
195
|
-
const [sig, version] = decrypt(signature2, hashString(cert, 32), hashString(buffer, 16)).split("%");
|
|
196
|
-
const result = createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
|
|
197
|
-
return result ? version : void 0;
|
|
198
|
-
} catch (error) {
|
|
199
|
-
return void 0;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// src/utils/crypto/encrypt.ts
|
|
204
|
-
import { createCipheriv, createPrivateKey, createSign } from "node:crypto";
|
|
205
|
-
function encrypt(plainText, key, iv) {
|
|
206
|
-
const cipher = createCipheriv("aes-256-cbc", key, iv);
|
|
207
|
-
let encrypted = cipher.update(plainText, "utf8", "base64url");
|
|
208
|
-
encrypted += cipher.final("base64url");
|
|
209
|
-
return encrypted;
|
|
210
|
-
}
|
|
211
|
-
function signature(buffer, privateKey, cert, version) {
|
|
212
|
-
const sig = createSign("RSA-SHA256").update(buffer).sign(createPrivateKey(privateKey), "base64");
|
|
213
|
-
return encrypt(`${sig}%${version}`, hashString(cert, 32), hashString(buffer, 16));
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export {
|
|
217
|
-
__require,
|
|
218
|
-
handleUnexpectedErrors,
|
|
219
|
-
parseVersion,
|
|
220
|
-
isLowerVersionDefault,
|
|
221
|
-
isUpdateJSON,
|
|
222
|
-
isDev,
|
|
223
|
-
isWin,
|
|
224
|
-
isMac,
|
|
225
|
-
isLinux,
|
|
226
|
-
getPathFromAppNameAsar,
|
|
227
|
-
getAppVersion,
|
|
228
|
-
getEntryVersion,
|
|
229
|
-
requireNative,
|
|
230
|
-
restartApp,
|
|
231
|
-
setAppUserModelId,
|
|
232
|
-
disableHWAccForWin7,
|
|
233
|
-
singleInstance,
|
|
234
|
-
setPortableAppDataPath,
|
|
235
|
-
waitAppReady,
|
|
236
|
-
loadPage,
|
|
237
|
-
getPathFromPreload,
|
|
238
|
-
getPathFromPublic,
|
|
239
|
-
getPathFromEntryAsar,
|
|
240
|
-
unzipFile,
|
|
241
|
-
zipFile,
|
|
242
|
-
hashString,
|
|
243
|
-
decrypt,
|
|
244
|
-
verifySignatureDefault,
|
|
245
|
-
encrypt,
|
|
246
|
-
signature
|
|
247
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
declare function decrypt(encryptedText: string, key: Buffer, iv: Buffer): string;
|
|
2
|
-
declare function verifySignatureDefault(buffer: Buffer, signature: string, cert: string): string | undefined | Promise<string | undefined>;
|
|
3
|
-
|
|
4
|
-
export { decrypt as d, verifySignatureDefault as v };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
declare function decrypt(encryptedText: string, key: Buffer, iv: Buffer): string;
|
|
2
|
-
declare function verifySignatureDefault(buffer: Buffer, signature: string, cert: string): string | undefined | Promise<string | undefined>;
|
|
3
|
-
|
|
4
|
-
export { decrypt as d, verifySignatureDefault as v };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
-
import { U as UpdateJSON, a as UpdateInfo } from './version-CffZWDhZ.cjs';
|
|
3
|
-
|
|
4
|
-
type URLHandler = (url: string, isDownloadAsar: boolean) => string;
|
|
5
|
-
type OnDownloading = (progress: DownloadingInfo) => void;
|
|
6
|
-
interface DownloadingInfo {
|
|
7
|
-
/**
|
|
8
|
-
* downloaded percent, 0% - 100%
|
|
9
|
-
*/
|
|
10
|
-
percent: `${number}%`;
|
|
11
|
-
/**
|
|
12
|
-
* total size
|
|
13
|
-
*/
|
|
14
|
-
total: number;
|
|
15
|
-
/**
|
|
16
|
-
* downloaded size
|
|
17
|
-
*/
|
|
18
|
-
current: number;
|
|
19
|
-
}
|
|
20
|
-
interface IProvider {
|
|
21
|
-
/**
|
|
22
|
-
* provider name
|
|
23
|
-
*/
|
|
24
|
-
name: string;
|
|
25
|
-
/**
|
|
26
|
-
* custom url handler
|
|
27
|
-
*
|
|
28
|
-
* for Github, there are some {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 public CDN links}
|
|
29
|
-
*/
|
|
30
|
-
urlHandler?: URLHandler;
|
|
31
|
-
onDownloading?: OnDownloading;
|
|
32
|
-
/**
|
|
33
|
-
* download update json
|
|
34
|
-
* @param versionPath parsed version path
|
|
35
|
-
*/
|
|
36
|
-
downloadJSON: (versionPath: string) => Promise<UpdateJSON>;
|
|
37
|
-
/**
|
|
38
|
-
* download update asar
|
|
39
|
-
* @param name app name
|
|
40
|
-
* @param updateInfo existing update info
|
|
41
|
-
* @param onDownloading hook for on downloading
|
|
42
|
-
*/
|
|
43
|
-
downloadBuffer: (name: string, updateInfo: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void) => Promise<Buffer>;
|
|
44
|
-
/**
|
|
45
|
-
* compare version
|
|
46
|
-
* @param oldVer old version string
|
|
47
|
-
* @param newVer new version string
|
|
48
|
-
* @returns if version1 < version2
|
|
49
|
-
*/
|
|
50
|
-
isLowerVersion: (oldVer: string, newVer: string) => Promisable<boolean>;
|
|
51
|
-
/**
|
|
52
|
-
* verify asar signature
|
|
53
|
-
* @param buffer file buffer
|
|
54
|
-
* @param signature signature
|
|
55
|
-
* @param cert certificate
|
|
56
|
-
* @returns if signature is valid, returns the version, otherwise returns `undefined`
|
|
57
|
-
*/
|
|
58
|
-
verifySignaure: (buffer: Buffer, signature: string, cert: string) => Promisable<string | undefined>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export type { DownloadingInfo as D, IProvider as I, OnDownloading as O, URLHandler as U };
|
package/dist/types-seJf3Wbc.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
-
import { U as UpdateJSON, a as UpdateInfo } from './version-CffZWDhZ.js';
|
|
3
|
-
|
|
4
|
-
type URLHandler = (url: string, isDownloadAsar: boolean) => string;
|
|
5
|
-
type OnDownloading = (progress: DownloadingInfo) => void;
|
|
6
|
-
interface DownloadingInfo {
|
|
7
|
-
/**
|
|
8
|
-
* downloaded percent, 0% - 100%
|
|
9
|
-
*/
|
|
10
|
-
percent: `${number}%`;
|
|
11
|
-
/**
|
|
12
|
-
* total size
|
|
13
|
-
*/
|
|
14
|
-
total: number;
|
|
15
|
-
/**
|
|
16
|
-
* downloaded size
|
|
17
|
-
*/
|
|
18
|
-
current: number;
|
|
19
|
-
}
|
|
20
|
-
interface IProvider {
|
|
21
|
-
/**
|
|
22
|
-
* provider name
|
|
23
|
-
*/
|
|
24
|
-
name: string;
|
|
25
|
-
/**
|
|
26
|
-
* custom url handler
|
|
27
|
-
*
|
|
28
|
-
* for Github, there are some {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 public CDN links}
|
|
29
|
-
*/
|
|
30
|
-
urlHandler?: URLHandler;
|
|
31
|
-
onDownloading?: OnDownloading;
|
|
32
|
-
/**
|
|
33
|
-
* download update json
|
|
34
|
-
* @param versionPath parsed version path
|
|
35
|
-
*/
|
|
36
|
-
downloadJSON: (versionPath: string) => Promise<UpdateJSON>;
|
|
37
|
-
/**
|
|
38
|
-
* download update asar
|
|
39
|
-
* @param name app name
|
|
40
|
-
* @param updateInfo existing update info
|
|
41
|
-
* @param onDownloading hook for on downloading
|
|
42
|
-
*/
|
|
43
|
-
downloadBuffer: (name: string, updateInfo: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void) => Promise<Buffer>;
|
|
44
|
-
/**
|
|
45
|
-
* compare version
|
|
46
|
-
* @param oldVer old version string
|
|
47
|
-
* @param newVer new version string
|
|
48
|
-
* @returns if version1 < version2
|
|
49
|
-
*/
|
|
50
|
-
isLowerVersion: (oldVer: string, newVer: string) => Promisable<boolean>;
|
|
51
|
-
/**
|
|
52
|
-
* verify asar signature
|
|
53
|
-
* @param buffer file buffer
|
|
54
|
-
* @param signature signature
|
|
55
|
-
* @param cert certificate
|
|
56
|
-
* @returns if signature is valid, returns the version, otherwise returns `undefined`
|
|
57
|
-
*/
|
|
58
|
-
verifySignaure: (buffer: Buffer, signature: string, cert: string) => Promisable<string | undefined>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export type { DownloadingInfo as D, IProvider as I, OnDownloading as O, URLHandler as U };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* handle all unhandled error
|
|
3
|
-
* @param callback callback function
|
|
4
|
-
*/
|
|
5
|
-
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
6
|
-
interface Version {
|
|
7
|
-
major: number;
|
|
8
|
-
minor: number;
|
|
9
|
-
patch: number;
|
|
10
|
-
stage: string;
|
|
11
|
-
stageVersion: number;
|
|
12
|
-
}
|
|
13
|
-
declare function parseVersion(version: string): Version;
|
|
14
|
-
declare function isLowerVersionDefault(oldVer: string, newVer: string): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* update info json
|
|
17
|
-
*/
|
|
18
|
-
type UpdateInfo = {
|
|
19
|
-
signature: string;
|
|
20
|
-
minimumVersion: string;
|
|
21
|
-
version: string;
|
|
22
|
-
size: number;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* {@link UpdateInfo} with beta
|
|
26
|
-
*/
|
|
27
|
-
type UpdateJSON = UpdateInfo & {
|
|
28
|
-
beta: UpdateInfo;
|
|
29
|
-
};
|
|
30
|
-
declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
31
|
-
|
|
32
|
-
export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, isUpdateJSON as b, handleUnexpectedErrors as h, isLowerVersionDefault as i, parseVersion as p };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* handle all unhandled error
|
|
3
|
-
* @param callback callback function
|
|
4
|
-
*/
|
|
5
|
-
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
6
|
-
interface Version {
|
|
7
|
-
major: number;
|
|
8
|
-
minor: number;
|
|
9
|
-
patch: number;
|
|
10
|
-
stage: string;
|
|
11
|
-
stageVersion: number;
|
|
12
|
-
}
|
|
13
|
-
declare function parseVersion(version: string): Version;
|
|
14
|
-
declare function isLowerVersionDefault(oldVer: string, newVer: string): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* update info json
|
|
17
|
-
*/
|
|
18
|
-
type UpdateInfo = {
|
|
19
|
-
signature: string;
|
|
20
|
-
minimumVersion: string;
|
|
21
|
-
version: string;
|
|
22
|
-
size: number;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* {@link UpdateInfo} with beta
|
|
26
|
-
*/
|
|
27
|
-
type UpdateJSON = UpdateInfo & {
|
|
28
|
-
beta: UpdateInfo;
|
|
29
|
-
};
|
|
30
|
-
declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
31
|
-
|
|
32
|
-
export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, isUpdateJSON as b, handleUnexpectedErrors as h, isLowerVersionDefault as i, parseVersion as p };
|