electron-incremental-update 2.2.1 → 2.2.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.
- package/README.md +6 -4
- package/dist/{bytecode-7V24FFYI.js → bytecode-R2B4KTMV.js} +3 -3
- package/dist/{chunk-PUVBFHOK.js → chunk-XGWQQVIZ.js} +12 -12
- package/dist/{esm-UJAQJA65.js → esm-4S4XCVEW.js} +1 -1
- package/dist/index.cjs +16 -16
- package/dist/index.d.cts +16 -7
- package/dist/index.d.ts +16 -7
- package/dist/index.js +12 -8
- package/dist/provider.cjs +44 -48
- package/dist/provider.d.cts +36 -35
- package/dist/provider.d.ts +36 -35
- package/dist/provider.js +19 -22
- package/dist/{types-C6lSLZWB.d.cts → types-CStrrQPl.d.ts} +4 -3
- package/dist/{types-nE_pIMPo.d.ts → types-CWtySwqA.d.cts} +4 -3
- package/dist/utils.cjs +37 -37
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +1 -1
- package/dist/{version-BYVQ367i.d.cts → version-Bl_0oO5f.d.cts} +12 -0
- package/dist/{version-BYVQ367i.d.ts → version-Bl_0oO5f.d.ts} +12 -0
- package/dist/vite.d.ts +47 -24
- package/dist/vite.js +28 -19
- package/dist/{crypto-Zynscwmj.d.ts → zip-DQdr8pFv.d.cts} +12 -12
- package/dist/{crypto-Zynscwmj.d.cts → zip-DQdr8pFv.d.ts} +12 -12
- package/package.json +86 -87
- package/dist/{chunk-7JCGLFGU.js → chunk-LR7LR5WG.js} +3 -3
package/README.md
CHANGED
|
@@ -94,8 +94,8 @@ See all config in [types](#plugin)
|
|
|
94
94
|
in `vite.config.mts`
|
|
95
95
|
|
|
96
96
|
```ts
|
|
97
|
-
import { defineConfig } from 'vite'
|
|
98
97
|
import { debugStartup, electronWithUpdater } from 'electron-incremental-update/vite'
|
|
98
|
+
import { defineConfig } from 'vite'
|
|
99
99
|
|
|
100
100
|
export default defineConfig(async ({ command }) => {
|
|
101
101
|
const isBuild = command === 'build'
|
|
@@ -180,9 +180,9 @@ The update steps are similar to [electron-updater](https://github.com/electron-u
|
|
|
180
180
|
in `electron/main/index.ts`
|
|
181
181
|
|
|
182
182
|
```ts
|
|
183
|
-
import { UpdaterError, startupWithUpdater } from 'electron-incremental-update'
|
|
184
|
-
import { getPathFromAppNameAsar, getVersions } from 'electron-incremental-update/utils'
|
|
185
183
|
import { app } from 'electron'
|
|
184
|
+
import { startupWithUpdater, UpdaterError } from 'electron-incremental-update'
|
|
185
|
+
import { getPathFromAppNameAsar, getVersions } from 'electron-incremental-update/utils'
|
|
186
186
|
|
|
187
187
|
export default startupWithUpdater((updater) => {
|
|
188
188
|
await app.whenReady()
|
|
@@ -260,7 +260,7 @@ const plugin = electronWithUpdater({
|
|
|
260
260
|
db: './electron/native/db.ts',
|
|
261
261
|
img: './electron/native/img.ts',
|
|
262
262
|
},
|
|
263
|
-
postBuild: async ({ copyToEntryOutputDir }) => {
|
|
263
|
+
postBuild: async ({ copyToEntryOutputDir, copyModules }) => {
|
|
264
264
|
// for better-sqlite3
|
|
265
265
|
copyToEntryOutputDir({
|
|
266
266
|
from: './node_modules/better-sqlite3/build/Release/better_sqlite3.node',
|
|
@@ -273,6 +273,8 @@ const plugin = electronWithUpdater({
|
|
|
273
273
|
copyToEntryOutputDir({
|
|
274
274
|
from: `./node_modules/.pnpm/${fileName}/node_modules/@napi-rs/image-${archName}/image.${archName}.node`,
|
|
275
275
|
})
|
|
276
|
+
// or just copy specific dependency
|
|
277
|
+
copyModules({ modules: ['better-sqlite3'] })
|
|
276
278
|
},
|
|
277
279
|
},
|
|
278
280
|
},
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { readableSize } from './chunk-TPTWE33H.js';
|
|
2
|
-
import { convertLiteral, bytecodeModuleLoaderCode, bytecodeModuleLoader, convertArrowFunctionAndTemplate, compileToBytecode, useStrict, toRelativePath } from './chunk-
|
|
2
|
+
import { convertLiteral, bytecodeModuleLoaderCode, bytecodeModuleLoader, convertArrowFunctionAndTemplate, compileToBytecode, useStrict, toRelativePath } from './chunk-LR7LR5WG.js';
|
|
3
3
|
import { bytecodeLog, bytecodeId } from './chunk-5NKEXGI3.js';
|
|
4
|
-
import path from 'node:path';
|
|
5
4
|
import fs from 'node:fs';
|
|
6
|
-
import
|
|
5
|
+
import path from 'node:path';
|
|
7
6
|
import MagicString from 'magic-string';
|
|
7
|
+
import { createFilter, normalizePath } from 'vite';
|
|
8
8
|
|
|
9
9
|
function getBytecodeLoaderBlock(chunkFileName) {
|
|
10
10
|
return `require("${toRelativePath(bytecodeModuleLoader, normalizePath(chunkFileName))}");`;
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import zlib from 'node:zlib';
|
|
2
1
|
import crypto from 'node:crypto';
|
|
2
|
+
import zlib from 'node:zlib';
|
|
3
3
|
|
|
4
|
-
// src/utils/
|
|
5
|
-
async function defaultZipFile(buffer) {
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
zlib.brotliCompress(buffer, (err, buffer2) => err ? reject(err) : resolve(buffer2));
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
async function defaultUnzipFile(buffer) {
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
zlib.brotliDecompress(buffer, (err, buffer2) => err ? reject(err) : resolve(buffer2));
|
|
13
|
-
});
|
|
14
|
-
}
|
|
4
|
+
// src/utils/crypto.ts
|
|
15
5
|
function hashBuffer(data, length) {
|
|
16
6
|
const hash = crypto.createHash("SHA256").update(data).digest("binary");
|
|
17
7
|
return Buffer.from(hash).subarray(0, length);
|
|
@@ -39,5 +29,15 @@ function defaultVerifySignature(buffer, version, signature, cert) {
|
|
|
39
29
|
return false;
|
|
40
30
|
}
|
|
41
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
42
|
|
|
43
43
|
export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, hashBuffer };
|
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var fs3 = require('fs');
|
|
4
|
-
var
|
|
4
|
+
var path2 = require('path');
|
|
5
5
|
var electron = require('electron');
|
|
6
|
-
var
|
|
6
|
+
var events = require('events');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
|
|
10
10
|
var fs3__default = /*#__PURE__*/_interopDefault(fs3);
|
|
11
|
+
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
11
12
|
var electron__default = /*#__PURE__*/_interopDefault(electron);
|
|
12
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
13
13
|
|
|
14
14
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
15
15
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
@@ -17,18 +17,12 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
17
17
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
18
18
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
// src/utils/version.ts
|
|
22
|
-
var is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
23
|
-
function isUpdateJSON(json) {
|
|
24
|
-
return is(json) && is(json?.beta);
|
|
25
|
-
}
|
|
26
20
|
var isDev = __EIU_IS_DEV__;
|
|
27
21
|
process.platform === "win32";
|
|
28
22
|
process.platform === "darwin";
|
|
29
23
|
process.platform === "linux";
|
|
30
24
|
function getPathFromAppNameAsar(...paths) {
|
|
31
|
-
return isDev ? "DEV.asar" :
|
|
25
|
+
return isDev ? "DEV.asar" : path2__default.default.join(path2__default.default.dirname(electron__default.default.app.getAppPath()), `${electron__default.default.app.name}.asar`, ...paths);
|
|
32
26
|
}
|
|
33
27
|
function getAppVersion() {
|
|
34
28
|
return isDev ? getEntryVersion() : fs3__default.default.readFileSync(getPathFromAppNameAsar("version"), "utf-8");
|
|
@@ -40,8 +34,11 @@ function restartApp() {
|
|
|
40
34
|
electron__default.default.app.relaunch();
|
|
41
35
|
electron__default.default.app.quit();
|
|
42
36
|
}
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
|
|
38
|
+
// src/utils/version.ts
|
|
39
|
+
var is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
40
|
+
function isUpdateJSON(json) {
|
|
41
|
+
return is(json) && is(json?.beta);
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
// src/entry/types.ts
|
|
@@ -136,18 +133,19 @@ var Updater = class extends events.EventEmitter {
|
|
|
136
133
|
if (!_data) {
|
|
137
134
|
return emitUnavailable("Failed to get update info", "UNAVAILABLE_ERROR");
|
|
138
135
|
}
|
|
139
|
-
const { signature, version, minimumVersion, url = "" } = this.receiveBeta ? _data.beta : _data;
|
|
136
|
+
const { signature, version, minimumVersion, url = "", ...rest } = this.receiveBeta ? _data.beta : _data;
|
|
140
137
|
const info = { signature, minimumVersion, version, url };
|
|
141
138
|
const extraVersionInfo = {
|
|
142
139
|
signature,
|
|
143
140
|
minimumVersion,
|
|
144
141
|
version,
|
|
145
142
|
appVersion: getAppVersion(),
|
|
146
|
-
entryVersion: getEntryVersion()
|
|
143
|
+
entryVersion: getEntryVersion(),
|
|
144
|
+
...rest
|
|
147
145
|
};
|
|
148
146
|
this.logger?.debug(`Checked update, version: ${version}, signature: ${signature}`);
|
|
149
147
|
if (isDev && !this.forceUpdate && !data) {
|
|
150
|
-
return emitUnavailable("Skip check update in dev mode. To force update, set `updater.forceUpdate` to true or call checkUpdate with UpdateJSON", "UNAVAILABLE_DEV"
|
|
148
|
+
return emitUnavailable("Skip check update in dev mode. To force update, set `updater.forceUpdate` to true or call checkUpdate with UpdateJSON", "UNAVAILABLE_DEV");
|
|
151
149
|
}
|
|
152
150
|
const isLowerVersion = this.provider.isLowerVersion;
|
|
153
151
|
try {
|
|
@@ -225,6 +223,8 @@ async function autoUpdate(updater) {
|
|
|
225
223
|
updater.quitAndInstall();
|
|
226
224
|
}
|
|
227
225
|
}
|
|
226
|
+
|
|
227
|
+
// src/entry/core.ts
|
|
228
228
|
function startupWithUpdater(fn) {
|
|
229
229
|
return fn;
|
|
230
230
|
}
|
|
@@ -235,7 +235,7 @@ var defaultOnInstall = (install, _, __, logger) => {
|
|
|
235
235
|
async function createElectronApp(appOptions = {}) {
|
|
236
236
|
const appNameAsarPath = getPathFromAppNameAsar();
|
|
237
237
|
const {
|
|
238
|
-
mainPath =
|
|
238
|
+
mainPath = isDev ? path2__default.default.join(electron__default.default.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "main", __EIU_MAIN_FILE__) : path2__default.default.join(path2__default.default.dirname(electron__default.default.app.getAppPath()), __EIU_ASAR_BASE_NAME__, "main", __EIU_MAIN_FILE__),
|
|
239
239
|
updater,
|
|
240
240
|
onInstall = defaultOnInstall,
|
|
241
241
|
beforeStart,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { EventEmitter } from 'node:events';
|
|
2
|
-
import { U as UpdateInfo, a as UpdateJSON } from './version-BYVQ367i.cjs';
|
|
3
|
-
import { I as IProvider, D as DownloadingInfo, U as UpdateJSONWithURL } from './types-C6lSLZWB.cjs';
|
|
4
1
|
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
+
import { I as IProvider, D as DownloadingInfo, U as UpdateJSONWithURL } from './types-CWtySwqA.cjs';
|
|
3
|
+
import { U as UpdateInfo, a as UpdateJSON } from './version-Bl_0oO5f.cjs';
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
5
|
+
import 'node:url';
|
|
5
6
|
|
|
6
7
|
type UpdaterErrorCode = 'ERR_DOWNLOAD' | 'ERR_VALIDATE' | 'ERR_PARAM' | 'ERR_NETWORK';
|
|
7
8
|
type UpdaterUnavailableCode = 'UNAVAILABLE_ERROR' | 'UNAVAILABLE_DEV' | 'UNAVAILABLE_VERSION';
|
|
@@ -36,15 +37,23 @@ interface UpdaterOption {
|
|
|
36
37
|
*/
|
|
37
38
|
logger?: Logger;
|
|
38
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Update info with current app version and entry version
|
|
42
|
+
*/
|
|
39
43
|
type UpdateInfoWithExtraVersion = UpdateInfo & {
|
|
44
|
+
/**
|
|
45
|
+
* Current app version
|
|
46
|
+
*/
|
|
40
47
|
appVersion: string;
|
|
48
|
+
/**
|
|
49
|
+
* Current entry version
|
|
50
|
+
*/
|
|
41
51
|
entryVersion: string;
|
|
42
52
|
};
|
|
43
53
|
|
|
44
|
-
declare class Updater extends EventEmitter<{
|
|
45
|
-
'
|
|
46
|
-
'update-available': [
|
|
47
|
-
'update-not-available': [code: UpdaterUnavailableCode, msg: string, info?: UpdateInfoWithExtraVersion];
|
|
54
|
+
declare class Updater<T extends UpdateInfoWithExtraVersion = UpdateInfoWithExtraVersion> extends EventEmitter<{
|
|
55
|
+
'update-available': [data: T];
|
|
56
|
+
'update-not-available': [code: UpdaterUnavailableCode, msg: string, info?: T];
|
|
48
57
|
'error': [error: UpdaterError];
|
|
49
58
|
'download-progress': [info: DownloadingInfo];
|
|
50
59
|
'update-downloaded': any;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { EventEmitter } from 'node:events';
|
|
2
|
-
import { U as UpdateInfo, a as UpdateJSON } from './version-BYVQ367i.js';
|
|
3
|
-
import { I as IProvider, D as DownloadingInfo, U as UpdateJSONWithURL } from './types-nE_pIMPo.js';
|
|
4
1
|
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
+
import { I as IProvider, D as DownloadingInfo, U as UpdateJSONWithURL } from './types-CStrrQPl.js';
|
|
3
|
+
import { U as UpdateInfo, a as UpdateJSON } from './version-Bl_0oO5f.js';
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
5
|
+
import 'node:url';
|
|
5
6
|
|
|
6
7
|
type UpdaterErrorCode = 'ERR_DOWNLOAD' | 'ERR_VALIDATE' | 'ERR_PARAM' | 'ERR_NETWORK';
|
|
7
8
|
type UpdaterUnavailableCode = 'UNAVAILABLE_ERROR' | 'UNAVAILABLE_DEV' | 'UNAVAILABLE_VERSION';
|
|
@@ -36,15 +37,23 @@ interface UpdaterOption {
|
|
|
36
37
|
*/
|
|
37
38
|
logger?: Logger;
|
|
38
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Update info with current app version and entry version
|
|
42
|
+
*/
|
|
39
43
|
type UpdateInfoWithExtraVersion = UpdateInfo & {
|
|
44
|
+
/**
|
|
45
|
+
* Current app version
|
|
46
|
+
*/
|
|
40
47
|
appVersion: string;
|
|
48
|
+
/**
|
|
49
|
+
* Current entry version
|
|
50
|
+
*/
|
|
41
51
|
entryVersion: string;
|
|
42
52
|
};
|
|
43
53
|
|
|
44
|
-
declare class Updater extends EventEmitter<{
|
|
45
|
-
'
|
|
46
|
-
'update-available': [
|
|
47
|
-
'update-not-available': [code: UpdaterUnavailableCode, msg: string, info?: UpdateInfoWithExtraVersion];
|
|
54
|
+
declare class Updater<T extends UpdateInfoWithExtraVersion = UpdateInfoWithExtraVersion> extends EventEmitter<{
|
|
55
|
+
'update-available': [data: T];
|
|
56
|
+
'update-not-available': [code: UpdaterUnavailableCode, msg: string, info?: T];
|
|
48
57
|
'error': [error: UpdaterError];
|
|
49
58
|
'download-progress': [info: DownloadingInfo];
|
|
50
59
|
'update-downloaded': any;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { isDev, getAppVersion, getEntryVersion, getPathFromAppNameAsar, restartApp
|
|
1
|
+
import { isDev, getAppVersion, getEntryVersion, getPathFromAppNameAsar, restartApp } from './chunk-JI27JWJN.js';
|
|
2
2
|
import { isUpdateJSON, __require } from './chunk-AAAM44NW.js';
|
|
3
3
|
import fs2 from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import electron2 from 'electron';
|
|
4
6
|
import { EventEmitter } from 'node:events';
|
|
5
|
-
import electron from 'electron';
|
|
6
7
|
|
|
7
8
|
// src/entry/types.ts
|
|
8
9
|
var UpdaterError = class extends Error {
|
|
@@ -66,7 +67,7 @@ var Updater = class extends EventEmitter {
|
|
|
66
67
|
}
|
|
67
68
|
this.logger?.debug(`Download from \`${this.provider.name}\``);
|
|
68
69
|
try {
|
|
69
|
-
const result = format === "json" ? await this.provider.downloadJSON(
|
|
70
|
+
const result = format === "json" ? await this.provider.downloadJSON(electron2.app.name, __EIU_VERSION_PATH__, this.controller.signal) : await this.provider.downloadAsar(this.info, this.controller.signal, (info) => this.emit("download-progress", info));
|
|
70
71
|
this.logger?.debug(`Download ${format} success${format === "buffer" ? `, file size: ${result.length}` : ""}`);
|
|
71
72
|
return result;
|
|
72
73
|
} catch (e) {
|
|
@@ -96,18 +97,19 @@ var Updater = class extends EventEmitter {
|
|
|
96
97
|
if (!_data) {
|
|
97
98
|
return emitUnavailable("Failed to get update info", "UNAVAILABLE_ERROR");
|
|
98
99
|
}
|
|
99
|
-
const { signature, version, minimumVersion, url = "" } = this.receiveBeta ? _data.beta : _data;
|
|
100
|
+
const { signature, version, minimumVersion, url = "", ...rest } = this.receiveBeta ? _data.beta : _data;
|
|
100
101
|
const info = { signature, minimumVersion, version, url };
|
|
101
102
|
const extraVersionInfo = {
|
|
102
103
|
signature,
|
|
103
104
|
minimumVersion,
|
|
104
105
|
version,
|
|
105
106
|
appVersion: getAppVersion(),
|
|
106
|
-
entryVersion: getEntryVersion()
|
|
107
|
+
entryVersion: getEntryVersion(),
|
|
108
|
+
...rest
|
|
107
109
|
};
|
|
108
110
|
this.logger?.debug(`Checked update, version: ${version}, signature: ${signature}`);
|
|
109
111
|
if (isDev && !this.forceUpdate && !data) {
|
|
110
|
-
return emitUnavailable("Skip check update in dev mode. To force update, set `updater.forceUpdate` to true or call checkUpdate with UpdateJSON", "UNAVAILABLE_DEV"
|
|
112
|
+
return emitUnavailable("Skip check update in dev mode. To force update, set `updater.forceUpdate` to true or call checkUpdate with UpdateJSON", "UNAVAILABLE_DEV");
|
|
111
113
|
}
|
|
112
114
|
const isLowerVersion = this.provider.isLowerVersion;
|
|
113
115
|
try {
|
|
@@ -185,6 +187,8 @@ async function autoUpdate(updater) {
|
|
|
185
187
|
updater.quitAndInstall();
|
|
186
188
|
}
|
|
187
189
|
}
|
|
190
|
+
|
|
191
|
+
// src/entry/core.ts
|
|
188
192
|
function startupWithUpdater(fn) {
|
|
189
193
|
return fn;
|
|
190
194
|
}
|
|
@@ -195,7 +199,7 @@ var defaultOnInstall = (install, _, __, logger) => {
|
|
|
195
199
|
async function createElectronApp(appOptions = {}) {
|
|
196
200
|
const appNameAsarPath = getPathFromAppNameAsar();
|
|
197
201
|
const {
|
|
198
|
-
mainPath =
|
|
202
|
+
mainPath = isDev ? path.join(electron2.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "main", __EIU_MAIN_FILE__) : path.join(path.dirname(electron2.app.getAppPath()), __EIU_ASAR_BASE_NAME__, "main", __EIU_MAIN_FILE__),
|
|
199
203
|
updater,
|
|
200
204
|
onInstall = defaultOnInstall,
|
|
201
205
|
beforeStart,
|
|
@@ -218,7 +222,7 @@ async function createElectronApp(appOptions = {}) {
|
|
|
218
222
|
} catch (error) {
|
|
219
223
|
logger?.error("startup error", error);
|
|
220
224
|
onStartError?.(error, logger);
|
|
221
|
-
|
|
225
|
+
electron2.app.quit();
|
|
222
226
|
}
|
|
223
227
|
}
|
|
224
228
|
var initApp = createElectronApp;
|
package/dist/provider.cjs
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var url = require('url');
|
|
4
|
-
var electron = require('electron');
|
|
5
3
|
var crypto = require('crypto');
|
|
6
4
|
var zlib = require('zlib');
|
|
5
|
+
var electron = require('electron');
|
|
6
|
+
var url = require('url');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
|
|
10
|
-
var electron__default = /*#__PURE__*/_interopDefault(electron);
|
|
11
10
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
12
11
|
var zlib__default = /*#__PURE__*/_interopDefault(zlib);
|
|
12
|
+
var electron__default = /*#__PURE__*/_interopDefault(electron);
|
|
13
13
|
|
|
14
|
-
// src/
|
|
14
|
+
// src/utils/crypto.ts
|
|
15
|
+
function hashBuffer(data, length) {
|
|
16
|
+
const hash = crypto__default.default.createHash("SHA256").update(data).digest("binary");
|
|
17
|
+
return Buffer.from(hash).subarray(0, length);
|
|
18
|
+
}
|
|
19
|
+
function aesDecrypt(encryptedText, key, iv) {
|
|
20
|
+
const decipher = crypto__default.default.createDecipheriv("aes-256-cbc", key, iv);
|
|
21
|
+
return decipher.update(encryptedText, "base64url", "utf8") + decipher.final("utf8");
|
|
22
|
+
}
|
|
23
|
+
function defaultVerifySignature(buffer, version, signature, cert) {
|
|
24
|
+
try {
|
|
25
|
+
const [sig, ver] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
|
|
26
|
+
if (ver !== version) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return crypto__default.default.createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
15
34
|
|
|
16
35
|
// src/utils/version.ts
|
|
17
36
|
function parseVersion(version) {
|
|
@@ -61,8 +80,28 @@ var is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
|
61
80
|
function isUpdateJSON(json) {
|
|
62
81
|
return is(json) && is(json?.beta);
|
|
63
82
|
}
|
|
83
|
+
async function defaultUnzipFile(buffer) {
|
|
84
|
+
return new Promise((resolve, reject) => {
|
|
85
|
+
zlib__default.default.brotliDecompress(buffer, (err, buffer2) => err ? reject(err) : resolve(buffer2));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
64
88
|
|
|
65
|
-
// src/provider/
|
|
89
|
+
// src/provider/base.ts
|
|
90
|
+
var BaseProvider = class {
|
|
91
|
+
name = "BaseProvider";
|
|
92
|
+
/**
|
|
93
|
+
* @inheritdoc
|
|
94
|
+
*/
|
|
95
|
+
isLowerVersion = defaultIsLowerVersion;
|
|
96
|
+
/**
|
|
97
|
+
* @inheritdoc
|
|
98
|
+
*/
|
|
99
|
+
verifySignaure = defaultVerifySignature;
|
|
100
|
+
/**
|
|
101
|
+
* @inheritdoc
|
|
102
|
+
*/
|
|
103
|
+
unzipFile = defaultUnzipFile;
|
|
104
|
+
};
|
|
66
105
|
function getHeader(headers, key) {
|
|
67
106
|
const value = headers[key];
|
|
68
107
|
if (Array.isArray(value)) {
|
|
@@ -154,49 +193,6 @@ async function defaultDownloadAsar(url, headers, signal, onDownloading) {
|
|
|
154
193
|
}
|
|
155
194
|
);
|
|
156
195
|
}
|
|
157
|
-
function hashBuffer(data, length) {
|
|
158
|
-
const hash = crypto__default.default.createHash("SHA256").update(data).digest("binary");
|
|
159
|
-
return Buffer.from(hash).subarray(0, length);
|
|
160
|
-
}
|
|
161
|
-
function aesDecrypt(encryptedText, key, iv) {
|
|
162
|
-
const decipher = crypto__default.default.createDecipheriv("aes-256-cbc", key, iv);
|
|
163
|
-
return decipher.update(encryptedText, "base64url", "utf8") + decipher.final("utf8");
|
|
164
|
-
}
|
|
165
|
-
function defaultVerifySignature(buffer, version, signature, cert) {
|
|
166
|
-
try {
|
|
167
|
-
const [sig, ver] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
|
|
168
|
-
if (ver !== version) {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
return crypto__default.default.createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
|
|
172
|
-
} catch {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
async function defaultUnzipFile(buffer) {
|
|
177
|
-
return new Promise((resolve, reject) => {
|
|
178
|
-
zlib__default.default.brotliDecompress(buffer, (err, buffer2) => err ? reject(err) : resolve(buffer2));
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// src/provider/base.ts
|
|
183
|
-
var BaseProvider = class {
|
|
184
|
-
name = "BaseProvider";
|
|
185
|
-
/**
|
|
186
|
-
* @inheritdoc
|
|
187
|
-
*/
|
|
188
|
-
isLowerVersion = defaultIsLowerVersion;
|
|
189
|
-
/**
|
|
190
|
-
* @inheritdoc
|
|
191
|
-
*/
|
|
192
|
-
verifySignaure = defaultVerifySignature;
|
|
193
|
-
/**
|
|
194
|
-
* @inheritdoc
|
|
195
|
-
*/
|
|
196
|
-
unzipFile = defaultUnzipFile;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
// src/provider/github.ts
|
|
200
196
|
var GitHubProvider = class extends BaseProvider {
|
|
201
197
|
name = "GithubProvider";
|
|
202
198
|
options;
|
package/dist/provider.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { I as IProvider, U as UpdateJSONWithURL, a as UpdateInfoWithURL, D as DownloadingInfo,
|
|
2
|
-
import {
|
|
3
|
-
import { d as defaultIsLowerVersion, a as UpdateJSON } from './version-
|
|
1
|
+
import { I as IProvider, U as UpdateJSONWithURL, a as UpdateInfoWithURL, D as DownloadingInfo, O as OnDownloading, b as URLHandler } from './types-CWtySwqA.cjs';
|
|
2
|
+
import { c as defaultVerifySignature, f as defaultUnzipFile } from './zip-DQdr8pFv.cjs';
|
|
3
|
+
import { d as defaultIsLowerVersion, a as UpdateJSON } from './version-Bl_0oO5f.cjs';
|
|
4
4
|
import { Arrayable } from '@subframe7536/type-utils';
|
|
5
|
+
import 'node:url';
|
|
5
6
|
|
|
6
7
|
declare abstract class BaseProvider implements IProvider {
|
|
7
8
|
name: string;
|
|
@@ -27,6 +28,38 @@ declare abstract class BaseProvider implements IProvider {
|
|
|
27
28
|
abstract downloadAsar(info: UpdateInfoWithURL, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Safe get value from header
|
|
33
|
+
* @param headers response header
|
|
34
|
+
* @param key target header key
|
|
35
|
+
*/
|
|
36
|
+
declare function getHeader(headers: Record<string, Arrayable<string>>, key: any): any;
|
|
37
|
+
type ResolveDataFn = (data: string, resolve: (data: any) => void, reject: (e: any) => void) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Default function to download json and parse to UpdateJson
|
|
40
|
+
* @param url target url
|
|
41
|
+
* @param headers extra headers
|
|
42
|
+
* @param signal abort signal
|
|
43
|
+
* @param resolveData on resolve
|
|
44
|
+
*/
|
|
45
|
+
declare function defaultDownloadJSON<T>(url: string, headers: Record<string, any>, signal: AbortSignal, resolveData?: ResolveDataFn): Promise<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Default function to download json and parse to UpdateJson
|
|
48
|
+
* @param url target url
|
|
49
|
+
* @param headers extra headers
|
|
50
|
+
* @param signal abort signal
|
|
51
|
+
*/
|
|
52
|
+
declare function defaultDownloadUpdateJSON(url: string, headers: Record<string, any>, signal: AbortSignal): Promise<UpdateJSON>;
|
|
53
|
+
/**
|
|
54
|
+
* Default function to download asar buffer,
|
|
55
|
+
* get total size from `Content-Length` header
|
|
56
|
+
* @param url target url
|
|
57
|
+
* @param headers extra headers
|
|
58
|
+
* @param signal abort signal
|
|
59
|
+
* @param onDownloading on downloading callback
|
|
60
|
+
*/
|
|
61
|
+
declare function defaultDownloadAsar(url: string, headers: Record<string, any>, signal: AbortSignal, onDownloading?: OnDownloading): Promise<Buffer>;
|
|
62
|
+
|
|
30
63
|
interface GitHubProviderOptions {
|
|
31
64
|
/**
|
|
32
65
|
* Github user name
|
|
@@ -131,36 +164,4 @@ declare class GitHubApiProvider extends BaseProvider {
|
|
|
131
164
|
downloadAsar(info: UpdateInfoWithURL, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
|
|
132
165
|
}
|
|
133
166
|
|
|
134
|
-
/**
|
|
135
|
-
* Safe get value from header
|
|
136
|
-
* @param headers response header
|
|
137
|
-
* @param key target header key
|
|
138
|
-
*/
|
|
139
|
-
declare function getHeader(headers: Record<string, Arrayable<string>>, key: any): any;
|
|
140
|
-
type ResolveDataFn = (data: string, resolve: (data: any) => void, reject: (e: any) => void) => void;
|
|
141
|
-
/**
|
|
142
|
-
* Default function to download json and parse to UpdateJson
|
|
143
|
-
* @param url target url
|
|
144
|
-
* @param headers extra headers
|
|
145
|
-
* @param signal abort signal
|
|
146
|
-
* @param resolveData on resolve
|
|
147
|
-
*/
|
|
148
|
-
declare function defaultDownloadJSON<T>(url: string, headers: Record<string, any>, signal: AbortSignal, resolveData?: ResolveDataFn): Promise<T>;
|
|
149
|
-
/**
|
|
150
|
-
* Default function to download json and parse to UpdateJson
|
|
151
|
-
* @param url target url
|
|
152
|
-
* @param headers extra headers
|
|
153
|
-
* @param signal abort signal
|
|
154
|
-
*/
|
|
155
|
-
declare function defaultDownloadUpdateJSON(url: string, headers: Record<string, any>, signal: AbortSignal): Promise<UpdateJSON>;
|
|
156
|
-
/**
|
|
157
|
-
* Default function to download asar buffer,
|
|
158
|
-
* get total size from `Content-Length` header
|
|
159
|
-
* @param url target url
|
|
160
|
-
* @param headers extra headers
|
|
161
|
-
* @param signal abort signal
|
|
162
|
-
* @param onDownloading on downloading callback
|
|
163
|
-
*/
|
|
164
|
-
declare function defaultDownloadAsar(url: string, headers: Record<string, any>, signal: AbortSignal, onDownloading?: OnDownloading): Promise<Buffer>;
|
|
165
|
-
|
|
166
167
|
export { BaseProvider, DownloadingInfo, GitHubApiProvider, type GitHubApiProviderOptions, GitHubProvider, type GitHubProviderOptions, IProvider, OnDownloading, URLHandler, UpdateInfoWithURL, UpdateJSONWithURL, defaultDownloadAsar, defaultDownloadJSON, defaultDownloadUpdateJSON, getHeader };
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { I as IProvider, U as UpdateJSONWithURL, a as UpdateInfoWithURL, D as DownloadingInfo,
|
|
2
|
-
import {
|
|
3
|
-
import { d as defaultIsLowerVersion, a as UpdateJSON } from './version-
|
|
1
|
+
import { I as IProvider, U as UpdateJSONWithURL, a as UpdateInfoWithURL, D as DownloadingInfo, O as OnDownloading, b as URLHandler } from './types-CStrrQPl.js';
|
|
2
|
+
import { c as defaultVerifySignature, f as defaultUnzipFile } from './zip-DQdr8pFv.js';
|
|
3
|
+
import { d as defaultIsLowerVersion, a as UpdateJSON } from './version-Bl_0oO5f.js';
|
|
4
4
|
import { Arrayable } from '@subframe7536/type-utils';
|
|
5
|
+
import 'node:url';
|
|
5
6
|
|
|
6
7
|
declare abstract class BaseProvider implements IProvider {
|
|
7
8
|
name: string;
|
|
@@ -27,6 +28,38 @@ declare abstract class BaseProvider implements IProvider {
|
|
|
27
28
|
abstract downloadAsar(info: UpdateInfoWithURL, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Safe get value from header
|
|
33
|
+
* @param headers response header
|
|
34
|
+
* @param key target header key
|
|
35
|
+
*/
|
|
36
|
+
declare function getHeader(headers: Record<string, Arrayable<string>>, key: any): any;
|
|
37
|
+
type ResolveDataFn = (data: string, resolve: (data: any) => void, reject: (e: any) => void) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Default function to download json and parse to UpdateJson
|
|
40
|
+
* @param url target url
|
|
41
|
+
* @param headers extra headers
|
|
42
|
+
* @param signal abort signal
|
|
43
|
+
* @param resolveData on resolve
|
|
44
|
+
*/
|
|
45
|
+
declare function defaultDownloadJSON<T>(url: string, headers: Record<string, any>, signal: AbortSignal, resolveData?: ResolveDataFn): Promise<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Default function to download json and parse to UpdateJson
|
|
48
|
+
* @param url target url
|
|
49
|
+
* @param headers extra headers
|
|
50
|
+
* @param signal abort signal
|
|
51
|
+
*/
|
|
52
|
+
declare function defaultDownloadUpdateJSON(url: string, headers: Record<string, any>, signal: AbortSignal): Promise<UpdateJSON>;
|
|
53
|
+
/**
|
|
54
|
+
* Default function to download asar buffer,
|
|
55
|
+
* get total size from `Content-Length` header
|
|
56
|
+
* @param url target url
|
|
57
|
+
* @param headers extra headers
|
|
58
|
+
* @param signal abort signal
|
|
59
|
+
* @param onDownloading on downloading callback
|
|
60
|
+
*/
|
|
61
|
+
declare function defaultDownloadAsar(url: string, headers: Record<string, any>, signal: AbortSignal, onDownloading?: OnDownloading): Promise<Buffer>;
|
|
62
|
+
|
|
30
63
|
interface GitHubProviderOptions {
|
|
31
64
|
/**
|
|
32
65
|
* Github user name
|
|
@@ -131,36 +164,4 @@ declare class GitHubApiProvider extends BaseProvider {
|
|
|
131
164
|
downloadAsar(info: UpdateInfoWithURL, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
|
|
132
165
|
}
|
|
133
166
|
|
|
134
|
-
/**
|
|
135
|
-
* Safe get value from header
|
|
136
|
-
* @param headers response header
|
|
137
|
-
* @param key target header key
|
|
138
|
-
*/
|
|
139
|
-
declare function getHeader(headers: Record<string, Arrayable<string>>, key: any): any;
|
|
140
|
-
type ResolveDataFn = (data: string, resolve: (data: any) => void, reject: (e: any) => void) => void;
|
|
141
|
-
/**
|
|
142
|
-
* Default function to download json and parse to UpdateJson
|
|
143
|
-
* @param url target url
|
|
144
|
-
* @param headers extra headers
|
|
145
|
-
* @param signal abort signal
|
|
146
|
-
* @param resolveData on resolve
|
|
147
|
-
*/
|
|
148
|
-
declare function defaultDownloadJSON<T>(url: string, headers: Record<string, any>, signal: AbortSignal, resolveData?: ResolveDataFn): Promise<T>;
|
|
149
|
-
/**
|
|
150
|
-
* Default function to download json and parse to UpdateJson
|
|
151
|
-
* @param url target url
|
|
152
|
-
* @param headers extra headers
|
|
153
|
-
* @param signal abort signal
|
|
154
|
-
*/
|
|
155
|
-
declare function defaultDownloadUpdateJSON(url: string, headers: Record<string, any>, signal: AbortSignal): Promise<UpdateJSON>;
|
|
156
|
-
/**
|
|
157
|
-
* Default function to download asar buffer,
|
|
158
|
-
* get total size from `Content-Length` header
|
|
159
|
-
* @param url target url
|
|
160
|
-
* @param headers extra headers
|
|
161
|
-
* @param signal abort signal
|
|
162
|
-
* @param onDownloading on downloading callback
|
|
163
|
-
*/
|
|
164
|
-
declare function defaultDownloadAsar(url: string, headers: Record<string, any>, signal: AbortSignal, onDownloading?: OnDownloading): Promise<Buffer>;
|
|
165
|
-
|
|
166
167
|
export { BaseProvider, DownloadingInfo, GitHubApiProvider, type GitHubApiProviderOptions, GitHubProvider, type GitHubProviderOptions, IProvider, OnDownloading, URLHandler, UpdateInfoWithURL, UpdateJSONWithURL, defaultDownloadAsar, defaultDownloadJSON, defaultDownloadUpdateJSON, getHeader };
|