2022-09-24 06:59:30 +02:00
|
|
|
/**
|
|
|
|
* @typedef
|
|
|
|
* {{
|
|
|
|
* url: string,
|
|
|
|
* len: (number|undefined),
|
2022-10-24 14:36:47 +02:00
|
|
|
* headers: (Object<string, *>|undefined),
|
2022-09-24 06:59:30 +02:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
var TsaServiceInfo;
|
2022-09-18 09:49:56 +02:00
|
|
|
/**
|
|
|
|
* the base point of x, y is top left corner.
|
2024-08-09 14:57:20 +02:00
|
|
|
* wDraw, hDraw: Only for internal process.
|
2022-09-18 09:49:56 +02:00
|
|
|
* @typedef
|
|
|
|
* {{
|
|
|
|
* x: number,
|
|
|
|
* y: number,
|
2024-08-09 14:57:20 +02:00
|
|
|
* w: (number|undefined),
|
|
|
|
* h: (number|undefined),
|
|
|
|
* wDraw: (number|undefined),
|
|
|
|
* hDraw: (number|undefined),
|
2022-09-18 09:49:56 +02:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
var SignAreaInfo;
|
|
|
|
/**
|
2024-08-09 14:57:20 +02:00
|
|
|
* fontData: default: StandardFonts.Helvetica
|
|
|
|
* color: A Hex string of color. default: #000
|
|
|
|
* opacity: valid value is from 0 to 1. default: 1 // Not implemented
|
|
|
|
* blendMode: https://pdf-lib.js.org/docs/api/enums/blendmode // Not implemented
|
|
|
|
* lineHeight: default is the height of the font at the given size
|
|
|
|
* xOffset: An offset from SignAreaInfo's x
|
|
|
|
* yOffset: An offset from SignAreaInfo's y
|
|
|
|
* align: Text alignment: 0 left, 1 center, 2 right. default: 0
|
|
|
|
* noBreaks: A regular expression string that indicates which characters should not be used to break a word. default: [A-Za-z0-9]
|
|
|
|
*
|
|
|
|
* @typedef
|
|
|
|
* {{
|
|
|
|
* text: string,
|
|
|
|
* fontData: (Array<number>|Uint8Array|ArrayBuffer|string|undefined),
|
|
|
|
* color: (string|undefined),
|
|
|
|
* opacity: (number|undefined),
|
|
|
|
* blendMode: (string|undefined),
|
|
|
|
* lineHeight: (number|undefined),
|
|
|
|
* size: number,
|
|
|
|
* xOffset: (number|undefined),
|
|
|
|
* yOffset: (number|undefined),
|
|
|
|
* wMax: (number|undefined),
|
|
|
|
* align: (number|undefined),
|
|
|
|
* noBreaks: (string|undefined),
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
var SignTextInfo;
|
|
|
|
/**
|
|
|
|
* opacity: valid value is from 0 to 1. default: 1 // Not implemented
|
|
|
|
* blendMode: https://pdf-lib.js.org/docs/api/enums/blendmode // Not implemented
|
|
|
|
*
|
|
|
|
* @typedef
|
|
|
|
* {{
|
|
|
|
* imgData: (Array<number>|Uint8Array|ArrayBuffer|string|undefined),
|
|
|
|
* imgType: (string|undefined),
|
|
|
|
* opacity: (number|undefined),
|
|
|
|
* blendMode: (string|undefined),
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
var SignImageInfo;
|
|
|
|
/**
|
|
|
|
* The signature can be placed in the same position on multiple pages, but all pages must have the same size and rotation angle.
|
|
|
|
* pageidx: Can be a string to indicate placing the signature on multiple pages.
|
|
|
|
* For example: A pdf contains 17 pages and specify "-3,5-7,9,12,15-" means [0,1,2,3,5,6,7,9,12,15,16]
|
|
|
|
* imgData, imgType: Deprecated, use imgInfo instead.
|
|
|
|
* img, font: Only for internal process.
|
|
|
|
*
|
2022-09-18 09:49:56 +02:00
|
|
|
* @typedef
|
|
|
|
* {{
|
|
|
|
* area: SignAreaInfo,
|
2024-08-09 14:57:20 +02:00
|
|
|
* pageidx: (number|string|undefined),
|
2022-09-24 06:59:30 +02:00
|
|
|
* imgData: (Array<number>|Uint8Array|ArrayBuffer|string|undefined),
|
2022-09-18 09:49:56 +02:00
|
|
|
* imgType: (string|undefined),
|
2024-08-09 14:57:20 +02:00
|
|
|
* imgInfo: (SignImageInfo|undefined),
|
|
|
|
* textInfo: (SignTextInfo|undefined),
|
2022-09-18 09:49:56 +02:00
|
|
|
* img: (PDFLib.PDFImage|undefined),
|
|
|
|
* font: (PDFLib.PDFFont|undefined),
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
var SignDrawInfo;
|
|
|
|
/**
|
2022-10-24 14:36:47 +02:00
|
|
|
* In the case of adding a document timestamp, the p12cert and pwd must be omitted. But meanwhile the tsa must be provided.
|
2022-11-06 10:03:48 +01:00
|
|
|
*
|
2022-10-14 14:12:43 +02:00
|
|
|
* permission: (DocMDP) The modification permissions granted for this document. Valid values are:
|
|
|
|
* 1 : No changes to the document are permitted; any change to the document invalidates the signature.
|
|
|
|
* 2 : Permitted changes are filling in forms, instantiating page templates, and signing; other changes invalidate the signature.
|
|
|
|
* 3 : Permitted changes are the same as for 2, as well as annotation creation, deletion, and modification; other changes invalidate the signature.
|
|
|
|
*
|
2022-11-06 10:03:48 +01:00
|
|
|
* ltv: Type of Long-Term Validation. Valid values are:
|
|
|
|
* 1 : auto; Try using ocsp only to enable the LTV first; If can't, try using crl to enable the LTV.
|
|
|
|
* 2 : crl only; Only try using crl to enable the LTV.
|
|
|
|
*
|
2022-09-18 09:49:56 +02:00
|
|
|
* @typedef
|
|
|
|
* {{
|
2022-10-24 14:36:47 +02:00
|
|
|
* p12cert: (Array<number>|Uint8Array|ArrayBuffer|string|undefined),
|
|
|
|
* pwd: (string|undefined),
|
2022-10-14 14:12:43 +02:00
|
|
|
* permission: (number|undefined),
|
2022-09-18 09:49:56 +02:00
|
|
|
* reason: (string|undefined),
|
|
|
|
* location: (string|undefined),
|
|
|
|
* contact: (string|undefined),
|
2022-09-24 06:59:30 +02:00
|
|
|
* signdate: (Date|TsaServiceInfo|string|undefined),
|
2022-09-18 09:49:56 +02:00
|
|
|
* signame: (string|undefined),
|
|
|
|
* drawinf: (SignDrawInfo|undefined),
|
2022-11-06 10:03:48 +01:00
|
|
|
* ltv: (number|undefined),
|
2022-09-24 06:59:30 +02:00
|
|
|
* debug: (boolean|undefined),
|
2022-09-18 09:49:56 +02:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
var SignOption;
|
2022-10-02 14:45:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef
|
|
|
|
* {{
|
2022-10-14 14:12:43 +02:00
|
|
|
* c: (Array<number>|Uint8Array|ArrayBuffer|string|forge_cert|undefined),
|
2022-10-04 14:37:17 +02:00
|
|
|
* p: (Array<string>|undefined),
|
2022-10-02 14:45:06 +02:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
var PubKeyInfo;
|
|
|
|
/**
|
|
|
|
* permissions: The set of permissions (specify the ones you want to block):
|
2022-10-06 15:02:11 +02:00
|
|
|
* copy : (Only valid on public-key mode) Copy text and graphics from the document;
|
2022-10-02 14:45:06 +02:00
|
|
|
* print : Print the document;
|
|
|
|
* modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';
|
2022-10-06 15:02:11 +02:00
|
|
|
* copy-extract : Copy or otherwise extract text and graphics from the document;
|
2022-10-02 14:45:06 +02:00
|
|
|
* annot-forms : Add or modify text annotations, fill in interactive form fields, and, if 'modify' is also set, create or modify interactive form fields (including signature fields);
|
|
|
|
* fill-forms : Fill in existing interactive form fields (including signature fields), even if 'annot-forms' is not specified;
|
|
|
|
* extract : Extract text and graphics (in support of accessibility to users with disabilities or for other purposes);
|
|
|
|
* assemble : Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if 'modify' is not set;
|
|
|
|
* print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.
|
|
|
|
*
|
|
|
|
* ownerpwd: Owner password If not specified, a random value is used.
|
|
|
|
*
|
2022-10-06 15:02:11 +02:00
|
|
|
* pubkeys: Array of recipients containing public-key certificates ('c') and permissions ('p'). If want to encrypt the pdf by the certificate of signing, just apply a PubKeyInfo without c.
|
2022-10-02 14:45:06 +02:00
|
|
|
*
|
|
|
|
* @typedef
|
|
|
|
* {{
|
|
|
|
* mode: Zga.Crypto.Mode,
|
2022-10-04 14:37:17 +02:00
|
|
|
* permissions: (Array<string>|undefined),
|
2022-10-02 14:45:06 +02:00
|
|
|
* userpwd: (string|undefined),
|
|
|
|
* ownerpwd: (string|undefined),
|
|
|
|
* pubkeys: (Array<PubKeyInfo>|undefined),
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
var EncryptOption;
|
|
|
|
/**
|
|
|
|
* @typedef
|
|
|
|
* {{
|
|
|
|
* CFM: string,
|
|
|
|
* Length: (number|undefined),
|
|
|
|
* EncryptMetadata: (boolean|undefined),
|
|
|
|
* AuthEvent: (string|undefined),
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
var CFType;
|
|
|
|
/**
|
|
|
|
* enckey: Last RC4 key encrypted.
|
|
|
|
* enckeyc: Last RC4 computed key.
|
|
|
|
* @typedef
|
|
|
|
* {{
|
|
|
|
* enckey: string,
|
|
|
|
* enckeyc: Array<number>,
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
var RC4LastInfo;
|
2022-11-06 10:03:48 +01:00
|
|
|
/**
|
|
|
|
* @typedef
|
|
|
|
* {{
|
|
|
|
* certs: (Array<forge_cert>|undefined),
|
|
|
|
* ocsps: (Array<Uint8Array>|undefined),
|
|
|
|
* crls: (Array<Uint8Array>|undefined),
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
var DSSInfo;
|
|
|
|
/**
|
|
|
|
* @typedef
|
|
|
|
* {{
|
|
|
|
* resp: (Uint8Array|undefined),
|
|
|
|
* cchainIdx: (number|undefined),
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
var OcspData;
|
2022-10-04 14:37:17 +02:00
|
|
|
|
|
|
|
var Zga = {};
|
2022-10-14 14:12:43 +02:00
|
|
|
/**
|
|
|
|
* @param {Uint8Array} uarr
|
|
|
|
* @return {string}
|
|
|
|
*/
|
|
|
|
Zga.u8arrToRaw = function(uarr){};
|
|
|
|
/**
|
|
|
|
* @param {string} raw
|
|
|
|
* @return {Uint8Array}
|
|
|
|
*/
|
|
|
|
Zga.rawToU8arr = function(raw){};
|
|
|
|
|
2022-10-04 14:37:17 +02:00
|
|
|
Zga.Crypto = {};
|
|
|
|
/** @enum {number} */
|
|
|
|
Zga.Crypto.Mode = {
|
|
|
|
RC4_40: 0,
|
|
|
|
RC4_128: 1,
|
|
|
|
AES_128: 2,
|
|
|
|
AES_256: 3,
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* @param {EncryptOption} encopt
|
|
|
|
*/
|
|
|
|
Zga.PdfCryptor = function(encopt){};
|
|
|
|
/**
|
|
|
|
* @param {PDFLib.PDFDocument|Array<number>|Uint8Array|ArrayBuffer|string} pdf
|
2022-10-14 14:12:43 +02:00
|
|
|
* @param {PDFLib.PDFRef=} ref
|
2022-10-04 14:37:17 +02:00
|
|
|
* @return {Promise<PDFLib.PDFDocument>}
|
|
|
|
*/
|
2022-10-14 14:12:43 +02:00
|
|
|
Zga.PdfCryptor.prototype.encryptPdf = function(pdf, ref){};
|
2022-11-14 14:20:19 +01:00
|
|
|
/**
|
|
|
|
* @param {number} num
|
|
|
|
* @param {PDFLib.PDFObject} val
|
|
|
|
*/
|
|
|
|
Zga.PdfCryptor.prototype.encryptObject = function(num, val){};
|
2022-11-06 10:03:48 +01:00
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* @param {Array<forge_cert|forge.asn1|string>=} certs
|
|
|
|
*/
|
|
|
|
Zga.CertsChain = function(certs){};
|
|
|
|
/**
|
|
|
|
* @return {forge_cert}
|
|
|
|
*/
|
|
|
|
Zga.CertsChain.prototype.getSignCert = function(){};
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
Zga.CertsChain.prototype.isSelfSignedCert = function(){};
|
|
|
|
/**
|
|
|
|
* @return {Array<forge_cert>}
|
|
|
|
*/
|
|
|
|
Zga.CertsChain.prototype.getAllCerts = function(){};
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
* @param {forge_cert} cert
|
|
|
|
* @return {Promise<boolean>}
|
|
|
|
*/
|
|
|
|
Zga.CertsChain.prototype.buildChain = function(cert){};
|
|
|
|
/**
|
|
|
|
* @param {boolean=} crlOnly
|
|
|
|
* @return {Promise<DSSInfo>}
|
|
|
|
*/
|
|
|
|
Zga.CertsChain.prototype.prepareDSSInf = function(crlOnly){};
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* @param {TsaServiceInfo} inf
|
|
|
|
*/
|
|
|
|
Zga.TsaFetcher = function(inf){};
|
2022-11-14 14:20:19 +01:00
|
|
|
/** @type {string} */
|
|
|
|
Zga.TsaFetcher.prototype.url;
|
|
|
|
/** @type {number} */
|
|
|
|
Zga.TsaFetcher.prototype.len;
|
2022-11-06 10:03:48 +01:00
|
|
|
/**
|
|
|
|
* @param {string=} data
|
|
|
|
* @return {Promise<string>}
|
|
|
|
*/
|
|
|
|
Zga.TsaFetcher.prototype.queryTsa = function(data){};
|
|
|
|
/**
|
|
|
|
* @param {boolean=} forP7
|
|
|
|
* @return {forge.asn1}
|
|
|
|
*/
|
|
|
|
Zga.TsaFetcher.prototype.getToken = function(forP7){};
|
|
|
|
/**
|
|
|
|
* @return {Zga.CertsChain}
|
|
|
|
*/
|
|
|
|
Zga.TsaFetcher.prototype.getCertsChain = function(){};
|
|
|
|
|
2022-10-14 14:12:43 +02:00
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* @param {SignOption} signopt
|
|
|
|
*/
|
|
|
|
Zga.PdfSigner = function(signopt){};
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
* @param {PDFLib.PDFDocument|Array<number>|Uint8Array|ArrayBuffer|string} pdf
|
|
|
|
* @param {EncryptOption=} cypopt
|
|
|
|
* @return {Promise<Uint8Array>}
|
|
|
|
*/
|
|
|
|
Zga.PdfSigner.prototype.sign = function(pdf, cypopt){};
|