Skip to content

Commit

Permalink
Changed folder structure and working on LTV.
Browse files Browse the repository at this point in the history
  • Loading branch information
zboris12 committed Nov 6, 2022
1 parent 8b008cc commit 3f0dd0a
Show file tree
Hide file tree
Showing 11 changed files with 1,718 additions and 350 deletions.
6 changes: 3 additions & 3 deletions closure/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ doskey csr=%csr% $*
set externs=--externs closure\google-ext.js --externs closure\forge-ext.js --externs closure\pdflib-ext.js --externs closure\zb-externs.js

rem main
set src=.
set jss=--js %src%\zgapdfcryptor.js --js %src%\zgapdfsigner.js
set src=lib
set jss=--js %src%\zgacertsutil.js --js %src%\zgapdfcryptor.js --js %src%\zgapdfsigner.js --js %src%\zgaindex.js
echo $
set chkj=%%externs%% --checks_only %%jss%%
echo chkj=csr %chkj%
doskey chkj=%csr% %chkj%
set csrj=%%externs%% %%jss%% --js_output_file %src%\dist\zgapdfsigner.min.js
set csrj=%%externs%% %%jss%% --js_output_file dist\zgapdfsigner.min.js
echo csrj=csr %csrj%
doskey csrj=%csr% %csrj%
87 changes: 83 additions & 4 deletions closure/forge-ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ forge.util.hexToBytes = function(hex){};
* @return {string}
*/
forge.util.decodeUtf8 = function(value){};
forge.util.binary = {};
forge.util.binary.hex = {};
/**
* @param {string} str
* @return {Uint8Array}
*/
forge.util.binary.hex.decode = function(str){};

/** @constructor */
forge.asn1 = function(){};
Expand Down Expand Up @@ -119,6 +126,12 @@ forge.asn1.Type.OID;
forge.asn1.Type.NULL;
/** @type {number} */
forge.asn1.Type.OCTETSTRING;
/** @type {number} */
forge.asn1.Type.PRINTABLESTRING;
/** @type {number} */
forge.asn1.Type.ENUMERATED;
/** @type {number} */
forge.asn1.Type.BITSTRING;
forge.asn1.Class = {};
/** @type {number} */
forge.asn1.Class.UNIVERSAL;
Expand All @@ -133,8 +146,21 @@ forge.asn1.Class.CONTEXT_SPECIFIC;
* @return {forge.asn1}
*/
forge.asn1.create = function(tagClass, type, constructed, value, options){};
/** @type {Array<forge.asn1>} */
/**
* @param {forge.asn1} obj
* @param {Object<string, *>} v
* @param {Object<string, *>} capture
* @param {Array<string>} errors
*/
forge.asn1.validate = function(obj, v, capture, errors){};
/** @type {Array<forge.asn1>|string} */
forge.asn1.prototype.value;
/** @type {number} */
forge.asn1.prototype.tagClass;
/** @type {number} */
forge.asn1.prototype.type;
/** @type {boolean} */
forge.asn1.prototype.constructed;

/** @constructor */
const forge_BigInteger = function(){};
Expand All @@ -149,6 +175,20 @@ const forge_cert = function(){};
forge_cert.prototype.publicKey;
/** @type {forge_cert_issuer} */
forge_cert.prototype.issuer;
/** @type {string} */
forge_cert.prototype.serialNumber;
/** @type {forge_cert_issuer} */
forge_cert.prototype.subject;
/**
* @param {forge_cert} parent
* @return {boolean}
*/
forge_cert.prototype.isIssuer = function(parent){};
/**
* @param {string|forge_cert_extension} nm
* @return {forge_cert_extension}
*/
forge_cert.prototype.getExtension = function(nm){};
/** @constructor */
const forge_key = function(){};
/** @type {forge_BigInteger} */
Expand All @@ -159,6 +199,23 @@ forge_key.prototype.e;
const forge_cert_issuer = function(){};
/** @type {Array<forge_cert_attr>} */
forge_cert_issuer.prototype.attributes;
/**
* @param {string} sn
* @return {forge.asn1}
*/
forge_cert_issuer.prototype.getField = function(sn){};
/**
* @typedef
* {{
* id: (string|undefined),
* name: (string|undefined),
* critical: (boolean|undefined),
* value: (string|undefined),
* cA: (boolean|undefined),
* }}
*/
var forge_cert_extension;

/**
* @typedef
* {{
Expand Down Expand Up @@ -263,16 +320,15 @@ var P12Bag;
*/
forge.pkcs12.prototype.getBags = function(filter){};

