benmore 0.1.35 → 0.1.38
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 +4 -1
- package/bin/benmore.js +27 -8
- package/bin/checksums.json +10 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -10,7 +10,10 @@ benmore new my-app && cd my-app && benmore deploy
|
|
|
10
10
|
This package is a small launcher. On first run it downloads the CLI release
|
|
11
11
|
matching its version from
|
|
12
12
|
[Benmore-Studio/benmore-cli](https://github.com/Benmore-Studio/benmore-cli/releases),
|
|
13
|
-
checks the archive's SHA-256 against the
|
|
13
|
+
checks the archive's SHA-256 against the value embedded in this package at
|
|
14
|
+
publish time (taken from the release's `checksums.txt` after its Sigstore
|
|
15
|
+
signature was verified in the release workflow, so editing the GitHub release
|
|
16
|
+
later cannot change what the launcher accepts), caches the
|
|
14
17
|
binary under `~/.cache/benmore/npm/<version>` (`%LOCALAPPDATA%\benmore\npm` on
|
|
15
18
|
Windows, or `$BENMORE_NPM_CACHE`) and runs it. It has no install scripts.
|
|
16
19
|
|
package/bin/benmore.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
// Thin launcher for the Benmore CLI. On first run it downloads the release
|
|
3
3
|
// archive for this platform from the public Benmore-Studio/benmore-cli GitHub
|
|
4
4
|
// release matching this package's version, checks its SHA-256 against the
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
5
|
+
// value embedded in this package (bin/checksums.json, written at publish time
|
|
6
|
+
// from the Sigstore-verified release checksums), caches the binary and runs
|
|
7
|
+
// it. Later runs use the cache. No install scripts, so it works with
|
|
8
|
+
// `npx benmore` and with --ignore-scripts. The Homebrew cask
|
|
9
|
+
// (brew install benmore-studio/benmore/benmore) remains the preferred install
|
|
10
|
+
// on macOS.
|
|
9
11
|
'use strict';
|
|
10
12
|
|
|
11
13
|
const { spawnSync } = require('node:child_process');
|
|
@@ -24,6 +26,26 @@ function fail(msg) {
|
|
|
24
26
|
process.exit(1);
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
// The trusted SHA-256 values ship inside the npm tarball. The release's own
|
|
30
|
+
// checksums.txt is deliberately NOT consulted: anyone able to edit the GitHub
|
|
31
|
+
// release could replace an archive and its checksums.txt line together.
|
|
32
|
+
function pinnedChecksum(archive) {
|
|
33
|
+
let pinned;
|
|
34
|
+
try {
|
|
35
|
+
pinned = require('./checksums.json');
|
|
36
|
+
} catch (_) {
|
|
37
|
+
fail('this package has no embedded checksums (bin/checksums.json); refusing to download an unverifiable binary');
|
|
38
|
+
}
|
|
39
|
+
if (!pinned || pinned.version !== VERSION || !pinned.archives) {
|
|
40
|
+
fail('embedded checksums do not match package version ' + VERSION + '; refusing to download');
|
|
41
|
+
}
|
|
42
|
+
const want = pinned.archives[archive];
|
|
43
|
+
if (typeof want !== 'string' || !/^[0-9a-f]{64}$/.test(want)) {
|
|
44
|
+
fail('no embedded checksum for ' + archive + '; refusing to download');
|
|
45
|
+
}
|
|
46
|
+
return want;
|
|
47
|
+
}
|
|
48
|
+
|
|
27
49
|
function cacheDir() {
|
|
28
50
|
const base = process.env.BENMORE_NPM_CACHE ||
|
|
29
51
|
(process.platform === 'win32'
|
|
@@ -43,11 +65,8 @@ async function install(binPath) {
|
|
|
43
65
|
fail('no prebuilt CLI for ' + process.platform + '/' + process.arch + '. See https://benmore.ai/cli');
|
|
44
66
|
}
|
|
45
67
|
const archive = 'benmore_' + VERSION + '_' + OS + '_' + ARCH + (OS === 'windows' ? '.zip' : '.tar.gz');
|
|
68
|
+
const want = pinnedChecksum(archive);
|
|
46
69
|
process.stderr.write('Downloading Benmore CLI ' + VERSION + ' (' + OS + '/' + ARCH + ')...\n');
|
|
47
|
-
const sums = (await download(REPO + 'checksums.txt')).toString('utf8');
|
|
48
|
-
const line = sums.split('\n').find((l) => l.trim().endsWith(' ' + archive) || l.trim().endsWith(' ' + archive));
|
|
49
|
-
if (!line) fail('checksums.txt does not list ' + archive);
|
|
50
|
-
const want = line.trim().split(/\s+/)[0].toLowerCase();
|
|
51
70
|
const data = await download(REPO + archive);
|
|
52
71
|
const got = crypto.createHash('sha256').update(data).digest('hex');
|
|
53
72
|
if (got !== want) fail('checksum mismatch for ' + archive + ' (expected ' + want + ', got ' + got + '); nothing was installed');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.1.38",
|
|
3
|
+
"archives": {
|
|
4
|
+
"benmore_0.1.38_darwin_amd64.tar.gz": "41342f53a5d0253564d55899b0dd1eedd4f4a1d0628f970322b1af7eb30bb31d",
|
|
5
|
+
"benmore_0.1.38_darwin_arm64.tar.gz": "dbd9c961743b424736777a45b0f0aaa0d094f3e09fdd2e78f85ec096b7ff6c0b",
|
|
6
|
+
"benmore_0.1.38_linux_amd64.tar.gz": "affcdc08fffd4bb4e095a19fedb3ebb07beb393268353e287e803a59ce29d685",
|
|
7
|
+
"benmore_0.1.38_linux_arm64.tar.gz": "d68db32c2414d1c4bed8af455df626fdbc24354740a31b78e780131796d89f7a",
|
|
8
|
+
"benmore_0.1.38_windows_amd64.zip": "64a8811629f2673b0f4da8f24751cdd3141744087ce7c699f8651c4ea4409449"
|
|
9
|
+
}
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "benmore",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
4
4
|
"description": "The Benmore CLI: build, deploy and verify apps on benmore.ai",
|
|
5
5
|
"homepage": "https://benmore.ai/cli",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"bin/benmore.js",
|
|
12
|
+
"bin/checksums.json",
|
|
12
13
|
"README.md"
|
|
13
14
|
],
|
|
14
15
|
"engines": {
|