foliojs/restructure

Unusable with CSP directives

mrudelle opened this issue ยท 14 comments

Ref to issue foliojs/pdfkit#757

This line evaluates generated code and thus cannot be used on projects relying on CSP. (without adding the unsafe-eval directive)

see PR #22

Great to see work on this issue @firien, let's hope your work gets merged soon.

I'd like also to stress that all my big project is not on green with Google CSP validator merely because of this issue, through pdfmake.

image

pdfmake admin refers:

Pdfmake using pdfkit library for creating pdf files, this has a dependency on restructure library where eval is used. It can not be replaced by another library. Pdfmake can not solve this problem, it must be resolved in restructure library.
Exists issue #28 and PR #22 in restructure. We can only wait for a new version of restructure library.

Anyway, thanks for the free library and let us wait :)

+1

Should be fixed by #34. Released in v2.0.0.

When will datatables with pdfmake include v2.0 - or is there a way to force it to use version 2.0 so that I can use native capability for PDFS that match my tables?

You can try https://www.npmjs.com/package/pdfmake-lite. It does not supports IE

@thomasazdon pdfmake not using v2.0 because dependency on restructure is in fontkit and there was no new version with restructure v2.0.

Reopened.
Issue is not fixed completely:

this.versionGetter = new Function('parent', `return parent.${this.type}`);
this.versionSetter = new Function('parent', 'version', `return parent.${this.type} = version`);

you can look at #22. it's 3 years old, but was updated for js a few months ago.

its a closed pull request, and i think that is why it is not asking to pull in new commits - but i did just tack on a new commit: 26dc864

Prepared PR #36 for fix.
Prepared PR #37 for fix.

Thanks for fixing this! Will there be a release soon so that pdfmake can be used without the CSP unsafe-eval?

@flip-it, as stated at bpampuch/pdfmake#1360 a lot of things have to happen for a new pdfmake release.

a new release of restruture is a tiny step. fontkit is still pinned at restructure v0.5.4. fontkits current babel (v6) implementation does not like the new es6 style of restructure 2.x. I tried playing around with it, but ran into issues with rollup, which is out of date (v0.34.13 is 3ยฝ years old), and fontkits own creator has since authored Parcelโ€ฆ

For compatibility with new restructure in fontkit is ready in foliojs/fontkit#225 and foliojs/fontkit#196.
But merge and release a new version of restructure and fontkit @devongovett has to do it.