codewhale 0.10.2 → 0.10.3
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 +1 -1
- package/codewhale-notices/LICENSE +21 -0
- package/codewhale-notices/THIRD_PARTY_NOTICES.md +1011 -0
- package/codewhale-notices/docs/THIRD_PARTY_NOTICES.md +66 -0
- package/package.json +4 -3
- package/scripts/artifacts.js +128 -17
- package/scripts/install.js +37 -11
- package/scripts/verify-release-assets.js +102 -126
- package/test/artifacts.test.js +73 -10
- package/test/install.test.js +58 -0
- package/test/release-assets.test.js +65 -0
- package/test/source-selection.test.js +14 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
Codewhale is MIT licensed (see [`LICENSE`](../LICENSE)). Portions of it are
|
|
4
|
+
adapted from other open-source projects. Their copyright and permission
|
|
5
|
+
notices are reproduced here, and each adapted file carries an attribution
|
|
6
|
+
header pointing back to its origin.
|
|
7
|
+
|
|
8
|
+
Rust crate dependencies are covered by `cargo deny` (see [`deny.toml`](../deny.toml))
|
|
9
|
+
and are not duplicated here; this file records source-level adaptations, where
|
|
10
|
+
the licence obligation travels with the code rather than with a package.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## pi-mono — credential resolution design
|
|
15
|
+
|
|
16
|
+
- **Project:** pi-mono (<https://github.com/earendil-works/pi-mono>)
|
|
17
|
+
- **Author:** Mario Zechner
|
|
18
|
+
- **Licence:** MIT
|
|
19
|
+
- **Used in:** `crates/runtime/src/credentials/` and
|
|
20
|
+
`crates/runtime/src/config/credential_resolve.rs`
|
|
21
|
+
- **What was taken:** the design of `packages/ai/src/auth/` — one type-tagged
|
|
22
|
+
credential per provider, `modify` as the only serialized write path, a single
|
|
23
|
+
stated precedence rule enforced in one place, an injectable auth context, and
|
|
24
|
+
a resolution result that names its source. This is a design port into
|
|
25
|
+
idiomatic synchronous Rust over Codewhale's existing stores, not a
|
|
26
|
+
line-for-line copy; several doc comments are adapted closely.
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
MIT License
|
|
30
|
+
|
|
31
|
+
Copyright (c) 2025 Mario Zechner
|
|
32
|
+
|
|
33
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
34
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
35
|
+
in the Software without restriction, including without limitation the rights
|
|
36
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
37
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
38
|
+
furnished to do so, subject to the following conditions:
|
|
39
|
+
|
|
40
|
+
The above copyright notice and this permission notice shall be included in all
|
|
41
|
+
copies or substantial portions of the Software.
|
|
42
|
+
|
|
43
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
44
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
45
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
46
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
47
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
48
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
49
|
+
SOFTWARE.
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Other source-level adaptations
|
|
55
|
+
|
|
56
|
+
These predate this file. Each already names its origin in a header comment on
|
|
57
|
+
the adapting file; they are listed here so the set is discoverable from one
|
|
58
|
+
place. Their licence text has not been reproduced below — that is a gap, not a
|
|
59
|
+
claim that none is required.
|
|
60
|
+
|
|
61
|
+
| Codewhale file | Adapted from |
|
|
62
|
+
| --- | --- |
|
|
63
|
+
| `crates/tui/src/tui/frame_rate_limiter.rs` | `codex-rs/tui/src/tui/frame_rate_limiter.rs`, [openai/codex](https://github.com/openai/codex) |
|
|
64
|
+
| `crates/tui/src/tui/display_refresh.rs` | Grok CLI's host display-refresh probe |
|
|
65
|
+
| `patches/unicode-width-0.2.2/` | vendored patch; upstream `LICENSE-MIT` retained in-tree |
|
|
66
|
+
| `patches/crossterm-0.29.0/` | vendored patch (surrogate key-up handling in `src/event/sys/windows/parse.rs`, the change proposed upstream as crossterm-rs/crossterm#1073); upstream MIT `LICENSE` retained in-tree |
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codewhale",
|
|
3
|
-
"version": "0.10.
|
|
4
|
-
"codewhaleBinaryVersion": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
|
+
"codewhaleBinaryVersion": "0.10.3",
|
|
5
5
|
"description": "Terminal coding agent for supported hosted and local models. One runtime on your machine. Rust, MIT.",
|
|
6
6
|
"author": "Hmbown",
|
|
7
7
|
"license": "MIT",
|
|
@@ -45,13 +45,14 @@
|
|
|
45
45
|
"test": "node --test test/*.test.js"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
|
-
"node": ">=
|
|
48
|
+
"node": ">=22"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"preferGlobal": true,
|
|
54
54
|
"files": [
|
|
55
|
+
"codewhale-notices",
|
|
55
56
|
"bin/*.js",
|
|
56
57
|
"scripts/*.js",
|
|
57
58
|
"test/*.js",
|
package/scripts/artifacts.js
CHANGED
|
@@ -3,8 +3,21 @@ const os = require("os");
|
|
|
3
3
|
const compiledHosts = require("./compiled-hosts");
|
|
4
4
|
|
|
5
5
|
const CHECKSUM_MANIFEST = "codewhale-artifacts-sha256.txt";
|
|
6
|
+
const CHECKSUM_SIGNATURE = `${CHECKSUM_MANIFEST}.sig`;
|
|
6
7
|
const BUNDLE_CHECKSUM_MANIFEST = "codewhale-bundles-sha256.txt";
|
|
7
8
|
const WINDOWS_INSTALLER_ASSET = "CodeWhaleSetup.exe";
|
|
9
|
+
const RELEASE_GITHUB_HOSTS = new Set([
|
|
10
|
+
"github.com",
|
|
11
|
+
"api.github.com",
|
|
12
|
+
"objects.githubusercontent.com",
|
|
13
|
+
"release-assets.githubusercontent.com",
|
|
14
|
+
"github-releases.githubusercontent.com",
|
|
15
|
+
]);
|
|
16
|
+
const RELEASE_CNB_HOST = "cnb.cool";
|
|
17
|
+
const UPDATE_ALLOWED_HOSTS_ENV = "CODEWHALE_UPDATE_ALLOWED_HOSTS";
|
|
18
|
+
const transportOptions = {
|
|
19
|
+
allowLoopbackHttp: false,
|
|
20
|
+
};
|
|
8
21
|
|
|
9
22
|
// Compatibility bridge introduced in v0.9.5: already-shipped v0.9.4 clients
|
|
10
23
|
// require these names before
|
|
@@ -15,6 +28,10 @@ const LEGACY_TUI_BRIDGE_ASSET_NAMES = [
|
|
|
15
28
|
"codewhale-tui-linux-x64",
|
|
16
29
|
"codewhale-tui-linux-arm64",
|
|
17
30
|
"codewhale-tui-android-arm64",
|
|
31
|
+
// Published for symmetry with every other platform: the name exists so
|
|
32
|
+
// release completeness stays one rule, not a case analysis. No shipped client
|
|
33
|
+
// requests it; nothing else references it.
|
|
34
|
+
"codewhale-tui-ohos-arm64",
|
|
18
35
|
"codewhale-tui-macos-x64",
|
|
19
36
|
"codewhale-tui-macos-arm64",
|
|
20
37
|
"codewhale-tui-windows-x64.exe",
|
|
@@ -35,6 +52,7 @@ const BUNDLE_ASSET_NAMES = [
|
|
|
35
52
|
"codewhale-linux-x64.tar.gz",
|
|
36
53
|
"codewhale-linux-arm64.tar.gz",
|
|
37
54
|
"codewhale-android-arm64.tar.gz",
|
|
55
|
+
"codewhale-ohos-arm64.tar.gz",
|
|
38
56
|
"codewhale-macos-x64.tar.gz",
|
|
39
57
|
"codewhale-macos-arm64.tar.gz",
|
|
40
58
|
"codewhale-windows-x64.zip",
|
|
@@ -51,6 +69,12 @@ const ASSET_MATRIX = {
|
|
|
51
69
|
android: {
|
|
52
70
|
arm64: ["codewhale-android-arm64", "codew-android-arm64"],
|
|
53
71
|
},
|
|
72
|
+
// Native HarmonyOS/OpenHarmony (aarch64-unknown-linux-ohos). These binaries
|
|
73
|
+
// only run on a device when they are code-signed, so the release build
|
|
74
|
+
// self-signs them; see docs/HarmonyOS.md.
|
|
75
|
+
openharmony: {
|
|
76
|
+
arm64: ["codewhale-ohos-arm64", "codew-ohos-arm64"],
|
|
77
|
+
},
|
|
54
78
|
darwin: {
|
|
55
79
|
x64: ["codewhale-macos-x64", "codew-macos-x64"],
|
|
56
80
|
arm64: ["codewhale-macos-arm64", "codew-macos-arm64"],
|
|
@@ -61,21 +85,14 @@ const ASSET_MATRIX = {
|
|
|
61
85
|
},
|
|
62
86
|
};
|
|
63
87
|
|
|
64
|
-
// Native HarmonyOS/OpenHarmony (openharmony) gets the static musl Linux build as
|
|
65
|
-
// a best effort; that build is untested on native HarmonyOS.
|
|
66
|
-
const PLATFORM_ALIASES = {
|
|
67
|
-
openharmony: "linux",
|
|
68
|
-
};
|
|
69
|
-
|
|
70
88
|
function detectBinaryNames() {
|
|
71
|
-
const
|
|
72
|
-
const platform = PLATFORM_ALIASES[rawPlatform] || rawPlatform;
|
|
89
|
+
const platform = os.platform();
|
|
73
90
|
const arch = os.arch();
|
|
74
91
|
const defaults = ASSET_MATRIX[platform];
|
|
75
92
|
if (!defaults) {
|
|
76
93
|
const supported = Object.keys(ASSET_MATRIX).map(p => `'${p}'`).join(', ');
|
|
77
94
|
throw new Error(
|
|
78
|
-
`Unsupported platform: ${
|
|
95
|
+
`Unsupported platform: ${platform}. Supported platforms: ${supported}.\n\n` +
|
|
79
96
|
unsupportedBuildHint(),
|
|
80
97
|
);
|
|
81
98
|
}
|
|
@@ -178,10 +195,9 @@ function hasExplicitReleaseBase(env = process.env) {
|
|
|
178
195
|
}
|
|
179
196
|
|
|
180
197
|
function isCnbSupportedTarget(
|
|
181
|
-
|
|
198
|
+
platform = os.platform(),
|
|
182
199
|
arch = os.arch(),
|
|
183
200
|
) {
|
|
184
|
-
const platform = PLATFORM_ALIASES[rawPlatform] || rawPlatform;
|
|
185
201
|
return platform === "linux" && arch === "x64";
|
|
186
202
|
}
|
|
187
203
|
|
|
@@ -207,11 +223,11 @@ function usesCnbMirror(env = process.env) {
|
|
|
207
223
|
|
|
208
224
|
function shouldRaceFirstPartyMirrors(
|
|
209
225
|
env = process.env,
|
|
210
|
-
|
|
226
|
+
platform = os.platform(),
|
|
211
227
|
arch = os.arch(),
|
|
212
228
|
) {
|
|
213
229
|
return (
|
|
214
|
-
isCnbSupportedTarget(
|
|
230
|
+
isCnbSupportedTarget(platform, arch) &&
|
|
215
231
|
!hasExplicitReleaseBase(env) &&
|
|
216
232
|
env.CODEWHALE_USE_CNB_MIRROR !== "1"
|
|
217
233
|
);
|
|
@@ -233,15 +249,16 @@ function firstPartyReleaseSources(version, repo = "codewhale-hq/CodeWhale") {
|
|
|
233
249
|
}
|
|
234
250
|
|
|
235
251
|
function assertCnbMirrorSupportedPlatform(
|
|
236
|
-
|
|
252
|
+
platform = os.platform(),
|
|
237
253
|
arch = os.arch(),
|
|
238
254
|
) {
|
|
239
|
-
if (isCnbSupportedTarget(
|
|
255
|
+
if (isCnbSupportedTarget(platform, arch)) {
|
|
240
256
|
return;
|
|
241
257
|
}
|
|
242
258
|
throw new Error(
|
|
243
|
-
"CODEWHALE_USE_CNB_MIRROR=1 currently supports only Linux x64 " +
|
|
244
|
-
`
|
|
259
|
+
"CODEWHALE_USE_CNB_MIRROR=1 currently supports only Linux x64; " +
|
|
260
|
+
`detected ${platform} ${arch}. Native HarmonyOS has its own asset and ` +
|
|
261
|
+
"no CNB mirror. " +
|
|
245
262
|
"Use the GitHub Release or set CODEWHALE_RELEASE_BASE_URL to a " +
|
|
246
263
|
"complete mirror for this platform.",
|
|
247
264
|
);
|
|
@@ -255,6 +272,94 @@ function checksumManifestUrl(version, repo = "codewhale-hq/CodeWhale") {
|
|
|
255
272
|
return releaseAssetUrl(CHECKSUM_MANIFEST, version, repo);
|
|
256
273
|
}
|
|
257
274
|
|
|
275
|
+
function redactUrl(rawUrl) {
|
|
276
|
+
const input = String(rawUrl || "");
|
|
277
|
+
try {
|
|
278
|
+
const parsed = new URL(input);
|
|
279
|
+
if (parsed.username || parsed.password) {
|
|
280
|
+
parsed.username = "";
|
|
281
|
+
parsed.password = "";
|
|
282
|
+
return parsed.toString();
|
|
283
|
+
}
|
|
284
|
+
return input;
|
|
285
|
+
} catch {
|
|
286
|
+
return input.replace(/^([a-z][a-z0-9+\-.]*:\/\/)[^/@\s]+@/i, "$1");
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function extraAllowedReleaseHosts(env = process.env) {
|
|
291
|
+
const extra = new Set();
|
|
292
|
+
const override = explicitReleaseBase(env);
|
|
293
|
+
if (override) {
|
|
294
|
+
try {
|
|
295
|
+
const parsed = new URL(override);
|
|
296
|
+
if (parsed.hostname) {
|
|
297
|
+
extra.add(parsed.hostname.toLowerCase());
|
|
298
|
+
}
|
|
299
|
+
} catch {
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
const configured = env && env[UPDATE_ALLOWED_HOSTS_ENV];
|
|
303
|
+
if (configured) {
|
|
304
|
+
for (const part of String(configured).split(",")) {
|
|
305
|
+
const host = part.trim().toLowerCase();
|
|
306
|
+
if (host) {
|
|
307
|
+
extra.add(host);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return extra;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function isAllowedReleaseHost(hostname, env = process.env) {
|
|
315
|
+
const host = String(hostname || "").toLowerCase();
|
|
316
|
+
if (!host) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
if (
|
|
320
|
+
RELEASE_GITHUB_HOSTS.has(host) ||
|
|
321
|
+
host === RELEASE_CNB_HOST ||
|
|
322
|
+
host.endsWith(`.${RELEASE_CNB_HOST}`)
|
|
323
|
+
) {
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
return extraAllowedReleaseHosts(env).has(host);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function isLoopbackHost(hostname) {
|
|
330
|
+
const host = String(hostname || "").toLowerCase();
|
|
331
|
+
return host === "127.0.0.1" || host === "localhost" || host === "::1" || host === "[::1]";
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function validateReleaseUrl(rawUrl, options = {}) {
|
|
335
|
+
const env = options.env || process.env;
|
|
336
|
+
const allowLoopbackHttp =
|
|
337
|
+
options.allowLoopbackHttp === undefined
|
|
338
|
+
? transportOptions.allowLoopbackHttp
|
|
339
|
+
: Boolean(options.allowLoopbackHttp);
|
|
340
|
+
const safeUrl = redactUrl(rawUrl);
|
|
341
|
+
let parsed;
|
|
342
|
+
try {
|
|
343
|
+
parsed = new URL(rawUrl);
|
|
344
|
+
} catch (err) {
|
|
345
|
+
throw new Error(`Invalid release URL: ${safeUrl} (${err.message})`);
|
|
346
|
+
}
|
|
347
|
+
if (allowLoopbackHttp && parsed.protocol === "http:" && isLoopbackHost(parsed.hostname)) {
|
|
348
|
+
return parsed;
|
|
349
|
+
}
|
|
350
|
+
if (parsed.protocol !== "https:") {
|
|
351
|
+
throw new Error(`Release download requires HTTPS, not ${parsed.protocol}: ${safeUrl}`);
|
|
352
|
+
}
|
|
353
|
+
if (!isAllowedReleaseHost(parsed.hostname, env)) {
|
|
354
|
+
throw new Error(
|
|
355
|
+
`Release host "${parsed.hostname}" is not an allowed release host. ` +
|
|
356
|
+
"A private mirror's host is allowed when it is the CODEWHALE_RELEASE_BASE_URL HTTPS base URL; " +
|
|
357
|
+
`any other host can be added with ${UPDATE_ALLOWED_HOSTS_ENV}=host1,host2`,
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
return parsed;
|
|
361
|
+
}
|
|
362
|
+
|
|
258
363
|
function releaseBinaryDirectory() {
|
|
259
364
|
return path.join(__dirname, "..", "bin", "downloads");
|
|
260
365
|
}
|
|
@@ -292,6 +397,7 @@ module.exports = {
|
|
|
292
397
|
BUNDLE_ASSET_NAMES,
|
|
293
398
|
BUNDLE_CHECKSUM_MANIFEST,
|
|
294
399
|
CHECKSUM_MANIFEST,
|
|
400
|
+
CHECKSUM_SIGNATURE,
|
|
295
401
|
checksummedReleaseAssetNames,
|
|
296
402
|
CNB_BINARY_ASSET_NAMES,
|
|
297
403
|
CNB_RELEASE_ASSET_NAMES,
|
|
@@ -303,14 +409,19 @@ module.exports = {
|
|
|
303
409
|
firstPartyReleaseSources,
|
|
304
410
|
githubReleaseBaseUrl,
|
|
305
411
|
hasExplicitReleaseBase,
|
|
412
|
+
isAllowedReleaseHost,
|
|
306
413
|
isCnbSupportedTarget,
|
|
307
414
|
LEGACY_TUI_BRIDGE_ASSET_NAMES,
|
|
308
415
|
openHarmonyDirections,
|
|
416
|
+
redactUrl,
|
|
309
417
|
releaseAssetUrl,
|
|
310
418
|
releaseAssetUrlFromBase,
|
|
311
419
|
releaseBaseUrl,
|
|
312
420
|
releaseBinaryDirectory,
|
|
313
421
|
shouldRaceFirstPartyMirrors,
|
|
422
|
+
transportOptions,
|
|
423
|
+
UPDATE_ALLOWED_HOSTS_ENV,
|
|
314
424
|
usesCnbMirror,
|
|
425
|
+
validateReleaseUrl,
|
|
315
426
|
WINDOWS_INSTALLER_ASSET,
|
|
316
427
|
};
|
package/scripts/install.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
function assertSupportedNode() {
|
|
2
2
|
const version = process.versions && process.versions.node ? process.versions.node : "unknown";
|
|
3
3
|
const major = Number.parseInt(String(version).split(".")[0], 10);
|
|
4
|
-
if (Number.isNaN(major) || major <
|
|
4
|
+
if (Number.isNaN(major) || major < 22) {
|
|
5
5
|
process.stderr.write(
|
|
6
|
-
"codewhale: Node.js
|
|
6
|
+
"codewhale: Node.js 22 or newer is required for npm installation. " +
|
|
7
7
|
`Current Node.js version is ${version}. ` +
|
|
8
8
|
"Please upgrade Node.js and rerun `npm install -g codewhale`.\n",
|
|
9
9
|
);
|
|
@@ -35,11 +35,13 @@ const {
|
|
|
35
35
|
firstPartyReleaseSources,
|
|
36
36
|
githubReleaseBaseUrl,
|
|
37
37
|
openHarmonyDirections,
|
|
38
|
+
redactUrl,
|
|
38
39
|
releaseAssetUrl,
|
|
39
40
|
releaseAssetUrlFromBase,
|
|
40
41
|
releaseBinaryDirectory,
|
|
41
42
|
shouldRaceFirstPartyMirrors,
|
|
42
43
|
usesCnbMirror,
|
|
44
|
+
validateReleaseUrl,
|
|
43
45
|
} = require("./artifacts");
|
|
44
46
|
const { preflightGlibc, detectHostGlibc, detectBinaryRequiredGlibc, _internal: glibc } = require("./preflight-glibc");
|
|
45
47
|
const compiledHosts = require("./compiled-hosts");
|
|
@@ -78,7 +80,7 @@ class NonRetryableError extends Error {
|
|
|
78
80
|
|
|
79
81
|
class HttpStatusError extends Error {
|
|
80
82
|
constructor(status, url) {
|
|
81
|
-
super(`Request failed with status ${status}: ${url}`);
|
|
83
|
+
super(`Request failed with status ${status}: ${redactUrl(url)}`);
|
|
82
84
|
this.name = "HttpStatusError";
|
|
83
85
|
this.status = status;
|
|
84
86
|
}
|
|
@@ -254,7 +256,7 @@ function installFailureHint(error) {
|
|
|
254
256
|
if (releaseBase) {
|
|
255
257
|
return [
|
|
256
258
|
"codewhale install hint:",
|
|
257
|
-
` CODEWHALE_RELEASE_BASE_URL resolves to ${releaseBase}`,
|
|
259
|
+
` CODEWHALE_RELEASE_BASE_URL resolves to ${redactUrl(releaseBase)}`,
|
|
258
260
|
" Verify that this directory contains codewhale-artifacts-sha256.txt",
|
|
259
261
|
" plus the codewhale/codew binary assets for your platform (single binary).",
|
|
260
262
|
].join("\n");
|
|
@@ -549,7 +551,7 @@ function httpRequest(rawUrl, opts = {}) {
|
|
|
549
551
|
try {
|
|
550
552
|
url = new URL(rawUrl);
|
|
551
553
|
} catch (err) {
|
|
552
|
-
reject(new NonRetryableError(`Invalid URL: ${rawUrl} (${err.message})`));
|
|
554
|
+
reject(new NonRetryableError(`Invalid URL: ${redactUrl(rawUrl)} (${err.message})`));
|
|
553
555
|
return;
|
|
554
556
|
}
|
|
555
557
|
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
@@ -998,18 +1000,28 @@ async function followRedirects(url, opts = {}) {
|
|
|
998
1000
|
const maxRedirects = 10;
|
|
999
1001
|
let current = url;
|
|
1000
1002
|
for (let hop = 0; hop < maxRedirects; hop++) {
|
|
1003
|
+
try {
|
|
1004
|
+
validateReleaseUrl(current, {
|
|
1005
|
+
env: opts.env,
|
|
1006
|
+
allowLoopbackHttp: opts.allowLoopbackHttp,
|
|
1007
|
+
});
|
|
1008
|
+
} catch (err) {
|
|
1009
|
+
throw new NonRetryableError(err.message);
|
|
1010
|
+
}
|
|
1001
1011
|
const result = await httpRequest(current, opts);
|
|
1002
1012
|
if (result.redirect) {
|
|
1003
1013
|
try {
|
|
1004
1014
|
current = new URL(result.redirect, current).toString();
|
|
1005
|
-
} catch {
|
|
1006
|
-
|
|
1015
|
+
} catch (err) {
|
|
1016
|
+
throw new NonRetryableError(
|
|
1017
|
+
`Invalid redirect URL from ${redactUrl(current)}: ${err.message}`,
|
|
1018
|
+
);
|
|
1007
1019
|
}
|
|
1008
1020
|
continue;
|
|
1009
1021
|
}
|
|
1010
1022
|
return result;
|
|
1011
1023
|
}
|
|
1012
|
-
throw new NonRetryableError(`too many redirects starting at ${url}`);
|
|
1024
|
+
throw new NonRetryableError(`too many redirects starting at ${redactUrl(url)}`);
|
|
1013
1025
|
}
|
|
1014
1026
|
|
|
1015
1027
|
function streamToFile(response, destination, progress, signal) {
|
|
@@ -1063,6 +1075,8 @@ async function download(url, destination, options = {}) {
|
|
|
1063
1075
|
await withRetry(`download ${assetName}`, async (attempt) => {
|
|
1064
1076
|
const result = await followRedirects(url, {
|
|
1065
1077
|
context,
|
|
1078
|
+
env: options.env,
|
|
1079
|
+
allowLoopbackHttp: options.allowLoopbackHttp,
|
|
1066
1080
|
totalTimeoutMs: downloadTimeoutMs(context),
|
|
1067
1081
|
stallMs: downloadStallMs(context),
|
|
1068
1082
|
signal: options.signal,
|
|
@@ -1100,9 +1114,11 @@ async function downloadText(url, options = {}) {
|
|
|
1100
1114
|
options.stallMs === undefined || options.stallMs === null
|
|
1101
1115
|
? downloadStallMs(context)
|
|
1102
1116
|
: options.stallMs;
|
|
1103
|
-
return withRetry(`fetch ${url}`, async () => {
|
|
1117
|
+
return withRetry(`fetch ${redactUrl(url)}`, async () => {
|
|
1104
1118
|
const result = await followRedirects(url, {
|
|
1105
1119
|
context,
|
|
1120
|
+
env: options.env,
|
|
1121
|
+
allowLoopbackHttp: options.allowLoopbackHttp,
|
|
1106
1122
|
totalTimeoutMs,
|
|
1107
1123
|
stallMs,
|
|
1108
1124
|
signal: options.signal,
|
|
@@ -1258,6 +1274,7 @@ async function fetchChecksumManifest(url, options) {
|
|
|
1258
1274
|
const fetchText = options.fetchText || downloadText;
|
|
1259
1275
|
const text = await fetchText(url, {
|
|
1260
1276
|
context: options.context,
|
|
1277
|
+
env: options.env,
|
|
1261
1278
|
signal: options.signal,
|
|
1262
1279
|
totalTimeoutMs:
|
|
1263
1280
|
options.totalTimeoutMs === undefined || options.totalTimeoutMs === null
|
|
@@ -1370,6 +1387,7 @@ async function raceFirstPartyManifests(sources, options) {
|
|
|
1370
1387
|
const source = sources[i];
|
|
1371
1388
|
loadSourceManifest(source, {
|
|
1372
1389
|
context: options.context,
|
|
1390
|
+
env: options.env,
|
|
1373
1391
|
fetchText: options.fetchText,
|
|
1374
1392
|
requiredAssets: options.requiredAssets,
|
|
1375
1393
|
signal: controllers[i].signal,
|
|
@@ -1408,6 +1426,7 @@ async function selectReleaseSource(options) {
|
|
|
1408
1426
|
},
|
|
1409
1427
|
{
|
|
1410
1428
|
context,
|
|
1429
|
+
env,
|
|
1411
1430
|
fetchText,
|
|
1412
1431
|
requiredAssets,
|
|
1413
1432
|
},
|
|
@@ -1424,6 +1443,7 @@ async function selectReleaseSource(options) {
|
|
|
1424
1443
|
},
|
|
1425
1444
|
{
|
|
1426
1445
|
context,
|
|
1446
|
+
env,
|
|
1427
1447
|
fetchText,
|
|
1428
1448
|
requiredAssets,
|
|
1429
1449
|
},
|
|
@@ -1434,6 +1454,7 @@ async function selectReleaseSource(options) {
|
|
|
1434
1454
|
return raceFirstPartyManifests(sources, {
|
|
1435
1455
|
version,
|
|
1436
1456
|
context,
|
|
1457
|
+
env,
|
|
1437
1458
|
fetchText,
|
|
1438
1459
|
requiredAssets,
|
|
1439
1460
|
});
|
|
@@ -1447,6 +1468,7 @@ async function selectReleaseSource(options) {
|
|
|
1447
1468
|
},
|
|
1448
1469
|
{
|
|
1449
1470
|
context,
|
|
1471
|
+
env,
|
|
1450
1472
|
fetchText,
|
|
1451
1473
|
requiredAssets,
|
|
1452
1474
|
},
|
|
@@ -1542,7 +1564,7 @@ async function ensureBinary(targetPath, assetName, version, repo, getChecksums,
|
|
|
1542
1564
|
const progressName = locked.sourceLabel
|
|
1543
1565
|
? `${assetName} from ${locked.sourceLabel}`
|
|
1544
1566
|
: assetName;
|
|
1545
|
-
await downloadFn(url, destination, { assetName: progressName, context: options.context });
|
|
1567
|
+
await downloadFn(url, destination, { assetName: progressName, context: options.context, env });
|
|
1546
1568
|
try {
|
|
1547
1569
|
await verifyChecksum(destination, assetName, checksums, locked.sourceLabel);
|
|
1548
1570
|
preflightGlibc(destination);
|
|
@@ -1709,7 +1731,10 @@ async function run(options = {}) {
|
|
|
1709
1731
|
!isQuietInstall(env)
|
|
1710
1732
|
) {
|
|
1711
1733
|
process.stderr.write(
|
|
1712
|
-
`codewhale:
|
|
1734
|
+
`codewhale: note: installing ${paths.codewhale.asset}, the native HarmonyOS/OpenHarmony build.\n` +
|
|
1735
|
+
`It is code-signed, but a native HarmonyOS terminal (HiShell) is not a Linux shell:\n` +
|
|
1736
|
+
`there is no git and no package manager, and the debugging shell (hdc shell) cannot\n` +
|
|
1737
|
+
`execute it at all. details: docs/HarmonyOS.md\n` +
|
|
1713
1738
|
`${openHarmonyDirections()}\n`,
|
|
1714
1739
|
);
|
|
1715
1740
|
}
|
|
@@ -1789,6 +1814,7 @@ module.exports = {
|
|
|
1789
1814
|
adoptExistingBinaryIfValid,
|
|
1790
1815
|
shouldIgnoreInstallFailure,
|
|
1791
1816
|
shouldSkipOptionalPostinstall,
|
|
1817
|
+
followRedirects,
|
|
1792
1818
|
httpRequest,
|
|
1793
1819
|
defaultTimeoutMs,
|
|
1794
1820
|
defaultStallMs,
|