mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 14:25:17 +00:00
Revert "Added Bundle.prototype.files getter to prevent exposing filesSymbol"
This reverts commit 6f7a597cbe.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Stream } from "stream";
|
||||
import { default as Bundle } from "../lib/Bundle";
|
||||
import { default as Bundle, filesSymbol } from "../lib/Bundle";
|
||||
|
||||
describe("Bundle", () => {
|
||||
let bundle: InstanceType<typeof Bundle>;
|
||||
@@ -24,7 +24,7 @@ describe("Bundle", () => {
|
||||
const buffer = Buffer.alloc(0);
|
||||
bundle.addBuffer("pass.json", buffer);
|
||||
|
||||
expect(bundle.files).toEqual({ "pass.json": buffer });
|
||||
expect(bundle[filesSymbol]).toEqual({ "pass.json": buffer });
|
||||
});
|
||||
|
||||
it("should throw error if freezed", async () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Stream } from "stream";
|
||||
import { ZipFile } from "yazl";
|
||||
|
||||
const filesSymbol = Symbol("bundleFiles");
|
||||
export const filesSymbol = Symbol("bundleFiles");
|
||||
const bundleStateSymbol = Symbol("state");
|
||||
const archiveSymbol = Symbol("zip");
|
||||
|
||||
@@ -78,14 +78,6 @@ export default class Bundle {
|
||||
return this[bundleStateSymbol] === BundleState.CLOSED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of files added to the bundle
|
||||
*/
|
||||
|
||||
public get files() {
|
||||
return this[filesSymbol];
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows files to be added to the bundle.
|
||||
* If the bundle is closed, it will throw an error.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import FieldsArray from "./fieldsArray";
|
||||
import { default as Bundle } from "./Bundle";
|
||||
import { default as Bundle, filesSymbol } from "./Bundle";
|
||||
import { getModelFolderContents } from "./parser";
|
||||
import * as Schemas from "./schemas";
|
||||
import { Stream } from "stream";
|
||||
@@ -73,7 +73,7 @@ export default class PKPass extends Bundle {
|
||||
certificates = source.certificates;
|
||||
buffers = {};
|
||||
|
||||
const buffersEntries = Object.entries(source.files);
|
||||
const buffersEntries = Object.entries(source[filesSymbol]);
|
||||
|
||||
/** Cloning all the buffers to prevent unwanted edits */
|
||||
for (let i = 0; i < buffersEntries.length; i++) {
|
||||
@@ -285,7 +285,7 @@ export default class PKPass extends Bundle {
|
||||
}
|
||||
|
||||
if (/pass\.json/.test(pathName)) {
|
||||
if (this.files["pass.json"]) {
|
||||
if (this[filesSymbol]["pass.json"]) {
|
||||
/**
|
||||
* Ignoring any further addition. In a
|
||||
* future we might consider merging instead
|
||||
@@ -374,7 +374,7 @@ export default class PKPass extends Bundle {
|
||||
}
|
||||
|
||||
private [createManifestSymbol]() {
|
||||
return Object.entries(this.files).reduce<Schemas.Manifest>(
|
||||
return Object.entries(this[filesSymbol]).reduce<Schemas.Manifest>(
|
||||
(acc, [fileName, buffer]) => {
|
||||
const hashFlow = forge.md.sha1.create();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user