forge.oids = {};
/** @type {string} */
forge.oids.sha256;
forge.pki = {};
forge.pki.oids = {};
/** @type {string} */
forge.pki.oids.certBag;
/** @type {string} */
forge.pki.oids.pkcs8ShroudedKeyBag;
/** @type {string} */
forge.pki.oids.sha1;
/** @type {string} */
forge.pki.oids.sha256;
/** @type {string} */
forge.pki.oids.contentType;
Expand All @@ -282,12 +338,35 @@ forge.pki.oids.data;
forge.pki.oids.messageDigest;
/** @type {string} */
forge.pki.oids.signingTime;
/** @type {string} */
forge.pki.oids.rsaEncryption;
/** @type {string} */
forge.pki.oids.sha256WithRSAEncryption;
/** @type {string} */
forge.pki.oids.commonName;
/** @lends {forge.pki.oids} */
forge.oids = forge.pki.oids;
/**
* @param {forge.asn1} obj
* @param {boolean=} computeHash
* @return {forge_cert}
*/
forge.pki.certificateFromAsn1 = function(obj, computeHash){};
/**
* @param {forge_cert} cert
* @return {forge.asn1}
*/
forge.pki.certificateToAsn1 = function(cert){};
/**
* @param {forge_cert_issuer} obj
* @return {forge.asn1}
*/
forge.pki.distinguishedNameToAsn1 = function(obj){};
/**
* @param {forge_key} key
* @return {forge.asn1}
*/
forge.pki.publicKeyToRSAPublicKey = function(key){};

forge.md = {};
/** @constructor */
Expand Down
17 changes: 16 additions & 1 deletion closure/pdflib-ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ PDFLib.PDFAcroForm.prototype.addField = function(field){};
/** @type {PDFLib.PDFDict} */
PDFLib.PDFAcroForm.prototype.dict;

/** @constructor */
/**
* @constructor
* @extends {PDFLib.PDFDict}
*/
PDFLib.PDFCatalog = function(){};
/**
* @param {PDFLib.PDFName} name
Expand Down Expand Up @@ -196,6 +199,7 @@ PDFLib.PDFContext.prototype.enumerateIndirectObjects = function(){};
* @typedef
* {{
* Root: PDFLib.PDFRef,
* Info: PDFLib.PDFRef,
* ID: (PDFLib.PDFArray|undefined),
* }}
*/
Expand All @@ -221,6 +225,12 @@ PDFLib.PDFContext.prototype.nextRef = function(){};
* @return {PDFLib.PDFObject}
*/
PDFLib.PDFContext.prototype.obj = function(literal){};
/**
* @param {string|Uint8Array} contents
* @param {PDFLib.PDFDict=} dict
* @return {PDFLib.PDFRawStream}
*/
PDFLib.PDFContext.prototype.flateStream = function(contents, dict){};
/**
* @param {PDFLib.PDFRef} ref
* @return {PDFLib.PDFObject}
Expand Down Expand Up @@ -425,6 +435,11 @@ PDFLib.PDFContentStream = function(){};
* @return {PDFLib.PDFContentStream}
*/
PDFLib.PDFContentStream.of = function(dict, operators, encode){};
/**
* @constructor
* @extends {PDFLib.PDFStream}
*/
PDFLib.PDFRawStream = function(){};

/**
* @constructor
Expand Down
73 changes: 72 additions & 1 deletion closure/zb-externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ var SignAreaInfo;
var SignDrawInfo;
/**
* In the case of adding a document timestamp, the p12cert and pwd must be omitted. But meanwhile the tsa must be provided.
*
*
* 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.
*
* 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.
*
* @typedef
* {{
* p12cert: (Array<number>|Uint8Array|ArrayBuffer|string|undefined),
Expand All @@ -51,6 +55,7 @@ var SignDrawInfo;
* signdate: (Date|TsaServiceInfo|string|undefined),
* signame: (string|undefined),
* drawinf: (SignDrawInfo|undefined),
* ltv: (number|undefined),
* debug: (boolean|undefined),
* }}
*/
Expand Down Expand Up @@ -110,6 +115,23 @@ var CFType;
* }}
*/
var RC4LastInfo;
/**
* @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;

var Zga = {};
/**
Expand Down Expand Up @@ -142,6 +164,55 @@ Zga.PdfCryptor = function(encopt){};
* @return {Promise<PDFLib.PDFDocument>}
*/
Zga.PdfCryptor.prototype.encryptPdf = function(pdf, ref){};
/**
* @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){};
/**
* @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(){};

/**
* @constructor
* @param {SignOption} signopt
Expand Down
Loading

0 comments on commit 3f0dd0a

Please sign in to comment.