Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@signpdf/utils

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@signpdf/utils - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

LICENSE

24

dist/const.d.ts

@@ -7,2 +7,26 @@ export const DEFAULT_SIGNATURE_LENGTH: 8192;

export const SUBFILTER_ETSI_CADES_DETACHED: "ETSI.CAdES.detached";
/**
* Signature flags (bitmask) to be used under /SigFlags.
*
* {@link https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/pdfreference1.3.pdf}
* See TABLE 7.42 and 7.43
*/
export type SIG_FLAGS = number;
export namespace SIG_FLAGS {
let SIGNATURES_EXIST: number;
let APPEND_ONLY: number;
}
/**
* * {@link https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/pdfreference1.3.pdf}See TABLE 7.10
*/
export type ANNOTATION_FLAGS = number;
export namespace ANNOTATION_FLAGS {
let INVISIBLE: number;
let HIDDEN: number;
let PRINT: number;
let NO_ZOOM: number;
let NO_ROTATE: number;
let NO_VIEW: number;
let READ_ONLY: number;
}
//# sourceMappingURL=const.d.ts.map

66

dist/const.js

@@ -6,3 +6,3 @@ "use strict";

});
exports.SUBFILTER_ETSI_CADES_DETACHED = exports.SUBFILTER_ADOBE_X509_SHA1 = exports.SUBFILTER_ADOBE_PKCS7_SHA1 = exports.SUBFILTER_ADOBE_PKCS7_DETACHED = exports.DEFAULT_SIGNATURE_LENGTH = exports.DEFAULT_BYTE_RANGE_PLACEHOLDER = void 0;
exports.SUBFILTER_ETSI_CADES_DETACHED = exports.SUBFILTER_ADOBE_X509_SHA1 = exports.SUBFILTER_ADOBE_PKCS7_SHA1 = exports.SUBFILTER_ADOBE_PKCS7_DETACHED = exports.SIG_FLAGS = exports.DEFAULT_SIGNATURE_LENGTH = exports.DEFAULT_BYTE_RANGE_PLACEHOLDER = exports.ANNOTATION_FLAGS = void 0;
const DEFAULT_SIGNATURE_LENGTH = exports.DEFAULT_SIGNATURE_LENGTH = 8192;

@@ -13,2 +13,64 @@ const DEFAULT_BYTE_RANGE_PLACEHOLDER = exports.DEFAULT_BYTE_RANGE_PLACEHOLDER = '**********';

const SUBFILTER_ADOBE_X509_SHA1 = exports.SUBFILTER_ADOBE_X509_SHA1 = 'adbe.x509.rsa.sha1';
const SUBFILTER_ETSI_CADES_DETACHED = exports.SUBFILTER_ETSI_CADES_DETACHED = 'ETSI.CAdES.detached';
const SUBFILTER_ETSI_CADES_DETACHED = exports.SUBFILTER_ETSI_CADES_DETACHED = 'ETSI.CAdES.detached';
/**
* Signature flags (bitmask) to be used under /SigFlags.
*
* {@link https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/pdfreference1.3.pdf}
* See TABLE 7.42 and 7.43
* @readonly
* @enum {number}
*/
const SIG_FLAGS = exports.SIG_FLAGS = {
/**
* If set, the document contains at least one signature field.
*/
SIGNATURES_EXIST: 1,
/**
* If set, the document contains signatures that may be invalidated
* if the file is saved (written) in a way that alters its previous contents.
*/
APPEND_ONLY: 2
};
/**
* Annotation flags (bitmask) to be used in /F under /Annot
*
* @readonly
* @enum {number}
* {@link https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/pdfreference1.3.pdf}
* See TABLE 7.10
*/
const ANNOTATION_FLAGS = exports.ANNOTATION_FLAGS = {
/**
* If set, do not display the annotation if it does not belong to one of the
* standard annotation types and no annotation handler is available.
*/
INVISIBLE: 1,
/**
* If set, do not display or print the annotation or allow it to interact with the user,
* regardless of its annotation type or whether an annotation handler is available.
*/
HIDDEN: 2,
/**
* If set, print the annotation when the page is printed. If clear, never print the
* annotation, regardless of whether it is displayed on the screen.
*/
PRINT: 4,
/**
* If set, do not scale the annotation’s appearance to match the magnification of the page.
*/
NO_ZOOM: 8,
/**
* If set, do not rotate the annotation’s appearance to match the rotation of the page.
*/
NO_ROTATE: 16,
/**
* If set, do not display the annotation on the screen or allow it to interact with the user.
*/
NO_VIEW: 32,
/**
* If set, do not allow the annotation to interact with the user.
*/
READ_ONLY: 64
};

@@ -1,2 +0,8 @@

