Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
fix: sign packaged stickman runtime on macOS
Leggett27ffc0beae5b
diff --git a/apps/desktop/scripts/sign-creator-runtime-after-pack.mjs b/apps/desktop/scripts/sign-creator-runtime-after-pack.mjsindex 711426d4..b4fd8af6 100644--- a/apps/desktop/scripts/sign-creator-runtime-after-pack.mjs+++ b/apps/desktop/scripts/sign-creator-runtime-after-pack.mjs@@ -12,6 +12,7 @@ import { createHash } from 'node:crypto';import { join, relative } from 'node:path';import { spawnSync } from 'node:child_process';import { verifyCreatorRuntime } from './creator-runtime-contract.mjs';+import { verifyStickmanRuntime } from './stickman-runtime-contract.mjs';import { findDeveloperIdIdentity } from './mac-signing.mjs';const machOMagicValues = new Set([@@ -28,9 +29,26 @@ const machOMagicValues = new Set([export async function afterPack(context) {if (process.env.OPENCREATOR_SIGN_CREATOR_RUNTIME !== '1') return;await signCreatorRuntimeBundle(context);+ await signStickmanRuntimeBundle(context);}export async function signCreatorRuntimeBundle(context, options = {}) {+ return signPackagedRuntime(context, options, {+ name: 'Creator Runtime',+ relativeRoot: ['creator-runtime', 'krillinai'],+ verifyRuntime: options.verifyRuntime ?? verifyCreatorRuntime+ });+}++export async function signStickmanRuntimeBundle(context, options = {}) {+ return signPackagedRuntime(context, options, {+ name: 'Stickman Runtime',+ relativeRoot: ['stickman-runtime'],+ verifyRuntime: options.verifyRuntime ?? verifyStickmanRuntime+ });+}++async function signPackagedRuntime(context, options, runtime) {const env = options.env ?? process.env;if (context.electronPlatformName !== 'darwin') {throw new Error('Creator Runtime Developer ID signing requires macOS');@@ -51,14 +69,13 @@ export async function signCreatorRuntimeBundle(context, options = {}) {`${productFilename}.app`,'Contents','Resources',- 'creator-runtime',- 'krillinai'+ ...runtime.relativeRoot);if (!existsSync(runtimeRoot)) {- throw new Error(`Creator Runtime is missing from the app: ${runtimeRoot}`);+ throw new Error(`${runtime.name} is missing from the app: ${runtimeRoot}`);}- const verifyRuntime = options.verifyRuntime ?? verifyCreatorRuntime;+ const verifyRuntime = runtime.verifyRuntime;verifyRuntime(runtimeRoot, 'darwin', arch);const signingInfo = await context.packager.codeSigningInfo.value;@@ -68,7 +85,7 @@ export async function signCreatorRuntimeBundle(context, options = {}) {const findBinaries = options.findBinaries ?? findMachOBinaries;const binaries = findBinaries(runtimeRoot);if (binaries.length === 0) {- throw new Error('Creator Runtime does not contain any Mach-O binaries');+ throw new Error(`${runtime.name} does not contain any Mach-O binaries`);}const signBinary = options.signBinary ?? signMachOBinary;@@ -78,7 +95,7 @@ export async function signCreatorRuntimeBundle(context, options = {}) {updateManifestHashes(runtimeRoot, binaries);verifyRuntime(runtimeRoot, 'darwin', arch);console.log(- `[desktop-package] Signed ${binaries.length} Creator Runtime binaries`+ `[desktop-package] Signed ${binaries.length} ${runtime.name} binaries`);}@@ -97,6 +114,9 @@ export function updateManifestHashes(runtimeRoot, signedPaths) {);}resource.sha256 = hashFile(path);+ if (Number.isSafeInteger(resource.bytes)) {+ resource.bytes = statSync(path).size;+ }}writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);}diff --git a/apps/desktop/test/creator-runtime-signing.test.mjs b/apps/desktop/test/creator-runtime-signing.test.mjsindex 3846d086..d198b5da 100644--- a/apps/desktop/test/creator-runtime-signing.test.mjs+++ b/apps/desktop/test/creator-runtime-signing.test.mjs@@ -10,8 +10,10 @@ import { tmpdir } from 'node:os';import { dirname, join, relative } from 'node:path';import { afterEach, describe, expect, it, vi } from 'vitest';import { verifyCreatorRuntime } from '../scripts/creator-runtime-contract.mjs';+import { verifyStickmanRuntime } from '../scripts/stickman-runtime-contract.mjs';import {signCreatorRuntimeBundle,+ signStickmanRuntimeBundle,updateManifestHashes} from '../scripts/sign-creator-runtime-after-pack.mjs';@@ -92,8 +94,52 @@ describe('Creator Runtime Developer ID signing', () => {[undeclared])).toThrow(/absent from its manifest/i);});++ it('signs the packaged Stickman browser and refreshes its manifest', async () => {+ const fixture = createStickmanFixture();+ const signBinary = vi.fn(path => {+ writeFileSync(path, Buffer.concat([+ readFileSync(path),+ Buffer.from('-developer-id-signature')+ ]));+ });++ await signStickmanRuntimeBundle(createContext(fixture.appOutDir), {+ env: signingEnv(),+ findIdentity: () => 'Developer ID Application: Junxi YIN (NVRH5R5DJ5)',+ findBinaries: () => fixture.binaryPaths,+ signBinary+ });++ expect(signBinary).toHaveBeenCalledTimes(fixture.binaryPaths.length);+ expect(() => verifyStickmanRuntime(+ fixture.runtimeRoot,+ 'darwin',+ 'arm64'+ )).not.toThrow();+ });});+function createContext(appOutDir) {+ return {+ electronPlatformName: 'darwin',+ appOutDir,+ packager: {+ appInfo: { productFilename: 'OpenCreator' },+ codeSigningInfo: {+ value: Promise.resolve({ keychainFile: '/tmp/release.keychain' })+ }+ }+ };+}++function signingEnv() {+ return {+ OPENCREATOR_APPLE_TEAM_ID: 'NVRH5R5DJ5',+ OPENCREATOR_DESKTOP_TARGET_ARCH: 'arm64'+ };+}+function createFixture() {const root = mkdtempSync(join(tmpdir(), 'opencreator-runtime-signing-'));temporaryDirectories.push(root);@@ -156,6 +202,66 @@ function createFixture() {};}+function createStickmanFixture() {+ const root = mkdtempSync(join(tmpdir(), 'opencreator-stickman-signing-'));+ temporaryDirectories.push(root);+ const appOutDir = join(root, 'mac-arm64');+ const runtimeRoot = join(+ appOutDir,+ 'OpenCreator.app',+ 'Contents',+ 'Resources',+ 'stickman-runtime'+ );+ const files = {+ 'bundle/site/index.html': '<html></html>',+ 'browser/chrome-headless-shell': 'chromium',+ 'fonts/NotoSans-Bold.woff2': 'font',+ 'fonts/NotoSansSC-Bold.woff2': 'font',+ 'fonts/OFL.txt': 'license',+ 'visual-assets/catalog.json': '{}'+ };+ for (const character of [+ 'default', 'tech-guy', 'long-hair', 'short-hair', 'hiphop',+ 'student', 'elder', 'manager', 'chef', 'fitness'+ ]) {+ files[`characters/${character}.png`] = character;+ }+ for (const [relativePath, contents] of Object.entries(files)) {+ const path = join(runtimeRoot, relativePath);+ mkdirSync(dirname(path), { recursive: true });+ writeFileSync(path, contents);+ }+ const resources = Object.keys(files).map(path => ({+ path,+ kind: path.startsWith('browser/') ? 'browser'+ : path.startsWith('bundle/') ? 'bundle'+ : path.startsWith('fonts/') ? 'font'+ : path.startsWith('characters/') ? 'character'+ : 'visual-asset',+ sha256: hashFile(join(runtimeRoot, path)),+ bytes: readFileSync(join(runtimeRoot, path)).length,+ version: 'test',+ platform: 'darwin',+ arch: 'arm64'+ }));+ writeFileSync(join(runtimeRoot, 'manifest.json'), `${JSON.stringify({+ version: 1,+ platform: 'darwin',+ arch: 'arm64',+ remotionVersion: '4.0.473',+ chromiumVersion: '149.0.7790.0',+ bundlePath: 'bundle/site',+ browserExecutable: 'browser/chrome-headless-shell',+ resources+ }, null, 2)}\n`);+ return {+ appOutDir,+ runtimeRoot,+ binaryPaths: [join(runtimeRoot, 'browser', 'chrome-headless-shell')]+ };+}+function hashFile(path) {return createHash('sha256').update(readFileSync(path)).digest('hex');}