@solidnative-dev/cli 0.0.0-stage → 0.1.0-alpha.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
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
import { createHash, randomUUID, sign, verify, } from "node:crypto";
|
|
2
|
+
import { rename, rm, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { formatNativeReleaseVerification, nativeReleaseFingerprintMatches, readNativeReleaseManifest, verifyNativeReleaseManifest, } from "./release.js";
|
|
5
|
+
import { publicEd25519KeyFromSpki, readDetachedEd25519Signature, readEd25519PrivateKey, readEd25519PublicKey, readStableRegularFile, } from "./signature-utilities.js";
|
|
6
|
+
const MAX_SIGNATURE_STATEMENT_BYTES = 64 * 1024;
|
|
7
|
+
const MAX_SIGNING_REQUEST_BYTES = 64 * 1024;
|
|
8
|
+
const MAX_TRUST_POLICY_BYTES = 64 * 1024;
|
|
9
|
+
const MAX_TRUST_POLICY_KEYS = 32;
|
|
10
|
+
const KEY_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:/@-]{0,127}$/u;
|
|
11
|
+
const RELEASE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$/u;
|
|
12
|
+
const CHANNEL_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u;
|
|
13
|
+
const REVISION_PATTERN = /^[a-f0-9]{7,64}$/u;
|
|
14
|
+
const SHA256_PATTERN = /^[a-f0-9]{64}$/u;
|
|
15
|
+
const FINGERPRINT_PATTERN = /^sha256:[a-f0-9]{64}$/u;
|
|
16
|
+
const BASE64URL_PATTERN = /^[A-Za-z0-9_-]{86}$/u;
|
|
17
|
+
const SIGNATURE_CONTEXT = "solid-native.release-signature.v0\0";
|
|
18
|
+
const RELEASE_AUTHORIZATION_REQUIRED_KEYS = [
|
|
19
|
+
"projectName",
|
|
20
|
+
"platform",
|
|
21
|
+
"channel",
|
|
22
|
+
];
|
|
23
|
+
const RELEASE_AUTHORIZATION_ALLOWED_KEYS = [
|
|
24
|
+
...RELEASE_AUTHORIZATION_REQUIRED_KEYS,
|
|
25
|
+
"release",
|
|
26
|
+
"sourceRevision",
|
|
27
|
+
"releaseFingerprint",
|
|
28
|
+
"bundleFingerprint",
|
|
29
|
+
"nativeCompatibilityFingerprint",
|
|
30
|
+
"artifactSha256",
|
|
31
|
+
];
|
|
32
|
+
function isRecord(value) {
|
|
33
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34
|
+
}
|
|
35
|
+
function hasExactKeys(value, expected) {
|
|
36
|
+
return (Object.keys(value).length === expected.length &&
|
|
37
|
+
expected.every((key) => Object.hasOwn(value, key)));
|
|
38
|
+
}
|
|
39
|
+
function assertKeyId(value, label) {
|
|
40
|
+
if (typeof value !== "string" || !KEY_ID_PATTERN.test(value)) {
|
|
41
|
+
throw new TypeError(`${label} must be a static key identifier.`);
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
function assertPolicyToken(value, label, pattern) {
|
|
46
|
+
if (typeof value !== "string" || !pattern.test(value)) {
|
|
47
|
+
throw new TypeError(`The release authorization ${label} is invalid.`);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
function optionalPolicyToken(value, label, pattern) {
|
|
52
|
+
return value === undefined
|
|
53
|
+
? undefined
|
|
54
|
+
: assertPolicyToken(value, label, pattern);
|
|
55
|
+
}
|
|
56
|
+
function parseReleaseAuthorizationPolicy(value) {
|
|
57
|
+
if (!isRecord(value) ||
|
|
58
|
+
!RELEASE_AUTHORIZATION_REQUIRED_KEYS.every((key) => Object.hasOwn(value, key)) ||
|
|
59
|
+
!Object.keys(value).every((key) => RELEASE_AUTHORIZATION_ALLOWED_KEYS.includes(key)) ||
|
|
60
|
+
typeof value.projectName !== "string" ||
|
|
61
|
+
value.projectName.length === 0 ||
|
|
62
|
+
value.projectName.length > 214 ||
|
|
63
|
+
/[\r\n\0]/u.test(value.projectName) ||
|
|
64
|
+
(value.platform !== "android" && value.platform !== "ios")) {
|
|
65
|
+
throw new TypeError("The release authorization policy is invalid.");
|
|
66
|
+
}
|
|
67
|
+
const release = optionalPolicyToken(value.release, "release identifier", RELEASE_PATTERN);
|
|
68
|
+
const sourceRevision = optionalPolicyToken(value.sourceRevision, "source revision", REVISION_PATTERN);
|
|
69
|
+
const releaseFingerprint = optionalPolicyToken(value.releaseFingerprint, "release fingerprint", FINGERPRINT_PATTERN);
|
|
70
|
+
const bundleFingerprint = optionalPolicyToken(value.bundleFingerprint, "bundle fingerprint", FINGERPRINT_PATTERN);
|
|
71
|
+
const nativeCompatibilityFingerprint = optionalPolicyToken(value.nativeCompatibilityFingerprint, "native compatibility fingerprint", FINGERPRINT_PATTERN);
|
|
72
|
+
const artifactSha256 = optionalPolicyToken(value.artifactSha256, "artifact SHA-256", SHA256_PATTERN);
|
|
73
|
+
return {
|
|
74
|
+
projectName: value.projectName,
|
|
75
|
+
platform: value.platform,
|
|
76
|
+
channel: assertPolicyToken(value.channel, "channel", CHANNEL_PATTERN),
|
|
77
|
+
...(release === undefined ? {} : { release }),
|
|
78
|
+
...(sourceRevision === undefined ? {} : { sourceRevision }),
|
|
79
|
+
...(releaseFingerprint === undefined ? {} : { releaseFingerprint }),
|
|
80
|
+
...(bundleFingerprint === undefined ? {} : { bundleFingerprint }),
|
|
81
|
+
...(nativeCompatibilityFingerprint === undefined
|
|
82
|
+
? {}
|
|
83
|
+
: { nativeCompatibilityFingerprint }),
|
|
84
|
+
...(artifactSha256 === undefined ? {} : { artifactSha256 }),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function parseNativeReleaseTrustPolicy(value) {
|
|
88
|
+
const allowedKeys = [
|
|
89
|
+
"schemaVersion",
|
|
90
|
+
"policySequence",
|
|
91
|
+
"keys",
|
|
92
|
+
...RELEASE_AUTHORIZATION_ALLOWED_KEYS,
|
|
93
|
+
];
|
|
94
|
+
if (!isRecord(value) ||
|
|
95
|
+
value.schemaVersion !== 0 ||
|
|
96
|
+
typeof value.policySequence !== "number" ||
|
|
97
|
+
!Number.isSafeInteger(value.policySequence) ||
|
|
98
|
+
value.policySequence <= 0 ||
|
|
99
|
+
!Array.isArray(value.keys) ||
|
|
100
|
+
value.keys.length === 0 ||
|
|
101
|
+
value.keys.length > MAX_TRUST_POLICY_KEYS ||
|
|
102
|
+
!Object.keys(value).every((key) => allowedKeys.includes(key))) {
|
|
103
|
+
throw new TypeError("The release trust policy has an invalid schema.");
|
|
104
|
+
}
|
|
105
|
+
const authorization = parseReleaseAuthorizationPolicy(Object.fromEntries(RELEASE_AUTHORIZATION_ALLOWED_KEYS.filter((key) => Object.hasOwn(value, key)).map((key) => [key, value[key]])));
|
|
106
|
+
const keyIds = new Set();
|
|
107
|
+
const publicKeys = new Set();
|
|
108
|
+
const keys = value.keys
|
|
109
|
+
.map((entry, index) => {
|
|
110
|
+
if (!isRecord(entry) ||
|
|
111
|
+
!hasExactKeys(entry, [
|
|
112
|
+
"keyId",
|
|
113
|
+
"algorithm",
|
|
114
|
+
"publicKeySpki",
|
|
115
|
+
"status",
|
|
116
|
+
]) ||
|
|
117
|
+
entry.algorithm !== "ed25519" ||
|
|
118
|
+
typeof entry.publicKeySpki !== "string" ||
|
|
119
|
+
(entry.status !== "active" && entry.status !== "revoked")) {
|
|
120
|
+
throw new TypeError(`Release trust policy key ${String(index)} has an invalid schema.`);
|
|
121
|
+
}
|
|
122
|
+
const keyId = assertKeyId(entry.keyId, `Release trust policy key ${String(index)} ID`);
|
|
123
|
+
if (keyIds.has(keyId)) {
|
|
124
|
+
throw new TypeError(`Release trust policy key ID ${keyId} is duplicated.`);
|
|
125
|
+
}
|
|
126
|
+
keyIds.add(keyId);
|
|
127
|
+
publicEd25519KeyFromSpki(entry.publicKeySpki, `Release trust policy key ${keyId}`);
|
|
128
|
+
if (publicKeys.has(entry.publicKeySpki)) {
|
|
129
|
+
throw new TypeError(`Release trust policy key ${keyId} duplicates another public key.`);
|
|
130
|
+
}
|
|
131
|
+
publicKeys.add(entry.publicKeySpki);
|
|
132
|
+
return Object.freeze({
|
|
133
|
+
keyId,
|
|
134
|
+
algorithm: "ed25519",
|
|
135
|
+
publicKeySpki: entry.publicKeySpki,
|
|
136
|
+
status: entry.status,
|
|
137
|
+
});
|
|
138
|
+
})
|
|
139
|
+
.sort((left, right) => left.keyId < right.keyId ? -1 : left.keyId > right.keyId ? 1 : 0);
|
|
140
|
+
return Object.freeze({
|
|
141
|
+
schemaVersion: 0,
|
|
142
|
+
policySequence: value.policySequence,
|
|
143
|
+
...authorization,
|
|
144
|
+
keys: Object.freeze(keys),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function fingerprintParsedReleaseTrustPolicy(policy) {
|
|
148
|
+
return `sha256:${createHash("sha256")
|
|
149
|
+
.update(JSON.stringify(policy), "utf8")
|
|
150
|
+
.digest("hex")}`;
|
|
151
|
+
}
|
|
152
|
+
export function nativeReleaseTrustPolicyFingerprint(policy) {
|
|
153
|
+
return fingerprintParsedReleaseTrustPolicy(parseNativeReleaseTrustPolicy(policy));
|
|
154
|
+
}
|
|
155
|
+
function releaseAuthorizationMismatches(manifest, policy) {
|
|
156
|
+
const actual = {
|
|
157
|
+
projectName: manifest.projectName,
|
|
158
|
+
platform: manifest.platform,
|
|
159
|
+
channel: manifest.channel,
|
|
160
|
+
release: manifest.release,
|
|
161
|
+
sourceRevision: manifest.sourceRevision,
|
|
162
|
+
releaseFingerprint: manifest.releaseFingerprint,
|
|
163
|
+
bundleFingerprint: manifest.bundleFingerprint,
|
|
164
|
+
nativeCompatibilityFingerprint: manifest.nativeCompatibilityFingerprint,
|
|
165
|
+
artifactSha256: manifest.artifact.sha256,
|
|
166
|
+
};
|
|
167
|
+
return Object.entries(policy)
|
|
168
|
+
.filter(([key, expected]) => actual[key] !== expected)
|
|
169
|
+
.map(([key]) => key);
|
|
170
|
+
}
|
|
171
|
+
export async function readNativeReleaseTrustPolicy(policyPath) {
|
|
172
|
+
if (typeof policyPath !== "string" || policyPath.length === 0) {
|
|
173
|
+
throw new TypeError("The release trust policy path must be a string.");
|
|
174
|
+
}
|
|
175
|
+
const file = await readStableRegularFile(policyPath, "Release trust policy", MAX_TRUST_POLICY_BYTES);
|
|
176
|
+
try {
|
|
177
|
+
return parseNativeReleaseTrustPolicy(JSON.parse(file.bytes.toString("utf8")));
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
if (error instanceof SyntaxError) {
|
|
181
|
+
throw new TypeError(`The release trust policy is not valid JSON: ${error.message}`);
|
|
182
|
+
}
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function signaturePayload(statement) {
|
|
187
|
+
return Buffer.from(`${SIGNATURE_CONTEXT}${JSON.stringify(statement)}`, "utf8");
|
|
188
|
+
}
|
|
189
|
+
function signingStatement(keyId, releaseFingerprint) {
|
|
190
|
+
return {
|
|
191
|
+
schemaVersion: 0,
|
|
192
|
+
algorithm: "ed25519",
|
|
193
|
+
keyId: assertKeyId(keyId, "The signing key ID"),
|
|
194
|
+
releaseFingerprint,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function signingRequestForStatement(statement) {
|
|
198
|
+
const payload = signaturePayload(statement);
|
|
199
|
+
return Object.freeze({
|
|
200
|
+
...statement,
|
|
201
|
+
payloadBase64url: payload.toString("base64url"),
|
|
202
|
+
payloadSha256: createHash("sha256").update(payload).digest("hex"),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function parseNativeReleaseSigningRequest(value) {
|
|
206
|
+
if (!isRecord(value) ||
|
|
207
|
+
!hasExactKeys(value, [
|
|
208
|
+
"schemaVersion",
|
|
209
|
+
"algorithm",
|
|
210
|
+
"keyId",
|
|
211
|
+
"releaseFingerprint",
|
|
212
|
+
"payloadBase64url",
|
|
213
|
+
"payloadSha256",
|
|
214
|
+
]) ||
|
|
215
|
+
value.schemaVersion !== 0 ||
|
|
216
|
+
value.algorithm !== "ed25519" ||
|
|
217
|
+
typeof value.releaseFingerprint !== "string" ||
|
|
218
|
+
!FINGERPRINT_PATTERN.test(value.releaseFingerprint) ||
|
|
219
|
+
typeof value.payloadBase64url !== "string" ||
|
|
220
|
+
typeof value.payloadSha256 !== "string" ||
|
|
221
|
+
!SHA256_PATTERN.test(value.payloadSha256)) {
|
|
222
|
+
throw new TypeError("The release signing request has an invalid schema.");
|
|
223
|
+
}
|
|
224
|
+
const statement = signingStatement(value.keyId, value.releaseFingerprint);
|
|
225
|
+
const expected = signingRequestForStatement(statement);
|
|
226
|
+
if (value.payloadBase64url !== expected.payloadBase64url ||
|
|
227
|
+
value.payloadSha256 !== expected.payloadSha256) {
|
|
228
|
+
throw new TypeError("The release signing request payload does not match its statement.");
|
|
229
|
+
}
|
|
230
|
+
return expected;
|
|
231
|
+
}
|
|
232
|
+
export async function readNativeReleaseSigningRequest(requestPath) {
|
|
233
|
+
if (typeof requestPath !== "string" || requestPath.length === 0) {
|
|
234
|
+
throw new TypeError("The release signing request path must be a string.");
|
|
235
|
+
}
|
|
236
|
+
const file = await readStableRegularFile(requestPath, "Release signing request", MAX_SIGNING_REQUEST_BYTES);
|
|
237
|
+
try {
|
|
238
|
+
return parseNativeReleaseSigningRequest(JSON.parse(file.bytes.toString("utf8")));
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
if (error instanceof SyntaxError) {
|
|
242
|
+
throw new TypeError(`The release signing request is not valid JSON: ${error.message}`);
|
|
243
|
+
}
|
|
244
|
+
throw error;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function parseNativeReleaseSignature(value) {
|
|
248
|
+
if (!isRecord(value) ||
|
|
249
|
+
!hasExactKeys(value, [
|
|
250
|
+
"schemaVersion",
|
|
251
|
+
"algorithm",
|
|
252
|
+
"keyId",
|
|
253
|
+
"releaseFingerprint",
|
|
254
|
+
"signature",
|
|
255
|
+
]) ||
|
|
256
|
+
value.schemaVersion !== 0 ||
|
|
257
|
+
value.algorithm !== "ed25519" ||
|
|
258
|
+
typeof value.keyId !== "string" ||
|
|
259
|
+
typeof value.releaseFingerprint !== "string" ||
|
|
260
|
+
!FINGERPRINT_PATTERN.test(value.releaseFingerprint) ||
|
|
261
|
+
typeof value.signature !== "string" ||
|
|
262
|
+
!BASE64URL_PATTERN.test(value.signature)) {
|
|
263
|
+
throw new TypeError("The release signature has an invalid schema.");
|
|
264
|
+
}
|
|
265
|
+
const signatureBytes = Buffer.from(value.signature, "base64url");
|
|
266
|
+
if (signatureBytes.length !== 64 ||
|
|
267
|
+
signatureBytes.toString("base64url") !== value.signature) {
|
|
268
|
+
throw new TypeError("The release signature is not canonical base64url.");
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
schemaVersion: 0,
|
|
272
|
+
algorithm: "ed25519",
|
|
273
|
+
keyId: assertKeyId(value.keyId, "The release signature key ID"),
|
|
274
|
+
releaseFingerprint: value.releaseFingerprint,
|
|
275
|
+
signature: value.signature,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
async function readNativeReleaseSignature(signaturePath) {
|
|
279
|
+
const file = await readStableRegularFile(signaturePath, "Release signature", MAX_SIGNATURE_STATEMENT_BYTES);
|
|
280
|
+
try {
|
|
281
|
+
return parseNativeReleaseSignature(JSON.parse(file.bytes.toString("utf8")));
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
if (error instanceof SyntaxError) {
|
|
285
|
+
throw new TypeError(`The release signature is not valid JSON: ${error.message}`);
|
|
286
|
+
}
|
|
287
|
+
throw error;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function check(id, pass, success, failure) {
|
|
291
|
+
return {
|
|
292
|
+
id,
|
|
293
|
+
status: pass ? "pass" : "fail",
|
|
294
|
+
message: pass ? success : failure,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
export async function createNativeReleaseSigningRequest(options) {
|
|
298
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
299
|
+
const manifestPath = path.resolve(cwd, options.manifestPath);
|
|
300
|
+
if ((options.bundleManifestPath === undefined) !==
|
|
301
|
+
(options.artifactPath === undefined)) {
|
|
302
|
+
throw new TypeError("Verified release signing requests require both a bundle manifest and native artifact.");
|
|
303
|
+
}
|
|
304
|
+
const bundleManifestPath = options.bundleManifestPath === undefined
|
|
305
|
+
? undefined
|
|
306
|
+
: path.resolve(cwd, options.bundleManifestPath);
|
|
307
|
+
const artifactPath = options.artifactPath === undefined
|
|
308
|
+
? undefined
|
|
309
|
+
: path.resolve(cwd, options.artifactPath);
|
|
310
|
+
let verification;
|
|
311
|
+
if (bundleManifestPath !== undefined && artifactPath !== undefined) {
|
|
312
|
+
verification = await verifyNativeReleaseManifest({
|
|
313
|
+
cwd,
|
|
314
|
+
manifestPath,
|
|
315
|
+
bundleManifestPath,
|
|
316
|
+
artifactPath,
|
|
317
|
+
});
|
|
318
|
+
if (!verification.ok) {
|
|
319
|
+
throw new TypeError(`The release inputs failed verification; refusing to prepare a signing request.\n${formatNativeReleaseVerification(verification)}`);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
const manifest = await readNativeReleaseManifest(manifestPath);
|
|
323
|
+
if (!nativeReleaseFingerprintMatches(manifest)) {
|
|
324
|
+
throw new TypeError("The release manifest fingerprint is invalid; refusing to prepare a signing request.");
|
|
325
|
+
}
|
|
326
|
+
if (verification !== undefined &&
|
|
327
|
+
verification.releaseFingerprint !== manifest.releaseFingerprint) {
|
|
328
|
+
throw new TypeError("The release manifest changed after its inputs were verified.");
|
|
329
|
+
}
|
|
330
|
+
const request = signingRequestForStatement(signingStatement(options.keyId, manifest.releaseFingerprint));
|
|
331
|
+
const requestPath = path.resolve(cwd, options.outputPath ?? `${manifestPath}.signing-request.json`);
|
|
332
|
+
if (requestPath === manifestPath ||
|
|
333
|
+
requestPath === bundleManifestPath ||
|
|
334
|
+
requestPath === artifactPath) {
|
|
335
|
+
throw new TypeError("The release signing request must not overwrite a release input.");
|
|
336
|
+
}
|
|
337
|
+
const parentMetadata = await stat(path.dirname(requestPath)).catch(() => undefined);
|
|
338
|
+
if (parentMetadata?.isDirectory() !== true) {
|
|
339
|
+
throw new TypeError("The release signing request output directory does not exist.");
|
|
340
|
+
}
|
|
341
|
+
const finalManifest = await readNativeReleaseManifest(manifestPath);
|
|
342
|
+
if (!nativeReleaseFingerprintMatches(finalManifest) ||
|
|
343
|
+
JSON.stringify(finalManifest) !== JSON.stringify(manifest)) {
|
|
344
|
+
throw new TypeError("The release manifest changed while preparing its signing request.");
|
|
345
|
+
}
|
|
346
|
+
const temporaryPath = `${requestPath}.solid-native-${randomUUID()}.tmp`;
|
|
347
|
+
try {
|
|
348
|
+
await writeFile(temporaryPath, `${JSON.stringify(request, null, 2)}\n`, {
|
|
349
|
+
flag: "wx",
|
|
350
|
+
mode: 0o644,
|
|
351
|
+
});
|
|
352
|
+
await rename(temporaryPath, requestPath);
|
|
353
|
+
}
|
|
354
|
+
finally {
|
|
355
|
+
await rm(temporaryPath, { force: true });
|
|
356
|
+
}
|
|
357
|
+
return {
|
|
358
|
+
requestPath,
|
|
359
|
+
request,
|
|
360
|
+
...(verification === undefined ? {} : { verification }),
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
export async function createNativeReleaseSignature(options) {
|
|
364
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
365
|
+
const manifestPath = path.resolve(cwd, options.manifestPath);
|
|
366
|
+
const privateKeyPath = path.resolve(cwd, options.privateKeyPath);
|
|
367
|
+
if ((options.bundleManifestPath === undefined) !==
|
|
368
|
+
(options.artifactPath === undefined)) {
|
|
369
|
+
throw new TypeError("Verified release signing requires both a bundle manifest and native artifact.");
|
|
370
|
+
}
|
|
371
|
+
const bundleManifestPath = options.bundleManifestPath === undefined
|
|
372
|
+
? undefined
|
|
373
|
+
: path.resolve(cwd, options.bundleManifestPath);
|
|
374
|
+
const artifactPath = options.artifactPath === undefined
|
|
375
|
+
? undefined
|
|
376
|
+
: path.resolve(cwd, options.artifactPath);
|
|
377
|
+
let verification;
|
|
378
|
+
if (bundleManifestPath !== undefined && artifactPath !== undefined) {
|
|
379
|
+
verification = await verifyNativeReleaseManifest({
|
|
380
|
+
cwd,
|
|
381
|
+
manifestPath,
|
|
382
|
+
bundleManifestPath,
|
|
383
|
+
artifactPath,
|
|
384
|
+
});
|
|
385
|
+
if (!verification.ok) {
|
|
386
|
+
throw new TypeError(`The release inputs failed verification; refusing to sign them.\n${formatNativeReleaseVerification(verification)}`);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
const manifest = await readNativeReleaseManifest(manifestPath);
|
|
390
|
+
if (!nativeReleaseFingerprintMatches(manifest)) {
|
|
391
|
+
throw new TypeError("The release manifest fingerprint is invalid; refusing to sign it.");
|
|
392
|
+
}
|
|
393
|
+
if (verification !== undefined &&
|
|
394
|
+
verification.releaseFingerprint !== manifest.releaseFingerprint) {
|
|
395
|
+
throw new TypeError("The release manifest changed after its inputs were verified.");
|
|
396
|
+
}
|
|
397
|
+
const privateKey = await readEd25519PrivateKey(privateKeyPath);
|
|
398
|
+
const statement = signingStatement(options.keyId, manifest.releaseFingerprint);
|
|
399
|
+
const signature = {
|
|
400
|
+
...statement,
|
|
401
|
+
signature: sign(null, signaturePayload(statement), privateKey).toString("base64url"),
|
|
402
|
+
};
|
|
403
|
+
const signaturePath = path.resolve(cwd, options.outputPath ?? `${manifestPath}.sig.json`);
|
|
404
|
+
if (signaturePath === manifestPath ||
|
|
405
|
+
signaturePath === privateKeyPath ||
|
|
406
|
+
signaturePath === bundleManifestPath ||
|
|
407
|
+
signaturePath === artifactPath) {
|
|
408
|
+
throw new TypeError("The release signature must not overwrite a signing input.");
|
|
409
|
+
}
|
|
410
|
+
const parentMetadata = await stat(path.dirname(signaturePath)).catch(() => undefined);
|
|
411
|
+
if (parentMetadata?.isDirectory() !== true) {
|
|
412
|
+
throw new TypeError("The release signature output directory does not exist.");
|
|
413
|
+
}
|
|
414
|
+
const finalManifest = await readNativeReleaseManifest(manifestPath);
|
|
415
|
+
if (!nativeReleaseFingerprintMatches(finalManifest) ||
|
|
416
|
+
JSON.stringify(finalManifest) !== JSON.stringify(manifest)) {
|
|
417
|
+
throw new TypeError("The release manifest changed while being signed.");
|
|
418
|
+
}
|
|
419
|
+
const temporaryPath = `${signaturePath}.solid-native-${randomUUID()}.tmp`;
|
|
420
|
+
try {
|
|
421
|
+
await writeFile(temporaryPath, `${JSON.stringify(signature, null, 2)}\n`, {
|
|
422
|
+
flag: "wx",
|
|
423
|
+
mode: 0o644,
|
|
424
|
+
});
|
|
425
|
+
await rename(temporaryPath, signaturePath);
|
|
426
|
+
}
|
|
427
|
+
finally {
|
|
428
|
+
await rm(temporaryPath, { force: true });
|
|
429
|
+
}
|
|
430
|
+
return {
|
|
431
|
+
signaturePath,
|
|
432
|
+
signature,
|
|
433
|
+
...(verification === undefined ? {} : { verification }),
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
export async function assembleNativeReleaseSignature(options) {
|
|
437
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
438
|
+
const requestPath = path.resolve(cwd, options.requestPath);
|
|
439
|
+
const detachedSignaturePath = path.resolve(cwd, options.detachedSignaturePath);
|
|
440
|
+
const publicKeyPath = path.resolve(cwd, options.publicKeyPath);
|
|
441
|
+
const signaturePath = path.resolve(cwd, options.outputPath ?? `${requestPath}.sig.json`);
|
|
442
|
+
if (signaturePath === requestPath ||
|
|
443
|
+
signaturePath === detachedSignaturePath ||
|
|
444
|
+
signaturePath === publicKeyPath) {
|
|
445
|
+
throw new TypeError("The assembled release signature must not overwrite an assembly input.");
|
|
446
|
+
}
|
|
447
|
+
const [request, detachedSignature, publicKey] = await Promise.all([
|
|
448
|
+
readNativeReleaseSigningRequest(requestPath),
|
|
449
|
+
readDetachedEd25519Signature(detachedSignaturePath),
|
|
450
|
+
readEd25519PublicKey(publicKeyPath),
|
|
451
|
+
]);
|
|
452
|
+
const statement = signingStatement(request.keyId, request.releaseFingerprint);
|
|
453
|
+
const payload = signaturePayload(statement);
|
|
454
|
+
if (!verify(null, payload, publicKey, detachedSignature.bytes)) {
|
|
455
|
+
throw new TypeError("The detached Ed25519 signature does not authenticate the release signing request with the supplied public key.");
|
|
456
|
+
}
|
|
457
|
+
const signature = parseNativeReleaseSignature({
|
|
458
|
+
...statement,
|
|
459
|
+
signature: detachedSignature.base64url,
|
|
460
|
+
});
|
|
461
|
+
const parentMetadata = await stat(path.dirname(signaturePath)).catch(() => undefined);
|
|
462
|
+
if (parentMetadata?.isDirectory() !== true) {
|
|
463
|
+
throw new TypeError("The assembled release signature output directory does not exist.");
|
|
464
|
+
}
|
|
465
|
+
const temporaryPath = `${signaturePath}.solid-native-${randomUUID()}.tmp`;
|
|
466
|
+
try {
|
|
467
|
+
await writeFile(temporaryPath, `${JSON.stringify(signature, null, 2)}\n`, {
|
|
468
|
+
flag: "wx",
|
|
469
|
+
mode: 0o644,
|
|
470
|
+
});
|
|
471
|
+
await rename(temporaryPath, signaturePath);
|
|
472
|
+
}
|
|
473
|
+
finally {
|
|
474
|
+
await rm(temporaryPath, { force: true });
|
|
475
|
+
}
|
|
476
|
+
return { requestPath, signaturePath, signature };
|
|
477
|
+
}
|
|
478
|
+
export async function verifyNativeReleaseSignature(options) {
|
|
479
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
480
|
+
const manifestPath = path.resolve(cwd, options.manifestPath);
|
|
481
|
+
const signaturePath = path.resolve(cwd, options.signaturePath);
|
|
482
|
+
const uncheckedMode = options;
|
|
483
|
+
const { bundleManifestPath, artifactPath, envelopeOnly } = uncheckedMode;
|
|
484
|
+
if (envelopeOnly !== undefined && typeof envelopeOnly !== "boolean") {
|
|
485
|
+
throw new TypeError("Release signature envelope-only mode must be a boolean.");
|
|
486
|
+
}
|
|
487
|
+
if ((bundleManifestPath !== undefined &&
|
|
488
|
+
typeof bundleManifestPath !== "string") ||
|
|
489
|
+
(artifactPath !== undefined && typeof artifactPath !== "string")) {
|
|
490
|
+
throw new TypeError("Release signature input paths must be strings when supplied.");
|
|
491
|
+
}
|
|
492
|
+
if ((bundleManifestPath === undefined) !== (artifactPath === undefined)) {
|
|
493
|
+
throw new TypeError("Release signature input verification requires both a bundle manifest and native artifact.");
|
|
494
|
+
}
|
|
495
|
+
if (envelopeOnly === true &&
|
|
496
|
+
(bundleManifestPath !== undefined || artifactPath !== undefined)) {
|
|
497
|
+
throw new TypeError("Envelope-only signature verification cannot also verify release inputs.");
|
|
498
|
+
}
|
|
499
|
+
if (envelopeOnly !== true &&
|
|
500
|
+
bundleManifestPath === undefined &&
|
|
501
|
+
artifactPath === undefined) {
|
|
502
|
+
throw new TypeError("Release signature verification requires release inputs or explicit envelope-only mode.");
|
|
503
|
+
}
|
|
504
|
+
const uncheckedTrust = options;
|
|
505
|
+
const { expectedKeyId: uncheckedExpectedKeyId, minimumTrustPolicySequence: uncheckedMinimumTrustPolicySequence, policy: uncheckedPolicy, publicKeyPath: uncheckedPublicKeyPath, trustPolicyPath: uncheckedTrustPolicyPath, } = uncheckedTrust;
|
|
506
|
+
if (uncheckedMinimumTrustPolicySequence !== undefined &&
|
|
507
|
+
(typeof uncheckedMinimumTrustPolicySequence !== "number" ||
|
|
508
|
+
!Number.isSafeInteger(uncheckedMinimumTrustPolicySequence) ||
|
|
509
|
+
uncheckedMinimumTrustPolicySequence <= 0)) {
|
|
510
|
+
throw new TypeError("The minimum release trust policy sequence must be a positive safe integer.");
|
|
511
|
+
}
|
|
512
|
+
if (uncheckedTrustPolicyPath !== undefined &&
|
|
513
|
+
typeof uncheckedTrustPolicyPath !== "string") {
|
|
514
|
+
throw new TypeError("The release trust policy path must be a string.");
|
|
515
|
+
}
|
|
516
|
+
const pinnedTrustSupplied = uncheckedExpectedKeyId !== undefined ||
|
|
517
|
+
uncheckedPolicy !== undefined ||
|
|
518
|
+
uncheckedPublicKeyPath !== undefined;
|
|
519
|
+
if (uncheckedTrustPolicyPath !== undefined && pinnedTrustSupplied) {
|
|
520
|
+
throw new TypeError("Release signature verification cannot combine a trust policy file with pinned-key options.");
|
|
521
|
+
}
|
|
522
|
+
if (uncheckedTrustPolicyPath === undefined &&
|
|
523
|
+
uncheckedMinimumTrustPolicySequence !== undefined) {
|
|
524
|
+
throw new TypeError("A minimum release trust policy sequence requires a trust policy file.");
|
|
525
|
+
}
|
|
526
|
+
if (uncheckedTrustPolicyPath === undefined &&
|
|
527
|
+
(uncheckedExpectedKeyId === undefined ||
|
|
528
|
+
uncheckedPolicy === undefined ||
|
|
529
|
+
typeof uncheckedPublicKeyPath !== "string")) {
|
|
530
|
+
throw new TypeError("Release signature verification requires a trust policy file or complete pinned-key options.");
|
|
531
|
+
}
|
|
532
|
+
const inputVerificationPromise = bundleManifestPath === undefined || artifactPath === undefined
|
|
533
|
+
? Promise.resolve(undefined)
|
|
534
|
+
: verifyNativeReleaseManifest({
|
|
535
|
+
cwd,
|
|
536
|
+
manifestPath,
|
|
537
|
+
bundleManifestPath: path.resolve(cwd, bundleManifestPath),
|
|
538
|
+
artifactPath: path.resolve(cwd, artifactPath),
|
|
539
|
+
});
|
|
540
|
+
const [manifest, signatureStatement, inputVerification] = await Promise.all([
|
|
541
|
+
readNativeReleaseManifest(manifestPath),
|
|
542
|
+
readNativeReleaseSignature(signaturePath),
|
|
543
|
+
inputVerificationPromise,
|
|
544
|
+
]);
|
|
545
|
+
let policy;
|
|
546
|
+
let publicKey;
|
|
547
|
+
let keyAuthorized;
|
|
548
|
+
let keySuccess;
|
|
549
|
+
let keyFailure;
|
|
550
|
+
let trustPolicyPath;
|
|
551
|
+
let trustPolicyFingerprint;
|
|
552
|
+
let trustPolicySequence;
|
|
553
|
+
let trustPolicySequenceAccepted = true;
|
|
554
|
+
if (uncheckedTrustPolicyPath !== undefined) {
|
|
555
|
+
trustPolicyPath = path.resolve(cwd, uncheckedTrustPolicyPath);
|
|
556
|
+
const trustPolicy = await readNativeReleaseTrustPolicy(trustPolicyPath);
|
|
557
|
+
const { schemaVersion: _schemaVersion, policySequence, keys, ...authorization } = trustPolicy;
|
|
558
|
+
policy = authorization;
|
|
559
|
+
trustPolicySequence = policySequence;
|
|
560
|
+
trustPolicyFingerprint = fingerprintParsedReleaseTrustPolicy(trustPolicy);
|
|
561
|
+
trustPolicySequenceAccepted =
|
|
562
|
+
uncheckedMinimumTrustPolicySequence === undefined ||
|
|
563
|
+
policySequence >= uncheckedMinimumTrustPolicySequence;
|
|
564
|
+
const trustedKey = keys.find((entry) => entry.keyId === signatureStatement.keyId);
|
|
565
|
+
publicKey =
|
|
566
|
+
trustedKey === undefined
|
|
567
|
+
? undefined
|
|
568
|
+
: publicEd25519KeyFromSpki(trustedKey.publicKeySpki, `Release trust policy key ${trustedKey.keyId}`);
|
|
569
|
+
keyAuthorized = trustedKey?.status === "active";
|
|
570
|
+
keySuccess = "The authenticated key is active in the release trust policy.";
|
|
571
|
+
keyFailure =
|
|
572
|
+
trustedKey?.status === "revoked"
|
|
573
|
+
? "The authenticated key is revoked by the release trust policy."
|
|
574
|
+
: "The authenticated key is absent from the release trust policy.";
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
const expectedKeyId = assertKeyId(uncheckedExpectedKeyId, "The expected signing key ID");
|
|
578
|
+
policy = parseReleaseAuthorizationPolicy(uncheckedPolicy);
|
|
579
|
+
publicKey = await readEd25519PublicKey(path.resolve(cwd, uncheckedPublicKeyPath));
|
|
580
|
+
keyAuthorized = signatureStatement.keyId === expectedKeyId;
|
|
581
|
+
keySuccess = "The authenticated key ID matches the pinned key identity.";
|
|
582
|
+
keyFailure =
|
|
583
|
+
"The authenticated key ID does not match the pinned key identity.";
|
|
584
|
+
}
|
|
585
|
+
const policyMismatches = releaseAuthorizationMismatches(manifest, policy);
|
|
586
|
+
const unsignedStatement = {
|
|
587
|
+
schemaVersion: signatureStatement.schemaVersion,
|
|
588
|
+
algorithm: signatureStatement.algorithm,
|
|
589
|
+
keyId: signatureStatement.keyId,
|
|
590
|
+
releaseFingerprint: signatureStatement.releaseFingerprint,
|
|
591
|
+
};
|
|
592
|
+
const checks = [
|
|
593
|
+
check("envelope", nativeReleaseFingerprintMatches(manifest) &&
|
|
594
|
+
manifest.releaseFingerprint === signatureStatement.releaseFingerprint, "The signed release fingerprint matches the canonical envelope.", "The signed release fingerprint does not match the canonical envelope."),
|
|
595
|
+
...(trustPolicyPath === undefined
|
|
596
|
+
? []
|
|
597
|
+
: [
|
|
598
|
+
check("trust-policy", trustPolicySequenceAccepted, uncheckedMinimumTrustPolicySequence === undefined
|
|
599
|
+
? `The release trust policy sequence ${String(trustPolicySequence)} is valid.`
|
|
600
|
+
: `The release trust policy sequence ${String(trustPolicySequence)} satisfies the required minimum ${String(uncheckedMinimumTrustPolicySequence)}.`, `The release trust policy sequence ${String(trustPolicySequence)} is below the required minimum ${String(uncheckedMinimumTrustPolicySequence)}.`),
|
|
601
|
+
]),
|
|
602
|
+
check("key", keyAuthorized, keySuccess, keyFailure),
|
|
603
|
+
check("signature", publicKey !== undefined &&
|
|
604
|
+
verify(null, signaturePayload(unsignedStatement), publicKey, Buffer.from(signatureStatement.signature, "base64url")), trustPolicyPath === undefined
|
|
605
|
+
? "The Ed25519 signature is valid for the pinned public key."
|
|
606
|
+
: "The Ed25519 signature is valid for the trust-policy public key.", trustPolicyPath === undefined
|
|
607
|
+
? "The Ed25519 signature is invalid for the pinned public key."
|
|
608
|
+
: "The Ed25519 signature is invalid for the trust-policy public key."),
|
|
609
|
+
check("policy", policyMismatches.length === 0, "The signed envelope matches the trusted release authorization policy.", `The signed envelope does not match release policy: ${policyMismatches.join(", ")}.`),
|
|
610
|
+
...(inputVerification === undefined
|
|
611
|
+
? []
|
|
612
|
+
: [
|
|
613
|
+
check("inputs", inputVerification.ok &&
|
|
614
|
+
inputVerification.releaseFingerprint ===
|
|
615
|
+
manifest.releaseFingerprint, "The bundle, native artifact, embedded Hermes, and compatibility inputs match this signed envelope.", "The release inputs do not match this signed envelope."),
|
|
616
|
+
]),
|
|
617
|
+
];
|
|
618
|
+
const ok = checks.every((entry) => entry.status === "pass");
|
|
619
|
+
const authorizedRelease = ok
|
|
620
|
+
? Object.freeze({
|
|
621
|
+
schemaVersion: 0,
|
|
622
|
+
projectName: manifest.projectName,
|
|
623
|
+
platform: manifest.platform,
|
|
624
|
+
release: manifest.release,
|
|
625
|
+
channel: manifest.channel,
|
|
626
|
+
sourceRevision: manifest.sourceRevision,
|
|
627
|
+
releaseFingerprint: manifest.releaseFingerprint,
|
|
628
|
+
bundleFingerprint: manifest.bundleFingerprint,
|
|
629
|
+
nativeCompatibilityFingerprint: manifest.nativeCompatibilityFingerprint,
|
|
630
|
+
artifactSha256: manifest.artifact.sha256,
|
|
631
|
+
authenticatedKeyId: signatureStatement.keyId,
|
|
632
|
+
inputsVerified: inputVerification !== undefined,
|
|
633
|
+
...(trustPolicyFingerprint === undefined
|
|
634
|
+
? {}
|
|
635
|
+
: { trustPolicyFingerprint }),
|
|
636
|
+
...(trustPolicySequence === undefined ? {} : { trustPolicySequence }),
|
|
637
|
+
})
|
|
638
|
+
: undefined;
|
|
639
|
+
const report = {
|
|
640
|
+
schemaVersion: 0,
|
|
641
|
+
manifestPath,
|
|
642
|
+
signaturePath,
|
|
643
|
+
releaseFingerprint: signatureStatement.releaseFingerprint,
|
|
644
|
+
keyId: signatureStatement.keyId,
|
|
645
|
+
policy,
|
|
646
|
+
...(trustPolicyPath === undefined ? {} : { trustPolicyPath }),
|
|
647
|
+
...(trustPolicyFingerprint === undefined ? {} : { trustPolicyFingerprint }),
|
|
648
|
+
...(trustPolicySequence === undefined ? {} : { trustPolicySequence }),
|
|
649
|
+
...(inputVerification === undefined ? {} : { inputVerification }),
|
|
650
|
+
checks,
|
|
651
|
+
};
|
|
652
|
+
return ok
|
|
653
|
+
? { ...report, ok: true, authorizedRelease: authorizedRelease }
|
|
654
|
+
: { ...report, ok: false };
|
|
655
|
+
}
|
|
656
|
+
export function formatNativeReleaseSignatureVerification(report) {
|
|
657
|
+
return [
|
|
658
|
+
`${report.ok ? "PASS" : "FAIL"} Solid Native release signature ${report.releaseFingerprint}`,
|
|
659
|
+
`Key: ${report.keyId}`,
|
|
660
|
+
...(report.trustPolicyPath === undefined
|
|
661
|
+
? []
|
|
662
|
+
: [`Trust policy: ${report.trustPolicyPath}`]),
|
|
663
|
+
...(report.trustPolicyFingerprint === undefined ||
|
|
664
|
+
report.trustPolicySequence === undefined
|
|
665
|
+
? []
|
|
666
|
+
: [
|
|
667
|
+
`Trust policy identity: ${report.trustPolicyFingerprint} (sequence ${String(report.trustPolicySequence)})`,
|
|
668
|
+
]),
|
|
669
|
+
`Manifest: ${report.manifestPath}`,
|
|
670
|
+
`Signature: ${report.signaturePath}`,
|
|
671
|
+
...report.checks.map((entry) => `${entry.status === "pass" ? "PASS" : "FAIL"} ${entry.id}: ${entry.message}`),
|
|
672
|
+
...(report.inputVerification === undefined
|
|
673
|
+
? ["Inputs: envelope only; native build inputs were not verified."]
|
|
674
|
+
: ["", formatNativeReleaseVerification(report.inputVerification)]),
|
|
675
|
+
].join("\n");
|
|
676
|
+
}
|
|
677
|
+
//# sourceMappingURL=release-signatures.js.map
|