export function findByteRange(pdf: Buffer, placeholder?: string): any;
export function findByteRange(pdf: Buffer, placeholder?: string): OutputType;
export type OutputType = {
byteRangePlaceholder: string | undefined;
byteRangePlaceholderPosition: number | undefined;
byteRangeStrings: string[];
byteRange: string[];
};
//# sourceMappingURL=findByteRange.d.ts.map

@@ -10,6 +10,14 @@ "use strict";

/**
* @typedef {object} OutputType
* @property {string | undefined} byteRangePlaceholder
* @property {number | undefined} byteRangePlaceholderPosition
* @property {string[]} byteRangeStrings
* @property {string[]} byteRange
*/
/**
* Finds ByteRange information within a given PDF Buffer if one exists
*
* @param {Buffer} pdf
* @returns {Object} {byteRangePlaceholder: String, byteRangeStrings: String[], byteRange: String[]}
* @returns {OutputType}
*/

@@ -20,10 +28,33 @@ const findByteRange = (pdf, placeholder = _const.DEFAULT_BYTE_RANGE_PLACEHOLDER) => {

}
const byteRangeStrings = pdf.toString().match(/\/ByteRange\s*\[{1}\s*(?:(?:\d*|\/\*{10})\s+){3}(?:\d+|\/\*{10}){1}\s*]{1}/g);
if (!byteRangeStrings) {
throw new _SignPdfError.SignPdfError('No ByteRangeStrings found within PDF buffer', _SignPdfError.SignPdfError.TYPE_PARSE);
}
const byteRangePlaceholder = byteRangeStrings.find(s => s.includes(`/${placeholder}`));
const byteRanges = byteRangeStrings.map(brs => brs.match(/[^[\s]*(?:\d|\/\*{10})/g));
let byteRangePlaceholder;
let byteRangePlaceholderPosition;
const byteRangeStrings = [];
const byteRanges = [];
let offset = 0;
do {
const position = pdf.indexOf('/ByteRange', offset);
if (position === -1) {
break;
}
const rangeStart = pdf.indexOf('[', position);
const rangeEnd = pdf.indexOf(']', rangeStart);
const byteRangeString = pdf.subarray(position, rangeEnd + 1);
byteRangeStrings.push(byteRangeString.toString());
const range = pdf.subarray(rangeStart + 1, rangeEnd).toString().split(' ').filter(c => c !== '').map(c => c.trim());
byteRanges.push(range);
const placeholderName = `/${placeholder}`;
if (range[0] === '0' && range[1] === placeholderName && range[2] === placeholderName && range[3] === placeholderName) {
if (typeof byteRangePlaceholder !== 'undefined') {
throw new _SignPdfError.SignPdfError('Found multiple ByteRange placeholders.', _SignPdfError.SignPdfError.TYPE_INPUT);
}
byteRangePlaceholder = byteRangeString.toString();
byteRangePlaceholderPosition = position;
}
offset = rangeEnd;
// eslint-disable-next-line no-constant-condition
} while (true);
return {
byteRangePlaceholder,
byteRangePlaceholderPosition,
byteRangeStrings,

@@ -30,0 +61,0 @@ byteRanges

4

dist/Signer.d.ts
export class Signer {
/**
* @param {Buffer} pdfBuffer
* @returns {Buffer}
* @returns {Promise<Buffer> | Buffer}
*/
sign(pdfBuffer: Buffer): Buffer;
sign(pdfBuffer: Buffer): Promise<Buffer> | Buffer;
}
//# sourceMappingURL=Signer.d.ts.map

@@ -13,5 +13,5 @@ "use strict";

* @param {Buffer} pdfBuffer
* @returns {Buffer}
* @returns {Promise<Buffer> | Buffer}
*/
async sign(pdfBuffer) {
sign(pdfBuffer) {
throw new _SignPdfError.SignPdfError(`sign() is not implemented on ${this.constructor.name}`, _SignPdfError.SignPdfError.TYPE_INPUT);

@@ -18,0 +18,0 @@ }

{
"name": "@signpdf/utils",
"version": "3.0.0",
"version": "3.1.0",
"description": "Utilities for the @signpdf packages.",

@@ -47,3 +47,3 @@ "repository": {

"@babel/preset-env": "^7.4.2",
"@signpdf/eslint-config": "^3.0.0",
"@signpdf/eslint-config": "^3.1.0",
"@signpdf/internal-utils": "^3.0.0",

@@ -67,3 +67,3 @@ "@types/node": ">=12.0.0",

},
"gitHead": "cf8d5f40b2e2e513919ba586df03bad4fb87982c"
"gitHead": "5d5ec00c21e072613acb9776c7c6ac7697314955"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc