@e-sig/core 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +92 -0
  3. package/dist/index.d.ts +7 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +7 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/pem-signer.d.ts +26 -5
  8. package/dist/pem-signer.d.ts.map +1 -1
  9. package/dist/pem-signer.js +84 -13
  10. package/dist/pem-signer.js.map +1 -1
  11. package/dist/pq-cert.d.ts +76 -0
  12. package/dist/pq-cert.d.ts.map +1 -0
  13. package/dist/pq-cert.js +295 -0
  14. package/dist/pq-cert.js.map +1 -0
  15. package/dist/pq-embed.d.ts +22 -0
  16. package/dist/pq-embed.d.ts.map +1 -0
  17. package/dist/pq-embed.js +119 -0
  18. package/dist/pq-embed.js.map +1 -0
  19. package/dist/pq-lifecycle.d.ts +59 -0
  20. package/dist/pq-lifecycle.d.ts.map +1 -0
  21. package/dist/pq-lifecycle.js +55 -0
  22. package/dist/pq-lifecycle.js.map +1 -0
  23. package/dist/pq-seal.d.ts +183 -0
  24. package/dist/pq-seal.d.ts.map +1 -0
  25. package/dist/pq-seal.js +345 -0
  26. package/dist/pq-seal.js.map +1 -0
  27. package/dist/pq-verify.d.ts +99 -0
  28. package/dist/pq-verify.d.ts.map +1 -0
  29. package/dist/pq-verify.js +135 -0
  30. package/dist/pq-verify.js.map +1 -0
  31. package/dist/render-pdf.d.ts +5 -5
  32. package/dist/render-pdf.d.ts.map +1 -1
  33. package/dist/render-pdf.js +51 -17
  34. package/dist/render-pdf.js.map +1 -1
  35. package/dist/sign-document.d.ts +16 -0
  36. package/dist/sign-document.d.ts.map +1 -1
  37. package/dist/sign-document.js +10 -0
  38. package/dist/sign-document.js.map +1 -1
  39. package/dist/sign-pdf.d.ts +66 -4
  40. package/dist/sign-pdf.d.ts.map +1 -1
  41. package/dist/sign-pdf.js +51 -2
  42. package/dist/sign-pdf.js.map +1 -1
  43. package/dist/types.d.ts +36 -0
  44. package/dist/types.d.ts.map +1 -1
  45. package/dist/vendor/placeholder-plain/LICENSE-signpdf.md +47 -0
  46. package/dist/vendor/placeholder-plain/createBufferPageWithAnnotation.d.ts +6 -0
  47. package/dist/vendor/placeholder-plain/createBufferPageWithAnnotation.d.ts.map +1 -0
  48. package/dist/vendor/placeholder-plain/createBufferPageWithAnnotation.js +38 -0
  49. package/dist/vendor/placeholder-plain/createBufferPageWithAnnotation.js.map +1 -0
  50. package/dist/vendor/placeholder-plain/createBufferRootWithAcroform.d.ts +6 -0
  51. package/dist/vendor/placeholder-plain/createBufferRootWithAcroform.d.ts.map +1 -0
  52. package/dist/vendor/placeholder-plain/createBufferRootWithAcroform.js +15 -0
  53. package/dist/vendor/placeholder-plain/createBufferRootWithAcroform.js.map +1 -0
  54. package/dist/vendor/placeholder-plain/createBufferTrailer.d.ts +4 -0
  55. package/dist/vendor/placeholder-plain/createBufferTrailer.d.ts.map +1 -0
  56. package/dist/vendor/placeholder-plain/createBufferTrailer.js +26 -0
  57. package/dist/vendor/placeholder-plain/createBufferTrailer.js.map +1 -0
  58. package/dist/vendor/placeholder-plain/findObject.d.ts +4 -0
  59. package/dist/vendor/placeholder-plain/findObject.d.ts.map +1 -0
  60. package/dist/vendor/placeholder-plain/findObject.js +18 -0
  61. package/dist/vendor/placeholder-plain/findObject.js.map +1 -0
  62. package/dist/vendor/placeholder-plain/getIndexFromRef.d.ts +4 -0
  63. package/dist/vendor/placeholder-plain/getIndexFromRef.d.ts.map +1 -0
  64. package/dist/vendor/placeholder-plain/getIndexFromRef.js +13 -0
  65. package/dist/vendor/placeholder-plain/getIndexFromRef.js.map +1 -0
  66. package/dist/vendor/placeholder-plain/getPageRef.d.ts +6 -0
  67. package/dist/vendor/placeholder-plain/getPageRef.d.ts.map +1 -0
  68. package/dist/vendor/placeholder-plain/getPageRef.js +18 -0
  69. package/dist/vendor/placeholder-plain/getPageRef.js.map +1 -0
  70. package/dist/vendor/placeholder-plain/getPagesDictionaryRef.d.ts +3 -0
  71. package/dist/vendor/placeholder-plain/getPagesDictionaryRef.d.ts.map +1 -0
  72. package/dist/vendor/placeholder-plain/getPagesDictionaryRef.js +12 -0
  73. package/dist/vendor/placeholder-plain/getPagesDictionaryRef.js.map +1 -0
  74. package/dist/vendor/placeholder-plain/index.d.ts +2 -0
  75. package/dist/vendor/placeholder-plain/index.d.ts.map +1 -0
  76. package/dist/vendor/placeholder-plain/index.js +4 -0
  77. package/dist/vendor/placeholder-plain/index.js.map +1 -0
  78. package/dist/vendor/placeholder-plain/pdfObject.d.ts +13 -0
  79. package/dist/vendor/placeholder-plain/pdfObject.d.ts.map +1 -0
  80. package/dist/vendor/placeholder-plain/pdfObject.js +142 -0
  81. package/dist/vendor/placeholder-plain/pdfObject.js.map +1 -0
  82. package/dist/vendor/placeholder-plain/pdfkitAddPlaceholder.d.ts +49 -0
  83. package/dist/vendor/placeholder-plain/pdfkitAddPlaceholder.d.ts.map +1 -0
  84. package/dist/vendor/placeholder-plain/pdfkitAddPlaceholder.js +115 -0
  85. package/dist/vendor/placeholder-plain/pdfkitAddPlaceholder.js.map +1 -0
  86. package/dist/vendor/placeholder-plain/plainAddPlaceholder.d.ts +41 -0
  87. package/dist/vendor/placeholder-plain/plainAddPlaceholder.d.ts.map +1 -0
  88. package/dist/vendor/placeholder-plain/plainAddPlaceholder.js +95 -0
  89. package/dist/vendor/placeholder-plain/plainAddPlaceholder.js.map +1 -0
  90. package/dist/vendor/placeholder-plain/readPdf.d.ts +20 -0
  91. package/dist/vendor/placeholder-plain/readPdf.d.ts.map +1 -0
  92. package/dist/vendor/placeholder-plain/readPdf.js +47 -0
  93. package/dist/vendor/placeholder-plain/readPdf.js.map +1 -0
  94. package/dist/vendor/placeholder-plain/readRefTable.d.ts +17 -0
  95. package/dist/vendor/placeholder-plain/readRefTable.d.ts.map +1 -0
  96. package/dist/vendor/placeholder-plain/readRefTable.js +84 -0
  97. package/dist/vendor/placeholder-plain/readRefTable.js.map +1 -0
  98. package/dist/vendor/placeholder-plain/xrefToRefMap.d.ts +3 -0
  99. package/dist/vendor/placeholder-plain/xrefToRefMap.d.ts.map +1 -0
  100. package/dist/vendor/placeholder-plain/xrefToRefMap.js +38 -0
  101. package/dist/vendor/placeholder-plain/xrefToRefMap.js.map +1 -0
  102. package/package.json +10 -8
