diff --git a/API.md b/API.md index b214027..1dd3531 100644 --- a/API.md +++ b/API.md @@ -93,26 +93,26 @@ ltv | number | optional | The method of how to enable [LTV](#note) :three: debug | boolean | optional | To output debug informations or not :one: `permission` is a setting of [DocMDP](#note). 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. + * `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. :two: `signdate` * When it is a Date, it means the date and time of signing. * When it is a string, it can be an url of [TSA](#note) or an index of the preset [TSA](#note)s as below: - * "1": http://ts.ssl.com - * "2": http://timestamp.digicert.com - * "3": http://timestamp.sectigo.com - * "4": http://timestamp.entrust.net/TSS/RFC3161sha2TS - * "5": http://timestamp.apple.com/ts01 - * "6": http://www.langedge.jp/tsa - * "7": https://freetsa.org/tsr + * `"1"`: http://ts.ssl.com + * `"2"`: http://timestamp.digicert.com + * `"3"`: http://timestamp.sectigo.com + * `"4"`: http://timestamp.entrust.net/TSS/RFC3161sha2TS + * `"5"`: http://timestamp.apple.com/ts01 + * `"6"`: http://www.langedge.jp/tsa + * `"7"`: https://freetsa.org/tsr * When it is a [TsaServiceInfo](#TsaServiceInfo), it means a full customized information of a [TSA](#note). * When it is omitted, the system timestamp will be used. :three: `ltv`'s valid values are: - * 1: auto; Try using [OCSP](#note) only to enable the [LTV](#note) first; If can't, try using [CRL](#note) to enable the [LTV](#note). - * 2: crl only; Only try using [CRL](#note) to enable the [LTV](#note). + * `1`: auto; Try using [OCSP](#note) only to enable the [LTV](#note) first; If can't, try using [CRL](#note) to enable the [LTV](#note). + * `2`: crl only; Only try using [CRL](#note) to enable the [LTV](#note). ## TsaServiceInfo @@ -127,19 +127,17 @@ headers | Object\ | optional | The customized headers for sending to # Function Definitions ## u8arrToRaw -:fondue::fondue::fondue: -#### u8arrToRaw(uarr) :arrow_right: string +:fondue::fondue::fondue: +u8arrToRaw(uarr) :arrow_right: string Converts an Uint8Array to a raw string. - Name | Type | Attributes | Description --- | --- | --- | --- uarr | Uint8Array | required | The target Uint8Array ## rawToU8arr -:fondue::fondue::fondue: -#### rawToU8arr(raw) :arrow_right: Uint8Array +:fondue::fondue::fondue: +rawToU8arr(raw) :arrow_right: Uint8Array Converts a raw string to an Uint8Array. - Name | Type | Attributes | Description --- | --- | --- | --- raw | string | required | The target string @@ -149,32 +147,34 @@ raw | string | required | The target string ## CertsChain :croissant::croissant::croissant: ### Constructor -#### new CertsChain(certs*opt*) - +new CertsChain(certs*opt*) Name | Type | Attributes | Description --- | --- | --- | --- certs | Array\
:fork_and_knife:Array\
:fork_and_knife:Array\ | optional | An array of certificates. ### Methods -#### buildChain(cert) :arrow_right: Promise\ +#### buildChain +buildChain(cert) :arrow_right: Promise\ Build the certificates chain from the specified certificate, and returns true if this operation is successful. - Name | Type | Attributes | Description --- | --- | --- | --- cert | forge_cert | required | A certificate to start build by looking for it's issuer. -#### getAllCerts() :arrow_right: Array\ +#### getAllCerts +getAllCerts() :arrow_right: Array\ Returns an array of all certificates. -#### getSignCert() :arrow_right: forge_cert +#### getSignCert +getSignCert() :arrow_right: forge_cert Returns the certificate for signing. -#### isSelfSignedCert() :arrow_right: boolean +#### isSelfSignedCert +isSelfSignedCert() :arrow_right: boolean Returns true if the certificate for signing is a self-signed certificate. -#### prepareDSSInf(crlOnly*opt*) :arrow_right: Promise\<[DSSInfo](#dssinfo)\> +#### prepareDSSInf +prepareDSSInf(crlOnly*opt*) :arrow_right: Promise\<[DSSInfo](#dssinfo)\> Returns the informations of [DSS](#note). - Name | Type | Attributes | Description --- | --- | --- | --- crlOnly | boolean | optional | Query [CRL](#note) only or try query [OCSP](#note) first. @@ -182,24 +182,23 @@ crlOnly | boolean | optional | Query [CRL](#note) only or try query [OCSP](#note ## PdfCryptor :croissant::croissant::croissant: ### Constructor -#### new PdfCryptor(encopt) - +new PdfCryptor(encopt) Name | Type | Attributes | Description --- | --- | --- | --- encopt | [EncryptOption](#EncryptOption) | required | Infomations of encryption. ### Methods -#### encryptObject(num, val) +#### encryptObject +encryptObject(num, val) Encrypts the content of the specified pdf object. - Name | Type | Attributes | Description --- | --- | --- | --- num | number | required | The object number. val | PDFLib.PDFObject | required | The target object. -#### encryptPdf(pdf, ref*opt*) :arrow_right: Promise\ +#### encryptPdf +encryptPdf(pdf, ref*opt*) :arrow_right: Promise\ Encrypts the contents in the pdf and returns the pdf document. - Name | Type | Attributes | Description --- | --- | --- | --- pdf | PDFLib.PDFDocument
:fork_and_knife:Array\
:fork_and_knife:Uint8Array
:fork_and_knife:ArrayBuffer
:fork_and_knife:string | required | The target pdf. @@ -208,16 +207,15 @@ ref | PDFLib.PDFRef | optional | The unique reference will be assigned to the en ## PdfSigner :croissant::croissant::croissant: ### Constructor -#### new PdfSigner(signopt) - +new PdfSigner(signopt) Name | Type | Attributes | Description --- | --- | --- | --- signopt | [SignOption](#SignOption) | required | Infomations of signing. ### Methods -#### sign(pdf, cypopt*opt*) :arrow_right: Promise\ +#### sign +sign(pdf, cypopt*opt*) :arrow_right: Promise\ Sign the pdf and returns the binary data. - Name | Type | Attributes | Description --- | --- | --- | --- pdf | PDFLib.PDFDocument|Array\|Uint8Array|ArrayBuffer|string | required | The target pdf. @@ -226,39 +224,40 @@ cypopt | [EncryptOption](#EncryptOption) | optional | The informations of encryp ## TsaFetcher :croissant::croissant::croissant: ### Constructor -#### new TsaFetcher(inf) - +new TsaFetcher(inf) Name | Type | Attributes | Description --- | --- | --- | --- inf | [TsaServiceInfo](#TsaServiceInfo) | required | Infomations of [TSA](#note). ### Properties - Name | Type | Description --- | --- | --- url | string | The url of [TSA](#note). len | number | The length of signature which is generated by the [TSA](#note). ### Methods -#### getCertsChain() :arrow_right: [CertsChain](#CertsChain) +#### getCertsChain +getCertsChain() :arrow_right: [CertsChain](#CertsChain) Get the certificates' chain from the response of [TSA](#note). -#### getToken(forP7*opt*) :arrow_right: forge.asn1 +#### getToken +getToken(forP7*opt*) :arrow_right: forge.asn1 Get the token data in response from [TSA](#note). Name | Type | Attributes | Description --- | --- | --- | --- forP7 | boolean | optional | To create an asn1 for appending to a pkcs#7 signature or not. -#### queryTsa(data) :arrow_right: Promise\ +#### queryTsa +queryTsa(data) :arrow_right: Promise\ Query [TSA](#note) to sign the data and returns error message if error occured. Name | Type | Attributes | Description --- | --- | --- | --- data | string | required | The data needs to be signed. ## Note -1. __CRL__:loudspeaker: Certificate Revocation List -2. __DDS__:loudspeaker: Document Security Store -3. __DocMDP__:loudspeaker: Document Modification Detection and Prevention -4. __LTV__:loudspeaker: Long-Term Validation -5. __OCSP__:loudspeaker: Online Certificate Status Protocol -6. __TSA__:loudspeaker: Time Stamp Authority +* __CRL__:loudspeaker: Certificate Revocation List +* __DDS__:loudspeaker: Document Security Store +* __DocMDP__:loudspeaker: Document Modification Detection and Prevention +* __LTV__:loudspeaker: Long-Term Validation +* __OCSP__:loudspeaker: Online Certificate Status Protocol +* __TSA__:loudspeaker: Time Stamp Authority