@native-sdk/cli 0.10.0 → 0.10.1
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/build.zig
CHANGED
|
@@ -119,6 +119,9 @@ pub fn build(b: *std.Build) void {
|
|
|
119
119
|
_ = b.option(bool, "js-bridge", "Enable optional JavaScript bridge stubs") orelse false;
|
|
120
120
|
const package_target = b.option(PackageTarget, "package-target", "Package target: macos, windows, linux, ios, android") orelse .macos;
|
|
121
121
|
const signing_mode = b.option(SigningMode, "signing", "Signing mode: none, adhoc, identity") orelse .none;
|
|
122
|
+
const signing_identity = b.option([]const u8, "identity", "Code signing identity for distribution packages");
|
|
123
|
+
const signing_entitlements = b.option([]const u8, "entitlements", "Entitlements plist for identity signing");
|
|
124
|
+
const notary_profile = b.option([]const u8, "notary-profile", "notarytool Keychain profile for notarization");
|
|
122
125
|
const package_version = packageVersion(b);
|
|
123
126
|
const optimize_name = @tagName(optimize);
|
|
124
127
|
// Resolve against THIS build's root: as a dependency of a user app the
|
|
@@ -2962,6 +2965,8 @@ pub fn build(b: *std.Build) void {
|
|
|
2962
2965
|
});
|
|
2963
2966
|
package_run.addFileArg(embed_lib.getEmittedBin());
|
|
2964
2967
|
package_run.addArgs(&.{ "--manifest", "app.zon", "--assets", "assets", "--optimize", optimize_name, "--signing", @tagName(signing_mode), "--web-engine", @tagName(web_engine), "--cef-dir", cef_dir });
|
|
2968
|
+
if (signing_identity) |identity| package_run.addArgs(&.{ "--identity", identity });
|
|
2969
|
+
if (signing_entitlements) |entitlements| package_run.addArgs(&.{ "--entitlements", entitlements });
|
|
2965
2970
|
if (cef_auto_install) package_run.addArg("--cef-auto-install");
|
|
2966
2971
|
package_run.step.dependOn(&embed_lib.step);
|
|
2967
2972
|
package_run.step.dependOn(&bundle_run.step);
|
|
@@ -2999,6 +3004,13 @@ pub fn build(b: *std.Build) void {
|
|
|
2999
3004
|
const package_cef_smoke_step = b.step("test-package-cef-layout", "Verify macOS Chromium package layout");
|
|
3000
3005
|
package_cef_smoke_step.dependOn(&package_cef_check.step);
|
|
3001
3006
|
|
|
3007
|
+
// The repository's macOS distribution helpers need a real launchable
|
|
3008
|
+
// executable inside the .app. Keep the notarization helper on the same
|
|
3009
|
+
// emitted host CLI binary that the signed-package smoke executes below;
|
|
3010
|
+
// the SDK embed artifact is a static `.a` library and is not a valid
|
|
3011
|
+
// CFBundleExecutable even though codesign can seal a bundle around it.
|
|
3012
|
+
const macos_distribution_executable = host_cli_exe.getEmittedBin();
|
|
3013
|
+
|
|
3002
3014
|
// Signed-package seal pin: package an ad-hoc signed bundle and prove
|
|
3003
3015
|
// the signature survives packaging intact with codesign's own strict
|
|
3004
3016
|
// verifier. This is the regression gate for the ordering bug where a
|
|
@@ -3015,7 +3027,7 @@ pub fn build(b: *std.Build) void {
|
|
|
3015
3027
|
const package_signing_mode: []const u8 = if (b.graph.host.result.os.tag == .macos) "adhoc" else "none";
|
|
3016
3028
|
const package_signing_run = b.addRunArtifact(host_cli_exe);
|
|
3017
3029
|
package_signing_run.addArgs(&.{ "package", "--target", "macos", "--output", "zig-out/package/native-sdk-signing-verify.app", "--binary" });
|
|
3018
|
-
package_signing_run.addFileArg(
|
|
3030
|
+
package_signing_run.addFileArg(macos_distribution_executable);
|
|
3019
3031
|
package_signing_run.addArgs(&.{ "--manifest", "app.zon", "--assets", "assets", "--optimize", optimize_name, "--signing", package_signing_mode });
|
|
3020
3032
|
package_signing_run.has_side_effects = true;
|
|
3021
3033
|
const package_signing_check = b.addSystemCommand(&.{
|
|
@@ -3027,6 +3039,7 @@ pub fn build(b: *std.Build) void {
|
|
|
3027
3039
|
\\ exit 0
|
|
3028
3040
|
\\fi
|
|
3029
3041
|
\\codesign --verify --strict --deep "$app"
|
|
3042
|
+
\\"$app/Contents/MacOS/native-sdk" version >/dev/null
|
|
3030
3043
|
\\grep -q "ad-hoc signed" "$app/Contents/Resources/signing-plan.txt"
|
|
3031
3044
|
\\echo "signed package verify ok"
|
|
3032
3045
|
,
|
|
@@ -3094,10 +3107,13 @@ pub fn build(b: *std.Build) void {
|
|
|
3094
3107
|
b.fmt("zig-out/package/native-sdk-{s}-macos-{s}.app", .{ package_version, optimize_name }),
|
|
3095
3108
|
"--binary",
|
|
3096
3109
|
});
|
|
3097
|
-
notarize_run.addFileArg(
|
|
3098
|
-
notarize_run.addArgs(&.{ "--manifest", "app.zon", "--assets", "assets", "--optimize", optimize_name, "--signing", "identity", "--web-engine", @tagName(web_engine), "--cef-dir", cef_dir });
|
|
3110
|
+
notarize_run.addFileArg(macos_distribution_executable);
|
|
3111
|
+
notarize_run.addArgs(&.{ "--manifest", "app.zon", "--assets", "assets", "--optimize", optimize_name, "--signing", "identity", "--web-engine", @tagName(web_engine), "--cef-dir", cef_dir, "--archive", "--notarize" });
|
|
3112
|
+
if (signing_identity) |identity| notarize_run.addArgs(&.{ "--identity", identity });
|
|
3113
|
+
if (signing_entitlements) |entitlements| notarize_run.addArgs(&.{ "--entitlements", entitlements });
|
|
3114
|
+
if (notary_profile) |profile| notarize_run.addArgs(&.{ "--notary-profile", profile });
|
|
3099
3115
|
if (cef_auto_install) notarize_run.addArg("--cef-auto-install");
|
|
3100
|
-
notarize_run.step.dependOn(&
|
|
3116
|
+
notarize_run.step.dependOn(&host_cli_exe.step);
|
|
3101
3117
|
notarize_run.step.dependOn(&bundle_run.step);
|
|
3102
3118
|
const notarize_step = b.step("notarize", "Package, sign with identity, and notarize for macOS distribution");
|
|
3103
3119
|
notarize_step.dependOn(¬arize_run.step);
|
|
@@ -3118,6 +3134,8 @@ pub fn build(b: *std.Build) void {
|
|
|
3118
3134
|
});
|
|
3119
3135
|
dmg_run.addFileArg(embed_lib.getEmittedBin());
|
|
3120
3136
|
dmg_run.addArgs(&.{ "--manifest", "app.zon", "--assets", "assets", "--optimize", optimize_name, "--signing", @tagName(signing_mode), "--web-engine", @tagName(web_engine), "--cef-dir", cef_dir, "--archive" });
|
|
3137
|
+
if (signing_identity) |identity| dmg_run.addArgs(&.{ "--identity", identity });
|
|
3138
|
+
if (signing_entitlements) |entitlements| dmg_run.addArgs(&.{ "--entitlements", entitlements });
|
|
3121
3139
|
if (cef_auto_install) dmg_run.addArg("--cef-auto-install");
|
|
3122
3140
|
dmg_run.step.dependOn(&embed_lib.step);
|
|
3123
3141
|
dmg_run.step.dependOn(&bundle_run.step);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-sdk/cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "The Native SDK: the complete toolkit for building native desktop applications — declarative markup, native rendering, WebView surfaces, and OS capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"scriptc": "0.0.35"
|
|
40
40
|
},
|
|
41
41
|
"optionalDependencies": {
|
|
42
|
-
"@native-sdk/cli-darwin-arm64": "0.10.
|
|
43
|
-
"@native-sdk/cli-darwin-x64": "0.10.
|
|
44
|
-
"@native-sdk/cli-linux-arm64-gnu": "0.10.
|
|
45
|
-
"@native-sdk/cli-linux-arm64-musl": "0.10.
|
|
46
|
-
"@native-sdk/cli-linux-x64-gnu": "0.10.
|
|
47
|
-
"@native-sdk/cli-linux-x64-musl": "0.10.
|
|
48
|
-
"@native-sdk/cli-win32-arm64": "0.10.
|
|
49
|
-
"@native-sdk/cli-win32-x64": "0.10.
|
|
42
|
+
"@native-sdk/cli-darwin-arm64": "0.10.1",
|
|
43
|
+
"@native-sdk/cli-darwin-x64": "0.10.1",
|
|
44
|
+
"@native-sdk/cli-linux-arm64-gnu": "0.10.1",
|
|
45
|
+
"@native-sdk/cli-linux-arm64-musl": "0.10.1",
|
|
46
|
+
"@native-sdk/cli-linux-x64-gnu": "0.10.1",
|
|
47
|
+
"@native-sdk/cli-linux-x64-musl": "0.10.1",
|
|
48
|
+
"@native-sdk/cli-win32-arm64": "0.10.1",
|
|
49
|
+
"@native-sdk/cli-win32-x64": "0.10.1"
|
|
50
50
|
},
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-sdk/core",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@native-sdk/core",
|
|
9
|
-
"version": "0.10.
|
|
9
|
+
"version": "0.10.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"scriptc": "0.0.35"
|
|
12
12
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-sdk/core",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "The TypeScript authoring tier: the app-core subset, its checker and contract frontend, the exact-pinned core compiler dependency, and the SDK module cores import",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -106,9 +106,10 @@ Signing modes:
|
|
|
106
106
|
native package --target macos --signing none
|
|
107
107
|
native package --target macos --signing adhoc
|
|
108
108
|
native package --target macos --signing identity --identity "Developer ID Application: Your Name"
|
|
109
|
+
native package --target macos --signing identity --identity "Developer ID Application: Your Name" --archive --notarize --notary-profile "my-app-release"
|
|
109
110
|
```
|
|
110
111
|
|
|
111
|
-
For Chromium apps, verify the CEF framework and resources are included and signed before notarization.
|
|
112
|
+
Identity signing enables the hardened runtime and requires a secure timestamp. `--notarize` uses a `notarytool` Keychain profile, submits the final DMG when `--archive` is present, and staples and validates the accepted tickets. For Chromium apps, verify the CEF framework and resources are included and signed before notarization.
|
|
112
113
|
|
|
113
114
|
## Linux and Windows packages
|
|
114
115
|
|
package/src/tooling/codesign.zig
CHANGED
|
@@ -13,14 +13,13 @@ pub const CodesignArgs = struct {
|
|
|
13
13
|
identity: []const u8 = "-",
|
|
14
14
|
entitlements: ?[]const u8 = null,
|
|
15
15
|
hardened_runtime: bool = false,
|
|
16
|
+
secure_timestamp: bool = false,
|
|
16
17
|
deep: bool = true,
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
pub const NotarizeArgs = struct {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
apple_id: ?[]const u8 = null,
|
|
23
|
-
password_keychain_item: ?[]const u8 = null,
|
|
21
|
+
artifact_path: []const u8,
|
|
22
|
+
keychain_profile: []const u8,
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
// Every command in this pipeline is built as an ARGV ARRAY, never as a
|
|
@@ -29,7 +28,7 @@ pub const NotarizeArgs = struct {
|
|
|
29
28
|
// replaced split `My App.app` into two arguments, codesign signed
|
|
30
29
|
// nothing, and the failure never surfaced.
|
|
31
30
|
|
|
32
|
-
pub const sign_argv_capacity =
|
|
31
|
+
pub const sign_argv_capacity = 11;
|
|
33
32
|
|
|
34
33
|
pub fn signArgv(buffer: *[sign_argv_capacity][]const u8, args: CodesignArgs) []const []const u8 {
|
|
35
34
|
var len: usize = 0;
|
|
@@ -51,6 +50,10 @@ pub fn signArgv(buffer: *[sign_argv_capacity][]const u8, args: CodesignArgs) []c
|
|
|
51
50
|
buffer[len] = "runtime";
|
|
52
51
|
len += 1;
|
|
53
52
|
}
|
|
53
|
+
if (args.secure_timestamp) {
|
|
54
|
+
buffer[len] = "--timestamp";
|
|
55
|
+
len += 1;
|
|
56
|
+
}
|
|
54
57
|
if (args.entitlements) |ent| {
|
|
55
58
|
buffer[len] = "--entitlements";
|
|
56
59
|
len += 1;
|
|
@@ -67,6 +70,11 @@ pub fn verifyArgv(buffer: *[6][]const u8, app_path: []const u8) []const []const
|
|
|
67
70
|
return buffer;
|
|
68
71
|
}
|
|
69
72
|
|
|
73
|
+
pub fn verifyArtifactArgv(buffer: *[5][]const u8, artifact_path: []const u8) []const []const u8 {
|
|
74
|
+
buffer.* = .{ "codesign", "--verify", "--strict", "--verbose=2", artifact_path };
|
|
75
|
+
return buffer;
|
|
76
|
+
}
|
|
77
|
+
|
|
70
78
|
pub fn zipArgv(buffer: *[6][]const u8, app_path: []const u8, zip_path: []const u8) []const []const u8 {
|
|
71
79
|
buffer.* = .{ "ditto", "-c", "-k", "--keepParent", app_path, zip_path };
|
|
72
80
|
return buffer;
|
|
@@ -77,37 +85,18 @@ pub fn stapleArgv(buffer: *[4][]const u8, app_path: []const u8) []const []const
|
|
|
77
85
|
return buffer;
|
|
78
86
|
}
|
|
79
87
|
|
|
80
|
-
pub const
|
|
88
|
+
pub fn stapleValidateArgv(buffer: *[4][]const u8, app_path: []const u8) []const []const u8 {
|
|
89
|
+
buffer.* = .{ "xcrun", "stapler", "validate", app_path };
|
|
90
|
+
return buffer;
|
|
91
|
+
}
|
|
81
92
|
|
|
82
|
-
pub fn notarizeSubmitArgv(buffer: *[
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
buffer
|
|
89
|
-
len += 1;
|
|
90
|
-
buffer[len] = zip_path;
|
|
91
|
-
len += 1;
|
|
92
|
-
buffer[len] = "--team-id";
|
|
93
|
-
len += 1;
|
|
94
|
-
buffer[len] = args.team_id;
|
|
95
|
-
len += 1;
|
|
96
|
-
if (args.apple_id) |apple_id| {
|
|
97
|
-
buffer[len] = "--apple-id";
|
|
98
|
-
len += 1;
|
|
99
|
-
buffer[len] = apple_id;
|
|
100
|
-
len += 1;
|
|
101
|
-
}
|
|
102
|
-
if (password_value) |value| {
|
|
103
|
-
buffer[len] = "--password";
|
|
104
|
-
len += 1;
|
|
105
|
-
buffer[len] = value;
|
|
106
|
-
len += 1;
|
|
107
|
-
}
|
|
108
|
-
buffer[len] = "--wait";
|
|
109
|
-
len += 1;
|
|
110
|
-
return buffer[0..len];
|
|
93
|
+
pub fn notarizeSubmitArgv(buffer: *[9][]const u8, artifact_path: []const u8, keychain_profile: []const u8) []const []const u8 {
|
|
94
|
+
buffer.* = .{
|
|
95
|
+
"xcrun", "notarytool", "submit",
|
|
96
|
+
artifact_path, "--keychain-profile", keychain_profile,
|
|
97
|
+
"--wait", "--output-format", "json",
|
|
98
|
+
};
|
|
99
|
+
return buffer;
|
|
111
100
|
}
|
|
112
101
|
|
|
113
102
|
pub fn signAdHoc(allocator: std.mem.Allocator, io: std.Io, app_path: []const u8) !SignResult {
|
|
@@ -120,10 +109,20 @@ pub fn signIdentity(allocator: std.mem.Allocator, io: std.Io, app_path: []const
|
|
|
120
109
|
.identity = identity,
|
|
121
110
|
.entitlements = entitlements,
|
|
122
111
|
.hardened_runtime = true,
|
|
112
|
+
.secure_timestamp = true,
|
|
123
113
|
.deep = true,
|
|
124
114
|
});
|
|
125
115
|
}
|
|
126
116
|
|
|
117
|
+
pub fn signIdentityArtifact(allocator: std.mem.Allocator, io: std.Io, artifact_path: []const u8, identity: []const u8) !SignResult {
|
|
118
|
+
return runSign(allocator, io, .{
|
|
119
|
+
.app_path = artifact_path,
|
|
120
|
+
.identity = identity,
|
|
121
|
+
.secure_timestamp = true,
|
|
122
|
+
.deep = false,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
127
126
|
/// `codesign --verify --deep --strict` over the signed bundle: the same
|
|
128
127
|
/// check Gatekeeper and an Apple silicon launch effectively run, so a
|
|
129
128
|
/// signature that only LOOKS applied (stale seal, unsigned nested code)
|
|
@@ -133,37 +132,58 @@ pub fn verify(allocator: std.mem.Allocator, io: std.Io, app_path: []const u8) !S
|
|
|
133
132
|
return runTool(allocator, io, verifyArgv(&buffer, app_path));
|
|
134
133
|
}
|
|
135
134
|
|
|
136
|
-
pub fn
|
|
137
|
-
const
|
|
135
|
+
pub fn verifyArtifact(allocator: std.mem.Allocator, io: std.Io, artifact_path: []const u8) !SignResult {
|
|
136
|
+
var buffer: [5][]const u8 = undefined;
|
|
137
|
+
return runTool(allocator, io, verifyArtifactArgv(&buffer, artifact_path));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
pub fn notarizeApp(allocator: std.mem.Allocator, io: std.Io, args: NotarizeArgs) !SignResult {
|
|
141
|
+
const zip_path = try std.fmt.allocPrint(allocator, "{s}.notarize.zip", .{args.artifact_path});
|
|
138
142
|
defer allocator.free(zip_path);
|
|
143
|
+
defer std.Io.Dir.cwd().deleteFile(io, zip_path) catch {};
|
|
139
144
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
allocator.free(zip_result.message);
|
|
145
|
-
}
|
|
145
|
+
var zip_buffer: [6][]const u8 = undefined;
|
|
146
|
+
const zip_result = try runTool(allocator, io, zipArgv(&zip_buffer, args.artifact_path, zip_path));
|
|
147
|
+
if (!zip_result.ok) return failedStep(allocator, "ditto (zip for notarization)", zip_result);
|
|
148
|
+
allocator.free(zip_result.message);
|
|
146
149
|
|
|
147
|
-
{
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
defer if (password_value) |value| allocator.free(value);
|
|
153
|
-
var submit_buffer: [notarize_submit_argv_capacity][]const u8 = undefined;
|
|
154
|
-
const submit_result = try runTool(allocator, io, notarizeSubmitArgv(&submit_buffer, zip_path, password_value, args));
|
|
155
|
-
if (!submit_result.ok) return failedStep(allocator, "notarytool submit", submit_result);
|
|
156
|
-
allocator.free(submit_result.message);
|
|
157
|
-
}
|
|
150
|
+
return notarizeArtifact(allocator, io, .{
|
|
151
|
+
.artifact_path = args.artifact_path,
|
|
152
|
+
.keychain_profile = args.keychain_profile,
|
|
153
|
+
}, zip_path);
|
|
154
|
+
}
|
|
158
155
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
156
|
+
pub fn notarizeArtifact(allocator: std.mem.Allocator, io: std.Io, args: NotarizeArgs, submission_path: ?[]const u8) !SignResult {
|
|
157
|
+
var submit_buffer: [9][]const u8 = undefined;
|
|
158
|
+
const submit_result = try runTool(allocator, io, notarizeSubmitArgv(&submit_buffer, submission_path orelse args.artifact_path, args.keychain_profile));
|
|
159
|
+
if (!submit_result.ok) return failedStep(allocator, "notarytool submit", submit_result);
|
|
160
|
+
if (!notarizationAccepted(allocator, submit_result.message)) return failedStep(allocator, "notarytool returned a non-accepted status", submit_result);
|
|
161
|
+
allocator.free(submit_result.message);
|
|
165
162
|
|
|
166
|
-
|
|
163
|
+
var staple_buffer: [4][]const u8 = undefined;
|
|
164
|
+
const staple_result = try runTool(allocator, io, stapleArgv(&staple_buffer, args.artifact_path));
|
|
165
|
+
if (!staple_result.ok) return failedStep(allocator, "stapler staple", staple_result);
|
|
166
|
+
allocator.free(staple_result.message);
|
|
167
|
+
|
|
168
|
+
var validate_buffer: [4][]const u8 = undefined;
|
|
169
|
+
const validate_result = try runTool(allocator, io, stapleValidateArgv(&validate_buffer, args.artifact_path));
|
|
170
|
+
if (!validate_result.ok) return failedStep(allocator, "stapler validate", validate_result);
|
|
171
|
+
allocator.free(validate_result.message);
|
|
172
|
+
|
|
173
|
+
return .{ .ok = true, .message = try allocator.dupe(u8, "notarization accepted, stapled, and validated") };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
fn notarizationAccepted(allocator: std.mem.Allocator, output: []const u8) bool {
|
|
177
|
+
const start = std.mem.indexOfScalar(u8, output, '{') orelse return false;
|
|
178
|
+
const end = std.mem.lastIndexOfScalar(u8, output, '}') orelse return false;
|
|
179
|
+
if (end < start) return false;
|
|
180
|
+
var parsed = std.json.parseFromSlice(std.json.Value, allocator, output[start .. end + 1], .{}) catch return false;
|
|
181
|
+
defer parsed.deinit();
|
|
182
|
+
const status = switch (parsed.value) {
|
|
183
|
+
.object => |object| object.get("status") orelse return false,
|
|
184
|
+
else => return false,
|
|
185
|
+
};
|
|
186
|
+
return status == .string and std.mem.eql(u8, status.string, "Accepted");
|
|
167
187
|
}
|
|
168
188
|
|
|
169
189
|
fn failedStep(allocator: std.mem.Allocator, step: []const u8, result: SignResult) !SignResult {
|
|
@@ -215,13 +235,30 @@ test "identity sign argv includes runtime and entitlements as single arguments"
|
|
|
215
235
|
.identity = "Developer ID Application: Test Person (ABCD1234)",
|
|
216
236
|
.entitlements = "assets dir/native-sdk.entitlements",
|
|
217
237
|
.hardened_runtime = true,
|
|
238
|
+
.secure_timestamp = true,
|
|
239
|
+
});
|
|
240
|
+
const expected = [_][]const u8{
|
|
241
|
+
"codesign", "--sign",
|
|
242
|
+
"Developer ID Application: Test Person (ABCD1234)", "--force",
|
|
243
|
+
"--deep", "--options",
|
|
244
|
+
"runtime", "--timestamp",
|
|
245
|
+
"--entitlements", "assets dir/native-sdk.entitlements",
|
|
246
|
+
"/tmp/My Demo App.app",
|
|
247
|
+
};
|
|
248
|
+
try expectArgv(&expected, argv);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
test "distribution artifact sign argv requests a secure timestamp without app-only options" {
|
|
252
|
+
var buffer: [sign_argv_capacity][]const u8 = undefined;
|
|
253
|
+
const argv = signArgv(&buffer, .{
|
|
254
|
+
.app_path = "/tmp/My Demo App.dmg",
|
|
255
|
+
.identity = "Developer ID Application: Test Person (ABCD1234)",
|
|
256
|
+
.secure_timestamp = true,
|
|
257
|
+
.deep = false,
|
|
218
258
|
});
|
|
219
259
|
const expected = [_][]const u8{
|
|
220
|
-
"codesign",
|
|
221
|
-
"
|
|
222
|
-
"--deep", "--options",
|
|
223
|
-
"runtime", "--entitlements",
|
|
224
|
-
"assets dir/native-sdk.entitlements", "/tmp/My Demo App.app",
|
|
260
|
+
"codesign", "--sign", "Developer ID Application: Test Person (ABCD1234)",
|
|
261
|
+
"--force", "--timestamp", "/tmp/My Demo App.dmg",
|
|
225
262
|
};
|
|
226
263
|
try expectArgv(&expected, argv);
|
|
227
264
|
}
|
|
@@ -233,14 +270,17 @@ test "verify argv runs the strict deep check on the bundle path" {
|
|
|
233
270
|
try expectArgv(&expected, argv);
|
|
234
271
|
}
|
|
235
272
|
|
|
236
|
-
test "
|
|
237
|
-
var buffer: [
|
|
238
|
-
const argv =
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
273
|
+
test "artifact verify argv runs the strict check without bundle recursion" {
|
|
274
|
+
var buffer: [5][]const u8 = undefined;
|
|
275
|
+
const argv = verifyArtifactArgv(&buffer, "/tmp/My Demo App.dmg");
|
|
276
|
+
const expected = [_][]const u8{ "codesign", "--verify", "--strict", "--verbose=2", "/tmp/My Demo App.dmg" };
|
|
277
|
+
try expectArgv(&expected, argv);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
test "notarize submit argv uses a keychain profile, waits, and requests JSON" {
|
|
281
|
+
var buffer: [9][]const u8 = undefined;
|
|
282
|
+
const argv = notarizeSubmitArgv(&buffer, "/tmp/My Demo App.dmg", "vercel-release");
|
|
283
|
+
const expected = [_][]const u8{ "xcrun", "notarytool", "submit", "/tmp/My Demo App.dmg", "--keychain-profile", "vercel-release", "--wait", "--output-format", "json" };
|
|
244
284
|
try expectArgv(&expected, argv);
|
|
245
285
|
}
|
|
246
286
|
|
|
@@ -250,12 +290,23 @@ test "staple and zip argv carry spaced paths as single arguments" {
|
|
|
250
290
|
const staple_expected = [_][]const u8{ "xcrun", "stapler", "staple", "/tmp/My Demo App.app" };
|
|
251
291
|
try expectArgv(&staple_expected, staple);
|
|
252
292
|
|
|
293
|
+
var validate_buffer: [4][]const u8 = undefined;
|
|
294
|
+
const validate = stapleValidateArgv(&validate_buffer, "/tmp/My Demo App.app");
|
|
295
|
+
const validate_expected = [_][]const u8{ "xcrun", "stapler", "validate", "/tmp/My Demo App.app" };
|
|
296
|
+
try expectArgv(&validate_expected, validate);
|
|
297
|
+
|
|
253
298
|
var zip_buffer: [6][]const u8 = undefined;
|
|
254
299
|
const zip = zipArgv(&zip_buffer, "/tmp/My Demo App.app", "/tmp/My Demo App.app.zip");
|
|
255
300
|
const zip_expected = [_][]const u8{ "ditto", "-c", "-k", "--keepParent", "/tmp/My Demo App.app", "/tmp/My Demo App.app.zip" };
|
|
256
301
|
try expectArgv(&zip_expected, zip);
|
|
257
302
|
}
|
|
258
303
|
|
|
304
|
+
test "notarization accepts only an explicit Accepted JSON status" {
|
|
305
|
+
try std.testing.expect(notarizationAccepted(std.testing.allocator, "{\"id\":\"123\",\"status\":\"Accepted\"}\n"));
|
|
306
|
+
try std.testing.expect(!notarizationAccepted(std.testing.allocator, "{\"id\":\"123\",\"status\":\"Invalid\"}\n"));
|
|
307
|
+
try std.testing.expect(!notarizationAccepted(std.testing.allocator, "not JSON"));
|
|
308
|
+
}
|
|
309
|
+
|
|
259
310
|
test "a failing tool surfaces its own output, not a silent success" {
|
|
260
311
|
if (@import("builtin").os.tag == .windows) return error.SkipZigTest;
|
|
261
312
|
// `false` exits 1 with no output: the result must be a failure.
|
package/src/tooling/package.zig
CHANGED
|
@@ -54,7 +54,6 @@ pub const SigningConfig = struct {
|
|
|
54
54
|
identity: ?[]const u8 = null,
|
|
55
55
|
entitlements: ?[]const u8 = null,
|
|
56
56
|
profile: ?[]const u8 = null,
|
|
57
|
-
team_id: ?[]const u8 = null,
|
|
58
57
|
};
|
|
59
58
|
|
|
60
59
|
pub const PackageOptions = struct {
|
|
@@ -83,6 +82,10 @@ pub const PackageOptions = struct {
|
|
|
83
82
|
cef_dir: []const u8 = web_engine_tool.default_cef_dir,
|
|
84
83
|
signing: SigningConfig = .{},
|
|
85
84
|
archive: bool = false,
|
|
85
|
+
/// Submit the final macOS distribution artifact to Apple's notary service,
|
|
86
|
+
/// then staple and validate its ticket. Requires identity signing and a
|
|
87
|
+
/// notarytool Keychain profile in `signing.profile`.
|
|
88
|
+
notarize: bool = false,
|
|
86
89
|
/// Emit the ZIP consumed by the native updater. macOS only; unlike the
|
|
87
90
|
/// user-facing DMG, this archive contains exactly the packaged .app.
|
|
88
91
|
update_archive: bool = false,
|
|
@@ -152,6 +155,7 @@ pub const PackageStats = struct {
|
|
|
152
155
|
/// the proof behind the report's "signed, verified" line. A package
|
|
153
156
|
/// whose signing or verification fails never produces stats at all.
|
|
154
157
|
signing_verified: bool = false,
|
|
158
|
+
notarized: bool = false,
|
|
155
159
|
asset_count: usize = 0,
|
|
156
160
|
web_engine: WebEngine = .system,
|
|
157
161
|
web_layer: ?manifest_tool.WebLayer = null,
|
|
@@ -221,6 +225,20 @@ pub fn createPackage(allocator: std.mem.Allocator, io: std.Io, options: PackageO
|
|
|
221
225
|
return err;
|
|
222
226
|
};
|
|
223
227
|
try validateWebEngineTarget(options.target, options.web_engine);
|
|
228
|
+
if (options.notarize) {
|
|
229
|
+
if (options.target != .macos) {
|
|
230
|
+
std.debug.print("error: notarization is supported only for macOS packages\n", .{});
|
|
231
|
+
return error.UnsupportedNotarizationTarget;
|
|
232
|
+
}
|
|
233
|
+
if (options.signing.mode != .identity) {
|
|
234
|
+
std.debug.print("error: --notarize requires --signing identity and a Developer ID Application certificate\n", .{});
|
|
235
|
+
return error.NotarizationRequiresIdentity;
|
|
236
|
+
}
|
|
237
|
+
if (options.signing.profile == null) {
|
|
238
|
+
std.debug.print("error: --notarize requires --notary-profile <name>; create it with `xcrun notarytool store-credentials <name>`\n", .{});
|
|
239
|
+
return error.MissingNotaryProfile;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
224
242
|
if (options.metadata.updates.enabled() and options.target == .macos and options.web_engine == .chromium) {
|
|
225
243
|
std.debug.print("error: native updates currently require the system macOS host; package with --web-engine system or remove the updates block\n", .{});
|
|
226
244
|
return error.UnsupportedUpdateHost;
|
|
@@ -241,12 +259,24 @@ pub fn createPackage(allocator: std.mem.Allocator, io: std.Io, options: PackageO
|
|
|
241
259
|
.ios => try createIosArtifact(allocator, io, options),
|
|
242
260
|
.android => try createAndroidArtifact(allocator, io, options),
|
|
243
261
|
};
|
|
262
|
+
if (options.notarize) {
|
|
263
|
+
try runNotarization(allocator, io, options.output_path, options.signing.profile.?, true);
|
|
264
|
+
}
|
|
244
265
|
if (options.archive) {
|
|
245
266
|
const archive_path = try createArchive(allocator, io, options);
|
|
246
267
|
if (archive_path) |path| {
|
|
247
268
|
stats.archive_path = path;
|
|
269
|
+
if (options.target == .macos and options.signing.mode == .identity) {
|
|
270
|
+
try signDistributionArtifact(allocator, io, path, options.signing.identity.?);
|
|
271
|
+
}
|
|
272
|
+
if (options.notarize) {
|
|
273
|
+
try runNotarization(allocator, io, path, options.signing.profile.?, false);
|
|
274
|
+
}
|
|
248
275
|
}
|
|
249
276
|
}
|
|
277
|
+
if (options.notarize) {
|
|
278
|
+
stats.notarized = true;
|
|
279
|
+
}
|
|
250
280
|
if (options.update_archive) {
|
|
251
281
|
if (options.target != .macos) return error.UnsupportedUpdateTarget;
|
|
252
282
|
if (!options.metadata.updates.enabled()) return error.UpdatesNotConfigured;
|
|
@@ -286,6 +316,9 @@ pub fn printDiagnostic(stats: PackageStats) void {
|
|
|
286
316
|
if (stats.signing_verified) {
|
|
287
317
|
std.debug.print(" signing: {s} (signed, verified)\n", .{@tagName(stats.signing_mode)});
|
|
288
318
|
}
|
|
319
|
+
if (stats.notarized) {
|
|
320
|
+
std.debug.print(" notarization: accepted, stapled, validated\n", .{});
|
|
321
|
+
}
|
|
289
322
|
if (stats.windows_subsystem) |subsystem| {
|
|
290
323
|
switch (subsystem) {
|
|
291
324
|
.console => std.debug.print(" subsystem: console (a terminal window opens behind the app - rebuild with `native build`)\n", .{}),
|
|
@@ -1721,6 +1754,33 @@ fn runSigning(allocator: std.mem.Allocator, io: std.Io, dir: std.Io.Dir, options
|
|
|
1721
1754
|
return true;
|
|
1722
1755
|
}
|
|
1723
1756
|
|
|
1757
|
+
fn signDistributionArtifact(allocator: std.mem.Allocator, io: std.Io, path: []const u8, identity: []const u8) !void {
|
|
1758
|
+
const signed = try codesign.signIdentityArtifact(allocator, io, path, identity);
|
|
1759
|
+
defer allocator.free(signed.message);
|
|
1760
|
+
if (!signed.ok) {
|
|
1761
|
+
std.debug.print("error: code signing distribution artifact {s} with \"{s}\" failed:\n{s}\n", .{ path, identity, trimmedToolOutput(signed.message) });
|
|
1762
|
+
return error.SigningFailed;
|
|
1763
|
+
}
|
|
1764
|
+
const verified = try codesign.verifyArtifact(allocator, io, path);
|
|
1765
|
+
defer allocator.free(verified.message);
|
|
1766
|
+
if (!verified.ok) {
|
|
1767
|
+
std.debug.print("error: signed distribution artifact {s} failed strict codesign verification:\n{s}\n", .{ path, trimmedToolOutput(verified.message) });
|
|
1768
|
+
return error.SignatureVerificationFailed;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
fn runNotarization(allocator: std.mem.Allocator, io: std.Io, path: []const u8, profile: []const u8, app_bundle: bool) !void {
|
|
1773
|
+
const result = if (app_bundle)
|
|
1774
|
+
try codesign.notarizeApp(allocator, io, .{ .artifact_path = path, .keychain_profile = profile })
|
|
1775
|
+
else
|
|
1776
|
+
try codesign.notarizeArtifact(allocator, io, .{ .artifact_path = path, .keychain_profile = profile }, null);
|
|
1777
|
+
defer allocator.free(result.message);
|
|
1778
|
+
if (!result.ok) {
|
|
1779
|
+
std.debug.print("error: notarization failed for {s}:\n{s}\n", .{ path, trimmedToolOutput(result.message) });
|
|
1780
|
+
return error.NotarizationFailed;
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1724
1784
|
/// codesign's output, trimmed of trailing newlines so the teaching
|
|
1725
1785
|
/// message's fix line lands directly under it (the output itself stays
|
|
1726
1786
|
/// verbatim).
|
|
@@ -3630,6 +3690,30 @@ test "identity signing without an identity is a loud failure, not a silent unsig
|
|
|
3630
3690
|
}));
|
|
3631
3691
|
}
|
|
3632
3692
|
|
|
3693
|
+
test "notarization refuses unsigned non-macos and uncredentialed packages before artifact creation" {
|
|
3694
|
+
const metadata: manifest_tool.Metadata = .{ .id = "dev.example.notarize", .name = "notarize-demo", .version = "1.0.0" };
|
|
3695
|
+
try std.testing.expectError(error.NotarizationRequiresIdentity, createPackage(std.testing.allocator, std.testing.io, .{
|
|
3696
|
+
.metadata = metadata,
|
|
3697
|
+
.target = .macos,
|
|
3698
|
+
.output_path = ".zig-cache/test-notarize-unsigned.app",
|
|
3699
|
+
.notarize = true,
|
|
3700
|
+
}));
|
|
3701
|
+
try std.testing.expectError(error.UnsupportedNotarizationTarget, createPackage(std.testing.allocator, std.testing.io, .{
|
|
3702
|
+
.metadata = metadata,
|
|
3703
|
+
.target = .linux,
|
|
3704
|
+
.output_path = ".zig-cache/test-notarize-linux",
|
|
3705
|
+
.signing = .{ .mode = .identity, .identity = "Developer ID Application: Test" },
|
|
3706
|
+
.notarize = true,
|
|
3707
|
+
}));
|
|
3708
|
+
try std.testing.expectError(error.MissingNotaryProfile, createPackage(std.testing.allocator, std.testing.io, .{
|
|
3709
|
+
.metadata = metadata,
|
|
3710
|
+
.target = .macos,
|
|
3711
|
+
.output_path = ".zig-cache/test-notarize-no-profile.app",
|
|
3712
|
+
.signing = .{ .mode = .identity, .identity = "Developer ID Application: Test" },
|
|
3713
|
+
.notarize = true,
|
|
3714
|
+
}));
|
|
3715
|
+
}
|
|
3716
|
+
|
|
3633
3717
|
test "native-only windows package ships no WebView2 loader and reports web layer none" {
|
|
3634
3718
|
var cwd = std.Io.Dir.cwd();
|
|
3635
3719
|
const root = ".zig-cache/test-package-native-only-windows";
|