@percy/core 1.32.12-beta.3 → 1.32.12-beta.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.
- package/dist/install.js +29 -2
- package/package.json +10 -10
package/dist/install.js
CHANGED
|
@@ -2,6 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import url from 'url';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import https from 'https';
|
|
5
|
+
import crypto from 'crypto';
|
|
5
6
|
import logger from '@percy/logger';
|
|
6
7
|
import cp from 'child_process';
|
|
7
8
|
import { ProxyHttpsAgent, formatBytes } from '@percy/client/utils';
|
|
@@ -38,13 +39,15 @@ export function selectByPlatform(map) {
|
|
|
38
39
|
|
|
39
40
|
// Downloads and extracts an executable from a url into a local directory, returning the full path
|
|
40
41
|
// to the extracted binary. Skips installation if the executable already exists at the binary path.
|
|
42
|
+
// When a sha256 checksum is provided, the archive is verified against it before being extracted.
|
|
41
43
|
export async function download({
|
|
42
44
|
name,
|
|
43
45
|
revision,
|
|
44
46
|
url,
|
|
45
47
|
extract,
|
|
46
48
|
directory,
|
|
47
|
-
executable
|
|
49
|
+
executable,
|
|
50
|
+
sha256
|
|
48
51
|
}) {
|
|
49
52
|
let outdir = path.join(directory, revision);
|
|
50
53
|
if (process.env.NODE_ENV === 'executable') {
|
|
@@ -74,6 +77,7 @@ export async function download({
|
|
|
74
77
|
});
|
|
75
78
|
|
|
76
79
|
// download the file at the given URL
|
|
80
|
+
let hash = crypto.createHash('sha256');
|
|
77
81
|
await new Promise((resolve, reject) => https.get(url, {
|
|
78
82
|
agent: new ProxyHttpsAgent() // allow proxied requests
|
|
79
83
|
}, response => {
|
|
@@ -95,9 +99,18 @@ export async function download({
|
|
|
95
99
|
});
|
|
96
100
|
}
|
|
97
101
|
|
|
102
|
+
// hash the archive as it is downloaded
|
|
103
|
+
response.on('data', chunk => hash.update(chunk));
|
|
104
|
+
|
|
98
105
|
// pipe the response directly to a file
|
|
99
106
|
response.pipe(fs.createWriteStream(archive).on('finish', resolve).on('error', reject));
|
|
100
107
|
}).on('error', reject));
|
|
108
|
+
|
|
109
|
+
// never extract an archive that does not match its expected checksum
|
|
110
|
+
let checksum = hash.digest('hex');
|
|
111
|
+
if (sha256 && checksum !== sha256) {
|
|
112
|
+
throw new Error(`Checksum mismatch for ${name} ${revision}: ` + `expected sha256 ${sha256}, got ${checksum} - ${url}`);
|
|
113
|
+
}
|
|
101
114
|
if (process.env.NODE_ENV === 'executable') {
|
|
102
115
|
let output = cp.execSync(command, {
|
|
103
116
|
encoding: 'utf-8'
|
|
@@ -152,13 +165,17 @@ export function chromium({
|
|
|
152
165
|
darwin: path.join('chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium'),
|
|
153
166
|
darwinArm: path.join('chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium')
|
|
154
167
|
});
|
|
168
|
+
|
|
169
|
+
// checksums are only known for the default revisions
|
|
170
|
+
let sha256 = revision === selectByPlatform(chromium.revisions) ? selectByPlatform(chromium.checksums) : undefined;
|
|
155
171
|
return download({
|
|
156
172
|
name: 'Chromium',
|
|
157
173
|
revision,
|
|
158
174
|
url,
|
|
159
175
|
extract,
|
|
160
176
|
directory,
|
|
161
|
-
executable
|
|
177
|
+
executable,
|
|
178
|
+
sha256
|
|
162
179
|
});
|
|
163
180
|
}
|
|
164
181
|
|
|
@@ -172,5 +189,15 @@ chromium.revisions = {
|
|
|
172
189
|
darwinArm: '1536376'
|
|
173
190
|
};
|
|
174
191
|
|
|
192
|
+
// SHA-256 of each platform's archive for the revisions above; update both together. The downloaded
|
|
193
|
+
// archive is executed, so it must be verified even when served over TLS or from a custom base URL.
|
|
194
|
+
chromium.checksums = {
|
|
195
|
+
linux: 'c4bb3ae75dd6c174472b53439d65fa067efdbb4633e30776abf9dac180f92de3',
|
|
196
|
+
win64: '6521f300babef0bd0f202a7de0da58e392b8862ab7609ca792505326fb93cd71',
|
|
197
|
+
win32: 'a67e4404a0548d650b899e0c92024ed86ef32cf6d15009ffe8295917312d8557',
|
|
198
|
+
darwin: 'adead2a2a830d206cfe8b36171fc5ef64eddbe20152528f164c51946c75e5ff8',
|
|
199
|
+
darwinArm: '7eb76e4cf39b1a828c4680a4252bd21f608392545409fca4c20220f449804ad8'
|
|
200
|
+
};
|
|
201
|
+
|
|
175
202
|
// export the namespace by default
|
|
176
203
|
export * as default from './install.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.32.12-beta.
|
|
3
|
+
"version": "1.32.12-beta.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@grpc/grpc-js": "^1.14.3",
|
|
48
48
|
"@grpc/proto-loader": "^0.8.0",
|
|
49
|
-
"@percy/client": "1.32.12-beta.
|
|
50
|
-
"@percy/config": "1.32.12-beta.
|
|
51
|
-
"@percy/dom": "1.32.12-beta.
|
|
52
|
-
"@percy/logger": "1.32.12-beta.
|
|
53
|
-
"@percy/monitoring": "1.32.12-beta.
|
|
54
|
-
"@percy/webdriver-utils": "1.32.12-beta.
|
|
49
|
+
"@percy/client": "1.32.12-beta.4",
|
|
50
|
+
"@percy/config": "1.32.12-beta.4",
|
|
51
|
+
"@percy/dom": "1.32.12-beta.4",
|
|
52
|
+
"@percy/logger": "1.32.12-beta.4",
|
|
53
|
+
"@percy/monitoring": "1.32.12-beta.4",
|
|
54
|
+
"@percy/webdriver-utils": "1.32.12-beta.4",
|
|
55
55
|
"adm-zip": "^0.6.0",
|
|
56
56
|
"busboy": "^1.6.0",
|
|
57
57
|
"content-disposition": "^0.5.4",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"yaml": "^2.4.1"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
|
-
"@percy/cli-doctor": "1.32.12-beta.
|
|
71
|
-
"@percy/cli-pdf": "1.32.12-beta.
|
|
70
|
+
"@percy/cli-doctor": "1.32.12-beta.4",
|
|
71
|
+
"@percy/cli-pdf": "1.32.12-beta.4"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "916cdcd8854848b48c3d658d9d01779176feb2d0"
|
|
74
74
|
}
|