mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 16:25:21 +00:00
Moved manifest hashes generation to signature file
This commit is contained in:
@@ -4,7 +4,6 @@ import { getModelFolderContents } from "./parser";
|
|||||||
import * as Schemas from "./schemas";
|
import * as Schemas from "./schemas";
|
||||||
import { Stream } from "stream";
|
import { Stream } from "stream";
|
||||||
import { processDate } from "./processDate";
|
import { processDate } from "./processDate";
|
||||||
import forge from "node-forge";
|
|
||||||
import * as Signature from "./signature";
|
import * as Signature from "./signature";
|
||||||
import * as Strings from "./StringsUtils";
|
import * as Strings from "./StringsUtils";
|
||||||
import { isValidRGB } from "./utils";
|
import { isValidRGB } from "./utils";
|
||||||
@@ -513,16 +512,13 @@ export default class PKPass extends Bundle {
|
|||||||
private [createManifestSymbol](): Buffer {
|
private [createManifestSymbol](): Buffer {
|
||||||
const manifest = Object.entries(this[filesSymbol]).reduce<{
|
const manifest = Object.entries(this[filesSymbol]).reduce<{
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
}>((acc, [fileName, buffer]) => {
|
}>(
|
||||||
const hashFlow = forge.md.sha1.create();
|
(acc, [fileName, buffer]) => ({
|
||||||
|
|
||||||
hashFlow.update(buffer.toString("binary"));
|
|
||||||
|
|
||||||
return {
|
|
||||||
...acc,
|
...acc,
|
||||||
[fileName]: hashFlow.digest().toHex(),
|
[fileName]: Signature.createHash(buffer),
|
||||||
};
|
}),
|
||||||
}, {});
|
{},
|
||||||
|
);
|
||||||
|
|
||||||
return Buffer.from(JSON.stringify(manifest));
|
return Buffer.from(JSON.stringify(manifest));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,20 @@
|
|||||||
import forge from "node-forge";
|
import forge from "node-forge";
|
||||||
import type * as Schemas from "./schemas";
|
import type * as Schemas from "./schemas";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an hash for a buffer. Used by manifest
|
||||||
|
*
|
||||||
|
* @param buffer
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
|
||||||
|
export function createHash(buffer: Buffer) {
|
||||||
|
const hashFlow = forge.md.sha1.create();
|
||||||
|
hashFlow.update(buffer.toString("binary"));
|
||||||
|
|
||||||
|
return hashFlow.digest().toHex();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the PKCS #7 cryptografic signature for the manifest file.
|
* Generates the PKCS #7 cryptografic signature for the manifest file.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user