nw 0.89.0 → 0.90.0-1
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/LICENSE +20 -0
- package/README.md +1 -1
- package/package.json +10 -12
- package/src/get.js +6 -0
- package/src/postinstall.js +9 -0
- package/src/verify.js +47 -0
- package/src/verify.test.js +15 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2011-2019 NW.js Authors
|
|
2
|
+
Copyright (c) 2011-2019 The Chromium Authors
|
|
3
|
+
Copyright (c) 2011-2018 Intel Corp
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to use,
|
|
8
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
9
|
+
Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
16
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
|
17
|
+
A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
18
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
19
|
+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
|
|
20
|
+
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ npm install --save-dev nw@0.85.0-1
|
|
|
36
36
|
npm install --save-dev nw@sdk
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Or set `nwjs_build_type=sdk` in `.npmrc` or `NWJS_BUILD_TYPE=sdk` environment variable.
|
|
40
40
|
|
|
41
41
|
### Specify platform:
|
|
42
42
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nw",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "An installer for
|
|
3
|
+
"version": "0.90.0-1",
|
|
4
|
+
"description": "An installer for NW.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git://github.com/nwjs/npm-installer.git"
|
|
@@ -14,12 +14,9 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"postinstall": "node src/postinstall.js",
|
|
16
16
|
"test": "vitest run",
|
|
17
|
-
"test:
|
|
18
|
-
"demo": "nw ./test/app --log-level=verbose"
|
|
17
|
+
"test:coverage": "vitest --coverage.enabled true"
|
|
19
18
|
},
|
|
20
19
|
"files": [
|
|
21
|
-
"bin",
|
|
22
|
-
"lib",
|
|
23
20
|
"src"
|
|
24
21
|
],
|
|
25
22
|
"author": {
|
|
@@ -34,10 +31,10 @@
|
|
|
34
31
|
],
|
|
35
32
|
"license": "MIT",
|
|
36
33
|
"dependencies": {
|
|
37
|
-
"axios": "^1.7.
|
|
34
|
+
"axios": "^1.7.4",
|
|
38
35
|
"commander": "^12.1.0",
|
|
39
|
-
"semver": "^7.6.
|
|
40
|
-
"tar": "^7.4.
|
|
36
|
+
"semver": "^7.6.3",
|
|
37
|
+
"tar": "^7.4.3",
|
|
41
38
|
"yauzl-promise": "^4.0.0"
|
|
42
39
|
},
|
|
43
40
|
"keywords": [
|
|
@@ -53,8 +50,9 @@
|
|
|
53
50
|
"application"
|
|
54
51
|
],
|
|
55
52
|
"devDependencies": {
|
|
56
|
-
"@vitest/coverage-v8": "^
|
|
57
|
-
"
|
|
58
|
-
"
|
|
53
|
+
"@vitest/coverage-v8": "^2.0.5",
|
|
54
|
+
"patch-package": "^8.0.0",
|
|
55
|
+
"selenium-webdriver": "^4.23.0",
|
|
56
|
+
"vitest": "^2.0.2"
|
|
59
57
|
}
|
|
60
58
|
}
|
package/src/get.js
CHANGED
|
@@ -96,6 +96,12 @@ async function get(options) {
|
|
|
96
96
|
|
|
97
97
|
await decompress(nwFilePath, options.cacheDir);
|
|
98
98
|
|
|
99
|
+
await verify(
|
|
100
|
+
`${options.downloadUrl}/v${options.version}/SHASUMS256.txt`,
|
|
101
|
+
`${options.cacheDir}/shasum/${options.version}.txt`,
|
|
102
|
+
options.cacheDir,
|
|
103
|
+
);
|
|
104
|
+
|
|
99
105
|
await fs.promises.symlink(nwDirPath, './nwjs', );
|
|
100
106
|
|
|
101
107
|
if (options.ffmpeg === true) {
|
package/src/postinstall.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import child_process from 'node:child_process';
|
|
1
2
|
import fs from 'node:fs';
|
|
2
3
|
import process from 'node:process';
|
|
3
4
|
import path from 'node:path';
|
|
@@ -8,6 +9,14 @@ import semver from 'semver';
|
|
|
8
9
|
import get from './get.js';
|
|
9
10
|
import util from './util.js';
|
|
10
11
|
|
|
12
|
+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
13
|
+
|
|
14
|
+
const patchPackagePath = path.resolve(path.join(__dirname, '..', 'node_modules', 'patch-package'));
|
|
15
|
+
|
|
16
|
+
if (fs.existsSync(patchPackagePath)) {
|
|
17
|
+
child_process.execSync('node ' + patchPackagePath);
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
await postinstall()
|
|
12
21
|
.catch((error) => {
|
|
13
22
|
if (error.code === 'EPERM') {
|
package/src/verify.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
import request from './request.js';
|
|
6
|
+
import util from './util.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Verify the SHA256 checksum of downloaded artifacts.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} shaUrl - URL to get the shasum text file from.
|
|
12
|
+
* @param {string} shaOut - File path to shasum text file.
|
|
13
|
+
* @param {string} cacheDir - File path to cache directory.
|
|
14
|
+
* @throws {Error}
|
|
15
|
+
* @returns {Promise<boolean>}
|
|
16
|
+
*/
|
|
17
|
+
export default async function verify(shaUrl, shaOut, cacheDir) {
|
|
18
|
+
const shaOutExists = await util.fileExists(shaOut);
|
|
19
|
+
|
|
20
|
+
if (shaOutExists === false) {
|
|
21
|
+
/* Create directory if does not exist. */
|
|
22
|
+
await fs.promises.mkdir(path.dirname(shaOut), { recursive: true });
|
|
23
|
+
|
|
24
|
+
/* Download SHASUM text file. */
|
|
25
|
+
await request(shaUrl, shaOut);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Read SHASUM text file */
|
|
29
|
+
const shasum = await fs.promises.readFile(shaOut, { encoding: 'utf-8' });
|
|
30
|
+
const shasums = shasum.trim().split('\n');
|
|
31
|
+
for await (const line of shasums) {
|
|
32
|
+
const [storedSha, filePath] = line.split(' ');
|
|
33
|
+
const relativeFilePath = path.resolve(cacheDir, filePath);
|
|
34
|
+
const relativefilePathExists = await util.fileExists(relativeFilePath);
|
|
35
|
+
if (relativefilePathExists) {
|
|
36
|
+
const fileBuffer = await fs.promises.readFile(relativeFilePath);
|
|
37
|
+
const hash = crypto.createHash('sha256');
|
|
38
|
+
hash.update(fileBuffer);
|
|
39
|
+
const generatedSha = hash.digest('hex');
|
|
40
|
+
if (storedSha !== generatedSha) {
|
|
41
|
+
throw new Error('SHA256 checksums do not match.');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import verify from "./verify.js";
|
|
4
|
+
|
|
5
|
+
describe("get/verify", function () {
|
|
6
|
+
|
|
7
|
+
it("verify shasums", async function () {
|
|
8
|
+
const status = await verify(
|
|
9
|
+
'https://dl.nwjs.io/v0.90.0/SHASUMS256.txt',
|
|
10
|
+
'./shasum/0.90.0.txt',
|
|
11
|
+
'.'
|
|
12
|
+
);
|
|
13
|
+
expect(status).toBe(true);
|
|
14
|
+
}, Infinity);
|
|
15
|
+
});
|