@@ -0,0 +1,47 @@
1
+ # Vendored code license — @signpdf/placeholder-plain / @signpdf/placeholder-pdfkit010
2
+
3
+ The TypeScript sources in this directory are a faithful port of the compiled
4
+ JavaScript published as:
5
+
6
+ - `@signpdf/placeholder-plain@3.3.0` (all of `dist/`)
7
+ - `@signpdf/placeholder-pdfkit010@3.3.0` (`dist/pdfkitAddPlaceholder.js` only)
8
+
9
+ Both packages are part of the node-signpdf project
10
+ (https://github.com/vbuch/node-signpdf) by vbuch and contributors, published
11
+ under the MIT license reproduced below. They were vendored here to remove the
12
+ `@signpdf/placeholder-pdfkit010 -> pdfkit@0.10.0 (peer) -> crypto-js@3.3.0`
13
+ dependency chain; no logic was changed — only TypeScript types were added.
14
+ `@signpdf/utils` and `@signpdf/signpdf` remain regular dependencies and are
15
+ still imported by this vendored code.
16
+
17
+ **One deliberate divergence.** `pdfObject.ts` is a hardened replacement for
18
+ `PDFObject.convert` from `@signpdf/utils` (itself derived from pdfkit's
19
+ `PDFObject` by Devon Govett, MIT). It removes the raw-splice branch that
20
+ emits any value containing `<<` unconverted, and escapes PDF names per
21
+ ISO 32000-1 §7.3.5. Both close signature-dictionary injection paths reachable
22
+ from caller-supplied `signPdf` options. Output is byte-identical to upstream
23
+ for every input this package legitimately produces. See the file header.
24
+
25
+ ---
26
+
27
+ MIT License
28
+
29
+ Copyright (c) 2019 The Authors
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining a copy
32
+ of this software and associated documentation files (the "Software"), to deal
33
+ in the Software without restriction, including without limitation the rights
34
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35
+ copies of the Software, and to permit persons to whom the Software is
36
+ furnished to do so, subject to the following conditions:
37
+
38
+ The above copyright notice and this permission notice shall be included in all
39
+ copies or substantial portions of the Software.
40
+
41
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ import type { ReadPdfReturnType } from "./readPdf.js";
2
+ declare const createBufferPageWithAnnotation: (pdf: Buffer, info: ReadPdfReturnType, pagesRef: string, widget: {
3
+ toString(): string;
4
+ }) => Buffer;
5
+ export default createBufferPageWithAnnotation;
6
+ //# sourceMappingURL=createBufferPageWithAnnotation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBufferPageWithAnnotation.d.ts","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/createBufferPageWithAnnotation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,QAAA,MAAM,8BAA8B,GAClC,KAAK,MAAM,EACX,MAAM,iBAAiB,EACvB,UAAU,MAAM,EAChB,QAAQ;IAAE,QAAQ,IAAI,MAAM,CAAA;CAAE,KAC7B,MAgCF,CAAC;AAEF,eAAe,8BAA8B,CAAC"}
@@ -0,0 +1,38 @@
1
+ // Vendored from @signpdf/placeholder-plain@3.3.0 (MIT). See LICENSE-signpdf.md.
2
+ // Faithful TypeScript port — logic and byte-emitting paths are unchanged.
3
+ import findObject from "./findObject.js";
4
+ import getIndexFromRef from "./getIndexFromRef.js";
5
+ const createBufferPageWithAnnotation = (pdf, info, pagesRef, widget) => {
6
+ const pagesDictionary = findObject(pdf, info.xref, pagesRef).toString();
7
+ // Extend page dictionary with newly created annotations
8
+ let annotsStart;
9
+ let annotsEnd;
10
+ let annots;
11
+ annotsStart = pagesDictionary.indexOf("/Annots");
12
+ if (annotsStart > -1) {
13
+ annotsEnd = pagesDictionary.indexOf("]", annotsStart);
14
+ annots = pagesDictionary.substr(annotsStart, annotsEnd + 1 - annotsStart);
15
+ annots = annots.substr(0, annots.length - 1); // remove the trailing ]
16
+ }
17
+ else {
18
+ annotsStart = pagesDictionary.length;
19
+ annotsEnd = pagesDictionary.length;
20
+ annots = "/Annots [";
21
+ }
22
+ const pagesDictionaryIndex = getIndexFromRef(info.xref, pagesRef);
23
+ const widgetValue = widget.toString();
24
+ annots = `${annots} ${widgetValue}]`; // add the trailing ] back
25
+ const preAnnots = pagesDictionary.substr(0, annotsStart);
26
+ let postAnnots = "";
27
+ if (pagesDictionary.length > annotsEnd) {
28
+ postAnnots = pagesDictionary.substr(annotsEnd + 1);
29
+ }
30
+ return Buffer.concat([
31
+ Buffer.from(`${pagesDictionaryIndex} 0 obj\n`),
32
+ Buffer.from("<<\n"),
33
+ Buffer.from(`${preAnnots + annots + postAnnots}\n`),
34
+ Buffer.from("\n>>\nendobj\n"),
35
+ ]);
36
+ };
37
+ export default createBufferPageWithAnnotation;
38
+ //# sourceMappingURL=createBufferPageWithAnnotation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBufferPageWithAnnotation.js","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/createBufferPageWithAnnotation.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,0EAA0E;AAC1E,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAGnD,MAAM,8BA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GAAG,CAAC,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,MAAM,CAAC,IAAI,CAAC,GAAG,oBAAoB,UAAU,CAAC;QAC9C,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QACnB,MAAM,CAAC,IAAI,CAAC,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,IAAI,CAAC;QACnD,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC;KAC9B,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,8BAA8B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { ReadPdfReturnType } from "./readPdf.js";
2
+ declare const createBufferRootWithAcroform: (pdf: Buffer, info: ReadPdfReturnType, form: {
3
+ toString(): string;
4
+ }) => Buffer;
5
+ export default createBufferRootWithAcroform;
6
+ //# sourceMappingURL=createBufferRootWithAcroform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBufferRootWithAcroform.d.ts","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/createBufferRootWithAcroform.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,QAAA,MAAM,4BAA4B,GAChC,KAAK,MAAM,EACX,MAAM,iBAAiB,EACvB,MAAM;IAAE,QAAQ,IAAI,MAAM,CAAA;CAAE,KAC3B,MASF,CAAC;AAEF,eAAe,4BAA4B,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Vendored from @signpdf/placeholder-plain@3.3.0 (MIT). See LICENSE-signpdf.md.
2
+ // Faithful TypeScript port — logic and byte-emitting paths are unchanged.
3
+ import getIndexFromRef from "./getIndexFromRef.js";
4
+ const createBufferRootWithAcroform = (pdf, info, form) => {
5
+ const rootIndex = getIndexFromRef(info.xref, info.rootRef);
6
+ return Buffer.concat([
7
+ Buffer.from(`${rootIndex} 0 obj\n`),
8
+ Buffer.from("<<\n"),
9
+ Buffer.from(`${info.root}\n`),
10
+ Buffer.from(`/AcroForm ${form}`),
11
+ Buffer.from("\n>>\nendobj\n"),
12
+ ]);
13
+ };
14
+ export default createBufferRootWithAcroform;
15
+ //# sourceMappingURL=createBufferRootWithAcroform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBufferRootWithAcroform.js","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/createBufferRootWithAcroform.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,0EAA0E;AAC1E,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAGnD,MAAM,4BAA4B,GAAG,CACnC,GAAW,EACX,IAAuB,EACvB,IAA4B,EACpB,EAAE;IACV,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3D,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,MAAM,CAAC,IAAI,CAAC,GAAG,SAAS,UAAU,CAAC;QACnC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QACnB,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,aAAa,IAAI,EAAE,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC;KAC9B,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,4BAA4B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ReadPdfReturnType } from "./readPdf.js";
2
+ declare const createBufferTrailer: (pdf: Buffer, info: ReadPdfReturnType, addedReferences: Map<number, number>) => Buffer;
3
+ export default createBufferTrailer;
4
+ //# sourceMappingURL=createBufferTrailer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBufferTrailer.d.ts","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/createBufferTrailer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,QAAA,MAAM,mBAAmB,GACvB,KAAK,MAAM,EACX,MAAM,iBAAiB,EACvB,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KACnC,MAwBF,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,26 @@
1
+ const createBufferTrailer = (pdf, info, addedReferences) => {
2
+ const sparseRows = [];
3
+ sparseRows[0] = "0000000000 65535 f "; // info.xref.tableRows[0];
4
+ addedReferences.forEach((offset, index) => {
5
+ const paddedOffset = `0000000000${offset}`.slice(-10);
6
+ sparseRows[index + 1] = `${index} 1\n${paddedOffset} 00000 n `;
7
+ });
8
+ const rows = sparseRows.filter((row) => row !== undefined);
9
+ return Buffer.concat([
10
+ Buffer.from("xref\n"),
11
+ Buffer.from(`${info.xref.startingIndex} 1\n`),
12
+ Buffer.from(rows.join("\n")),
13
+ Buffer.from("\ntrailer\n"),
14
+ Buffer.from("<<\n"),
15
+ Buffer.from(`/Size ${info.xref.maxIndex + 1}\n`),
16
+ Buffer.from(`/Root ${info.rootRef}\n`),
17
+ Buffer.from(info.infoRef ? `/Info ${info.infoRef}\n` : ""),
18
+ Buffer.from(`/Prev ${info.xRefPosition}\n`),
19
+ Buffer.from(">>\n"),
20
+ Buffer.from("startxref\n"),
21
+ Buffer.from(`${pdf.length}\n`),
22
+ Buffer.from("%%EOF"),
23
+ ]);
24
+ };
25
+ export default createBufferTrailer;
26
+ //# sourceMappingURL=createBufferTrailer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBufferTrailer.js","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/createBufferTrailer.ts"],"names":[],"mappings":"AAMA,MAAM,mBAAmB,GAAG,CAC1B,GAAW,EACX,IAAuB,EACvB,eAAoC,EAC5B,EAAE;IACV,MAAM,UAAU,GAA8B,EAAE,CAAC;IACjD,UAAU,CAAC,CAAC,CAAC,GAAG,qBAAqB,CAAC,CAAC,0BAA0B;IAEjE,eAAe,CAAC,OAAO,CAAC,CAAC,M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AEF,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ReadRefTableReturnType } from "./readRefTable.js";
2
+ declare const findObject: (pdf: Buffer, refTable: ReadRefTableReturnType, ref: string) => Buffer;
3
+ export default findObject;
4
+ //# sourceMappingURL=findObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findObject.d.ts","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/findObject.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,QAAA,MAAM,UAAU,GAAI,KAAK,MAAM,EAAE,UAAU,sBAAsB,EAAE,KAAK,MAAM,KAAG,MAUhF,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,18 @@
1
+ // Vendored from @signpdf/placeholder-plain@3.3.0 (MIT). See LICENSE-signpdf.md.
2
+ // Faithful TypeScript port — logic and byte-emitting paths are unchanged.
3
+ // (Upstream passed 'utf8' as the second argument to indexOf/lastIndexOf; Node
4
+ // treats a string byteOffset as the encoding, i.e. identical to the defaults
5
+ // used here.)
6
+ import getIndexFromRef from "./getIndexFromRef.js";
7
+ const findObject = (pdf, refTable, ref) => {
8
+ const index = getIndexFromRef(refTable, ref);
9
+ const offset = refTable.offsets.get(index);
10
+ let slice = pdf.slice(offset);
11
+ slice = slice.slice(0, slice.indexOf("endobj"));
12
+ // FIXME: What if it is a stream?
13
+ slice = slice.slice(slice.indexOf("<<") + 2);
14
+ slice = slice.slice(0, slice.lastIndexOf(">>"));
15
+ return slice;
16
+ };
17
+ export default findObject;
18
+ //# sourceMappingURL=findObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findObject.js","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/findObject.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,0EAA0E;AAC1E,8EAA8E;AAC9E,6EAA6E;AAC7E,cAAc;AACd,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAGnD,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,QAAgC,EAAE,GAAW,EAAU,EAAE;IACxF,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAW,CAAC;IACrD,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEhD,iCAAiC;IACjC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ReadRefTableReturnType } from "./readRefTable.js";
2
+ declare const getIndexFromRef: (refTable: ReadRefTableReturnType, ref: string) => number;
3
+ export default getIndexFromRef;
4
+ //# sourceMappingURL=getIndexFromRef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIndexFromRef.d.ts","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/getIndexFromRef.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,QAAA,MAAM,eAAe,GAAI,UAAU,sBAAsB,EAAE,KAAK,MAAM,KAAG,MAOxE,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,13 @@
1
+ // Vendored from @signpdf/placeholder-plain@3.3.0 (MIT). See LICENSE-signpdf.md.
2
+ // Faithful TypeScript port — logic and byte-emitting paths are unchanged.
3
+ import { SignPdfError } from "@signpdf/utils";
4
+ const getIndexFromRef = (refTable, ref) => {
5
+ const [indexString] = ref.split(" ");
6
+ const index = parseInt(indexString);
7
+ if (!refTable.offsets.has(index)) {
8
+ throw new SignPdfError(`Failed to locate object "${ref}".`, SignPdfError.TYPE_PARSE);
9
+ }
10
+ return index;
11
+ };
12
+ export default getIndexFromRef;
13
+ //# sourceMappingURL=getIndexFromRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIndexFromRef.js","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/getIndexFromRef.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,0EAA0E;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,MAAM,eAAe,GAAG,CAAC,QAAgC,EAAE,GAAW,EAAU,EAAE;IAChF,MAAM,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;IACpC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,YAAY,CAAC,4BAA4B,GAAG,IAAI,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { ReadPdfReturnType } from "./readPdf.js";
2
+ /**
3
+ * Finds the reference to a page.
4
+ */
5
+ export default function getPageRef(pdfBuffer: Buffer, info: ReadPdfReturnType): string;
6
+ //# sourceMappingURL=getPageRef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPageRef.d.ts","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/getPageRef.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,MAAM,CASrF"}
@@ -0,0 +1,18 @@
1
+ // Vendored from @signpdf/placeholder-plain@3.3.0 (MIT). See LICENSE-signpdf.md.
2
+ // Faithful TypeScript port — logic and byte-emitting paths are unchanged.
3
+ import getPagesDictionaryRef from "./getPagesDictionaryRef.js";
4
+ import findObject from "./findObject.js";
5
+ /**
6
+ * Finds the reference to a page.
7
+ */
8
+ export default function getPageRef(pdfBuffer, info) {
9
+ const pagesRef = getPagesDictionaryRef(info);
10
+ const pagesDictionary = findObject(pdfBuffer, info.xref, pagesRef);
11
+ const kidsPosition = pagesDictionary.indexOf("/Kids");
12
+ const kidsStart = pagesDictionary.indexOf("[", kidsPosition) + 1;
13
+ const kidsEnd = pagesDictionary.indexOf("]", kidsPosition);
14
+ const pages = pagesDictionary.slice(kidsStart, kidsEnd).toString();
15
+ const split = pages.trim().split(" ", 3);
16
+ return `${split[0]} ${split[1]} ${split[2]}`;
17
+ }
18
+ //# sourceMappingURL=getPageRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPageRef.js","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/getPageRef.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,0EAA0E;AAC1E,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAGzC;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,SAAiB,EAAE,IAAuB;IAC3E,MAAM,QAAQ,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,eAAe,GAAG,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnE,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACtD,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACnE,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACzC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ReadPdfReturnType } from "./readPdf.js";
2
+ export default function getPagesDictionaryRef(info: ReadPdfReturnType): string;
3
+ //# sourceMappingURL=getPagesDictionaryRef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPagesDictionaryRef.d.ts","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/getPagesDictionaryRef.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAU7E"}
@@ -0,0 +1,12 @@
1
+ // Vendored from @signpdf/placeholder-plain@3.3.0 (MIT). See LICENSE-signpdf.md.
2
+ // Faithful TypeScript port — logic and byte-emitting paths are unchanged.
3
+ import { SignPdfError } from "@signpdf/utils";
4
+ export default function getPagesDictionaryRef(info) {
5
+ const pagesRefRegex = /\/Pages\s+(\d+\s+\d+\s+R)/g;
6
+ const match = pagesRefRegex.exec(info.root);
7
+ if (match === null) {
8
+ throw new SignPdfError("Failed to find the pages descriptor. This is probably a problem in node-signpdf.", SignPdfError.TYPE_PARSE);
9
+ }
10
+ return match[1];
11
+ }
12
+ //# sourceMappingURL=getPagesDictionaryRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPagesDictionaryRef.js","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/getPagesDictionaryRef.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,0EAA0E;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,IAAuB;IACnE,MAAM,aAAa,GAAG,4BAA4B,CAAC;IACnD,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,YAAY,CACpB,kFAAkF,EAClF,YAAY,CAAC,UAAU,CACxB,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { plainAddPlaceholder, type PlainAddPlaceholderInput } from "./plainAddPlaceholder.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Vendored from @signpdf/placeholder-plain@3.3.0 (MIT). See LICENSE-signpdf.md.
2
+ // Public surface mirrors the upstream package entry point.
3
+ export { plainAddPlaceholder } from "./plainAddPlaceholder.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,2DAA2D;AAC3D,OAAO,EAAE,mBAAmB,EAAiC,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Escape a PDF name body per ISO 32000-1 §7.3.5: every byte outside the
3
+ * regular-character range (0x21..0x7E minus the delimiters) is written as
4
+ * `#` followed by two uppercase hex digits. Regular names pass through
5
+ * unchanged, so this is a no-op for well-formed input.
6
+ */
7
+ export declare const escapePdfName: (name: string) => string;
8
+ /** Converts JavaScript types into their corresponding PDF types. */
9
+ export declare const convert: (object: unknown) => string;
10
+ export declare const PDFObject: {
11
+ convert: (object: unknown) => string;
12
+ };
13
+ //# sourceMappingURL=pdfObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdfObject.d.ts","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/pdfObject.ts"],"names":[],"mappings":"AAsDA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAU5C,CAAC;AAKF,oEAAoE;AACpE,eAAO,MAAM,OAAO,GAAI,QAAQ,OAAO,KAAG,MA2EzC,CAAC;AAEF,eAAO,MAAM,SAAS;sBA7EU,OAAO,KAAG,MAAM;CA6EZ,CAAC"}
@@ -0,0 +1,142 @@
1
+ // Hardened replacement for `PDFObject.convert` from @signpdf/utils@3.x
2
+ // (itself derived from pdfkit's PDFObject by Devon Govett, MIT — see
3
+ // LICENSE-signpdf.md). This is the ONE file in this directory that
4
+ // DELIBERATELY DIVERGES from upstream. Two changes, both security fixes:
5
+ //
6
+ // 1. Upstream's dictionary branch does:
7
+ // if (val.toString().indexOf('<<') !== -1) checkedValue = val;
8
+ // i.e. any value whose string form contains "<<" is spliced into the
9
+ // dictionary RAW — no conversion, no escaping, not even PDF-string
10
+ // parens. A caller-supplied `reason` / `name` / `location` /
11
+ // `contactInfo` containing "<<" therefore injects arbitrary keys into
12
+ // the signature dictionary. That branch exists upstream only so pdfkit
13
+ // can pass pre-rendered dictionary strings; nothing this package emits
14
+ // relies on it (Prop_Build is a real object and recurses correctly), so
15
+ // it is removed outright.
16
+ //
17
+ // 2. Upstream renders a JS string as a PDF name with `/${object}` and no
18
+ // escaping, so a name value can carry delimiters and whitespace and end
19
+ // the token early — the /SubFilter injection vector. Names are now
20
+ // escaped per ISO 32000-1 §7.3.5 (#xx for every non-regular byte).
21
+ //
22
+ // Both changes are byte-identical for every legitimate input this package
23
+ // produces: the names it emits (Sig, Adobe.PPKLite, ETSI.CAdES.detached,
24
+ // Widget, Annot, the "**********" ByteRange placeholder, and every
25
+ // dictionary key) consist solely of regular characters, and no legitimate
26
+ // value's string form contains "<<". Covered by test/sig-dict-injection.test.ts
27
+ // ::"is byte-identical to upstream for legitimate input".
28
+ //
29
+ // Reported by Uuaid-Lead 2026-08-11 (found while adversarially testing an
30
+ // independent verifier against the published @e-sig/core signPdf).
31
+ import { PDFAbstractReference } from "@signpdf/utils";
32
+ const pad = (str, length) => (Array(length + 1).join("0") + str).slice(-length);
33
+ const escapableRe = /[\n\r\t\b\f()\\]/g;
34
+ const escapable = {
35
+ "\n": "\\n",
36
+ "\r": "\\r",
37
+ "\t": "\\t",
38
+ "\b": "\\b",
39
+ "\f": "\\f",
40
+ "\\": "\\\\",
41
+ "(": "\\(",
42
+ ")": "\\)",
43
+ };
44
+ /**
45
+ * PDF name delimiters (ISO 32000-1 §7.2.2) plus '#', which introduces an
46
+ * escape and so must itself be escaped.
47
+ */
48
+ const NAME_DELIMITERS = new Set("()<>[]{}/%#".split("").map((c) => c.charCodeAt(0)));
49
+ /**
50
+ * Escape a PDF name body per ISO 32000-1 §7.3.5: every byte outside the
51
+ * regular-character range (0x21..0x7E minus the delimiters) is written as
52
+ * `#` followed by two uppercase hex digits. Regular names pass through
53
+ * unchanged, so this is a no-op for well-formed input.
54
+ */
55
+ export const escapePdfName = (name) => {
56
+ let out = "";
57
+ for (const byte of Buffer.from(name, "utf8")) {
58
+ if (byte >= 0x21 && byte <= 0x7e && !NAME_DELIMITERS.has(byte)) {
59
+ out += String.fromCharCode(byte);
60
+ }
61
+ else {
62
+ out += `#${byte.toString(16).padStart(2, "0").toUpperCase()}`;
63
+ }
64
+ }
65
+ return out;
66
+ };
67
+ // Convert little endian UTF-16 to big endian
68
+ const swapBytes = (buff) => buff.swap16();
69
+ /** Converts JavaScript types into their corresponding PDF types. */
70
+ export const convert = (object) => {
71
+ // String literals are converted to the PDF name type
72
+ if (typeof object === "string") {
73
+ return `/${escapePdfName(object)}`;
74
+ }
75
+ // String objects are converted to PDF strings (UTF-16)
76
+ if (object instanceof String) {
77
+ let string = String(object);
78
+ // Detect if this is a unicode string
79
+ let isUnicode = false;
80
+ for (let i = 0, end = string.length; i < end; i += 1) {
81
+ if (string.charCodeAt(i) > 0x7f) {
82
+ isUnicode = true;
83
+ break;
84
+ }
85
+ }
86
+ // If so, encode it as big endian UTF-16
87
+ const stringBuffer = isUnicode
88
+ ? swapBytes(Buffer.from(`\ufeff${string}`, "utf16le"))
89
+ : Buffer.from(string, "ascii");
90
+ string = stringBuffer.toString("binary");
91
+ // Escape characters as required by the spec
92
+ string = string.replace(escapableRe, (c) => escapable[c]);
93
+ return `(${string})`;
94
+ }
95
+ // Buffers are converted to PDF hex strings
96
+ if (Buffer.isBuffer(object)) {
97
+ return `<${object.toString("hex")}>`;
98
+ }
99
+ if (object instanceof PDFAbstractReference) {
100
+ // String(): @signpdf/utils types the abstract base's toString() as void
101
+ // (it throws); the concrete PDFKitReferenceMock returns "<index> 0 R".
102
+ return String(object);
103
+ }
104
+ if (object instanceof Date) {
105
+ const string = `D:${pad(object.getUTCFullYear(), 4)}${pad(object.getUTCMonth() + 1, 2)}` +
106
+ `${pad(object.getUTCDate(), 2)}${pad(object.getUTCHours(), 2)}` +
107
+ `${pad(object.getUTCMinutes(), 2)}${pad(object.getUTCSeconds(), 2)}Z`;
108
+ return `(${string})`;
109
+ }
110
+ if (Array.isArray(object)) {
111
+ const items = object.map((e) => convert(e)).join(" ");
112
+ return `[${items}]`;
113
+ }
114
+ if ({}.toString.call(object) === "[object Object]") {
115
+ const out = ["<<"];
116
+ let streamData;
117
+ Object.entries(object).forEach(([key, val]) => {
118
+ if (key === "stream") {
119
+ streamData = `${key}\n${val}\nendstream`;
120
+ }
121
+ else {
122
+ // NOTE: no raw-splice branch here — see the header. Every value is
123
+ // converted, and every key is escaped as a name.
124
+ out.push(`/${escapePdfName(key)} ${convert(val)}`);
125
+ }
126
+ });
127
+ out.push(">>");
128
+ if (streamData) {
129
+ out.push(streamData);
130
+ }
131
+ return out.join("\n");
132
+ }
133
+ if (typeof object === "number") {
134
+ if (object > -1e21 && object < 1e21) {
135
+ return String(Math.round(object * 1e6) / 1e6);
136
+ }
137
+ throw new Error(`unsupported number: ${object}`);
138
+ }
139
+ return `${object}`;
140
+ };
141
+ export const PDFObject = { convert };
142
+ //# sourceMappingURL=pdfObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdfObject.js","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/pdfObject.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,qEAAqE;AACrE,mEAAmE;AACnE,yEAAyE;AACzE,EAAE;AACF,yCAAyC;AACzC,uEAAuE;AACvE,yEAAyE;AACzE,uEAAuE;AACvE,iEAAiE;AACjE,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,4EAA4E;AAC5E,8BAA8B;AAC9B,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,uEAAuE;AACvE,uEAAuE;AACvE,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,mEAAmE;AACnE,0EAA0E;AAC1E,gFAAgF;AAChF,0DAA0D;AAC1D,EAAE;AACF,0EAA0E;AAC1E,mEAAmE;AAEnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,GAAG,GAAG,CAAC,GAAoB,EAAE,MAAc,EAAU,EAAE,CAC3D,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,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AC;gBACrB,UAAU,GAAG,GAAG,GAAG,KAAK,GAAG,aAAa,CAAC;YAC3C,CAAC;iBAAM,CAAC;gBACN,mEAAmE;gBACnE,iDAAiD;gBACjD,GAAG,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACrD,CAAC;QACH,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,IAAI,UAAU,EAAE,CAAC;YACf,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,IAAI,MAAM,GAAG,CAAC,IAAI,IAAI,MAAM,GAAG,IAAI,EAAE,CAAC;YACpC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,GAAG,MAAM,EAAE,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { PDFKitReferenceMock } from "@signpdf/utils";
2
+ /**
3
+ * The minimal PDFDocument-shaped surface that plainAddPlaceholder feeds in.
4
+ * (Upstream typed this as `object PDFDocument`.)
5
+ */
6
+ export interface PdfKitMock {
7
+ ref(input: Record<string, unknown>, knownIndex?: number): PDFKitReferenceMock;
8
+ page: {
9
+ dictionary: PDFKitReferenceMock & {
10
+ data: {
11
+ Annots: unknown[];
12
+ };
13
+ };
14
+ };
15
+ _root: {
16
+ data: {
17
+ AcroForm?: unknown;
18
+ };
19
+ };
20
+ }
21
+ export interface PdfkitAddPlaceholderInput {
22
+ pdf: PdfKitMock;
23
+ pdfBuffer: Buffer;
24
+ reason: string;
25
+ contactInfo: string;
26
+ name: string;
27
+ location: string;
28
+ signingTime?: Date;
29
+ signatureLength?: number;
30
+ byteRangePlaceholder?: string;
31
+ /** One of SUBFILTER_* from @signpdf/utils */
32
+ subFilter?: string;
33
+ /** [x1, y1, x2, y2] widget rectangle */
34
+ widgetRect?: number[];
35
+ /** Name of the application generating the signature */
36
+ appName?: string;
37
+ }
38
+ export interface PdfkitAddPlaceholderReturnType {
39
+ signature: PDFKitReferenceMock;
40
+ form: PDFKitReferenceMock;
41
+ widget: PDFKitReferenceMock;
42
+ }
43
+ /**
44
+ * Adds the objects that are needed for Adobe.PPKLite to read the signature.
45
+ * Also includes a placeholder for the actual signature.
46
+ * Returns an Object with all the added PDFReferences.
47
+ */
48
+ export declare const pdfkitAddPlaceholder: ({ pdf, pdfBuffer, reason, contactInfo, name, location, signingTime, signatureLength, byteRangePlaceholder, subFilter, widgetRect, appName, }: PdfkitAddPlaceholderInput) => PdfkitAddPlaceholderReturnType;
49
+ //# sourceMappingURL=pdfkitAddPlaceholder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdfkitAddPlaceholder.d.ts","sourceRoot":"","sources":["../../../src/vendor/placeholder-plain/pdfkitAddPlaceholder.ts"],"names":[],"mappings":"AAKA,OAAO,EAML,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAAC;IAC9E,IAAI,EAAE;QACJ,UAAU,EAAE,mBAAmB,GAAG;YAAE,IAAI,EAAE;gBAAE,MAAM,EAAE,OAAO,EAAE,CAAA;aAAE,CAAA;SAAE,CAAC;KACnE,CAAC;IACF,KAAK,EAAE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