vbuch / node-signpdf

Simple signing of PDFs in node.
MIT License
723 stars 178 forks source link

Helpers not works with pdfkit@0.11 #49

Closed vologab closed 4 years ago

vologab commented 4 years ago
 PASS  src/helpers/plainAddPlaceholder/createBufferPageWithAnnotation.test.js
 PASS  src/helpers/removeTrailingNewLine.test.js
 PASS  src/helpers/extractSignature.test.js
 PASS  src/SignPdfError.test.js
 PASS  src/helpers/index.test.js
 PASS  src/helpers/plainAddPlaceholder/readRefTable.test.js
 PASS  src/helpers/plainAddPlaceholder/getIndexFromRef.test.js
 PASS  src/helpers/plainAddPlaceholder/index.test.js
 PASS  src/helpers/pdfkitReferenceMock.test.js
 PASS  src/helpers/plainAddPlaceholder/getPagesDictionaryRef.test.js
 PASS  src/helpers/pdfkitAddPlaceholder.test.js
 FAIL  src/helpers.test.js
  ● Helpers › extract signature from signed pdf

    TypeError: Cannot read property 'fonts' of undefined

      52 |     // Also end the PDFDocument stream.
      53 |     // See pdf.on('end'... on how it is then converted to Buffer.
    > 54 |     pdf.end();
         |         ^
      55 | });
      56 | 
      57 | describe('Helpers', () => {

      at PDFDocument.endAcroForm (node_modules/pdfkit/lib/mixins/acroform.js:78:37)
      at PDFDocument.end (node_modules/pdfkit/lib/document.js:274:10)
      at src/helpers.test.js:54:9
      at createPdf (src/helpers.test.js:15:7)
      at Object.<anonymous> (src/helpers.test.js:59:33)

 FAIL  src/signpdf.test.js
  ● Test signing › expects a reasonably sized placeholder

    expect(received).toBe(expected) // Object.is equality

    Expected: true
    Received: false

      105 |             expect('here').not.toBe('here');
      106 |         } catch (e) {
    > 107 |             expect(e instanceof SignPdfError).toBe(true);
          |                                               ^
      108 |             expect(e.type).toBe(SignPdfError.TYPE_INPUT);
      109 |             expect(e.message).toMatchSnapshot();
      110 |         }

      at Object.<anonymous> (src/signpdf.test.js:107:47)

  ● Test signing › signs input PDF

    TypeError: Cannot read property 'fonts' of undefined

      59 |     // Also end the PDFDocument stream.
      60 |     // See pdf.on('end'... on how it is then converted to Buffer.
    > 61 |     pdf.end();
         |         ^
      62 | });
      63 | 
      64 | describe('Test signing', () => {

      at PDFDocument.endAcroForm (node_modules/pdfkit/lib/mixins/acroform.js:78:37)
      at PDFDocument.end (node_modules/pdfkit/lib/document.js:274:10)
      at src/signpdf.test.js:61:9
      at createPdf (src/signpdf.test.js:13:29)
      at Object.<anonymous> (src/signpdf.test.js:113:31)

  ● Test signing › signs detached

    TypeError: Cannot read property 'fonts' of undefined

      59 |     // Also end the PDFDocument stream.
      60 |     // See pdf.on('end'... on how it is then converted to Buffer.
    > 61 |     pdf.end();
         |         ^
      62 | });
      63 | 
      64 | describe('Test signing', () => {

      at PDFDocument.endAcroForm (node_modules/pdfkit/lib/mixins/acroform.js:78:37)
      at PDFDocument.end (node_modules/pdfkit/lib/document.js:274:10)
      at src/signpdf.test.js:61:9
      at createPdf (src/signpdf.test.js:13:29)
      at Object.<anonymous> (src/signpdf.test.js:126:31)

  ● Test signing › signs with ca, intermediate and multiple certificates bundle

    TypeError: Cannot read property 'fonts' of undefined

      59 |     // Also end the PDFDocument stream.
      60 |     // See pdf.on('end'... on how it is then converted to Buffer.
    > 61 |     pdf.end();
         |         ^
      62 | });
      63 | 
      64 | describe('Test signing', () => {

      at PDFDocument.endAcroForm (node_modules/pdfkit/lib/mixins/acroform.js:78:37)
      at PDFDocument.end (node_modules/pdfkit/lib/document.js:274:10)
      at src/signpdf.test.js:61:9
      at createPdf (src/signpdf.test.js:13:29)
      at Object.<anonymous> (src/signpdf.test.js:165:31)

  ● Test signing › signs with passphrased certificate

    TypeError: Cannot read property 'fonts' of undefined

      59 |     // Also end the PDFDocument stream.
      60 |     // See pdf.on('end'... on how it is then converted to Buffer.
    > 61 |     pdf.end();
         |         ^
      62 | });
      63 | 
      64 | describe('Test signing', () => {

      at PDFDocument.endAcroForm (node_modules/pdfkit/lib/mixins/acroform.js:78:37)
      at PDFDocument.end (node_modules/pdfkit/lib/document.js:274:10)
      at src/signpdf.test.js:61:9
      at createPdf (src/signpdf.test.js:13:29)
      at Object.<anonymous> (src/signpdf.test.js:176:31)

  ● Test signing › errors on wrong certificate passphrase

    TypeError: Cannot read property 'fonts' of undefined

      59 |     // Also end the PDFDocument stream.
      60 |     // See pdf.on('end'... on how it is then converted to Buffer.
    > 61 |     pdf.end();
         |         ^
      62 | });
      63 | 
      64 | describe('Test signing', () => {

      at PDFDocument.endAcroForm (node_modules/pdfkit/lib/mixins/acroform.js:78:37)
      at PDFDocument.end (node_modules/pdfkit/lib/document.js:274:10)
      at src/signpdf.test.js:61:9
      at createPdf (src/signpdf.test.js:13:29)
      at Object.<anonymous> (src/signpdf.test.js:191:33)

  ● Test signing › errors when no matching certificate is found in bags

    TypeError: Cannot read property 'fonts' of undefined

      59 |     // Also end the PDFDocument stream.
      60 |     // See pdf.on('end'... on how it is then converted to Buffer.
    > 61 |     pdf.end();
         |         ^
      62 | });
      63 | 
      64 | describe('Test signing', () => {

      at PDFDocument.endAcroForm (node_modules/pdfkit/lib/mixins/acroform.js:78:37)
      at PDFDocument.end (node_modules/pdfkit/lib/document.js:274:10)
      at src/signpdf.test.js:61:9
      at createPdf (src/signpdf.test.js:13:29)
      at Object.<anonymous> (src/signpdf.test.js:207:33)

Test Suites: 2 failed, 11 passed, 13 total
Tests:       8 failed, 27 passed, 35 total
Snapshots:   19 passed, 19 total
Time:        3.203s, estimated 4s
Ran all test suites.
vbuch commented 4 years ago

pdfkit 0.11 has AcroForms support. Someone has to take a look at how stuff is done with that.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had activity in the past 90 days. It will be closed if no further activity occurs. Thank you for your contributions.