Skip to content

Commit

Permalink
feat: set asar integrity resource on windows packages (#1697)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound authored Mar 27, 2024
1 parent d9655d4 commit 224cc6a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/resedit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import * as fs from 'fs-extra';
// 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 @@ export async function resedit(exePath: string, options: ExeMetadata) {
// Output version info
versionInfo[0].outputToResourceEntries(res.entries);

// Asar Integrity
if (options.asarIntegrity) {
res.entries.push({
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
Original file line number Diff line number Diff line change
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,
win32Metadata,
};
}
Expand Down

0 comments on commit 224cc6a

Please sign in to comment.