Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set asar integrity resource on windows packages #1697

Merged
merged 1 commit into from Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/resedit.ts
Expand Up @@ -2,13 +2,15 @@
// eslint-disable-next-line import/no-unresolved
import { load as loadResEdit } from 'resedit/cjs';
import { Win32MetadataOptions } from './types';
import { FileRecord } from '@electron/asar';

export type ExeMetadata = {
productVersion?: string;
fileVersion?: string;
legalCopyright?: string;
productName?: string;
iconPath?: string;
asarIntegrity?: Record<string, Pick<FileRecord['integrity'], 'algorithm' | 'hash'>>;
win32Metadata?: Win32MetadataOptions;
}

Expand Down Expand Up @@ -112,6 +114,17 @@
// Output version info
versionInfo[0].outputToResourceEntries(res.entries);

// Asar Integrity
if (options.asarIntegrity) {
res.entries.push({

Check warning on line 119 in src/resedit.ts

View check run for this annotation

Codecov / codecov/patch

src/resedit.ts#L119

Added line #L119 was not covered by tests
type: 'Integrity',
id: 'ElectronAsar',
bin: Buffer.from(JSON.stringify(options.asarIntegrity)).buffer,
lang: languageInfo[0].lang,
codepage: languageInfo[0].codepage,
});
}

res.outputResource(exe);

await fs.writeFile(exePath, Buffer.from(exe.generate()));
Expand Down
1 change: 1 addition & 0 deletions src/win32.ts
Expand Up @@ -33,6 +33,7 @@ export class WindowsApp extends App {
fileVersion: this.opts.buildVersion || this.opts.appVersion,
legalCopyright: this.opts.appCopyright,
productName: this.opts.win32metadata?.ProductName || this.opts.name,
asarIntegrity: this.asarIntegrity,
erickzhao marked this conversation as resolved.
Show resolved Hide resolved
win32Metadata,
};
}
Expand Down