mirror of
https://github.com/documenso/documenso.git
synced 2026-07-27 10:25:00 +10:00
🚚 ➕ add node-signpdf copy to signing packgage until npm includes fix
This commit is contained in:
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _findObject = _interopRequireDefault(require("./findObject"));
|
||||
|
||||
var _getIndexFromRef = _interopRequireDefault(require("./getIndexFromRef"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const createBufferPageWithAnnotation = (pdf, info, pagesRef, widget) => {
|
||||
const pagesDictionary = (0, _findObject.default)(pdf, info.xref, pagesRef).toString(); // Extend page dictionary with newly created annotations
|
||||
|
||||
let annotsStart;
|
||||
let annotsEnd;
|
||||
let annots;
|
||||
annotsStart = pagesDictionary.indexOf('/Annots');
|
||||
|
||||
if (annotsStart > -1) {
|
||||
annotsEnd = pagesDictionary.indexOf(']', annotsStart);
|
||||
annots = pagesDictionary.substr(annotsStart, annotsEnd + 1 - annotsStart);
|
||||
annots = annots.substr(0, annots.length - 1); // remove the trailing ]
|
||||
} else {
|
||||
annotsStart = pagesDictionary.length;
|
||||
annotsEnd = pagesDictionary.length;
|
||||
annots = '/Annots [';
|
||||
}
|
||||
|
||||
const pagesDictionaryIndex = (0, _getIndexFromRef.default)(info.xref, pagesRef);
|
||||
const widgetValue = widget.toString();
|
||||
annots = `${annots} ${widgetValue}]`; // add the trailing ] back
|
||||
|
||||
const preAnnots = pagesDictionary.substr(0, annotsStart);
|
||||
let postAnnots = '';
|
||||
|
||||
if (pagesDictionary.length > annotsEnd) {
|
||||
postAnnots = pagesDictionary.substr(annotsEnd + 1);
|
||||
}
|
||||
|
||||
return Buffer.concat([Buffer.from(`${pagesDictionaryIndex} 0 obj\n`), Buffer.from('<<\n'), Buffer.from(`${preAnnots + annots + postAnnots}\n`), Buffer.from('\n>>\nendobj\n')]);
|
||||
};
|
||||
|
||||
var _default = createBufferPageWithAnnotation;
|
||||
exports.default = _default;
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _getIndexFromRef = _interopRequireDefault(require("./getIndexFromRef"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const createBufferRootWithAcroform = (pdf, info, form) => {
|
||||
const rootIndex = (0, _getIndexFromRef.default)(info.xref, info.rootRef);
|
||||
return Buffer.concat([Buffer.from(`${rootIndex} 0 obj\n`), Buffer.from('<<\n'), Buffer.from(`${info.root}\n`), Buffer.from(`/AcroForm ${form}`), Buffer.from('\n>>\nendobj\n')]);
|
||||
};
|
||||
|
||||
var _default = createBufferRootWithAcroform;
|
||||
exports.default = _default;
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
const createBufferTrailer = (pdf, info, addedReferences) => {
|
||||
let rows = [];
|
||||
rows[0] = '0000000000 65535 f '; // info.xref.tableRows[0];
|
||||
|
||||
addedReferences.forEach((offset, index) => {
|
||||
const paddedOffset = `0000000000${offset}`.slice(-10);
|
||||
rows[index + 1] = `${index} 1\n${paddedOffset} 00000 n `;
|
||||
});
|
||||
rows = rows.filter(row => row !== undefined);
|
||||
return Buffer.concat([Buffer.from('xref\n'), Buffer.from(`${info.xref.startingIndex} 1\n`), Buffer.from(rows.join('\n')), Buffer.from('\ntrailer\n'), Buffer.from('<<\n'), Buffer.from(`/Size ${info.xref.maxIndex + 1}\n`), Buffer.from(`/Root ${info.rootRef}\n`), Buffer.from(info.infoRef ? `/Info ${info.infoRef}\n` : ''), Buffer.from(`/Prev ${info.xRefPosition}\n`), Buffer.from('>>\n'), Buffer.from('startxref\n'), Buffer.from(`${pdf.length}\n`), Buffer.from('%%EOF')]);
|
||||
};
|
||||
|
||||
var _default = createBufferTrailer;
|
||||
exports.default = _default;
|
||||
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _getIndexFromRef = _interopRequireDefault(require("./getIndexFromRef"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @param {Buffer} pdf
|
||||
* @param {Map} refTable
|
||||
* @returns {object}
|
||||
*/
|
||||
const findObject = (pdf, refTable, ref) => {
|
||||
const index = (0, _getIndexFromRef.default)(refTable, ref);
|
||||
const offset = refTable.offsets.get(index);
|
||||
let slice = pdf.slice(offset);
|
||||
slice = slice.slice(0, slice.indexOf('endobj', 'utf8')); // FIXME: What if it is a stream?
|
||||
|
||||
slice = slice.slice(slice.indexOf('<<', 'utf8') + 2);
|
||||
slice = slice.slice(0, slice.lastIndexOf('>>', 'utf8'));
|
||||
return slice;
|
||||
};
|
||||
|
||||
var _default = findObject;
|
||||
exports.default = _default;
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _SignPdfError = _interopRequireDefault(require("../../SignPdfError"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @param {object} refTable
|
||||
* @param {string} ref
|
||||
* @returns {number}
|
||||
*/
|
||||
const getIndexFromRef = (refTable, ref) => {
|
||||
let [index] = ref.split(' ');
|
||||
index = parseInt(index);
|
||||
|
||||
if (!refTable.offsets.has(index)) {
|
||||
throw new _SignPdfError.default(`Failed to locate object "${ref}".`, _SignPdfError.default.TYPE_PARSE);
|
||||
}
|
||||
|
||||
return index;
|
||||
};
|
||||
|
||||
var _default = getIndexFromRef;
|
||||
exports.default = _default;
|
||||
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = getPageRef;
|
||||
|
||||
var _getPagesDictionaryRef = _interopRequireDefault(require("./getPagesDictionaryRef"));
|
||||
|
||||
var _findObject = _interopRequireDefault(require("./findObject"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Finds the reference to a page.
|
||||
*
|
||||
* @param {Buffer} pdfBuffer
|
||||
* @param {Object} info As extracted from readRef()
|
||||
*/
|
||||
function getPageRef(pdfBuffer, info) {
|
||||
const pagesRef = (0, _getPagesDictionaryRef.default)(info);
|
||||
const pagesDictionary = (0, _findObject.default)(pdfBuffer, info.xref, pagesRef);
|
||||
const kidsPosition = pagesDictionary.indexOf('/Kids');
|
||||
const kidsStart = pagesDictionary.indexOf('[', kidsPosition) + 1;
|
||||
const kidsEnd = pagesDictionary.indexOf(']', kidsPosition);
|
||||
const pages = pagesDictionary.slice(kidsStart, kidsEnd).toString();
|
||||
const split = pages.trim().split(' ', 3);
|
||||
return `${split[0]} ${split[1]} ${split[2]}`;
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = getPagesDictionaryRef;
|
||||
|
||||
var _SignPdfError = _interopRequireDefault(require("../../SignPdfError"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @param {Object} info As extracted from readRef()
|
||||
*/
|
||||
function getPagesDictionaryRef(info) {
|
||||
const pagesRefRegex = /\/Pages\s+(\d+\s+\d+\s+R)/g;
|
||||
const match = pagesRefRegex.exec(info.root);
|
||||
|
||||
if (match === null) {
|
||||
throw new _SignPdfError.default('Failed to find the pages descriptor. This is probably a problem in node-signpdf.', _SignPdfError.default.TYPE_PARSE);
|
||||
}
|
||||
|
||||
return match[1];
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _pdfobject = _interopRequireDefault(require("../pdfkit/pdfobject"));
|
||||
|
||||
var _pdfkitReferenceMock = _interopRequireDefault(require("../pdfkitReferenceMock"));
|
||||
|
||||
var _removeTrailingNewLine = _interopRequireDefault(require("../removeTrailingNewLine"));
|
||||
|
||||
var _const = require("../const");
|
||||
|
||||
var _pdfkitAddPlaceholder = _interopRequireDefault(require("../pdfkitAddPlaceholder"));
|
||||
|
||||
var _getIndexFromRef = _interopRequireDefault(require("./getIndexFromRef"));
|
||||
|
||||
var _readPdf = _interopRequireDefault(require("./readPdf"));
|
||||
|
||||
var _getPageRef = _interopRequireDefault(require("./getPageRef"));
|
||||
|
||||
var _createBufferRootWithAcroform = _interopRequireDefault(require("./createBufferRootWithAcroform"));
|
||||
|
||||
var _createBufferPageWithAnnotation = _interopRequireDefault(require("./createBufferPageWithAnnotation"));
|
||||
|
||||
var _createBufferTrailer = _interopRequireDefault(require("./createBufferTrailer"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const isContainBufferRootWithAcroform = pdf => {
|
||||
const bufferRootWithAcroformRefRegex = /\/AcroForm\s+(\d+\s\d+\sR)/g;
|
||||
const match = bufferRootWithAcroformRefRegex.exec(pdf.toString());
|
||||
return match != null && match[1] != null && match[1] !== '';
|
||||
};
|
||||
/**
|
||||
* Adds a signature placeholder to a PDF Buffer.
|
||||
*
|
||||
* This contrasts with the default pdfkit-based implementation.
|
||||
* Parsing is done using simple string operations.
|
||||
* Adding is done with `Buffer.concat`.
|
||||
* This allows node-signpdf to be used on any PDF and
|
||||
* not only on a freshly created through PDFKit one.
|
||||
*/
|
||||
|
||||
|
||||
const plainAddPlaceholder = ({
|
||||
pdfBuffer,
|
||||
reason,
|
||||
contactInfo = 'emailfromp1289@gmail.com',
|
||||
name = 'Name from p12',
|
||||
location = 'Location from p12',
|
||||
signatureLength = _const.DEFAULT_SIGNATURE_LENGTH,
|
||||
subFilter = _const.SUBFILTER_ADOBE_PKCS7_DETACHED
|
||||
}) => {
|
||||
let pdf = (0, _removeTrailingNewLine.default)(pdfBuffer);
|
||||
const info = (0, _readPdf.default)(pdf);
|
||||
const pageRef = (0, _getPageRef.default)(pdf, info);
|
||||
const pageIndex = (0, _getIndexFromRef.default)(info.xref, pageRef);
|
||||
const addedReferences = new Map();
|
||||
const pdfKitMock = {
|
||||
ref: (input, additionalIndex) => {
|
||||
info.xref.maxIndex += 1;
|
||||
const index = additionalIndex != null ? additionalIndex : info.xref.maxIndex;
|
||||
addedReferences.set(index, pdf.length + 1); // + 1 new line
|
||||
|
||||
pdf = Buffer.concat([pdf, Buffer.from('\n'), Buffer.from(`${index} 0 obj\n`), Buffer.from(_pdfobject.default.convert(input)), Buffer.from('\nendobj\n')]);
|
||||
return new _pdfkitReferenceMock.default(info.xref.maxIndex);
|
||||
},
|
||||
page: {
|
||||
dictionary: new _pdfkitReferenceMock.default(pageIndex, {
|
||||
data: {
|
||||
Annots: []
|
||||
}
|
||||
})
|
||||
},
|
||||
_root: {
|
||||
data: {}
|
||||
}
|
||||
};
|
||||
const {
|
||||
form,
|
||||
widget
|
||||
} = (0, _pdfkitAddPlaceholder.default)({
|
||||
pdf: pdfKitMock,
|
||||
pdfBuffer,
|
||||
reason,
|
||||
contactInfo,
|
||||
name,
|
||||
location,
|
||||
signatureLength,
|
||||
subFilter
|
||||
});
|
||||
|
||||
if (!isContainBufferRootWithAcroform(pdf)) {
|
||||
const rootIndex = (0, _getIndexFromRef.default)(info.xref, info.rootRef);
|
||||
addedReferences.set(rootIndex, pdf.length + 1);
|
||||
pdf = Buffer.concat([pdf, Buffer.from('\n'), (0, _createBufferRootWithAcroform.default)(pdf, info, form)]);
|
||||
}
|
||||
|
||||
addedReferences.set(pageIndex, pdf.length + 1);
|
||||
pdf = Buffer.concat([pdf, Buffer.from('\n'), (0, _createBufferPageWithAnnotation.default)(pdf, info, pageRef, widget)]);
|
||||
pdf = Buffer.concat([pdf, Buffer.from('\n'), (0, _createBufferTrailer.default)(pdf, info, addedReferences)]);
|
||||
return pdf;
|
||||
};
|
||||
|
||||
var _default = plainAddPlaceholder;
|
||||
exports.default = _default;
|
||||
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _readRefTable = _interopRequireDefault(require("./readRefTable"));
|
||||
|
||||
var _findObject = _interopRequireDefault(require("./findObject"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const getValue = (trailer, key) => {
|
||||
let index = trailer.indexOf(key);
|
||||
|
||||
if (index === -1) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const slice = trailer.slice(index);
|
||||
index = slice.indexOf('/', 1);
|
||||
|
||||
if (index === -1) {
|
||||
index = slice.indexOf('>', 1);
|
||||
}
|
||||
|
||||
return slice.slice(key.length + 1, index).toString().trim(); // key + at least one space
|
||||
};
|
||||
/**
|
||||
* Simplified parsing of a PDF Buffer.
|
||||
* Extracts reference table, root info and trailer start.
|
||||
*
|
||||
* See section 7.5.5 (File Trailer) of the PDF specs.
|
||||
*
|
||||
* @param {Buffer} pdfBuffer
|
||||
*/
|
||||
|
||||
|
||||
const readPdf = pdfBuffer => {
|
||||
// Extract the trailer dictionary.
|
||||
const trailerStart = pdfBuffer.lastIndexOf('trailer'); // The trailer is followed by xref. Then an EOF. EOF's length is 6 characters.
|
||||
|
||||
const trailer = pdfBuffer.slice(trailerStart, pdfBuffer.length - 6);
|
||||
let xRefPosition = trailer.slice(trailer.lastIndexOf('startxref') + 10).toString();
|
||||
xRefPosition = parseInt(xRefPosition);
|
||||
const refTable = (0, _readRefTable.default)(pdfBuffer);
|
||||
const rootRef = getValue(trailer, '/Root');
|
||||
const root = (0, _findObject.default)(pdfBuffer, refTable, rootRef).toString();
|
||||
const infoRef = getValue(trailer, '/Info');
|
||||
return {
|
||||
xref: refTable,
|
||||
rootRef,
|
||||
root,
|
||||
infoRef,
|
||||
trailerStart,
|
||||
previousXrefs: [],
|
||||
xRefPosition
|
||||
};
|
||||
};
|
||||
|
||||
var _default = readPdf;
|
||||
exports.default = _default;
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getXref = exports.getLastTrailerPosition = exports.getFullXrefTable = exports.default = void 0;
|
||||
|
||||
var _SignPdfError = _interopRequireDefault(require("../../SignPdfError"));
|
||||
|
||||
var _xrefToRefMap = _interopRequireDefault(require("./xrefToRefMap"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const getLastTrailerPosition = pdf => {
|
||||
const trailerStart = pdf.lastIndexOf(Buffer.from('trailer', 'utf8'));
|
||||
const trailer = pdf.slice(trailerStart, pdf.length - 6);
|
||||
const xRefPosition = trailer.slice(trailer.lastIndexOf(Buffer.from('startxref', 'utf8')) + 10).toString();
|
||||
return parseInt(xRefPosition);
|
||||
};
|
||||
|
||||
exports.getLastTrailerPosition = getLastTrailerPosition;
|
||||
|
||||
const getXref = (pdf, position) => {
|
||||
let refTable = pdf.slice(position); // slice starting from where xref starts
|
||||
|
||||
const realPosition = refTable.indexOf(Buffer.from('xref', 'utf8'));
|
||||
|
||||
if (realPosition === -1) {
|
||||
throw new _SignPdfError.default(`Could not find xref anywhere at or after ${position}.`, _SignPdfError.default.TYPE_PARSE);
|
||||
}
|
||||
|
||||
if (realPosition > 0) {
|
||||
const prefix = refTable.slice(0, realPosition);
|
||||
|
||||
if (prefix.toString().replace(/\s*/g, '') !== '') {
|
||||
throw new _SignPdfError.default(`Expected xref at ${position} but found other content.`, _SignPdfError.default.TYPE_PARSE);
|
||||
}
|
||||
}
|
||||
|
||||
const nextEofPosition = refTable.indexOf(Buffer.from('%%EOF', 'utf8'));
|
||||
|
||||
if (nextEofPosition === -1) {
|
||||
throw new _SignPdfError.default('Expected EOF after xref and trailer but could not find one.', _SignPdfError.default.TYPE_PARSE);
|
||||
}
|
||||
|
||||
refTable = refTable.slice(0, nextEofPosition);
|
||||
refTable = refTable.slice(realPosition + 4); // move ahead with the "xref"
|
||||
|
||||
refTable = refTable.slice(refTable.indexOf('\n') + 1); // move after the next new line
|
||||
// extract the size
|
||||
|
||||
let size = refTable.toString().split('/Size')[1];
|
||||
|
||||
if (!size) {
|
||||
throw new _SignPdfError.default('Size not found in xref table.', _SignPdfError.default.TYPE_PARSE);
|
||||
}
|
||||
|
||||
size = /^\s*(\d+)/.exec(size);
|
||||
|
||||
if (size === null) {
|
||||
throw new _SignPdfError.default('Failed to parse size of xref table.', _SignPdfError.default.TYPE_PARSE);
|
||||
}
|
||||
|
||||
size = parseInt(size[1]);
|
||||
const [objects, infos] = refTable.toString().split('trailer');
|
||||
const isContainingPrev = infos.split('/Prev')[1] != null;
|
||||
let prev;
|
||||
|
||||
if (isContainingPrev) {
|
||||
const pagesRefRegex = /Prev (\d+)/g;
|
||||
const match = pagesRefRegex.exec(infos);
|
||||
const [, prevPosition] = match;
|
||||
prev = prevPosition;
|
||||
}
|
||||
|
||||
const xRefContent = (0, _xrefToRefMap.default)(objects);
|
||||
return {
|
||||
size,
|
||||
prev,
|
||||
xRefContent
|
||||
};
|
||||
};
|
||||
|
||||
exports.getXref = getXref;
|
||||
|
||||
const getFullXrefTable = pdf => {
|
||||
const lastTrailerPosition = getLastTrailerPosition(pdf);
|
||||
const lastXrefTable = getXref(pdf, lastTrailerPosition);
|
||||
|
||||
if (lastXrefTable.prev === undefined) {
|
||||
return lastXrefTable.xRefContent;
|
||||
}
|
||||
|
||||
const pdfWithoutLastTrailer = pdf.slice(0, lastTrailerPosition);
|
||||
const partOfXrefTable = getFullXrefTable(pdfWithoutLastTrailer);
|
||||
const mergedXrefTable = new Map([...partOfXrefTable, ...lastXrefTable.xRefContent]);
|
||||
return mergedXrefTable;
|
||||
};
|
||||
/**
|
||||
* @param {Buffer} pdfBuffer
|
||||
* @returns {object}
|
||||
*/
|
||||
|
||||
|
||||
exports.getFullXrefTable = getFullXrefTable;
|
||||
|
||||
const readRefTable = pdf => {
|
||||
const fullXrefTable = getFullXrefTable(pdf);
|
||||
const startingIndex = 0;
|
||||
const maxIndex = Math.max(...fullXrefTable.keys());
|
||||
return {
|
||||
startingIndex,
|
||||
maxIndex,
|
||||
offsets: fullXrefTable
|
||||
};
|
||||
};
|
||||
|
||||
var _default = readRefTable;
|
||||
exports.default = _default;
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _SignPdfError = _interopRequireDefault(require("../../SignPdfError"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const xrefToRefMap = xrefString => {
|
||||
const lines = xrefString.split('\n').filter(l => l !== '');
|
||||
let index = 0;
|
||||
let expectedLines = 0;
|
||||
const xref = new Map();
|
||||
lines.forEach(line => {
|
||||
const split = line.split(' ');
|
||||
|
||||
if (split.length === 2) {
|
||||
index = parseInt(split[0]);
|
||||
expectedLines = parseInt(split[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (expectedLines <= 0) {
|
||||
throw new _SignPdfError.default('Too many lines in xref table.', _SignPdfError.default.TYPE_PARSE);
|
||||
}
|
||||
|
||||
expectedLines -= 1;
|
||||
const [offset,, inUse] = split;
|
||||
|
||||
if (inUse.trim() === 'f') {
|
||||
index += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (inUse.trim() !== 'n') {
|
||||
throw new _SignPdfError.default(`Unknown in-use flag "${inUse}". Expected "n" or "f".`, _SignPdfError.default.TYPE_PARSE);
|
||||
}
|
||||
|
||||
if (!/^\d+$/.test(offset.trim())) {
|
||||
throw new _SignPdfError.default(`Expected integer offset. Got "${offset}".`, _SignPdfError.default.TYPE_PARSE);
|
||||
}
|
||||
|
||||
const storeOffset = parseInt(offset.trim());
|
||||
xref.set(index, storeOffset);
|
||||
index += 1;
|
||||
});
|
||||
return xref;
|
||||
};
|
||||
|
||||
var _default = xrefToRefMap;
|
||||
exports.default = _default;
|
||||
Reference in New Issue
Block a user