@solidnative-dev/cli 0.0.0-stage → 0.1.0-beta.0
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 +21 -0
- package/README.md +841 -2
- package/dist/android-apk-signing.d.ts +36 -0
- package/dist/android-apk-signing.d.ts.map +1 -0
- package/dist/android-apk-signing.js +292 -0
- package/dist/android-apk-signing.js.map +1 -0
- package/dist/android-bundle-signing.d.ts +34 -0
- package/dist/android-bundle-signing.d.ts.map +1 -0
- package/dist/android-bundle-signing.js +167 -0
- package/dist/android-bundle-signing.js.map +1 -0
- package/dist/android-causal-debug.d.ts +38 -0
- package/dist/android-causal-debug.d.ts.map +1 -0
- package/dist/android-causal-debug.js +239 -0
- package/dist/android-causal-debug.js.map +1 -0
- package/dist/android-device-proof.d.ts +58 -0
- package/dist/android-device-proof.d.ts.map +1 -0
- package/dist/android-device-proof.js +554 -0
- package/dist/android-device-proof.js.map +1 -0
- package/dist/android-logs.d.ts +50 -0
- package/dist/android-logs.d.ts.map +1 -0
- package/dist/android-logs.js +253 -0
- package/dist/android-logs.js.map +1 -0
- package/dist/android-release-signing.d.ts +12 -0
- package/dist/android-release-signing.d.ts.map +1 -0
- package/dist/android-release-signing.js +165 -0
- package/dist/android-release-signing.js.map +1 -0
- package/dist/android-run-lease.d.ts +15 -0
- package/dist/android-run-lease.d.ts.map +1 -0
- package/dist/android-run-lease.js +333 -0
- package/dist/android-run-lease.js.map +1 -0
- package/dist/android-run-preflight.d.ts +45 -0
- package/dist/android-run-preflight.d.ts.map +1 -0
- package/dist/android-run-preflight.js +183 -0
- package/dist/android-run-preflight.js.map +1 -0
- package/dist/android-signing-shared.d.ts +38 -0
- package/dist/android-signing-shared.d.ts.map +1 -0
- package/dist/android-signing-shared.js +210 -0
- package/dist/android-signing-shared.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +4530 -0
- package/dist/bin.js.map +1 -0
- package/dist/bundle-artifacts.d.ts +48 -0
- package/dist/bundle-artifacts.d.ts.map +1 -0
- package/dist/bundle-artifacts.js +427 -0
- package/dist/bundle-artifacts.js.map +1 -0
- package/dist/causal-debug-compare.d.ts +81 -0
- package/dist/causal-debug-compare.d.ts.map +1 -0
- package/dist/causal-debug-compare.js +238 -0
- package/dist/causal-debug-compare.js.map +1 -0
- package/dist/causal-debug-report.d.ts +33 -0
- package/dist/causal-debug-report.d.ts.map +1 -0
- package/dist/causal-debug-report.js +979 -0
- package/dist/causal-debug-report.js.map +1 -0
- package/dist/causal-debug-watch.d.ts +33 -0
- package/dist/causal-debug-watch.d.ts.map +1 -0
- package/dist/causal-debug-watch.js +92 -0
- package/dist/causal-debug-watch.js.map +1 -0
- package/dist/causal-debug.d.ts +131 -0
- package/dist/causal-debug.d.ts.map +1 -0
- package/dist/causal-debug.js +503 -0
- package/dist/causal-debug.js.map +1 -0
- package/dist/compatibility-catalog.d.ts +88 -0
- package/dist/compatibility-catalog.d.ts.map +1 -0
- package/dist/compatibility-catalog.js +344 -0
- package/dist/compatibility-catalog.js.map +1 -0
- package/dist/deep-link.d.ts +90 -0
- package/dist/deep-link.d.ts.map +1 -0
- package/dist/deep-link.js +346 -0
- package/dist/deep-link.js.map +1 -0
- package/dist/device-proof-signatures.d.ts +307 -0
- package/dist/device-proof-signatures.d.ts.map +1 -0
- package/dist/device-proof-signatures.js +1024 -0
- package/dist/device-proof-signatures.js.map +1 -0
- package/dist/fingerprint.d.ts +35 -0
- package/dist/fingerprint.d.ts.map +1 -0
- package/dist/fingerprint.js +454 -0
- package/dist/fingerprint.js.map +1 -0
- package/dist/index.d.ts +388 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2996 -0
- package/dist/index.js.map +1 -0
- package/dist/ios-causal-debug.d.ts +39 -0
- package/dist/ios-causal-debug.d.ts.map +1 -0
- package/dist/ios-causal-debug.js +318 -0
- package/dist/ios-causal-debug.js.map +1 -0
- package/dist/ios-logs.d.ts +58 -0
- package/dist/ios-logs.d.ts.map +1 -0
- package/dist/ios-logs.js +269 -0
- package/dist/ios-logs.js.map +1 -0
- package/dist/ios-process.d.ts +69 -0
- package/dist/ios-process.d.ts.map +1 -0
- package/dist/ios-process.js +389 -0
- package/dist/ios-process.js.map +1 -0
- package/dist/ios-run-preflight.d.ts +35 -0
- package/dist/ios-run-preflight.d.ts.map +1 -0
- package/dist/ios-run-preflight.js +172 -0
- package/dist/ios-run-preflight.js.map +1 -0
- package/dist/live-causal-debug-report.d.ts +49 -0
- package/dist/live-causal-debug-report.d.ts.map +1 -0
- package/dist/live-causal-debug-report.js +123 -0
- package/dist/live-causal-debug-report.js.map +1 -0
- package/dist/local-symbolication.d.ts +35 -0
- package/dist/local-symbolication.d.ts.map +1 -0
- package/dist/local-symbolication.js +89 -0
- package/dist/local-symbolication.js.map +1 -0
- package/dist/native-archive.d.ts +15 -0
- package/dist/native-archive.d.ts.map +1 -0
- package/dist/native-archive.js +441 -0
- package/dist/native-archive.js.map +1 -0
- package/dist/native-test.d.ts +43 -0
- package/dist/native-test.d.ts.map +1 -0
- package/dist/native-test.js +209 -0
- package/dist/native-test.js.map +1 -0
- package/dist/package-add.d.ts +56 -0
- package/dist/package-add.d.ts.map +1 -0
- package/dist/package-add.js +764 -0
- package/dist/package-add.js.map +1 -0
- package/dist/react-native-upgrade.d.ts +96 -0
- package/dist/react-native-upgrade.d.ts.map +1 -0
- package/dist/react-native-upgrade.js +882 -0
- package/dist/react-native-upgrade.js.map +1 -0
- package/dist/release-device-correlation.d.ts +40 -0
- package/dist/release-device-correlation.d.ts.map +1 -0
- package/dist/release-device-correlation.js +113 -0
- package/dist/release-device-correlation.js.map +1 -0
- package/dist/release-signatures.d.ts +168 -0
- package/dist/release-signatures.d.ts.map +1 -0
- package/dist/release-signatures.js +677 -0
- package/dist/release-signatures.js.map +1 -0
- package/dist/release.d.ts +88 -0
- package/dist/release.d.ts.map +1 -0
- package/dist/release.js +771 -0
- package/dist/release.js.map +1 -0
- package/dist/signature-utilities.d.ts +16 -0
- package/dist/signature-utilities.d.ts.map +1 -0
- package/dist/signature-utilities.js +114 -0
- package/dist/signature-utilities.js.map +1 -0
- package/dist/solid-diagnostics-correlation.d.ts +11 -0
- package/dist/solid-diagnostics-correlation.d.ts.map +1 -0
- package/dist/solid-diagnostics-correlation.js +78 -0
- package/dist/solid-diagnostics-correlation.js.map +1 -0
- package/dist/solid-diagnostics-debug.d.ts +15 -0
- package/dist/solid-diagnostics-debug.d.ts.map +1 -0
- package/dist/solid-diagnostics-debug.js +93 -0
- package/dist/solid-diagnostics-debug.js.map +1 -0
- package/dist/solid-diagnostics-inspection.d.ts +41 -0
- package/dist/solid-diagnostics-inspection.d.ts.map +1 -0
- package/dist/solid-diagnostics-inspection.js +196 -0
- package/dist/solid-diagnostics-inspection.js.map +1 -0
- package/dist/source-map.d.ts +36 -0
- package/dist/source-map.d.ts.map +1 -0
- package/dist/source-map.js +488 -0
- package/dist/source-map.js.map +1 -0
- package/dist/stack-symbolication.d.ts +56 -0
- package/dist/stack-symbolication.d.ts.map +1 -0
- package/dist/stack-symbolication.js +310 -0
- package/dist/stack-symbolication.js.map +1 -0
- package/dist/symbolication.d.ts +27 -0
- package/dist/symbolication.d.ts.map +1 -0
- package/dist/symbolication.js +75 -0
- package/dist/symbolication.js.map +1 -0
- package/dist/tree-debug.d.ts +53 -0
- package/dist/tree-debug.d.ts.map +1 -0
- package/dist/tree-debug.js +283 -0
- package/dist/tree-debug.js.map +1 -0
- package/dist/versions.d.ts +13 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +14 -0
- package/dist/versions.js.map +1 -0
- package/package.json +46 -3
- package/templates/react-native-0.88/README.md +328 -0
- package/templates/react-native-0.88/android/CMakeLists.txt +27 -0
- package/templates/react-native-0.88/android/MainActivity.kt +123 -0
- package/templates/react-native-0.88/android/MainApplication.kt +43 -0
- package/templates/react-native-0.88/android/OnLoad.cpp +60 -0
- package/templates/react-native-0.88/index.js +1 -0
- package/templates/react-native-0.88/ios/AppDelegate.swift +190 -0
- package/templates/react-native-0.88/metro.config.js +16 -0
- package/templates/react-native-0.88/specs/NativeSolidNativeDebug.ts +16 -0
- package/templates/react-native-0.88/specs/NativeSolidNativePlatformAndroid.ts +14 -0
- package/templates/react-native-0.88/src/App.tsx +161 -0
- package/templates/react-native-0.88/src/main.tsx +88 -0
- package/templates/react-native-0.88/test/App.test.tsx +152 -0
package/dist/release.js
ADDED
|
@@ -0,0 +1,771 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
|
+
import { constants, createReadStream } from "node:fs";
|
|
4
|
+
import { lstat, mkdir, mkdtemp, open, readFile, rename, rm, stat, writeFile, } from "node:fs/promises";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { formatNativeAndroidBundleSigningReport, verifyNativeAndroidBundleSigning, } from "./android-bundle-signing.js";
|
|
9
|
+
import { formatNativeAndroidApkSigningReport, verifyNativeAndroidApkSigning, } from "./android-apk-signing.js";
|
|
10
|
+
import { formatNativeBundleVerification, readNativeBundleManifest, verifyNativeBundleManifest, } from "./bundle-artifacts.js";
|
|
11
|
+
import { createNativeFingerprint, } from "./fingerprint.js";
|
|
12
|
+
import { inspectAndroidEmbeddedHermesBundle, inspectIOSEmbeddedHermesBundle, } from "./native-archive.js";
|
|
13
|
+
import { VERIFIED_HERMES_BYTECODE_VERSION } from "./versions.js";
|
|
14
|
+
const MAX_RELEASE_MANIFEST_BYTES = 4 * 1024 * 1024;
|
|
15
|
+
const MAX_RELEASE_ARTIFACT_BYTES = 8 * 1024 * 1024 * 1024;
|
|
16
|
+
const RELEASE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$/u;
|
|
17
|
+
const CHANNEL_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u;
|
|
18
|
+
const REVISION_PATTERN = /^[a-f0-9]{7,64}$/u;
|
|
19
|
+
const REVISION_INPUT_PATTERN = /^[A-Fa-f0-9]{7,64}$/u;
|
|
20
|
+
const SHA1_PATTERN = /^[a-f0-9]{40}$/u;
|
|
21
|
+
const SHA256_PATTERN = /^[a-f0-9]{64}$/u;
|
|
22
|
+
const FINGERPRINT_PATTERN = /^sha256:[a-f0-9]{64}$/u;
|
|
23
|
+
const IOS_EMBEDDED_BUNDLE_PATH = /^Payload\/[^/]{1,255}\.app\/main\.jsbundle$/u;
|
|
24
|
+
const HERMES_HEADER_BYTES = 32;
|
|
25
|
+
const HERMES_FOOTER_BYTES = 20;
|
|
26
|
+
function isRecord(value) {
|
|
27
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28
|
+
}
|
|
29
|
+
function hasExactKeys(value, expected) {
|
|
30
|
+
return (Object.keys(value).length === expected.length &&
|
|
31
|
+
expected.every((key) => Object.hasOwn(value, key)));
|
|
32
|
+
}
|
|
33
|
+
function digestValue(value) {
|
|
34
|
+
return `sha256:${createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
|
|
35
|
+
}
|
|
36
|
+
function assertToken(value, label, pattern) {
|
|
37
|
+
if (typeof value !== "string" || !pattern.test(value)) {
|
|
38
|
+
throw new TypeError(`The release ${label} has an invalid format.`);
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
async function digestReleaseArtifact(artifactPath) {
|
|
43
|
+
const absolutePath = path.resolve(artifactPath);
|
|
44
|
+
let before;
|
|
45
|
+
try {
|
|
46
|
+
before = await lstat(absolutePath);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
throw new TypeError(`Release artifact ${absolutePath} is missing or unreadable.`);
|
|
50
|
+
}
|
|
51
|
+
if (!before.isFile()) {
|
|
52
|
+
throw new TypeError("The release artifact must be a regular file.");
|
|
53
|
+
}
|
|
54
|
+
if (before.size === 0 || before.size > MAX_RELEASE_ARTIFACT_BYTES) {
|
|
55
|
+
throw new TypeError(`The release artifact must contain 1-${MAX_RELEASE_ARTIFACT_BYTES} bytes.`);
|
|
56
|
+
}
|
|
57
|
+
const name = path.basename(absolutePath);
|
|
58
|
+
if (name.length === 0 || name.length > 255 || /[\r\n\0]/u.test(name)) {
|
|
59
|
+
throw new TypeError("The release artifact has an invalid file name.");
|
|
60
|
+
}
|
|
61
|
+
const hash = createHash("sha256");
|
|
62
|
+
await new Promise((resolve, reject) => {
|
|
63
|
+
const stream = createReadStream(absolutePath);
|
|
64
|
+
stream.on("data", (chunk) => hash.update(chunk));
|
|
65
|
+
stream.once("error", reject);
|
|
66
|
+
stream.once("end", resolve);
|
|
67
|
+
});
|
|
68
|
+
const after = await lstat(absolutePath);
|
|
69
|
+
if (!after.isFile() ||
|
|
70
|
+
after.size !== before.size ||
|
|
71
|
+
after.mtimeMs !== before.mtimeMs) {
|
|
72
|
+
throw new TypeError("The release artifact changed while being hashed.");
|
|
73
|
+
}
|
|
74
|
+
return { name, bytes: before.size, sha256: hash.digest("hex") };
|
|
75
|
+
}
|
|
76
|
+
async function readHermesSourceBundle(bundleManifestPath) {
|
|
77
|
+
const manifest = await readNativeBundleManifest(bundleManifestPath);
|
|
78
|
+
if (manifest.minified) {
|
|
79
|
+
throw new TypeError(`Embedded ${manifest.platform} verification requires a bundle created with --hermes-source.`);
|
|
80
|
+
}
|
|
81
|
+
const sourcePath = path.resolve(path.dirname(bundleManifestPath), manifest.artifacts.bundle.path);
|
|
82
|
+
let handle;
|
|
83
|
+
try {
|
|
84
|
+
handle = await open(sourcePath, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
throw new TypeError("The Hermes source bundle is missing or unreadable.");
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const before = await handle.stat();
|
|
91
|
+
if (!before.isFile() ||
|
|
92
|
+
before.size === 0 ||
|
|
93
|
+
before.size > 256 * 1024 * 1024) {
|
|
94
|
+
throw new TypeError("The Hermes source bundle must be a bounded regular file.");
|
|
95
|
+
}
|
|
96
|
+
const bytes = await handle.readFile();
|
|
97
|
+
const after = await handle.stat();
|
|
98
|
+
if (!after.isFile() ||
|
|
99
|
+
bytes.length !== before.size ||
|
|
100
|
+
after.size !== before.size ||
|
|
101
|
+
after.mtimeMs !== before.mtimeMs) {
|
|
102
|
+
throw new TypeError("The Hermes source bundle changed while being read.");
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
platform: manifest.platform,
|
|
106
|
+
bytes,
|
|
107
|
+
sourceSha1: createHash("sha1").update(bytes).digest("hex"),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
await handle.close();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function inspectEmbeddedBundle(cwd, artifactPath, bundleManifestPath) {
|
|
115
|
+
const source = await readHermesSourceBundle(bundleManifestPath);
|
|
116
|
+
let embeddedBundle;
|
|
117
|
+
let iosCompilationSourceName;
|
|
118
|
+
if (source.platform === "android") {
|
|
119
|
+
embeddedBundle = await inspectAndroidEmbeddedHermesBundle(artifactPath);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const inspection = await inspectIOSEmbeddedHermesBundle(artifactPath);
|
|
123
|
+
embeddedBundle = inspection.artifact;
|
|
124
|
+
iosCompilationSourceName = inspection.compilationSourceName;
|
|
125
|
+
}
|
|
126
|
+
if (embeddedBundle.sourceSha1 !== source.sourceSha1) {
|
|
127
|
+
throw new TypeError("The embedded Hermes bytecode was not compiled from the reviewed bundle source.");
|
|
128
|
+
}
|
|
129
|
+
const compiledSha256 = await compileHermesSourceBundle(cwd, source, iosCompilationSourceName);
|
|
130
|
+
if (!compiledSha256.includes(embeddedBundle.sha256)) {
|
|
131
|
+
throw new TypeError("The embedded Hermes bytecode does not match the pinned compiler output for the reviewed bundle source.");
|
|
132
|
+
}
|
|
133
|
+
return embeddedBundle;
|
|
134
|
+
}
|
|
135
|
+
async function compileHermesSourceBundle(cwd, source, iosCompilationSourceName) {
|
|
136
|
+
let compilerPackagePath;
|
|
137
|
+
try {
|
|
138
|
+
const require = createRequire(path.join(cwd, "package.json"));
|
|
139
|
+
compilerPackagePath = require.resolve("hermes-compiler/package.json");
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
throw new TypeError("The application-local pinned Hermes compiler cannot be resolved.");
|
|
143
|
+
}
|
|
144
|
+
const compilerDirectory = process.platform === "darwin"
|
|
145
|
+
? "osx-bin"
|
|
146
|
+
: process.platform === "linux" && process.arch === "x64"
|
|
147
|
+
? "linux64-bin"
|
|
148
|
+
: undefined;
|
|
149
|
+
if (compilerDirectory === undefined) {
|
|
150
|
+
throw new TypeError(`Hermes release linkage is not supported on ${process.platform}-${process.arch}.`);
|
|
151
|
+
}
|
|
152
|
+
const compilerPath = path.join(path.dirname(compilerPackagePath), "hermesc", compilerDirectory, "hermesc");
|
|
153
|
+
const compilerMetadata = await lstat(compilerPath).catch(() => undefined);
|
|
154
|
+
if (compilerMetadata?.isFile() !== true) {
|
|
155
|
+
throw new TypeError("The application-local Hermes compiler is incomplete.");
|
|
156
|
+
}
|
|
157
|
+
const temporaryDirectory = await mkdtemp(path.join(tmpdir(), "solid-native-hermes-"));
|
|
158
|
+
try {
|
|
159
|
+
const sourceName = source.platform === "ios" && iosCompilationSourceName !== undefined
|
|
160
|
+
? syntheticIOSCompilationSourceName(Buffer.byteLength(iosCompilationSourceName, "utf8"))
|
|
161
|
+
: `index.${source.platform}.bundle`;
|
|
162
|
+
const sourcePath = path.join(temporaryDirectory, sourceName);
|
|
163
|
+
await mkdir(path.dirname(sourcePath), { recursive: true });
|
|
164
|
+
await writeFile(sourcePath, source.bytes, { flag: "wx" });
|
|
165
|
+
const compile = async (outputName, outputSourceMap) => {
|
|
166
|
+
const outputPath = path.join(temporaryDirectory, outputName);
|
|
167
|
+
await new Promise((resolve, reject) => {
|
|
168
|
+
execFile(compilerPath, [
|
|
169
|
+
"-w",
|
|
170
|
+
"-emit-binary",
|
|
171
|
+
"-max-diagnostic-width=80",
|
|
172
|
+
"-out",
|
|
173
|
+
outputPath,
|
|
174
|
+
sourceName,
|
|
175
|
+
"-O",
|
|
176
|
+
...(outputSourceMap ? ["-output-source-map"] : []),
|
|
177
|
+
], {
|
|
178
|
+
cwd: temporaryDirectory,
|
|
179
|
+
encoding: "utf8",
|
|
180
|
+
maxBuffer: 1024 * 1024,
|
|
181
|
+
timeout: 120_000,
|
|
182
|
+
}, (error, _stdout, stderr) => {
|
|
183
|
+
if (error === null) {
|
|
184
|
+
resolve();
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
reject(new TypeError(`The pinned Hermes compiler rejected the reviewed bundle source: ${stderr.trim() || error.message}`));
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
return readFile(outputPath);
|
|
191
|
+
};
|
|
192
|
+
if (source.platform === "android") {
|
|
193
|
+
const compiled = await compile("index.android.bundle.hbc", true);
|
|
194
|
+
return [createHash("sha256").update(compiled).digest("hex")];
|
|
195
|
+
}
|
|
196
|
+
const sourceMapCompiled = await compile("index.ios.sourcemap.hbc", true);
|
|
197
|
+
const candidates = [
|
|
198
|
+
createHash("sha256").update(sourceMapCompiled).digest("hex"),
|
|
199
|
+
];
|
|
200
|
+
if (iosCompilationSourceName !== undefined) {
|
|
201
|
+
const compiled = await compile("index.ios.debug.hbc", false);
|
|
202
|
+
candidates.push(digestIOSCompiledBundle(compiled, sourceName, iosCompilationSourceName));
|
|
203
|
+
}
|
|
204
|
+
return candidates;
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
await rm(temporaryDirectory, { force: true, recursive: true });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function syntheticIOSCompilationSourceName(byteLength) {
|
|
211
|
+
const suffix = "/main.jsbundle";
|
|
212
|
+
let remaining = byteLength - Buffer.byteLength(suffix, "utf8");
|
|
213
|
+
if (remaining < 1 || byteLength > 4_096) {
|
|
214
|
+
throw new TypeError("The embedded iOS Hermes compilation source name has an invalid size.");
|
|
215
|
+
}
|
|
216
|
+
const segments = [];
|
|
217
|
+
while (remaining > 100) {
|
|
218
|
+
segments.push("x".repeat(100));
|
|
219
|
+
remaining -= 101;
|
|
220
|
+
}
|
|
221
|
+
if (remaining < 1) {
|
|
222
|
+
segments[segments.length - 1] += "x";
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
segments.push("x".repeat(remaining));
|
|
226
|
+
}
|
|
227
|
+
const sourceName = `${segments.join("/")}${suffix}`;
|
|
228
|
+
if (Buffer.byteLength(sourceName, "utf8") !== byteLength) {
|
|
229
|
+
throw new TypeError("The embedded iOS Hermes compilation source name cannot be normalized safely.");
|
|
230
|
+
}
|
|
231
|
+
return sourceName;
|
|
232
|
+
}
|
|
233
|
+
function digestIOSCompiledBundle(compiled, syntheticSourceName, archivedSourceName) {
|
|
234
|
+
const synthetic = Buffer.from(syntheticSourceName);
|
|
235
|
+
const archived = Buffer.from(archivedSourceName);
|
|
236
|
+
if (synthetic.length !== archived.length) {
|
|
237
|
+
throw new TypeError("The embedded iOS Hermes compilation source name changed size during normalization.");
|
|
238
|
+
}
|
|
239
|
+
const sourceOffset = compiled.indexOf(synthetic);
|
|
240
|
+
const compilerChecksumMatches = compiled.length >= HERMES_HEADER_BYTES + HERMES_FOOTER_BYTES &&
|
|
241
|
+
createHash("sha1")
|
|
242
|
+
.update(compiled.subarray(0, -HERMES_FOOTER_BYTES))
|
|
243
|
+
.digest()
|
|
244
|
+
.equals(compiled.subarray(-HERMES_FOOTER_BYTES));
|
|
245
|
+
if (sourceOffset === -1 ||
|
|
246
|
+
compiled.indexOf(synthetic, sourceOffset + synthetic.length) !== -1 ||
|
|
247
|
+
!compilerChecksumMatches) {
|
|
248
|
+
throw new TypeError("The pinned Hermes compiler emitted invalid iOS source metadata.");
|
|
249
|
+
}
|
|
250
|
+
const normalized = Buffer.from(compiled);
|
|
251
|
+
archived.copy(normalized, sourceOffset);
|
|
252
|
+
createHash("sha1")
|
|
253
|
+
.update(normalized.subarray(0, -HERMES_FOOTER_BYTES))
|
|
254
|
+
.digest()
|
|
255
|
+
.copy(normalized, normalized.length - HERMES_FOOTER_BYTES);
|
|
256
|
+
return createHash("sha256").update(normalized).digest("hex");
|
|
257
|
+
}
|
|
258
|
+
function manifestPayload(manifest) {
|
|
259
|
+
return {
|
|
260
|
+
schemaVersion: manifest.schemaVersion,
|
|
261
|
+
algorithm: manifest.algorithm,
|
|
262
|
+
trust: manifest.trust,
|
|
263
|
+
projectName: manifest.projectName,
|
|
264
|
+
platform: manifest.platform,
|
|
265
|
+
release: manifest.release,
|
|
266
|
+
channel: manifest.channel,
|
|
267
|
+
sourceRevision: manifest.sourceRevision,
|
|
268
|
+
runtime: manifest.runtime,
|
|
269
|
+
nativeCompatibilityFingerprint: manifest.nativeCompatibilityFingerprint,
|
|
270
|
+
bundleFingerprint: manifest.bundleFingerprint,
|
|
271
|
+
artifact: manifest.artifact,
|
|
272
|
+
...(manifest.artifactSigning === undefined
|
|
273
|
+
? {}
|
|
274
|
+
: { artifactSigning: manifest.artifactSigning }),
|
|
275
|
+
...(manifest.embeddedBundle === undefined
|
|
276
|
+
? {}
|
|
277
|
+
: { embeddedBundle: manifest.embeddedBundle }),
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function parseRuntime(value) {
|
|
281
|
+
if (!isRecord(value)) {
|
|
282
|
+
throw new TypeError("The release manifest has an invalid runtime identity.");
|
|
283
|
+
}
|
|
284
|
+
const names = [
|
|
285
|
+
"reactNative",
|
|
286
|
+
"hermesCompiler",
|
|
287
|
+
"solid",
|
|
288
|
+
"solidNativeCore",
|
|
289
|
+
"solidNativeFabricHost",
|
|
290
|
+
"solidNativeRuntime",
|
|
291
|
+
"solidNativeMetro",
|
|
292
|
+
"solidNativeCompiler",
|
|
293
|
+
];
|
|
294
|
+
if (!hasExactKeys(value, names)) {
|
|
295
|
+
throw new TypeError("The release manifest has an invalid runtime identity.");
|
|
296
|
+
}
|
|
297
|
+
const runtime = {};
|
|
298
|
+
for (const name of names) {
|
|
299
|
+
const entry = value[name];
|
|
300
|
+
if (typeof entry !== "string" || entry.length === 0 || entry.length > 128) {
|
|
301
|
+
throw new TypeError(`The release manifest has an invalid ${name} runtime identity.`);
|
|
302
|
+
}
|
|
303
|
+
runtime[name] = entry;
|
|
304
|
+
}
|
|
305
|
+
return runtime;
|
|
306
|
+
}
|
|
307
|
+
function parseEmbeddedBundle(value, platform) {
|
|
308
|
+
if (!isRecord(value) ||
|
|
309
|
+
!hasExactKeys(value, [
|
|
310
|
+
"path",
|
|
311
|
+
"format",
|
|
312
|
+
"bytecodeVersion",
|
|
313
|
+
"bytes",
|
|
314
|
+
"sha256",
|
|
315
|
+
"sourceSha1",
|
|
316
|
+
]) ||
|
|
317
|
+
typeof value.path !== "string" ||
|
|
318
|
+
(platform === "android"
|
|
319
|
+
? value.path !== "assets/index.android.bundle" &&
|
|
320
|
+
value.path !== "base/assets/index.android.bundle"
|
|
321
|
+
: !IOS_EMBEDDED_BUNDLE_PATH.test(value.path)) ||
|
|
322
|
+
value.format !== "hermes-bytecode" ||
|
|
323
|
+
value.bytecodeVersion !== VERIFIED_HERMES_BYTECODE_VERSION ||
|
|
324
|
+
typeof value.bytes !== "number" ||
|
|
325
|
+
!Number.isSafeInteger(value.bytes) ||
|
|
326
|
+
value.bytes < 32 ||
|
|
327
|
+
value.bytes > 256 * 1024 * 1024 ||
|
|
328
|
+
typeof value.sha256 !== "string" ||
|
|
329
|
+
!SHA256_PATTERN.test(value.sha256) ||
|
|
330
|
+
typeof value.sourceSha1 !== "string" ||
|
|
331
|
+
!SHA1_PATTERN.test(value.sourceSha1)) {
|
|
332
|
+
throw new TypeError("The release manifest has an invalid embedded bundle identity.");
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
path: value.path,
|
|
336
|
+
format: "hermes-bytecode",
|
|
337
|
+
bytecodeVersion: VERIFIED_HERMES_BYTECODE_VERSION,
|
|
338
|
+
bytes: value.bytes,
|
|
339
|
+
sha256: value.sha256,
|
|
340
|
+
sourceSha1: value.sourceSha1,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function parseArtifactSigning(value, platform) {
|
|
344
|
+
if (platform !== "android" || !isRecord(value)) {
|
|
345
|
+
throw new TypeError("The release manifest has an invalid artifact-signing identity.");
|
|
346
|
+
}
|
|
347
|
+
if (value.scheme === "android-jar" &&
|
|
348
|
+
hasExactKeys(value, ["scheme", "certificateSha256"]) &&
|
|
349
|
+
typeof value.certificateSha256 === "string" &&
|
|
350
|
+
SHA256_PATTERN.test(value.certificateSha256)) {
|
|
351
|
+
return {
|
|
352
|
+
scheme: "android-jar",
|
|
353
|
+
certificateSha256: value.certificateSha256,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
if (value.scheme === "android-apk" &&
|
|
357
|
+
hasExactKeys(value, ["scheme", "certificateSha256s"]) &&
|
|
358
|
+
Array.isArray(value.certificateSha256s) &&
|
|
359
|
+
value.certificateSha256s.length >= 1 &&
|
|
360
|
+
value.certificateSha256s.length <= 8 &&
|
|
361
|
+
value.certificateSha256s.every((entry) => typeof entry === "string" && SHA256_PATTERN.test(entry)) &&
|
|
362
|
+
new Set(value.certificateSha256s).size ===
|
|
363
|
+
value.certificateSha256s.length &&
|
|
364
|
+
value.certificateSha256s.every((entry, index, values) => index === 0 || values[index - 1] < entry)) {
|
|
365
|
+
return {
|
|
366
|
+
scheme: "android-apk",
|
|
367
|
+
certificateSha256s: value.certificateSha256s,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
throw new TypeError("The release manifest has an invalid artifact-signing identity.");
|
|
371
|
+
}
|
|
372
|
+
function parseReleaseManifest(value) {
|
|
373
|
+
const manifestKeys = [
|
|
374
|
+
"schemaVersion",
|
|
375
|
+
"algorithm",
|
|
376
|
+
"trust",
|
|
377
|
+
"projectName",
|
|
378
|
+
"platform",
|
|
379
|
+
"release",
|
|
380
|
+
"channel",
|
|
381
|
+
"sourceRevision",
|
|
382
|
+
"runtime",
|
|
383
|
+
"nativeCompatibilityFingerprint",
|
|
384
|
+
"bundleFingerprint",
|
|
385
|
+
"artifact",
|
|
386
|
+
"releaseFingerprint",
|
|
387
|
+
...(isRecord(value) && Object.hasOwn(value, "artifactSigning")
|
|
388
|
+
? ["artifactSigning"]
|
|
389
|
+
: []),
|
|
390
|
+
...(isRecord(value) && Object.hasOwn(value, "embeddedBundle")
|
|
391
|
+
? ["embeddedBundle"]
|
|
392
|
+
: []),
|
|
393
|
+
];
|
|
394
|
+
if (!isRecord(value) ||
|
|
395
|
+
!hasExactKeys(value, manifestKeys) ||
|
|
396
|
+
value.schemaVersion !== 0 ||
|
|
397
|
+
value.algorithm !== "sha256" ||
|
|
398
|
+
value.trust !== "unsigned" ||
|
|
399
|
+
(value.platform !== "android" && value.platform !== "ios") ||
|
|
400
|
+
typeof value.projectName !== "string" ||
|
|
401
|
+
value.projectName.length === 0 ||
|
|
402
|
+
value.projectName.length > 214 ||
|
|
403
|
+
/[\r\n\0]/u.test(value.projectName) ||
|
|
404
|
+
typeof value.release !== "string" ||
|
|
405
|
+
typeof value.channel !== "string" ||
|
|
406
|
+
typeof value.sourceRevision !== "string" ||
|
|
407
|
+
typeof value.nativeCompatibilityFingerprint !== "string" ||
|
|
408
|
+
!FINGERPRINT_PATTERN.test(value.nativeCompatibilityFingerprint) ||
|
|
409
|
+
typeof value.bundleFingerprint !== "string" ||
|
|
410
|
+
!FINGERPRINT_PATTERN.test(value.bundleFingerprint) ||
|
|
411
|
+
typeof value.releaseFingerprint !== "string" ||
|
|
412
|
+
!FINGERPRINT_PATTERN.test(value.releaseFingerprint) ||
|
|
413
|
+
!isRecord(value.artifact)) {
|
|
414
|
+
throw new TypeError("The release manifest has an invalid schema.");
|
|
415
|
+
}
|
|
416
|
+
const release = assertToken(value.release, "identifier", RELEASE_PATTERN);
|
|
417
|
+
const channel = assertToken(value.channel, "channel", CHANNEL_PATTERN);
|
|
418
|
+
const sourceRevision = assertToken(value.sourceRevision, "source revision", REVISION_PATTERN);
|
|
419
|
+
if (!hasExactKeys(value.artifact, ["name", "bytes", "sha256"]) ||
|
|
420
|
+
typeof value.artifact.name !== "string" ||
|
|
421
|
+
value.artifact.name.length === 0 ||
|
|
422
|
+
value.artifact.name.length > 255 ||
|
|
423
|
+
/[\\/\r\n\0]/u.test(value.artifact.name) ||
|
|
424
|
+
typeof value.artifact.bytes !== "number" ||
|
|
425
|
+
!Number.isSafeInteger(value.artifact.bytes) ||
|
|
426
|
+
value.artifact.bytes <= 0 ||
|
|
427
|
+
value.artifact.bytes > MAX_RELEASE_ARTIFACT_BYTES ||
|
|
428
|
+
typeof value.artifact.sha256 !== "string" ||
|
|
429
|
+
!SHA256_PATTERN.test(value.artifact.sha256)) {
|
|
430
|
+
throw new TypeError("The release manifest has an invalid artifact identity.");
|
|
431
|
+
}
|
|
432
|
+
if (value.artifactSigning !== undefined) {
|
|
433
|
+
const artifactSigning = parseArtifactSigning(value.artifactSigning, value.platform);
|
|
434
|
+
const expectedExtension = artifactSigning.scheme === "android-jar" ? ".aab" : ".apk";
|
|
435
|
+
if (path.extname(value.artifact.name).toLowerCase() !== expectedExtension) {
|
|
436
|
+
throw new TypeError(`The release manifest can bind ${artifactSigning.scheme} signing only to an ${expectedExtension} artifact.`);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return {
|
|
440
|
+
schemaVersion: 0,
|
|
441
|
+
algorithm: "sha256",
|
|
442
|
+
trust: "unsigned",
|
|
443
|
+
projectName: value.projectName,
|
|
444
|
+
platform: value.platform,
|
|
445
|
+
release,
|
|
446
|
+
channel,
|
|
447
|
+
sourceRevision,
|
|
448
|
+
runtime: parseRuntime(value.runtime),
|
|
449
|
+
nativeCompatibilityFingerprint: value.nativeCompatibilityFingerprint,
|
|
450
|
+
bundleFingerprint: value.bundleFingerprint,
|
|
451
|
+
artifact: {
|
|
452
|
+
name: value.artifact.name,
|
|
453
|
+
bytes: value.artifact.bytes,
|
|
454
|
+
sha256: value.artifact.sha256,
|
|
455
|
+
},
|
|
456
|
+
...(value.artifactSigning === undefined
|
|
457
|
+
? {}
|
|
458
|
+
: {
|
|
459
|
+
artifactSigning: parseArtifactSigning(value.artifactSigning, value.platform),
|
|
460
|
+
}),
|
|
461
|
+
...(value.embeddedBundle === undefined
|
|
462
|
+
? {}
|
|
463
|
+
: {
|
|
464
|
+
embeddedBundle: parseEmbeddedBundle(value.embeddedBundle, value.platform),
|
|
465
|
+
}),
|
|
466
|
+
releaseFingerprint: value.releaseFingerprint,
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
export async function readNativeReleaseManifest(manifestPath) {
|
|
470
|
+
let metadata;
|
|
471
|
+
try {
|
|
472
|
+
metadata = await lstat(manifestPath);
|
|
473
|
+
}
|
|
474
|
+
catch {
|
|
475
|
+
throw new TypeError(`Release manifest ${manifestPath} is missing or unreadable.`);
|
|
476
|
+
}
|
|
477
|
+
if (!metadata.isFile() ||
|
|
478
|
+
metadata.size === 0 ||
|
|
479
|
+
metadata.size > MAX_RELEASE_MANIFEST_BYTES) {
|
|
480
|
+
throw new TypeError(`The release manifest must be a 1-${MAX_RELEASE_MANIFEST_BYTES} byte regular file.`);
|
|
481
|
+
}
|
|
482
|
+
let value;
|
|
483
|
+
try {
|
|
484
|
+
value = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
485
|
+
}
|
|
486
|
+
catch (error) {
|
|
487
|
+
throw new TypeError(`The release manifest is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
488
|
+
}
|
|
489
|
+
return parseReleaseManifest(value);
|
|
490
|
+
}
|
|
491
|
+
export function nativeReleaseFingerprintMatches(manifest) {
|
|
492
|
+
return digestValue(manifestPayload(manifest)) === manifest.releaseFingerprint;
|
|
493
|
+
}
|
|
494
|
+
function targetFingerprint(fingerprint, platform) {
|
|
495
|
+
const target = fingerprint.targets.find((entry) => entry.platform === platform);
|
|
496
|
+
if (target === undefined) {
|
|
497
|
+
throw new TypeError(`The native fingerprint omitted ${platform}.`);
|
|
498
|
+
}
|
|
499
|
+
return target.fingerprint;
|
|
500
|
+
}
|
|
501
|
+
export async function createNativeReleaseManifest(options) {
|
|
502
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
503
|
+
const bundleManifestPath = path.resolve(cwd, options.bundleManifestPath);
|
|
504
|
+
const bundle = await verifyNativeBundleManifest(bundleManifestPath);
|
|
505
|
+
if (!bundle.ok) {
|
|
506
|
+
throw new TypeError(formatNativeBundleVerification(bundle));
|
|
507
|
+
}
|
|
508
|
+
const fingerprint = await createNativeFingerprint({
|
|
509
|
+
cwd,
|
|
510
|
+
platform: bundle.platform,
|
|
511
|
+
});
|
|
512
|
+
const artifactPath = path.resolve(cwd, options.artifactPath);
|
|
513
|
+
const artifact = await digestReleaseArtifact(artifactPath);
|
|
514
|
+
let embeddedBundle;
|
|
515
|
+
if (options.inspectEmbeddedBundle === true) {
|
|
516
|
+
embeddedBundle = await inspectEmbeddedBundle(cwd, artifactPath, bundleManifestPath);
|
|
517
|
+
const [finalArtifact, finalBundle] = await Promise.all([
|
|
518
|
+
digestReleaseArtifact(artifactPath),
|
|
519
|
+
verifyNativeBundleManifest(bundleManifestPath),
|
|
520
|
+
]);
|
|
521
|
+
if (JSON.stringify(finalArtifact) !== JSON.stringify(artifact)) {
|
|
522
|
+
throw new TypeError("The release artifact changed while its embedded bundle was linked.");
|
|
523
|
+
}
|
|
524
|
+
if (!finalBundle.ok ||
|
|
525
|
+
finalBundle.bundleFingerprint !== bundle.bundleFingerprint) {
|
|
526
|
+
throw new TypeError("The reviewed bundle changed while the release artifact was linked.");
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
let artifactSigning;
|
|
530
|
+
if (options.androidSigningCertificateSha256s !== undefined &&
|
|
531
|
+
options.androidUploadCertificateSha256 !== undefined) {
|
|
532
|
+
throw new TypeError("Android APK signing certificates and an AAB upload certificate cannot be bound to the same release.");
|
|
533
|
+
}
|
|
534
|
+
if (options.androidSigningCertificateSha256s !== undefined) {
|
|
535
|
+
if (bundle.platform !== "android") {
|
|
536
|
+
throw new TypeError("Android APK signing verification requires an Android bundle manifest.");
|
|
537
|
+
}
|
|
538
|
+
const verifyAndroidSigning = options.dependencies?.verifyAndroidApkSigning ??
|
|
539
|
+
verifyNativeAndroidApkSigning;
|
|
540
|
+
const signing = await verifyAndroidSigning({
|
|
541
|
+
artifactPath,
|
|
542
|
+
cwd,
|
|
543
|
+
expectedCertificateSha256s: options.androidSigningCertificateSha256s,
|
|
544
|
+
});
|
|
545
|
+
if (!signing.ok) {
|
|
546
|
+
throw new TypeError(formatNativeAndroidApkSigningReport(signing));
|
|
547
|
+
}
|
|
548
|
+
if (path.resolve(signing.artifactPath) !== artifactPath ||
|
|
549
|
+
JSON.stringify(signing.artifact) !== JSON.stringify(artifact)) {
|
|
550
|
+
throw new TypeError("The Android APK changed between release hashing and signing verification.");
|
|
551
|
+
}
|
|
552
|
+
if (signing.signers.length === 0) {
|
|
553
|
+
throw new TypeError("Android APK signing verification did not return a signing-certificate identity.");
|
|
554
|
+
}
|
|
555
|
+
artifactSigning = parseArtifactSigning({
|
|
556
|
+
scheme: "android-apk",
|
|
557
|
+
certificateSha256s: signing.signers
|
|
558
|
+
.map((signer) => signer.certificateSha256)
|
|
559
|
+
.sort(),
|
|
560
|
+
}, "android");
|
|
561
|
+
const finalArtifact = await digestReleaseArtifact(artifactPath);
|
|
562
|
+
if (JSON.stringify(finalArtifact) !== JSON.stringify(artifact)) {
|
|
563
|
+
throw new TypeError("The Android APK changed while its signing identity was bound.");
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (options.androidUploadCertificateSha256 !== undefined) {
|
|
567
|
+
if (bundle.platform !== "android") {
|
|
568
|
+
throw new TypeError("Android upload-certificate verification requires an Android bundle manifest.");
|
|
569
|
+
}
|
|
570
|
+
const verifyAndroidSigning = options.dependencies?.verifyAndroidBundleSigning ??
|
|
571
|
+
verifyNativeAndroidBundleSigning;
|
|
572
|
+
const signing = await verifyAndroidSigning({
|
|
573
|
+
artifactPath,
|
|
574
|
+
cwd,
|
|
575
|
+
expectedCertificateSha256: options.androidUploadCertificateSha256,
|
|
576
|
+
});
|
|
577
|
+
if (!signing.ok) {
|
|
578
|
+
throw new TypeError(formatNativeAndroidBundleSigningReport(signing));
|
|
579
|
+
}
|
|
580
|
+
if (path.resolve(signing.artifactPath) !== artifactPath ||
|
|
581
|
+
JSON.stringify(signing.artifact) !== JSON.stringify(artifact)) {
|
|
582
|
+
throw new TypeError("The Android App Bundle changed between release hashing and signing verification.");
|
|
583
|
+
}
|
|
584
|
+
const signer = signing.signers[0];
|
|
585
|
+
if (signer === undefined) {
|
|
586
|
+
throw new TypeError("Android signing verification did not return the required upload certificate.");
|
|
587
|
+
}
|
|
588
|
+
artifactSigning = parseArtifactSigning({
|
|
589
|
+
scheme: "android-jar",
|
|
590
|
+
certificateSha256: signer.certificateSha256,
|
|
591
|
+
}, "android");
|
|
592
|
+
const finalArtifact = await digestReleaseArtifact(artifactPath);
|
|
593
|
+
if (JSON.stringify(finalArtifact) !== JSON.stringify(artifact)) {
|
|
594
|
+
throw new TypeError("The Android App Bundle changed while its signing identity was bound.");
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
const release = assertToken(options.release, "identifier", RELEASE_PATTERN);
|
|
598
|
+
const channel = assertToken(options.channel, "channel", CHANNEL_PATTERN);
|
|
599
|
+
const sourceRevision = assertToken(options.sourceRevision, "source revision", REVISION_INPUT_PATTERN).toLowerCase();
|
|
600
|
+
const payload = {
|
|
601
|
+
schemaVersion: 0,
|
|
602
|
+
algorithm: "sha256",
|
|
603
|
+
trust: "unsigned",
|
|
604
|
+
projectName: fingerprint.projectName,
|
|
605
|
+
platform: bundle.platform,
|
|
606
|
+
release,
|
|
607
|
+
channel,
|
|
608
|
+
sourceRevision,
|
|
609
|
+
runtime: fingerprint.runtime,
|
|
610
|
+
nativeCompatibilityFingerprint: targetFingerprint(fingerprint, bundle.platform),
|
|
611
|
+
bundleFingerprint: bundle.bundleFingerprint,
|
|
612
|
+
artifact,
|
|
613
|
+
...(artifactSigning === undefined ? {} : { artifactSigning }),
|
|
614
|
+
...(embeddedBundle === undefined ? {} : { embeddedBundle }),
|
|
615
|
+
};
|
|
616
|
+
const manifest = {
|
|
617
|
+
...payload,
|
|
618
|
+
releaseFingerprint: digestValue(payload),
|
|
619
|
+
};
|
|
620
|
+
const manifestPath = path.resolve(cwd, options.outputPath ??
|
|
621
|
+
path.join(path.dirname(bundleManifestPath), "solid-native-release.json"));
|
|
622
|
+
if (manifestPath === artifactPath || manifestPath === bundleManifestPath) {
|
|
623
|
+
throw new TypeError("The release manifest must not overwrite an input artifact or bundle manifest.");
|
|
624
|
+
}
|
|
625
|
+
const parent = path.dirname(manifestPath);
|
|
626
|
+
// Follow the parent directory itself so standard aliases such as macOS
|
|
627
|
+
// `/tmp` -> `/private/tmp` remain valid output locations. The newly-created
|
|
628
|
+
// manifest still uses an exclusive regular-file write in that directory.
|
|
629
|
+
const parentMetadata = await stat(parent).catch(() => undefined);
|
|
630
|
+
if (parentMetadata?.isDirectory() !== true) {
|
|
631
|
+
throw new TypeError("The release manifest output directory does not exist.");
|
|
632
|
+
}
|
|
633
|
+
const temporaryPath = `${manifestPath}.solid-native-${randomUUID()}.tmp`;
|
|
634
|
+
try {
|
|
635
|
+
await writeFile(temporaryPath, `${JSON.stringify(manifest, null, 2)}\n`, {
|
|
636
|
+
flag: "wx",
|
|
637
|
+
});
|
|
638
|
+
await rename(temporaryPath, manifestPath);
|
|
639
|
+
}
|
|
640
|
+
finally {
|
|
641
|
+
await rm(temporaryPath, { force: true });
|
|
642
|
+
}
|
|
643
|
+
return { manifestPath, manifest };
|
|
644
|
+
}
|
|
645
|
+
function check(id, pass, success, failure) {
|
|
646
|
+
return {
|
|
647
|
+
id,
|
|
648
|
+
status: pass ? "pass" : "fail",
|
|
649
|
+
message: pass ? success : failure,
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
export async function verifyNativeReleaseManifest(options) {
|
|
653
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
654
|
+
const manifestPath = path.resolve(cwd, options.manifestPath);
|
|
655
|
+
const artifactPath = path.resolve(cwd, options.artifactPath);
|
|
656
|
+
const bundleManifestPath = path.resolve(cwd, options.bundleManifestPath);
|
|
657
|
+
const manifest = await readNativeReleaseManifest(manifestPath);
|
|
658
|
+
const checks = [
|
|
659
|
+
check("fingerprint", nativeReleaseFingerprintMatches(manifest), "The release fingerprint matches the canonical envelope.", "The release fingerprint does not match the canonical envelope."),
|
|
660
|
+
];
|
|
661
|
+
try {
|
|
662
|
+
const artifact = await digestReleaseArtifact(artifactPath);
|
|
663
|
+
checks.push(check("artifact", JSON.stringify(artifact) === JSON.stringify(manifest.artifact), "The final native artifact matches the release envelope.", "The final native artifact does not match the release envelope."));
|
|
664
|
+
}
|
|
665
|
+
catch (error) {
|
|
666
|
+
checks.push({
|
|
667
|
+
id: "artifact",
|
|
668
|
+
status: "fail",
|
|
669
|
+
message: error instanceof Error ? error.message : String(error),
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
if (manifest.artifactSigning !== undefined) {
|
|
673
|
+
try {
|
|
674
|
+
if (manifest.artifactSigning.scheme === "android-jar") {
|
|
675
|
+
const verifyAndroidSigning = options.dependencies?.verifyAndroidBundleSigning ??
|
|
676
|
+
verifyNativeAndroidBundleSigning;
|
|
677
|
+
const signing = await verifyAndroidSigning({
|
|
678
|
+
artifactPath,
|
|
679
|
+
cwd,
|
|
680
|
+
expectedCertificateSha256: manifest.artifactSigning.certificateSha256,
|
|
681
|
+
});
|
|
682
|
+
checks.push(check("artifact-signing", signing.ok &&
|
|
683
|
+
path.resolve(signing.artifactPath) === artifactPath &&
|
|
684
|
+
JSON.stringify(signing.artifact) ===
|
|
685
|
+
JSON.stringify(manifest.artifact), "The Android App Bundle signature and upload certificate match the release envelope.", "The Android App Bundle signature does not match the release envelope."));
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
const verifyAndroidSigning = options.dependencies?.verifyAndroidApkSigning ??
|
|
689
|
+
verifyNativeAndroidApkSigning;
|
|
690
|
+
const signing = await verifyAndroidSigning({
|
|
691
|
+
artifactPath,
|
|
692
|
+
cwd,
|
|
693
|
+
expectedCertificateSha256s: manifest.artifactSigning.certificateSha256s,
|
|
694
|
+
});
|
|
695
|
+
checks.push(check("artifact-signing", signing.ok &&
|
|
696
|
+
path.resolve(signing.artifactPath) === artifactPath &&
|
|
697
|
+
JSON.stringify(signing.artifact) ===
|
|
698
|
+
JSON.stringify(manifest.artifact), "The Android APK signature and certificate set match the release envelope.", "The Android APK signature does not match the release envelope."));
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
catch (error) {
|
|
702
|
+
checks.push({
|
|
703
|
+
id: "artifact-signing",
|
|
704
|
+
status: "fail",
|
|
705
|
+
message: error instanceof Error ? error.message : String(error),
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
if (manifest.embeddedBundle !== undefined) {
|
|
710
|
+
try {
|
|
711
|
+
const embeddedBundle = await inspectEmbeddedBundle(cwd, artifactPath, bundleManifestPath);
|
|
712
|
+
checks.push(check("embedded-bundle", JSON.stringify(embeddedBundle) ===
|
|
713
|
+
JSON.stringify(manifest.embeddedBundle), "The archived Hermes bytecode matches the pinned compiler output for the reviewed bundle source.", "The archived Hermes bytecode does not match the release envelope."));
|
|
714
|
+
}
|
|
715
|
+
catch (error) {
|
|
716
|
+
checks.push({
|
|
717
|
+
id: "embedded-bundle",
|
|
718
|
+
status: "fail",
|
|
719
|
+
message: error instanceof Error ? error.message : String(error),
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
try {
|
|
724
|
+
const bundle = await verifyNativeBundleManifest(bundleManifestPath);
|
|
725
|
+
checks.push(check("bundle", bundle.ok &&
|
|
726
|
+
bundle.platform === manifest.platform &&
|
|
727
|
+
bundle.bundleFingerprint === manifest.bundleFingerprint, "The complete bundle artifact set matches the release envelope.", "The bundle artifact set does not match the release envelope."));
|
|
728
|
+
}
|
|
729
|
+
catch (error) {
|
|
730
|
+
checks.push({
|
|
731
|
+
id: "bundle",
|
|
732
|
+
status: "fail",
|
|
733
|
+
message: error instanceof Error ? error.message : String(error),
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
try {
|
|
737
|
+
const fingerprint = await createNativeFingerprint({
|
|
738
|
+
cwd,
|
|
739
|
+
platform: manifest.platform,
|
|
740
|
+
});
|
|
741
|
+
checks.push(check("native", fingerprint.projectName === manifest.projectName &&
|
|
742
|
+
JSON.stringify(fingerprint.runtime) ===
|
|
743
|
+
JSON.stringify(manifest.runtime) &&
|
|
744
|
+
targetFingerprint(fingerprint, manifest.platform) ===
|
|
745
|
+
manifest.nativeCompatibilityFingerprint, "The current native compatibility inputs match the release envelope.", "The current native compatibility inputs do not match the release envelope."));
|
|
746
|
+
}
|
|
747
|
+
catch (error) {
|
|
748
|
+
checks.push({
|
|
749
|
+
id: "native",
|
|
750
|
+
status: "fail",
|
|
751
|
+
message: error instanceof Error ? error.message : String(error),
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
return {
|
|
755
|
+
schemaVersion: 0,
|
|
756
|
+
ok: checks.every((entry) => entry.status === "pass"),
|
|
757
|
+
manifestPath,
|
|
758
|
+
releaseFingerprint: manifest.releaseFingerprint,
|
|
759
|
+
checks,
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
export function formatNativeReleaseVerification(report) {
|
|
763
|
+
return [
|
|
764
|
+
`${report.ok ? "PASS" : "FAIL"} Solid Native release ${report.releaseFingerprint}`,
|
|
765
|
+
`Manifest: ${report.manifestPath}`,
|
|
766
|
+
...report.checks.map((entry) => `${entry.status === "pass" ? "PASS" : "FAIL"} ${entry.id}: ${entry.message}`),
|
|
767
|
+
"",
|
|
768
|
+
"Integrity only: verify a trusted signature before accepting this release.",
|
|
769
|
+
].join("\n");
|
|
770
|
+
}
|
|
771
|
+
//# sourceMappingURL=release.js.map
|