feat: add support for auto-merging ElectronAsarIntegrity values

This commit is contained in:
Samuel Attard
2021-09-15 12:50:03 -07:00
parent fe8d99e31d
commit 36b58a84f3
5 changed files with 97 additions and 16 deletions

View File

@@ -1,3 +1,5 @@
import * as asar from 'asar';
import * as crypto from 'crypto';
import * as fs from 'fs-extra';
import * as path from 'path';
import { d } from './debug';
@@ -19,3 +21,13 @@ export const detectAsarMode = async (appPath: string) => {
d('determined has asar');
return AsarMode.HAS_ASAR;
};
export const generateAsarIntegrity = (asarPath: string) => {
return {
algorithm: 'SHA256' as const,
hash: crypto
.createHash('SHA256')
.update(asar.getRawHeader(asarPath).headerString)
.digest('hex'),
};
};