@omm-hippo/omm 0.2.149 → 0.3.33
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/lib/launcher.js +24 -1
- package/package.json +6 -6
package/lib/launcher.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require("node:fs");
|
|
4
4
|
const path = require("node:path");
|
|
5
|
+
const crypto = require("node:crypto");
|
|
5
6
|
const { spawnSync } = require("node:child_process");
|
|
6
7
|
|
|
7
8
|
const launcherManifest = require("../package.json");
|
|
@@ -53,6 +54,22 @@ function exactArray(value, expected) {
|
|
|
53
54
|
return Array.isArray(value) && value.length === 1 && value[0] === expected;
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
function sha256File(filePath) {
|
|
58
|
+
const digest = crypto.createHash("sha256");
|
|
59
|
+
const descriptor = fs.openSync(filePath, "r");
|
|
60
|
+
const buffer = Buffer.allocUnsafe(1024 * 1024);
|
|
61
|
+
try {
|
|
62
|
+
for (;;) {
|
|
63
|
+
const bytesRead = fs.readSync(descriptor, buffer, 0, buffer.length, null);
|
|
64
|
+
if (bytesRead === 0) break;
|
|
65
|
+
digest.update(buffer.subarray(0, bytesRead));
|
|
66
|
+
}
|
|
67
|
+
} finally {
|
|
68
|
+
fs.closeSync(descriptor);
|
|
69
|
+
}
|
|
70
|
+
return digest.digest("hex");
|
|
71
|
+
}
|
|
72
|
+
|
|
56
73
|
function resolvePlatformPackage(options = {}) {
|
|
57
74
|
const target = selectTarget(options.platform, options.arch, options.report);
|
|
58
75
|
const resolvePackage = options.resolvePackage || require.resolve;
|
|
@@ -77,7 +94,9 @@ function resolvePlatformPackage(options = {}) {
|
|
|
77
94
|
!metadata ||
|
|
78
95
|
metadata.distribution !== "omm-model" ||
|
|
79
96
|
metadata.target !== target.key ||
|
|
80
|
-
metadata.binary !== target.binary
|
|
97
|
+
metadata.binary !== target.binary ||
|
|
98
|
+
typeof metadata.sha256 !== "string" ||
|
|
99
|
+
!/^[0-9a-f]{64}$/.test(metadata.sha256)
|
|
81
100
|
) {
|
|
82
101
|
throw new LauncherError(
|
|
83
102
|
`The installed ${target.package} metadata does not match @omm-hippo/omm ${launcherManifest.version}.`,
|
|
@@ -97,6 +116,9 @@ function resolvePlatformPackage(options = {}) {
|
|
|
97
116
|
if (relative.startsWith("..") || path.isAbsolute(relative)) {
|
|
98
117
|
throw new LauncherError(`The ${target.package} executable escapes its package root.`);
|
|
99
118
|
}
|
|
119
|
+
if (sha256File(binary) !== metadata.sha256) {
|
|
120
|
+
throw new LauncherError(`The ${target.package} executable checksum is invalid.`);
|
|
121
|
+
}
|
|
100
122
|
return { root, binary, manifest, target };
|
|
101
123
|
}
|
|
102
124
|
|
|
@@ -133,4 +155,5 @@ module.exports = {
|
|
|
133
155
|
run,
|
|
134
156
|
runtimeLibc,
|
|
135
157
|
selectTarget,
|
|
158
|
+
sha256File,
|
|
136
159
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omm-hippo/omm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.33",
|
|
4
4
|
"description": "npm launcher for the Open Model Manager CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"test": "node --test test/*.test.js"
|
|
27
27
|
},
|
|
28
28
|
"optionalDependencies": {
|
|
29
|
-
"@omm-hippo/omm-darwin-arm64": "0.
|
|
30
|
-
"@omm-hippo/omm-darwin-x64": "0.
|
|
31
|
-
"@omm-hippo/omm-linux-arm64-gnu": "0.
|
|
32
|
-
"@omm-hippo/omm-linux-x64-gnu": "0.
|
|
33
|
-
"@omm-hippo/omm-win32-x64": "0.
|
|
29
|
+
"@omm-hippo/omm-darwin-arm64": "0.3.33",
|
|
30
|
+
"@omm-hippo/omm-darwin-x64": "0.3.33",
|
|
31
|
+
"@omm-hippo/omm-linux-arm64-gnu": "0.3.33",
|
|
32
|
+
"@omm-hippo/omm-linux-x64-gnu": "0.3.33",
|
|
33
|
+
"@omm-hippo/omm-win32-x64": "0.3.33"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public",
|